Skip to main content

Instant Articles

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.

How to?

Step 1: Install package

Install package by executing the following command.

pip install masonite-instant-article
Step 2: Add provider to your project

Add InstantArticleProvider into your project providers:

# config/providers
from instant_article.providers import InstantArticleProvider

PROVIDERS = [
    # ...
    InstantArticleProvider
]
Step 3: Publish Resources Files

You need to have some files setup and don't worry it's quite easy. You just have to execute the following command.

python craft package:publish instant_article
Step 4: 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
"""

Step 5: Implement Instant Article Interface to your Model and configure as follows

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
        })
Step 6: Awesome
  1. Your project is now ready to go :+1:.

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.6.tar.gz (9.7 kB view details)

Uploaded Source

File details

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

File metadata

  • Download URL: masonite-instant-article-0.0.6.tar.gz
  • Upload date:
  • Size: 9.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.7.1 importlib_metadata/4.10.0 pkginfo/1.8.2 requests/2.27.1 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.9.9

File hashes

Hashes for masonite-instant-article-0.0.6.tar.gz
Algorithm Hash digest
SHA256 f40127e0a7b37d80b5a882e39fd36a122203baf6ed4bc00d2dc4c12f4f896a33
MD5 1469798708b03d89919834942eb0f941
BLAKE2b-256 90d85e53ca8803fff2334d1f83431259112e84412557db88b2b55637b94f810e

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 Pingdom Monitoring Sentry Error logging StatusPage Status page