A very tiny blog script :
- source articles in Markdown format
- blog script written in Perl
- library CMark to translate Markdown to HTML
- library Source-Highlight to highlight
<code>in the HTML
- You write your article using a Markdown editor
- You save your article as an
.mdfile in thesource/directory. - You run the blog script
script_export.pl - You get your article as
.htmlin theexport/directory !
The Perl Script calls cmark and source-highlight so you must have them in your path. Normally when you install these two packages they will be known by these names.
The minimal blog structure is the two directories source/ and source/data/ and two possibly empty files source/top.html and source/bot.html.
The Perl script uses Perl libraries File::Basename, HTML::Entities and IPC::Open3.
These are the two .html files automatically included at the beginning and the end of every article.
top.html contains for example the <head>, with a link to an eventual css file.
The <title> is automatically filled with the content of the first <h1> found in the article.
bot.html contains for example the <footer>.
These must all go into the source/data/ directory.
The blog script creates a symlink of source/data/ in export/data.
So both source/ and export/ points to source/data/ directory.
You can create sub-directories inside source/data/.
Modifying a data (a css file or an image) does not imply to re-export, since export/data is linked to source/data/.
Careful ! export/data is a symlink to source/data !
So rm -r export/data/ (with the / at the end) will delete source/data/ !
Just use rm -r export/ and it will not follow the symlink.
The blog script will create export/ and export/data if they do not exist. So as long as you are careful it is fine to delete export/.
This github repository contains itself a little example. You will find two articles in source/ with a css file in source/data/css. The result of script_export.pl is in the export/ directory.
With the package inotify-tools, you run the following command :
inotifywait -r -m -e MODIFY source/ | while IFS= read -r line; do ./script_export.pl ; doneIt waits and notifies for all MODIFY events on all files in source/ folder recursively, and for each event call the script. Ctrl+C to stop.
-
an automatic summary generated at the beginning of each article
-
an automatic list of articles for the index page
-
categories/tags for organizing articles