Dirk Rüdiger 229c103994 Extended Documentation of the textbundle plugin. | 9 éve | |
---|---|---|
.. | ||
Readme.md | 9 éve | |
__init__.py | 9 éve | |
migrate.sh | 9 éve | |
textbundle.py | 9 éve |
This plugin helps you creating posts from Textbundles (http://textbundle.org/spec/).
In a nutshell a textbundle is a folder with a .textbundle
name suffix and
a predefined folder hierarchy. The Markdown text is always in a file text.md
,
all referenced assets (images, videos, etc.) are located in a subfolder named
assets/
and a file info.json
(obviously in JSON format) provides some meta
data.
This plugin needs Markdown to work. Install it with:
pip install Markdown
Install the textbundle plugin and add it to the PLUGINS
setting in
pelicanconf.py
:
PLUGINS = [
'textbundle',
...
]
Furthermore the content of the ARTICLE_PATHS
setting has to be appended to the
STATIC_PATHS
list.
ARTICLE_PATHS = ['posts']
...
STATIC_PATHS = [
'posts',
...
]
The output content pages has to be generated into files index.html
inside the
folder named after the page slug or article slug. This way the assets can be
placed next to the content file and do not interfere with asset files of other
textbundles.
A working example of article/page slugs and output URLs are:
ARTICLE_URL = 'post/{slug}/'
ARTICLE_SAVE_AS = 'post/{slug}/index.html'
PAGE_URL = '{slug}/'
PAGE_SAVE_AS = '{slug}/index.html'
Inside a Markdown file (the file text.md
in a textbundle) the files from the
assets/
folder are referenced using relative pathnames and the {attach}
suffix, as described in the pelican documentation, section
"Linking to static files".
An article with the slug "my-blog-post" and an image named screenshot.png
in
the assets/
folder contains a link like this:
![alt text]({attach}assets/screenshot.png "title text")
Assuming the above mentioned settings in pelicanconf.py
the following files
are generated in the output folder:
Further examples can be found in my personal blog (GitHub, Link).
To create a new post I have a shell function new_post
defined in ~/.bashrc
or
~/.zshrc
. Running
new_post "My next blogpost"
at the shell prompt creates the file structure of a textbundle in the posts dir of my blog project. The code can be found in my new_post gist. The path names are hardcoded as it's quite easy to adopt the script to one's personal needs.