Name | canonicalwebteam.blog JSON |
Version |
6.5.0
JSON |
| download |
home_page | None |
Summary | Flask extension to add a nice blog to your website |
upload_time | 2025-07-29 12:46:34 |
maintainer | None |
docs_url | None |
author | Canonical webteam |
requires_python | None |
license | None |
keywords |
|
VCS |
|
bugtrack_url |
|
requirements |
No requirements were recorded.
|
Travis-CI |
No Travis.
|
coveralls test coverage |
No coveralls.
|
# Canonical blog extension
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](https://admin.insights.ubuntu.com/wp-admin/) through the JSON API.
This extension provides a blueprint with 3 routes:
- "/": that returns the list of articles
- "/<slug>": the article page
- "/feed": provides a RSS feed for the page.
## Installation
To install this extension as a requirement in your project, you can use PIP;
```bash
pip3 install canonicalwebteam.blog
```
See also the documentation for [pip install](https://pip.pypa.io/en/stable/reference/pip_install/).
## Usage
### Local development
For local development, it's best to test this module with one of our website projects like [ubuntu.com](https://github.com/canonical-web-and-design/ubuntu.com/). For more information, follow [this guide (internal only)](https://discourse.canonical.com/t/how-to-run-our-python-modules-for-local-development/308).
### Templates
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.
### Usage
In your app you can then do the following:
```python3
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:
```python3
blog = build_blueprint(
BlogViews(
blog_title="Blog",
blog_path="blog",
tag_ids=[1, 12, 112],
excluded_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,
),
)
)
```
## Testing
All tests can be run with `./setup.py test`.
### Regenerating Fixtures
All API calls are caught with [VCR](https://vcrpy.readthedocs.io/en/latest/) 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`.
Raw data
{
"_id": null,
"home_page": null,
"name": "canonicalwebteam.blog",
"maintainer": null,
"docs_url": null,
"requires_python": null,
"maintainer_email": null,
"keywords": null,
"author": "Canonical webteam",
"author_email": "webteam@canonical.com",
"download_url": "https://files.pythonhosted.org/packages/83/8d/b0b04a4f78be4c58b443c1d0f05b43751718a4090e3854be4c854964332c/canonicalwebteam_blog-6.5.0.tar.gz",
"platform": null,
"description": "# Canonical blog extension\n\nThis extension allows you to add a simple frontend section to your flask app. All the articles\nare pulled from [Canonical's Wordpress back-end](https://admin.insights.ubuntu.com/wp-admin/) through the JSON API.\n\nThis extension provides a blueprint with 3 routes:\n\n- \"/\": that returns the list of articles\n- \"/<slug>\": the article page\n- \"/feed\": provides a RSS feed for the page.\n\n## Installation\n\nTo install this extension as a requirement in your project, you can use PIP;\n\n```bash\npip3 install canonicalwebteam.blog\n```\n\nSee also the documentation for [pip install](https://pip.pypa.io/en/stable/reference/pip_install/).\n\n## Usage\n\n### Local development\n\nFor local development, it's best to test this module with one of our website projects like [ubuntu.com](https://github.com/canonical-web-and-design/ubuntu.com/). For more information, follow [this guide (internal only)](https://discourse.canonical.com/t/how-to-run-our-python-modules-for-local-development/308).\n \n### Templates\n\nThe 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`.\n\nAn example of these templates can be found at https://github.com/canonical-websites/jp.ubuntu.com/tree/master/templates/blog.\n\n### Usage\n\nIn your app you can then do the following:\n\n```python3\nimport flask\nimport talisker.requests\nfrom flask_reggie import Reggie\nfrom canonicalwebteam.blog import BlogViews, build_blueprint, BlogAPI\n\napp = flask.Flask(__name__)\nReggie().init_app(app)\nsession = talisker.requests.get_session()\n\nblog = build_blueprint(\n BlogViews(\n api=BlogAPI(session=session),\n )\n)\napp.register_blueprint(blog, url_prefix=\"/blog\")\n```\n\nYou can customise the blog through the following optional arguments:\n\n```python3\nblog = build_blueprint(\n BlogViews(\n blog_title=\"Blog\",\n blog_path=\"blog\",\n tag_ids=[1, 12, 112],\n excluded_tags=[26, 34],\n per_page=12,\n feed_description=\"The Ubuntu Blog Feed\",\n api=BlogAPI(\n session=session,\n use_image_template=True,\n thumbnail_width=330,\n thumbnail_height=185,\n ),\n )\n)\n```\n\n## Testing\n\nAll tests can be run with `./setup.py test`.\n\n### Regenerating Fixtures\n\nAll API calls are caught with [VCR](https://vcrpy.readthedocs.io/en/latest/) 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.\n\nTo do this run `rm -rf fixtures && ./setup.py test`.\n",
"bugtrack_url": null,
"license": null,
"summary": "Flask extension to add a nice blog to your website",
"version": "6.5.0",
"project_urls": null,
"split_keywords": [],
"urls": [
{
"comment_text": null,
"digests": {
"blake2b_256": "9d273d501b971b3fe3593d52322c5d7cd5fb2f258dad35998ae1eb00b1ac1515",
"md5": "e8b6a43d5a9d0f509a3cdfbe6bc8457f",
"sha256": "0809dd60bcd7084c5b5d68d65067d74aff793521e0cf9ad7ff76610b5f9b7fd4"
},
"downloads": -1,
"filename": "canonicalwebteam_blog-6.5.0-py3-none-any.whl",
"has_sig": false,
"md5_digest": "e8b6a43d5a9d0f509a3cdfbe6bc8457f",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": null,
"size": 15341,
"upload_time": "2025-07-29T12:46:33",
"upload_time_iso_8601": "2025-07-29T12:46:33.470424Z",
"url": "https://files.pythonhosted.org/packages/9d/27/3d501b971b3fe3593d52322c5d7cd5fb2f258dad35998ae1eb00b1ac1515/canonicalwebteam_blog-6.5.0-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": null,
"digests": {
"blake2b_256": "838db0b04a4f78be4c58b443c1d0f05b43751718a4090e3854be4c854964332c",
"md5": "840e57183b6a43f8675436945bf14dc5",
"sha256": "6633a0d39d4506df35119a28cf069cf87966b5072b761062b02e7104414a3580"
},
"downloads": -1,
"filename": "canonicalwebteam_blog-6.5.0.tar.gz",
"has_sig": false,
"md5_digest": "840e57183b6a43f8675436945bf14dc5",
"packagetype": "sdist",
"python_version": "source",
"requires_python": null,
"size": 13600,
"upload_time": "2025-07-29T12:46:34",
"upload_time_iso_8601": "2025-07-29T12:46:34.689332Z",
"url": "https://files.pythonhosted.org/packages/83/8d/b0b04a4f78be4c58b443c1d0f05b43751718a4090e3854be4c854964332c/canonicalwebteam_blog-6.5.0.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2025-07-29 12:46:34",
"github": false,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"lcname": "canonicalwebteam.blog"
}