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 :+1:.

Contributing

Please read the Contributing Documentation here.

License

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

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

masonite-instant-article-0.0.7.tar.gz (22.4 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

masonite_instant_article-0.0.7-py3-none-any.whl (11.1 kB view details)

Uploaded Python 3

File details

Details for the file masonite-instant-article-0.0.7.tar.gz.

File metadata

  • Download URL: masonite-instant-article-0.0.7.tar.gz
  • Upload date:
  • Size: 22.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.8.0 pkginfo/1.8.2 readme-renderer/32.0 requests/2.27.1 requests-toolbelt/0.9.1 urllib3/1.26.8 tqdm/4.62.3 importlib-metadata/4.11.1 keyring/23.5.0 rfc3986/2.0.0 colorama/0.4.4 CPython/3.9.10

File hashes

Hashes for masonite-instant-article-0.0.7.tar.gz
Algorithm Hash digest
SHA256 9339fd63565232e84bf9fc10c92eed55a0af14282467bdd656ab092ff31062f0
MD5 ead148aadb101c9869a113ddf9be848b
BLAKE2b-256 f7771399dcebb2f35d0a195a0d1ad41639e493a917540e24c33ae8e3b61c2797

See more details on using hashes here.

File details

Details for the file masonite_instant_article-0.0.7-py3-none-any.whl.

File metadata

  • Download URL: masonite_instant_article-0.0.7-py3-none-any.whl
  • Upload date:
  • Size: 11.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.8.0 pkginfo/1.8.2 readme-renderer/32.0 requests/2.27.1 requests-toolbelt/0.9.1 urllib3/1.26.8 tqdm/4.62.3 importlib-metadata/4.11.1 keyring/23.5.0 rfc3986/2.0.0 colorama/0.4.4 CPython/3.9.10

File hashes

Hashes for masonite_instant_article-0.0.7-py3-none-any.whl
Algorithm Hash digest
SHA256 6aed398f726dea62ad2418bff44a7bc82eaaa36033ee0b55ff4de12f11398603
MD5 cbde032dc358e614f9a3a6d69cff4869
BLAKE2b-256 89d0deac7344364b16995595ae9ef9384a99fef176ae99f462c0a7f9cfb1c480

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page