Exploring the use of automated feeds in my notebook entries, which would make writing posts both faster and more complete. I had recently modified my Jekyll plugins to include commits on the day of the post. Consequently, I could add a bit of liquid code to any post, such as:
{% octokit_commits pdg_control%}
(or even to the post template) and have the commit log for the specified repository automatically imported. While such liquid tags are very handy for pages that are otherwise static and generate their updated content on compile (e.g. my lab-notebook homepage, this approach makes less sense for day-to-day entries (as Noam points out to me). For such entries, the content is already being composed from scratch, but is designed to be fixed once written. (In fact, that was one of the challenges in updating the plugin to pull in the commit log from the day of the post instead of the most recent updates to the repository). Generating this content for every post every time the site is build would be unnecessarily intensive, since it does not change. Further, I like to keep the post entries in pure markdown as much as possible. This makes the actual content not dependent on Jekyll (or on outside databases), which means the content displays fine by browsing the markdown, or using pandoc to compile to pdf or some other format.
To get the same time-savings from automatic imports, I followed Noam’s suggestion and added a little wrapper around my ruby scripts that would import the text of a commit log using a few vi commands. vi, my editor of choice, makes calling arbitrary scripts really easy. In fact one can just write out the bash script command as a line on the editor, and hit !!sh
, which replaces the command with its output. So for this purpose I just type the command out into the entry like so,
commits.rb pdg_control today
I get a listing the commits for that day (defaults to the current day if no day is given). Thanks to the Chronic
gem, the script recognizes a variety of natural language commands for the time, such as “3 days ago”. This pulls in all commits made at any point on the day given. For more background, see my vim SO question to pass visual blocks to a function.