duncanlock.net

As I mentioned previously, this site was put together using Pelican - a static site generator, written in Python.

Blueprint style diagram showing a brown Pelican
Figure 1. Pelecanus Occidentalis - the Brown Pelican. Original clipart Flying Pelican from OpenClipart, by molumen, Public Domain. More on Pelican, the bird.

Static site generators take your content, pour it into your templates and output the result as static pre-generated HTML, CSS, JS & image files. You can then just upload the resulting folder of output to your server and you’re done. All you need on the server is a web server of some sort, like Apache or Nginx - anything really - all it’s doing is serving static pages.

The huge advantage of this setup is simplicity:

  1. You can write your content in Markdown [1], reStructuredText [2] or AsciiDoc [3] - all simple text formats, designed to facilitate writing and get out of …
Continue reading “How I built this website, using Pelican: Part 1 - Setup”

https://github.com/hdeshev/pelican-site-example/blob/master/blog/pelicanconf.py

def popular_articles(articles):
    populars = [article for article in articles if hasattr(article, 'popularity')]

    def comparator(x, y):
        if x.popularity != y.popularity:
            return -1 * cmp(x.popularity, y.popularity)
        else:
            return -1 * cmp(x.date, y.date)

    return sorted(populars, cmp=comparator)


def media_url(url, site_root):
    if re.match("^https?://", "https://yahoo.com", re.IGNORECASE):
        return url
    else:
        return "%s/%s" %(site_root, url)


JINJA_FILTERS = {
    "popular_articles": popular_articles,
    "media_url": media_url,
}
Continue reading “Adding Jinja Filters to Pelican”

I’ve been meaning to consolidate my personal websites onto this domain for a long, long time. My original personal website, dflock.co.uk, started in the late nineties - and has been getting a bit long in the tooth of late.

Screenshot of the current version of the dflock.co.uk website homepage
Figure 1. Static text files - the gift that keeps on giving.

That site has been up, looking mostly like that, for ~15 years - with zero maintenance or downtime. Nice to know it’s still valid CSS 1.0 :)

When I created that site originally, the options were either Adobe PageMill, or hand editing HTML in a text editor. I’ve never been a fan of WYSIWYG (what-you-see-is(supposedly)-what-you-get) editors - and the early ones were…​ not good, so I wrote all the HTML code by hand.

That site also has some data heavy pages, which are manually published from …

Continue reading “Welcome to the New Site; same as the Old Site.”