Skip to main content

Instant Articles

GitHub Workflow Status PyPI Python Version GitHub release (latest by date including pre-releases) License star Code style: black

If you are seeking package for generating instant article or feeds in Masonite then yes, this package is for you.

This helps you generate facebooks instant articles and also regular feeds with enough customizations you might need.

Installation

pip install masonite-instant-article

Configuration

Add InstantArticleProvider to your project in config/providers.py:

# config/providers.py
# ...
from instant_article.providers import InstantArticleProvider

# ...
PROVIDERS = [
    # ...
    # Third Party Providers
    InstantArticleProvider
    # ...
]

Then you can publish the configuration by doing:

python craft package:publish instant_article

Update Configurations

You need to define options in your instant_article configuration file inside config directory.

# config
INSTANT_ARTICLE = {
    "force_validate": False,
    "feed_details": {
        "your-custom-route-name.xml": {
            'model': 'path-to-your-model-class',
            'title': '',
            'description': '',
            'lang': 'en-us',
            'brand': '',
            'type': 'instant-article' # feed, instant-article
        }
    }
}

# Example
INSTANT_ARTICLE = {
    "force_validate": False,
    "feed_details": {
        "blogs-rss.xml": {
            'model': 'app.models.Blog',
            'title': 'Blog Feed',
            'description': '',
            'lang': 'en-us',
            'brand': '',
            'type': 'instant-article' # feed, instant-article
        },
        "news-rss.xml": {
            'model': 'app.models.News',
            'title': 'News Feed',
            'description': '',
            'lang': 'en-us',
            'brand': '',
            'type': 'instant-article' # feed, instant-article
        }
    }
}

# Above feeds can be access from:
"""
https://your-domain.com/rss/blogs-rss.xml
https://your-domain.com/rss/news-rss.xml
"""

Implementation

from instant_article.interfaces.instant_article_interface import InstantArticleInterface
from instant_article.models.instant_article import InstantArticle


class YourModel(Model, InstantArticleInterface):


    @staticmethod
    def get_feed_items():
        return YourModel.all() # can be any query returning proper values

    def format_feed(self):
        return InstantArticle.create({
            'id': self.id, # required | integer
            'title': self.name, # required | string
            'subtitle': '', # nullable | string
            'kicker': '', # nullable | string
            'summary': '', # required | string
            'description': '', # required | string
            'cover': '', # nullable | string
            'updated': self.updated_at, # required | date
            'published': self.created_at, # required | date
            'link': '', # full url to item...
            'author': '' # nullable | email | string
        })

Your project is now ready to go 👍.

Contributing

Please read the Contributing Documentation here.

License

masonite-filemanager is open-sourced software licensed under the MIT license.

Metadata

Release files for masonite-instant-article 0.1.2

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for masonite-instant-article 0.1.2
File Size Uploaded
masonite-instant-article-0.1.2.tar.gz 23.7 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for masonite-instant-article 0.1.2
File Interpreter ABI Platform
masonite_instant_article-0.1.2-py3-none-any.whl Python 3 none any Details

Total release size: 34.8 kB

Release files / masonite-instant-article-0.1.2.tar.gz

Download URL masonite-instant-article-0.1.2.tar.gz
Size 23.7 kB
Tags Source
SHA-256 checksum
How to use checksums
9ad4d844f0837096b73744821c805b43a2c30ee7b00e91c938c946ea549b528e
BLAKE2b-256 checksum
How to use checksums
2eaa60d648a4db3b210429fc360ce5ff8957456568cf040217c6511a68b96543
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.1 CPython/3.9.13

Release files / masonite_instant_article-0.1.2-py3-none-any.whl

Download URL masonite_instant_article-0.1.2-py3-none-any.whl
Size 11.1 kB
Tags Python 3
SHA-256 checksum
How to use checksums
7df2df2ff6b2144ed42066934295b4b09b51ccb346b3df716e431f50fe9d5179
BLAKE2b-256 checksum
How to use checksums
10cec0779f636450928335f06caabd299bfa7cd10a5052dfe306c952e81980f1
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.1 CPython/3.9.13

Release history Release notifications | RSS feed

This release

0.1.2 This release

2 release files

0.1.0

2 release files

0.0.7

2 release files

0.0.6

1 release file

0.0.5

1 release file

0.0.4

1 release file

0.0.3

1 release file

0.0.2

1 release file

0.0.1

1 release file

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page