Stream of Consciousness Feed: Scope and intent
• Mark Eschbach
After reflecting on my website for a bit I found two areas I would love to improve. First is to get the header uptdated. Easy enough to do one off as I just need to run a script. Long term I might need to see if I can add an implicit dependency on the template files so they are properly updated. Right now the header on the main page isn’t updated at all. Second is to have a feed showing the top five most recently published articles on the Stream of Conciousness section.
In thoery this should be easy. My website is stored in Git as a series of PHP scripts or Jekyll markdown then rendered in static HTML. I should be able to use Git to find which are the last 5 - 10 files modified under specific subtrees. From there I simply drop them into a JSON file continaing the title and
href for them. For each page in the tmeplate I would then pull the JSON file and render the content. Sounds somple enough.
A while ago I looked into using Jekyll’s RSS/Atom feeds, however I was really disappointed to find how much information was published in the feed. The feed file is large which totally defeats the goal of reducing loading times and getting thing sup and running.
First challenge is getting the files which change in only a subtree. git log seems to be a perfect approach. Looks like the command would be something like
git log --name-only -10 stream-of-conciousness/_posts. A simple ruby script would probably issue this as a subcommand and slurp the entire output, making the JSON file creation simple.
On the browser side this wouldn’t be much different than most scripts I already have. Currently I only really have jQuery as a library. I would probably a have an elmeent in the template reposible for display which defaults to laoding. General gist would go:
- Register for DOM Loaded and do the following:
- On AJAX completion of
GETing the file from a well known resource
- Change state of element from loading to laoded.
- For each element within the file describing a post
- Initialize an HTML template continaing the date of last modified + title linking to the article.
Simple enough however the best laid plans of Mice and Men often go awry.