Tagged with markdown

Elisp to create a pelican blog entry

This is a quick one, mainly just to test out the little bit of elisp code that I wrote to automate the creation of blog posts. Which is what I am doing now. So meta.

Here's the code:

(defvar *blog-root*   "/path/to/pelican/website/content/")
(defvar *blog-author* "Your Name")

(defun strip-nonfile-chars (s)
  (replace-regexp-in-string "[^0-9a-zA-Z_ ]" "" s))

(defun space-to-dash (s)
  (replace-regexp-in-string " " "-" s))

(defun title-to-blog-filename (title)
  (concat (downcase (space-to-dash (strip-nonfile-chars title)))

(defun start-blog-entry ()
  "Creates a new markdown blog entry for pelican"
  (let ((title (read-from-minibuffer "Title of new blog entry? ")))
    (find-file (concat *blog-root* (title-to-blog-filename title)))
    (insert (format (concat "Title: %s\n"
                            "Date: %s\n"
                            "Category: Blog\n"
                            "Author: %s\n\n")
                    (format-time-string "%Y-%m-%d %R")

Fill in the vars, bind the start-blog-entry function to your favorite key sequence, and off you go.

Tagged , , , ,

Building a website with Pelican

So you want to get a website up, but would rather mess around with getting your site hosting framework perfect rather than generating actual content? Me too.

If you want to try static website content hosting and you're a python fan, Pelican seems to be a great choice. Supports Markdown, my minimalist text format of choice. I looked at hyde thinking it would be the python alternative to Jekyll, which people seem to love, but it seemed too complicated. With Pelican, you can write a single isolated blog post in markdown and have a website. As an experienced blogger (I've been blogging for all of 10 minutes now), that's what I want.


You'll generate a site skeleton with pelican-quickstart. You'll put blogposts as separate files in yoursite/content. E.g., yoursite/content/firstpost.md. Sitewide settings are in pelicanconf.py. You'll run

make html

which will generate all the content. You'll upload the content to your host of choice with something like

make rsync_upload

During development, you'll host your website locally with

make devserver

Just go to http://localhost:8000 to see your site.

Getting Started

The pelican documentation is great. Follow it.


Pelican comes with two themes built in, but there are many more on github. Let's see how easy it is to try them out. Change to a development directory and

git clone --recursive git://github.com/getpelican/pelican-themes.git

Be sure that --recursive is there, because some of the themes are included as submodules. I got some errors on this step because the url used for the submodules are formatted differently (e.g., http vs. https vs. git@github.com) and putty complained that their keys weren't cached. SSH into the offending url to update your cache. Also, it seems that you need a github key to get all of them. So, try leaving out the --recursive if you just want it to work, but some of the themes will be empty folders (e.g., chunk iris neat pelican-mockingbird relapse svbtle).

Now, lets install all of the themes so we can try them out. Just to be quick and dirty about it, lets do this manually. Change to the pelican-themes directory and

pelican-themes -i Just-Read basic bootlex bootstrap bootstrap2 brownstone built-texts cebong dev-random dev-random2 lightweight martyalchin mnmlist notmyidea-cms-fr notmyidea-cms sneakyidea subtle syte tuxlite_tbs waterspill-en waterspill chunk iris neat pelican-mockingbird relapse svbtle

Just to check this worked

pelican-themes --list

should list everything above.

Now, to try out a theme, just add (or change) in pelicanconf.py:


Great. Now, you can just flick through all of the themes that other people have worked really hard to build and convince yourself you are 'designing' a website.


It's really just copying, right? Pelican has some built in options for deploying, using rsync over ssh to save on transfer. But, I use windows because I like things difficult, and getting rsync working on windows is... difficult, especially if you are trying to do it with putty/plink. (I believe an older version of cwRsync is the closest, but then see here and here for workarounds. You can also try installing rsync with the MSYS developer tools, but it has the same plink issue.)

So, winscp has some rsync like functionality. Put this into a deploy.bat:

winscp.com /command "open username@webhost.com" "synchronize remote -delete -mirror -criteria=either -filemask=|*~;*#;*.pyc output/ /home/username/website/" "exit"

replacing all of the relevant fields. You need the 5.x version of winscp to use the filemask option.

Sweet! That's all for now.

Tagged , , ,