This week, I resolved to code. I hadn’t done anything serious for a while and I decided that that the right time had come. So I sat down, wondering what to do. I started surfing the Net. I ended up reading an article comparing web frameworks and CMSes. An idea slowly spawned about making my own CMS type software. Something simple. Like proof-of-concept.
What I ended up making was a Python script capable of taking a directory full of posts – with content in text files and laying out a page depending on the template desired. After writing what looked like a very specific case, I paused; realized that I could abstract this and refactored it.
Then, came along an object with template functions to handle each component of the webpage separately. I had been using a text file with a list of posts with each post to be included on a new line. This became inconvenient when I wished to handle metadata. Soon, this list became a JSON file-this would easier to access and modify than a database.
Using Python’s JSON module, I eliminated storing any post info in separate run-time variables and just dumped(literally) the whole JSON into a dictionary. Here is where I took a break. I still haven’t resumed work on it, but I’m toying with the idea of adding a plugin-manager and handling images more elegantly(actually, showing images at all, without the user having to code markup, I haven’t started handling images yet :P).
Right now, it’s a script that you have to call, that generates, well, static pages. Soon, I’d want to convert it into a server, so that the posts are served real-time. I don’t want to have to re-run the script every time I edit post or create a new one. The page template functions should be part of the HTTP response probably a GET query.
The header image is a screenshot of it – taken immediately after a fresh run of the generator script. Once this gets into more of an advanced stage, I will open-source it on my GitHub.
The original goal was to make a lightweight web publishing tool, so that anyone who wants to publish their writings, just needs to write a few text files. The styling is separately with CSS- the generator has classes assigned to important sections. Including stylesheets in the package so the publishing process becomes instantaneous would be a good idea. I should seriously consider adding a media-library. Oh wait! How about a GUI front-end to edit the metadata.
If it’s a server, then even better. All users would have to do would be to enter information about each post in the (proposed)GUI tool. I feel like getting my hands dirty right away.
See you soon!