How this site was made


This site was generated by a small bash script ( < 100 lines! ) and a markup rendering program I created called xemark The markdown language is of my own creation, and based off of markdown. The entire language can be described by in about 20 lines of BNF and a few notes of my own.

If you're actually taking a look and cross referencing the BNF with the files in the xe folder, you'll notice that these aren't valid xemark files. First off, they don't have the #XEMARK_ as the first line. Secondly they're all missing a title field indicated by an @ sign. So, how could the xemark executable parse these files correctly? A quick look in the source indicates that the execution of the parser stops if they header isn't right. The magic happens in the bash script used to generate the site. Specifically the use of the cat command. If you feed multiple files to cat before piping it's output, you'll merge together the two files. By merging together the header file and the other xe files, we have valid xe files that all share the same header. Effectively, we've accomplished something similar to a php include.

The next important feature of the script generating this site is the pagination of the blog posts. None of the older or newer post links are part of the file. They're being included in the same way as the header file is. Except they're being generated by the script itself. Unfortunately, you need to either feed a file to cat, or pipe echo's output to it. To make things simple, the footer is placed into a temporary file, then appended as each page is made.

While creating this website I also tested xemarks capabilities as a CGI script. I blogged about this a little bit, and used a Ruby on Rails server to do the heavy lifting of actually running an http server. But it's most definitely overkill to use a rails server to simply call a parsing program like xemark on a single file while sending the output to a browser. It might be more appropriate to construct a minimal python server (which takes a very small amount of code)

-:note: Note that you can grab example.xe and the python simple server script from the xemark repository. If you'd like to play around with them a little bit more.

Other Posts

comments powered by Disqus