Posted on 05/31/2013
When I decided to create a blog to log my thoughts and ideas, I didn't want to use any of the existing blogging platforms. For one, most of the existing (free) blogging sites require you to have a subdomain of their domain (i.e.
thedadams.blogspot.com). Tumblr was the only one I found that did not require this, but I will stay away from it now that it has been purchased by Yahoo. For another, these sites only give you a fixed number of free themes to work with, and instead of taking the time to write my own theme, I can simply use the CSS files I already have for my website. This all led me to create this blog from scratch. I would like to take this time to describe how I did that.
$_GET variable to retrieve the desired post. The PHP code that does this is robust; if the user changes or deletes the "post" entry in the URL, the code handles this by displaying an error message. The post HTML file also displays dates, comments, and archive mentioned above. The third HTML file is the credits page. It lists the appropriate credits and mentions for resources used in the blog.
The CSS files are self-explanatory. Yes, there are two. I decided that I wanted the blog to be responsive. This gives a bigger, easier to read version for screens with width 680 pixels or smaller. This is achieved using CSS media types and a viewport meta tag.
Not surprisingly, the three PHP files are the "meat and potatoes" of the blog. The first creates a class called "Post" which is used throughout the blog. Each Post contains instance variables
title, body, dateCreated, and
dateUpdated as well as getters and setters for each. I realize that creating a class for a blog post is a little overkill at this point, but as the blog evolves and features are added, I feel that having a Post class will be beneficial. The second PHP file creates the layout for the Archive section. This script searches the relevant directories for posts and puts them in the correct layout. All the HTML code for the hide-and-show functionality is also added by this PHP script. The last PHP file uses Pushover's API to send alerts to me when someone visits one of my blog posts (not the blog itself). This is just temporary; as my blog becomes more established, I won't care about getting these notifications in real-time. I would like to point out that I did find a way to use Pushover's API without using cURL as they suggest. The server where this blog was developed did not have cURL installed, and I did not have privileges to install it. Therefore, I had to find this workaround. If you are interested in how I did this, please leave a comment below and I will be happy to write about it. However, the current server has cURL. I switched cURL so that errors and callbacks can be handled.
The posts are saved in directories according to the date they were posted. For example, this post is saved in the directory
Posts/2013/May/ with file name
31. The posts are written in simple HTML so that links and code will render properly. The first line of the file is the title and the body of the post is everything else.
There are three other things on which I should comment. First, there are App.net and Twitter share buttons that go with each post. Their code was pulled directly from these websites. The blog credits page has direct links to the information used. The header of each page also includes follow buttons for both of these social networks. The code and resources for these are found in the same places are the share buttons. Secondly, the comments for this blog are handled by Disqus. That is a simple and effective solution for me. Lastly, you may have noticed the social media icons to the right. They are free and their license and location can be found on the credits page. Please feel free to interact with me however possible on those social networks. My preference is App.net, however, please use whichever is yours.
Finally, I did test this blog with a few browsers, but if you find any issues please let me know.
Update: @rikishiama pointed out that I was lacking an RSS feed. I have added one along with a link to subscribe on the right. This file was hand-written, but I will write a PHP script to handle its creation.
Allow me to introduce myself. I am a mathematician and programmer. Currently, I am working on a PhD in arithmetic geometry. I like to write about many things including math, sports, programming, education, and technology. If you would like to see my comments more frequently, you can follow me on my social profiles: