Flask extension and Django App to add a nice blog to your website
Project description
# Blog flask extension
This extension allows you to add a simple blog frontend to your flask app. All the articles
are pulled from the WordPress API that has the plugin WP-JSON.
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.
## How to use
### Flask
In your app you can:
```python
import canonicalwebteam.blog_extension import BlogExtension
blog = BlogExtension(app, "Blog title", [1], "tag_name", "/url-prefix")
```
If you use the factory pattern you can also:
```python
import canonicalwebteam.blog_extension import BlogExtension
blog = BlogExtension()
blog.init_app(app, "Blog title", [1], "tag_name", "/url-prefix")
```
### Django
- Add the blog module as a dependency to your Django project
- Load it at the desired path (f.e. "/blog") in the `urls.py` file
```python
from django.urls import path, include
urlpatterns = [path(r"blog/", include("canonicalwebteam.blog.django.urls"))]
```
- In your Django project settings (`settings.py`) you have to specify the following parameters:
```python
BLOG_CONFIG = {
# the id for tags that should be fetched for this blog
"TAGS_ID": [3184],
# the title of the blog
"BLOG_TITLE": "TITLE OF THE BLOG",
# the tag name for generating a feed
"TAG_NAME": "TAG NAME FOR GENERATING A FEED",
}
```
- You can now use the data from the blog. To display it the module expects templates at `blog/index.html`, `blog/article.html` and `blog/blog-card.html`. Inspiration can be found at https://github.com/canonical-websites/jp.ubuntu.com/tree/master/templates/blog.
- Run your project and verify that the blog is displaying at the path you specified (f.e. '/blog')
This extension allows you to add a simple blog frontend to your flask app. All the articles
are pulled from the WordPress API that has the plugin WP-JSON.
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.
## How to use
### Flask
In your app you can:
```python
import canonicalwebteam.blog_extension import BlogExtension
blog = BlogExtension(app, "Blog title", [1], "tag_name", "/url-prefix")
```
If you use the factory pattern you can also:
```python
import canonicalwebteam.blog_extension import BlogExtension
blog = BlogExtension()
blog.init_app(app, "Blog title", [1], "tag_name", "/url-prefix")
```
### Django
- Add the blog module as a dependency to your Django project
- Load it at the desired path (f.e. "/blog") in the `urls.py` file
```python
from django.urls import path, include
urlpatterns = [path(r"blog/", include("canonicalwebteam.blog.django.urls"))]
```
- In your Django project settings (`settings.py`) you have to specify the following parameters:
```python
BLOG_CONFIG = {
# the id for tags that should be fetched for this blog
"TAGS_ID": [3184],
# the title of the blog
"BLOG_TITLE": "TITLE OF THE BLOG",
# the tag name for generating a feed
"TAG_NAME": "TAG NAME FOR GENERATING A FEED",
}
```
- You can now use the data from the blog. To display it the module expects templates at `blog/index.html`, `blog/article.html` and `blog/blog-card.html`. Inspiration can be found at https://github.com/canonical-websites/jp.ubuntu.com/tree/master/templates/blog.
- Run your project and verify that the blog is displaying at the path you specified (f.e. '/blog')
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Close
Hashes for canonicalwebteam.blog-1.1.0.tar.gz
Algorithm | Hash digest | |
---|---|---|
SHA256 | 06583e2bde22a0a6e8ffc619dd1d3b910ece6baaceb2856437e343efc7771eb5 |
|
MD5 | d936766589be6c9f54c204b15d49463b |
|
BLAKE2b-256 | 29b61696c8ed01fb4e8b675b00f4a076c53f431a8ac501aa6a852c6e3ae59af9 |