A simple abstraction for publishing files as blog posts.
Project description
Easy Publish
Easy publish is a Python library that provides a simple abstraction for publishing text files as blog posts.
Installation
Requires: Python >= 3.6
python3 -m pip install easy-publish
Usage
To use easy publish import and call the generate_posts
function pointing it to the directory your files are located in. The generate_posts
function returns an object that has two useful class variables: metadata
and posts
. metadata
is a list of metadata about each of your posts(the "Including Markdown" section explains how to include metadata). posts
is a list of post objects that include metadata and post content.
Below is a simple flask app with jinja templating that utilizes easy publish and the metadata
/post
objects. While this example uses flask/jinja, any web framework/templating engine should work with easy publish.
app.py
from flask import Flask, render_template
from easy_publish import generate_posts
app = Flask(__name__)
posts = generate_posts("~/path/to/blogposts")
@app.route("/blog")
def blog():
return render_template("blog.html", metadata=posts.metadata)
@app.route("/blog/<p>")
def blogpost(p):
return render_template("post.html", post=posts.posts[p])
blog.html
{{% for post in metadata %}}
<li>{{ post.title }}</li>
<li>{{ post.date }}</li>
<li>{{ post.tags }}</li>
<li>{{ post.author }}</li>
{{% endfor %}}
post.html
<h1>{{ post.title }}</h1>
<h4>{{ post.date }}</h1>
<h4>{{ post.author }}</h1>
<p>{{ post.content }}</p>
Including Metadata
Easy publish expects text files to have a section at the top denoting metadata information. The section should be in the following format:
~
title: title would go here
date: date would go here
tags: tags, would, go, here (comma separated)
author: author would go here
~
The parser looks for information in between the ~'s and strips it out into the metadata. It's on the list of TODO's to add different ways to include metadata.
Contributing
Currently in heavy development and not a stable interface. Feel free to contribute ideas as issues or as a pull request.
License
MIT
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
Built Distribution
File details
Details for the file easy-publish-0.0.12.tar.gz
.
File metadata
- Download URL: easy-publish-0.0.12.tar.gz
- Upload date:
- Size: 7.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.4.1 importlib_metadata/3.7.3 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.59.0 CPython/3.9.2
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | e3b3ccfb242134285ad433150e479288f4f4dd7caefd1d0e41ff6cab2a8114d5 |
|
MD5 | 2c134bdec755920e3918f35519919b15 |
|
BLAKE2b-256 | d202ed7d4dfc29bdcec3e94e5cc3c55cf87f98aa11f7872e8e3472ccc6c30f3b |
File details
Details for the file easy_publish-0.0.12-py2.py3-none-any.whl
.
File metadata
- Download URL: easy_publish-0.0.12-py2.py3-none-any.whl
- Upload date:
- Size: 7.4 kB
- Tags: Python 2, Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.4.1 importlib_metadata/3.7.3 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.59.0 CPython/3.9.2
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 66f1b8150c2d8156f0f014a6b67776bedc1c200ed519a145d15a70af90654151 |
|
MD5 | 11fc975eb4823c415839ca61ad539b5b |
|
BLAKE2b-256 | 1e97f3c17fc13eddfc11908662f4e8ccb7520336897202122ce6c6f57e6dae70 |