Tag python

My Pelican enhancements

As written in my earlier blog post, I had some issues open for my blog:

  • create a proper sitemap
  • create a simple and responsive theme
  • minify all the things

To solve them, I created 2 Python packages and a theme for pelican installations. Refer to their PyPI or Github page for installation instructions.

pelican-extended-sitemap

Creates a sitemap.xml from your pages.
PyPI-Link: https://pypi.python.org/pypi/pelican-extended-sitemap
Github: https://github.com/dArignac/pelican-extended-sitemap
Example: https://www.zoe.vc/sitemap.xml

pelican-minification

Automatic minification for all HTML and CSS files used in a Pelican project.
PyPI-Link: https://pypi.python.org/pypi/pelican-minification
Github: https://github.com/dArignac/pelican-minification

pelican-theme-bootstrap3

A Bootstrap 3 based theme for Pelican sites. It's the theme you're currently viewing.
PyPI-Link: not available as this does not work with the Pelican theme mechanism
Github: https://github.com/dArignac/pelican-theme-bootstrap3

Install PyRun on current CentOS

Installing a current version of PyRun on CentOS 6.5 Final did not work for me, several issues occurred:

../bin/pyrun: error while loading shared libraries: libssl.so.1.0.0: cannot open shared object file: No such file or directory

On current CentOS installations there is no libssl.so.1.0.0, instead after patching the heartbleed bug through yum there is libssl.so.1.0.1e. So simply symlink the lib and you're fine:

ln -s /usr/lib64/libssl.so.1.0.1e /usr/lib64/libssl.so.1.0.0

But afterwards the PyRun installation still does not complete properly - there is another lib failing. Patch it by symlinking again:

../bin/pyrun: error while loading shared libraries: libcrypto.so.1.0.0: cannot open shared object file: No such file or directory
ln -s /usr/lib64/libcrypto.so.1.0.1e /usr/lib64/libcrypto.so.1.0.0

Now, the whole thing is running.

Switching from Wordpress to Pelican

I run a couple of sites that are based on Wordpress and my blog was one of them. There are several things that annoy me when it comes to Wordpress:

  • too many plugins that you need for a good site
  • updates, updates, updates (I merely spend my time in updating everything and keeping compatible)
  • the Wordpress core code
  • the themes HTML and structure that are PHP files
  • it's PHP
  • PHP-FPM consumes to much memory (if configured to serve a Wordpress site with good performance)

So for my blog, which really is static but for the comments, I looked around what tools or frameworks are there to replace the mighty Wordpress with a static site. I wanted something simple, something pythonic. By reading the blogs of people who also had switched from Wordpress I found two tools: Hyde, a pythonic fork of Jekyll, and Pelican. The majority of people who switched chose Pelican, so I did, too. It has more forks on Github and also a repository of plugins. In fact both tools are not very different from each other. Pelican just felt better while using.

The switch took me some days, I had a couple of problems to solve/things to do:

  • create a theme that comes near to my old one
  • configure Pelican to have behave nearly like the old Wordpress configuration
    • adjust all URLs and pagination
    • create nginx config to serve everything
  • convert all content to Markdown
    • Pelican can convert Wordpress xml exports to Markdown/restructuredText
    • some modification to the generated files had to be made
      • Pelican support only one category
      • I used the time to clean the content, too:
        • convert all tags to lowercase
        • fix all invalid URL slugs and create a nginx config to rewrite the old URLs to the new ones
  • create a sitemap.xml
  • integrate Disqus:
    • as Disqus takes Wordpress xml export files, too, it is easy import Wordpress comments to Disqus. Only thing to consider is to adjust the URLs that have changed, otherwise Disqus will not allocate the comments to the appropriate blog entry

The only thing a little mindfucking was the paging configuration but everything else was pretty easy. I can only recommend Pelican to you if your blog is simple and static. The code syntax highlighting feature using pygments is really nifty!

I'm still not totally happy with the blog, but it's nearly in its final form. The following things will be done in the future:

  • use a more readable font PT Sans (it's PT Sans now)
  • compress javascript and stylesheets
  • make the theme responsive PT Sans (at least it is readable)