content

A New Website

Notice: Please note that this blog post is out of date.

I made a new website! While I have made websites before, this one was particularly interesting because I could not use MySQL. Why? Well, The short story is because I'm cheap.

One of the first things you may want do when you want to host a website on the internet is find a hosting provider. Given the fact that I am cheap (as aforementioned) and that my site will likely not attract loads of traffic, I decided to go with NearlyFreeSpeech, which charges you based on how much bandwidth you use up. As of this blog post, NearlyFreeSpeech also charges you $0.01 a day as a baseline charge for PHP-enabled websites; however, for MySQL-enabled sites, it charges you an additional $0.02 to the baseline cost a day, tripling the cost of running the site. Deciding that adding MySQL service was too expensive for me, especially since my site will have low traffic, I wrote everything in PHP.

This was fine until I remembered that I wanted to incorporate a blog into my website. I fixed this problem by transferring each of my old Tumblr posts into XML files, which were then put into folders organized by date. Using PHP, I can now query the filesystem for posts, extract the information from the XML, and then format it nicely just for you to see. It may not be the most effecient or effective solution, but this is great! Unless you want formatting.

<xml version="1.0" encoding="ISO-8859-1"> 
<post> 
<time>YYYY-MM-DDThh:mm:ssTZD</time> 
<title>Title goes here</title> 
<tags>Tags, if any, seperated by commas</tags> 
<content>Content goes here</content> 
</post>

If you know XML, you'll know that the formatting of xml looks something like the above. The problem here is that HTML also uses the same characters ("<" and ">") for specifying pieces of code. This means that any HTML I put in the XML file will be recognized as a node, which is not what I want. One way to fix this is to use BBCode instead of HTML for formatting, so, being the programmer that I sometimes am, I wrote a BBCode parser for fun.

The other interesting thing I did while making this site was use JavaScript. I don't have much experience with Javascript, except for completing a few easy tutorials on CodeAcademy. I remember talking with a friend who once complained about the lack of control over the color scheme of sites or applications he used. Long story short, he wanted white text on black backgrounds instead of black text on white backgrounds. I enjoy switching to the darker theme as well sometimes, so I decided to implement such a theme into my site.

It's probably mislabeled as "Invert!", as it is more of a "Switch to Dark Theme" kind of thing, but you'll find the link in the footer to switch. All it does is sets a cookie that determines which CSS sheets we want to use for the site; just inverting all of the colors on the site might make for an unpleasant experience. The cookie only stays around for 30 days though, and I'm not going to take the time to make a user account system without MySQL just for that.

I also found out that, apparently, things like lists and tables don't belong in paragraph tags. You also aren't supposed to put paragraph tags inside paragraph tags either. Oh well.

meta

tags: website

created: published: migrated:

crossposts: @ dpek.tumblr.com

commit: 3877e6db