Southpaw 2.0

It's been the cards for a while but I've decided to finally move away from WordPress. That main issue with WordPress is that because it's such a popular platform, it will always be a prime target for attacks and exploits.

Another thing which is a bit of a minor annoyance to me is backing up, everything is stored in the database so the while thing has to be backed up and restored if needed. Also potential is is that of the database is corrupted then you could potentially lose everything.

Updating can also be a complete minefield, especially if you're using plugins. You need to make sure everything is kept up to date because of the aforementioned security issues and if there's any incompatability between the core files or the plugins, your whole site can break.

I've therefore decided to switch things up a bit and make my own platform to suit my own needs. The key factors being:

  • Fast
  • Easy to backup
  • Secure

Data

I've had the idea for a while now of using markdown for blog posts, it's nice to write and is perfect for source control add it's plain text. This would solve the backing up concerns of storing all the data in a database.

This did however bring up the consideration of whether to use a database at all. Because all the core blog data will be stored in external files, would a dedicated database be overkill? At this point I've decided to go ahead without one, purely because this site is quite small. If it reaches a larger size and the speed is impacted then perhaps I'll add a database to the setup. My current thinking would be that the values in the database would be completely built up from the markdown files so if the database was lost for whatever reason, it could be easily regenerated from the files. The database would also allow the usual benefits of easily filter and sort the data.

Structure

If no database is going to be used then an alternative method for storing structure data will be needed so I went with JSON.

The JSON will be used for the routes and the structure of each page:

routes.json

[
    {
        "url":"/",
        "page":"home"
    },
    {
        "url":"/blog.*?",
        "page":"blog"
    }
]

pages.json

{
    "global":{
        "template":"main.html",
        "templateVars":{
            "nav":"nav.html"
        }
    },
    "pages":{
        "home":{
            "templateVars":{
                "pageContent":"pages/home.html",
                "meep": "bah!",
                "test": "meh",
                "homeClass": "home"
            }
        },
        "blog":{
            "blog": {
                "base": "/blog/"
            },
            "templateVars":{
                "pageContent": "blog.html",
                "blogContent": "wheeeee"
            }
        }
    }
}

The routes JSON simply takes a regular expression of a URL and points it to an entry in the pages JSON. The pages JSON defines global and page based variable replacements which can be either plain text or HTML template files.

We'll also use JSON to automatically build up the structure of the categories and the posts. To do this we'll scan the markdown directory for any new files, scan their headers and update any structure JSON files where necessary.