Pablo Iranzo Gómez's blog

jun 03, 2016

New blog rendering engine: Pelican

As always, I don't usually find myself keen to write about things I do, until I later realize they might be helpful for others, and that's why in the past I decided to switch the place I was putting the information about why did to Github and also, take benefit of practicing markdown for writing the entries.

At that time, I moved my old blog posts to markdown to be used in conjunction with Jekyll and to use Octopress as the engine rendering the contents into a static website. The setup and migration was not difficult, but still require to use some ruby, while I was more familiar with Python.

Since some time ago, I was checking other platforms, following the same approach of rendering markdown files and sticker to Pelican, it's included in Fedora Repos (python-pelican). Pelican offers a similar behaviour, having also a server for allowing you to quickly test the new settings (plugins, themes, etc) and to publish the resulting website to a hosting provider.

As I did with Jekyll+Octopress, I'm still using github.io for it, and I'm in the process of adapting some changes like additional plugins, theme tweaks and consider to develop one of my own.

Click to read and post comments

abr 01, 2015

Migrate SPIP-RSS post feed to HTML

I had my old blog based on SPIP, and I wanted to keep all the posts together, to make it easier to migrate in the future.

Initially, I migrated my posts from blogger, where there's an option to export the contents and some plugins to allow easier importing to markdown files (to be used by Octopress), those were the recent posts, so part of the job was already done there.

Next step, was to migrate old posts on my spip site.

SPIP, being not as popular as other solutions, might lack plugins for importing the data, but has a nice feature: it allows to provide full article contents via RSS.

So:

  • I entered into my site private area /ecrire/
  • Entered to the administration section and under Content, I temporarly changed the syndication settings to provide full articles instead of just summary.
  • Then, I visited the url for my user, but on the rss generator template: spip.php?page=backend&id_rubrique=6, and saved it as file.xml

At this point I needed some software for automating the initial conversion, so I went to python's feedparser libraries to perform this with a bit of coding:

url="/path/to/your/xml/file.xml"

import codecs
import feedparser
feed=feedparser.parse(url)

for item in feed["items"]:
    filename=item["date"][0:10]+"-"+item["link"][23:] #remove the first 23 chars from article url http+domain
    print filename
    with codecs.open(filename,'w','utf-8') as f:
        f.write("---\n")
        f.write("layout: post\n")
        for elem in ["title","date"]:
            f.write("%s: %s\n" % (elem,item[elem]))
        f.write("---\n")
        f.write(item["content"][0].value)

After each iteration, a new file was created using the old http link to the article (which already had stripped problematic characters).

Just moving those files to source/_posts allows me to republish them on a different site, and later work the conversion to markdown by using pandoc and some manual tuning.

Click to read and post comments

mar 24, 2015

Octopress for jekyll blogging

After testing for some days Jekyll and github.io for blog posting, I was missing some features of other CMS, so I started doing some search on how to automate many other topics while keeping simplicity on blog posting.

Octopress Makes this extra step so you can still focus on your contents and of course have a nice template as starting point with integrations for some social plugins, etc.

Setup is well done if you follow the provided steps, without jumping anything, in my case, I moved my old pages (plain jekyll + poole) to OctoPress.

On Fedora and as my unprivileged user, I did:

One of the interesting things it that it uses two branches on git, master and source, where master is the one that github publishes (your live environment) and source is the actual code for your blog, templates, posts, etc that are later generated, previewed and deployed from above steps.

I'll be testing it for a while to see how it works, but so far, so good.

Click to read and post comments