Status Update 2014-05-31

I've been working on a lot of back-end things lately. Until just today, I was having issues with loading any posts other than the one you see on the home page. All of that seems to be solved now, and the issues I was facing are something that you should expect when writing everything yourself instead of using something like WordPress.

First of all, I use .htaccess mod_rewrite and $_SERVER['REDIRECT_STATUS'] when loading anything other than the homepage, and I wasn't using that correctly. My issue was that I was starting to look in the wrong place on the URL and including the localhost or chriszuber.com section (depending on if I was working on my laptop or server). That was a pretty quick fix once I finally got around to inspecting what was going on "under the hood."

Once I finally had that working, I was able to actually load other posts without error (that "Hello World" one alone was a bit embarrassing in my opinion). The first thing that I did was change from printing the HTML, using a variable here and there to fill in the actual content and author of the post to using a template. Again, regular expressions to the rescue!

For those of you unfamiliar with templates, the basic idea is that you have everything filled out in advance, and swap out placeholder text with what you actually want. For example, the template for what you are now reading has a section in the header that says "", and I am replacing that placeholder text with "Status Update 2014-05-31."

All is well so far, but I still didn't have a good way of writing new posts. Before, I had been writing the HTML by hand and manually inserting it into the database. That worked (and honestly, I will probably never have as much power doing it any other way), but it was slow and I just don't want to do it that way.

For awhile I was playing around with using a form with a textarea for the actual content of the article, but who wants to write like that? Instead, I'm using a blank blog post and the "contenteditable" attribute, and writing this pretty much exactly as you're seeing it. Just click and type! Soon, I intend on making something so that I can edit existing posts in the same way.

There are a few drawbacks to this that I haven't worked out just yet, namely that I cannot insert images, do different text styles (bold, italics, etc). I'll get to working on that soon enough, but for now I just wanted to say a little bit about what's going on.

Edit: Yes I can. There is a future post coming up post on how to use document.execCommand() with contextmenus, dataset, and contenteditable attributes to create a fully HTML5 and JavaScript based WYSIWYG editor.