Semantics, Code and Circumstance
April 10, 2010: This afternoon I recieved a visit from a plushy black cat. I've never seen her before and since she has a collar she may be moved in with her owner in the last days.
Read more about project 365 ...Coding in hastiness combined with a limited vocabulary late at night will certainly result in comprehension difficulties at the very next morning:
<%= "#{t("role.role")}" %>: <%= "#{t("role."+role.role)}" %>
Kids, don’t try this at home.
This is a very informative slideshare on inference and the power of the Semantic Web. To emphasize the potential of the Semantic Web, Myungjin Lee used RDF and OWL constructs to represent the statements of his slides. Very impressive, though.
It is wildly known and even somewhat accepted, that the pagination mechanism of Mephisto 0.8.2 is very buggy and non-functional. However, paging blog posts is a feature that kills a blog engine if it does not work. Fortunately, James of Rails Talk wrote a nice tutorial for bringing up paging again. His description is easy done and works well, as long as you have only one section, the mandatory Home section.
However, blogs with multiple sections (like this one) faced a strange problem with doubled section names in URLs. A workaround with separate URL helpers for each section exists, but is utterly unhandy. After some investigation it turns out, that a small change to the original tutorial solves the whole section difficulty. The original instruction was to add the following to mephisto_paged_article_list/lib/paged_article_list/link_helpers.rb:
def path_for( path_info, page_number )
return path_info[:path] + "/page/" + page_number.to_s
end
Now, when using this with multiple sections, path_info[:path] contains the name of the current section (or nothing, if the section is Home). Moreover, the produced path is a relative path, so that the returned string will be appended to the base URL that already contains the section name as the last part. This is where the doubled section names come from. To remove this behaviour, we need to change the code a little bit:
def path_for( path_info, page_number )
path = path_info[:path] + '/page/' + page_number.to_s
path_info[:path].blank? ? path : '/' + path
end
With this code, we assemble the path the same way, but precede it with a ’/’ whenever the section name is not empty. This gives us a non-relative URL without the doubled section name and thus correct pagination URLs for all sections.
If you ever did a web project that featured dated entries, like articles in a blog, you may have typed something like
<div id="navigation">
<ul>
<li>Home</li>
<li>Link 1</li>
<li>Link 2</li>
<li>Link 3</li>
</ul>
</div>
and
<span class="publication-date">2009-11-03</span>
Now, this is higly understandable for any developer and for most of your users, but not for crawlers and the like. As this is the central issue in the field of the semantic web, there are already some solutions that address this problem. You could, for example, enhance your code with semantic markup like RDFa or microformats.
But then, that may be overkill. Why not just use the possibilities that come with the shiny new HTML5? Most of the modern browsers already support at least some of the new features. Features, in this case, are new text-level semantic tags that allow a lightweight semantic annotation of content. With the use of these new tags, our first example would read:
<nav>
<ul>
<li>Home</li>
<li>Link 1</li>
<li>Link 2</li>
<li>Link 3</li>
</ul>
</nav>
This enables screen readers, mostly used by people with limited sight, to jump directly to the sites menu and allow a quick navigation. Even more fun comes with the second example:
<time datetime="2009-11-03" pubdate>2009-11-03</time>
This promotes the human readable string to a full machine readable timestamp that tells every crawler/browser/whatever the publication date of the embracing document.
If you want to learn more about these two and all the other cool new tags, please have a look at Dive into HTML5, a clearly structured and neatly designed publication by the great Mark Pilgrim.
Many people tend to understand structures much better when they are properly visualized. So it comes to no surprise that there were some proposals for a Graphical Topic Map notation (GTM) made in the past. The guys from musicDNA recently stepped into the spotlight with their latest publication that illustrates Topic Maps by using a Martian as example. Unsurprisingly, they call it Topic Map Martian Notation.
