Product
Introducing License Enforcement in Socket
Ensure open-source compliance with Socket’s License Enforcement Beta. Set up your License Policy and secure your software!
canonicalwebteam.blog
Advanced tools
This extension allows you to add a simple frontend section to your flask app. All the articles are pulled from Canonical's Wordpress back-end through the JSON API.
This extension provides a blueprint with 3 routes:
To install this extension as a requirement in your project, you can use PIP;
pip3 install canonicalwebteam.blog
See also the documentation for pip install.
For local development, it's best to test this module with one of our website projects like ubuntu.com. For more information, follow this guide (internal only).
The module expects HTML templates at blog/index.html
, blog/article.html
, blog/blog-card.html
, blog/archives.html
, blog/upcoming.html
and blog/author.html
.
An example of these templates can be found at https://github.com/canonical-websites/jp.ubuntu.com/tree/master/templates/blog.
In your app you can then do the following:
import flask
import talisker.requests
from flask_reggie import Reggie
from canonicalwebteam.blog import BlogViews, build_blueprint, BlogAPI
app = flask.Flask(__name__)
Reggie().init_app(app)
session = talisker.requests.get_session()
blog = build_blueprint(
BlogViews(
api=BlogAPI(session=session),
)
)
app.register_blueprint(blog, url_prefix="/blog")
You can customise the blog through the following optional arguments:
blog = build_blueprint(
BlogViews(
blog_title="Blog",
blog_path="blog",
tag_ids=[1, 12, 112],
exclude_tags=[26, 34],
per_page=12,
feed_description="The Ubuntu Blog Feed",
api=BlogAPI(
session=session,
use_image_template=True,
thumbnail_width=330,
thumbnail_height=185,
),
)
)
All tests can be run with ./setup.py test
.
All API calls are caught with VCR and saved as fixtures in the fixtures
directory. If the API updates, all fixtures can easily be updated by just removing the fixtures
directory and rerunning the tests.
To do this run rm -rf fixtures && ./setup.py test
.
FAQs
Flask extension to add a nice blog to your website
We found that canonicalwebteam.blog demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 6 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Product
Ensure open-source compliance with Socket’s License Enforcement Beta. Set up your License Policy and secure your software!
Product
We're launching a new set of license analysis and compliance features for analyzing, managing, and complying with licenses across a range of supported languages and ecosystems.
Product
We're excited to introduce Socket Optimize, a powerful CLI command to secure open source dependencies with tested, optimized package overrides.