We picked Pelican as the static blog generator after studying a somewhat outdated article about such generators (in Russian). It appeared that there are many of them, and one can choose any which looks good. We've had a Python background, some experience with Jinja2 templates (used in e.g. in publishers) and GitHub flavored Markdown markup. Although our docs are made up with Sphinx which adopts reStructuredText markup, we like Markdown better for it's cleaner syntax and general availability (GitHub, StackOverflow, etc.). Personally, reStructuredText makes me suffer, and it is one of the reasons perhaps why Veles documentation currently sucks. Anyway, that Habrahabr article showed that Pelican perfectly suited our tastes.
It appeared to be really nice and easy to understand, and the docs are good. There is one feature that miss out of the box - automatic Twitter updates after publishing. I found pelican_auto_tweet project on GitHub which seemed relevant,
but it does not support Python 3 and the code looked untidy. Then I recalled how I used excellent tweepy package for sending tweets and pygit2 for Git scripting and the solution came.
Basically, I took
libpelican.py from pelican_auto_tweet and the mentioned packages together with Jinja2. Refer to tweet.py.
auto_tweet() function is called on the script execution, which initializes
tweepy.API instance and triggers
status_update() with the rendered template for each new article (of class
get_new_articles() is a generator (I love generators) which compares the current set of Pelican articles with those committed in Git, takes only one language in case of a multilingual blog, yields the constructed objects and finally does
git commit followed by
git push. I added a new Makefile target "twitter" and set "ssh_upload" as the dependency.
make twitter publishes Pelican blog on disk, uploads it through SSH to velesnet.ml, creates the tweets pointing to new articles and finally pushes the changes back to my Git repository on GitHub. Sweet.
There are comments.