About this blog

This is the technical blog here at Openpolis. It hosts articles written by our technical staff, while facing and possibly solving problems during the day to day operations.

It is a pelican-based blog and we write the articles as simple Markdown or ReStructured text files.

Installation

You can install this solution for yourself! Fork https://github.com/openpolis/openpolis.github.com.git to your github account and clone the cloneable tag, to have an almost empty blog.

Use the git@github.com:[account]/[account].github.com.git naming convention to have the html pages hosted automagically on github’s user or organization pages at http://[account].github.com.

Now, follow these instructions:

$ mkvirtualenv [YOUR BLOG NAME]
$ git clone [YOUR GIT FORK] [YOUR BLOG NAME]
$ cd [YOUR BLOG NAME]/source
$ setvirtualenvproject
$ pip install -r requirements

Read the settings.py file, to adapt the blog to your context. You can select one among a set of pre-default themes, as a starting point for your customisations. You can activate the disqus comments, tipogrify enhancements, google analytics, twitter and github links.

Usage

To rebuild the html code:

$ fab pelican

to publish the html to github:

$ fab push

to compile and push at once:

$ fab publish

Notes

This is the directory tree:

./
 |- CNAME
 |- index.html
 |- author
 |  |- guglielmo.html
 |  |- danielef.html
 |- categories.html
 |- category
 |  |- python.html
 |  |- rest-api.html
 | ...
 |- source
    |- fabfile.py
    |- requirements.txt
    |- settings.py
    |- README.rst
    |- first.post.rst

Fabric is used to manage the ‘compile/push/publish’ tasks.

Activating the virtualenv with workon, places you inside the source folder, where the fabfile.py file lives. That enables you to use the fab tasks.

Note that the output folder is above the source folder. All output is removed before a rebuild, the source directory is excluded and the CNAME file, needed by github is re-generated. This is obtained through this fab code in the pelican task:

with lcd('..'):
  local('find * -maxdepth 0 ! -name source -print0 | xargs -0n1 rm -rf')
  local('touch CNAME; echo lab.openpolis.it >> CNAME')

Tmux and Tmuxinator

Just in case you’re using tmux and tmuxinator, I append my tmuxinator configuration. (In case you’re not, well, do it!)

# ~/.tmuxinator/lab.yml

# open a shell in the source (to work)
# open a pelican daemon, reloading on source changes
# open a basic http server (http://localhost:8000)
# open a browser with te locally-server site (wait 2 secs)

project_name: Lab Openpolis
project_root: ~/Workspace/openpolis.github.com
tabs:
  - shell: workon openpolis.github.com
  - pelican-reload: workon openpolis.github.com; fab pelican:reload_mode=True
  - http-server: workon openpolis.github.com; cd ..; python -m SimpleHTTPServer
  - browser: cd ~/Workspace/openpolis.github.com/; sleep 2; open index.html; exit
Fork me on GitHub