public
Description: An extension that provides some useful blogging tags for the Radiant CMS
Homepage: http://seansantry.com/projects/blogtags/
Clone URL: git://github.com/santry/blogtags.git
name age message
file LICENSE Wed Nov 01 14:32:16 -0800 2006 Added a LICENSE and content to the README [santry]
file README.markdown Thu Aug 21 12:46:40 -0700 2008 Updated README with GitHub URL and instructions... [santry]
file Rakefile Thu Nov 02 09:33:07 -0800 2006 Normalized the name to BlogTags (instead of Blo... [santry]
file blog_tags_extension.rb Wed Apr 18 13:07:37 -0700 2007 Converted to a Radiant Extension for Radiant 0.6 [santry]
directory lib/ Wed Apr 18 13:07:37 -0700 2007 Converted to a Radiant Extension for Radiant 0.6 [santry]
directory test/ Thu Nov 02 09:37:03 -0800 2006 Fixed names of test and task files for BlogTags [santry]
README.markdown

BlogTags

BlogTags is an extension for the Radiant CMS that provides some useful blogging tags. OK, for now there are just three tags. But they're really useful. Honest!

The latest version is available on GitHub. When cloning, ensure your clone is named blog_tags:

    git clone git://github.com/santry/blogtags.git vendor/extensions/blog_tags

previous and next

The previous and next tags get the previous and next siblings of the current page, sorted by the published_at date. For example,

<r:previous><r:link/></r:previous>

will get the previous page according to the published_at date and output a link to it. You can specify which attribute to use for comparison in the by attribute. To get the next page according to the page title, use

<r:next by="title"><r:link/></r:next>

Inside the next and previous tags you can use whatever page tags you like and they'll refer to the next or previous page. If your pages have a summary part, you could output the summary for the next page like this:

<r:next><r:content part="summary"/></r:next>

Of course I have no idea why you'd want to do that, but you could.

Since this is the BlogTags plugin, the previous and next tags are designed to be used in a blog. Here's how I use the previous and next tags on my site to provide links to the previous and next blog entries:

<div class="article-nav">
    <p><r:previous><r:link>&laquo;&nbsp;<r:title/></r:link>&nbsp;&nbsp;</r:previous>
       <r:next><r:link><r:title/>&nbsp;&raquo;</r:link></r:next></p>
</div>

This produces HTML like

<div class="article-nav">
    <p><a href="/articles/2006/06/06/jimmy-and-ginas-wedding/">&laquo;&nbsp;Jimmy and Gina's Wedding</a>&nbsp;&nbsp;<a  
        href="/articles/2006/06/22/railsconf-2006/">RailsConf 2006&nbsp;&raquo;</a></p>
</div>

When you're viewing the first page in a sequence, the previous tag outputs nothing. The next tag outputs nothing if you're at the last page in a sequence. Also, virtual pages (like "Archive Day Index" or "Page Not Found") are excluded from the page sequence, since you probably don't want to link to them this way.

time_ago_in_words

The time_ago_in_words tag outputs the published_at date of the page (or, for unpublished pages, created_at) in natural language. For example, if it's 4:00pm and the page was published at 1:00pm the tag

<r:time_ago_in_words/>

would output about 3 hours. I use it like this in my blog:

<p class="article-author">Posted by <r:author /> <r:time_ago_in_words /> ago</p>

which outputs something like:

<p class="article-author">Posted by Sean about 3 hours ago</p>

Questions?

If you have questions you can find me on the Radiant mailing lists or you can contact me through my website. Good luck!

Acknowledgments

Thanks to John Long for creating Radiant and for providing a starting point for the previous and next tags. Thanks also to Sean Cribbs for his suggestion on simplifying my time_ago_in_words implementation.