Posted 26 Mar 2013. Tagged: github, jQuery and blog

I just pushed the beta version of my commenting system for this blog to Github. Code-named talaria, it provides commenting for any file-identifiable1 content via Github commit message comments.

talaria works based on a number of assumptions:

  1. content (such as a blog post) is wrapped in a DOM container, such as a div or even better an article, which contains an a.permalink
  2. the permalink can be used to figure out the actual path and filename of the content-source (such as a markup file)
  3. the DOM provides the necessary nodes which talaria uses as template and reference points for comment insertion

A liquid template that enables usage of talaria would look structurally similar to the following:

...
    <script type="text/javascript" src="/path/to/comments.js"></script>
...
    <article>
        <header><a class="permalink" href="/permalink-to-post">A post</a></header>
        ...
        {% include comments-placeholder.html %}
    </article>
...
    <footer>
        {% include comments-template.html %}
    </footer>
...

The actual functionality is very simple and the majority of the work is handled by the Github API, but here’s a breakdown: talaria extracts all permalinks on the page. These are converted to the respective paths to the content source files. It then iterates over all files, querying the Github API for commits related to each file. Then it retrieves the comments for each commit. Retrieved data is cached locally2 (if supported by the browser) using sessionStorage. The next steps entail sorting the comments based on their updated_at field and rendering them using the template snippets. Finally, talaria sets the href for the buttons to add comments, and, if the current URL indicates paginated content, the comments are initially left hidden and an appropriate “view comments” link is displayed instead, if not, the comments are displayed.

Writing talaria was a great way to experiment with $.Deferred(), which are totally awesome!

  1. I consider content “file-identifiable”, if the full content is contained in its own file, such as the markup source for a blog post. 

  2. This also helps with the relatively low limit of 60 requests per hour (considering that with talaria the absolute minimum is 2 requests per page view) for unauthenticated queries against the Github API. 

Posted 22 Mar 2013. Tagged: jekyll and blog

I just moved my blog over to GitHub. The main reasons for moving are:

With regards to the GitHub-based comments, there are currently a number of people using a GitHub issues based approach. I personally dislike it, as comments are removed from the actual content you are commenting on. My plan is to base commenting on GitHub commit-comments. The system would roughly work as follows:

  1. Grab the permalink of a post and extrapolate the path to its source file
  2. Retrieve all commits for said file through the GitHub API
  3. Iterate over the commits and retrieve any comments from the API
  4. Display a comment-count on the index (click to fade-in the actual comments); display all comments contents on the permalink page

Along with the switch to jekyll, I also opted to redesign the blog. It now has a very simplistic design, which I believe offers good readability and makes good use of screen real-estate.

newer posts older posts