<?xml version="1.0" encoding="UTF-8"?>
<commit>
  <added type="array">
    <added>
      <filename>LICENSE</filename>
    </added>
  </added>
  <modified type="array">
    <modified>
      <diff>@@ -1,4 +1,59 @@
-00Blogtags
+Blogtags
 ==========
 
-Description goes here
\ No newline at end of file
+Blogtags is a plugin for the [Radiant CMS][1] that provides some useful blogging tags. OK, for now there are just two tags. But they're really useful. Honest!
+
+`previous` and `next`
+=====================
+The `previous` and `next` tags get the previous and next siblings of the current page. You can specify which attribute to use for comparison in the `by` attribute. For example,
+
+	&lt;r:previous by=&quot;published_at&quot;&gt;&lt;r:link/&gt;&lt;/r:previous&gt;
+	
+Will get the previous page according to the `published_at` date and output a link to it. 
+
+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:
+
+	&lt;r:next by=&quot;published_at&quot;&gt;&lt;r:content part=&quot;summary&quot;/&gt;&lt;/r:next&gt;
+	
+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][2] to provide links to the previous and next blog entries:
+
+	&lt;div class=&quot;article-nav&quot;&gt;
+		&lt;p&gt;&lt;r:previous by=&quot;published_at&quot;&gt;&lt;r:link&gt;&amp;laquo;&amp;nbsp;&lt;r:title/&gt;&lt;/r:link&gt;&amp;nbsp;&amp;nbsp;&lt;/r:previous&gt;&lt;r:next
+			by=&quot;published_at&quot;&gt;&lt;r:link&gt;&lt;r:title/&gt;&amp;nbsp;&amp;raquo;&lt;/r:link&gt;&lt;/r:next&gt;&lt;/p&gt;
+	&lt;/div&gt;
+	
+This produces HTML like
+
+	&lt;div class=&quot;article-nav&quot;&gt;
+		&lt;p&gt;&lt;a href=&quot;/articles/2006/06/06/jimmy-and-ginas-wedding/&quot;&gt;&amp;laquo;&amp;nbsp;Jimmy and Gina's Wedding&lt;/a&gt;&amp;nbsp;&amp;nbsp;&lt;a 	
+		    href=&quot;/articles/2006/06/22/railsconf-2006/&quot;&gt;RailsConf 2006&amp;nbsp;&amp;raquo;&lt;/a&gt;&lt;/p&gt;
+	&lt;/div&gt;
+
+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 &quot;Archive Day Index&quot; or &quot;Page Not Found&quot;) 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 in natural language. For example, if it's 4:00pm and the page was published at 1:00pm the tag
+
+	&lt;r:time_ago_in_words/&gt;
+	
+would output `about 3 hours`. I use it like this in my blog:
+
+	&lt;p class=&quot;article-author&quot;&gt;Posted by &lt;r:author /&gt; &lt;r:time_ago_in_words /&gt; ago&lt;/p&gt;
+	
+which outputs something like:
+
+	&lt;p class=&quot;article-author&quot;&gt;Posted by Sean about 3 hours ago&lt;/p&gt;
+
+Questions?
+==========
+If you have questions, I follow the [Radiant mailing lists][3], or you can contact me through [my website][2]. Good luck!
+
+
+
+[1]: http://radiantcms.org/
+[2]: http://seansantry.com/
+[3]: http://radiantcms.org/mailing-list/
\ No newline at end of file</diff>
      <filename>README</filename>
    </modified>
    <modified>
      <diff>@@ -3,13 +3,14 @@ Behavior::Base.define_tags do
   tag &quot;next&quot; do |tag|
     current = tag.locals.page
     by = tag.attr['by'] || 'title'
-    siblings = current.self_and_siblings.sort_by { |page| page.attributes[by] }
-    index = siblings.index(current)
-    next_page = siblings.fetch(index += 1, siblings[0])
-    while !(next_page.nil?) and next_page.behavior_id =~ /Archive/
-      next_page = siblings.fetch(index += 1, siblings[0]) 
-    end
     
+    # get the page's siblings, exclude any that have nil 
+    # for the sorting attribute, exclude virtual pages,
+    # and sort by the chosen attribute
+    siblings = current.self_and_siblings.delete_if { |s| s.send(by).nil? || s.virtual? }.sort_by { |page| page.attributes[by] }
+    index = siblings.index(current)
+    next_page = siblings[index + 1]
+  
     if next_page
       tag.locals.page = next_page
       tag.expand
@@ -19,12 +20,12 @@ Behavior::Base.define_tags do
   tag &quot;previous&quot; do |tag|
     current = tag.locals.page
     by = tag.attr['by'] || 'title'
-    siblings = current.self_and_siblings.sort_by { |page| page.attributes[by] }
+    siblings = current.self_and_siblings.delete_if { |s| s.send(by).nil? || s.virtual? }.sort_by { |page| page.attributes[by] }
     index = siblings.index(current)
-    previous = siblings.fetch(index -= 1, nil)    
-    while !(previous.nil?) and previous.behavior_id =~ /Archive/
-      previous = siblings.fetch(index -= 1, nil)
-    end
+
+    # we don't want to wrap around to the last article    
+    if index &gt; 0 then previous = siblings[index - 1] 
+    else previous = nil; end
     
     if previous
       tag.locals.page = previous</diff>
      <filename>lib/00_blogtags.rb</filename>
    </modified>
  </modified>
  <removed type="array"/>
  <parents type="array">
    <parent>
      <id>5be8eddb8564c244a4e64f6c7acced9eae9e71c8</id>
    </parent>
  </parents>
  <author>
    <name>santry</name>
    <email>santry@53b936e0-3221-0410-8748-df35822c787b</email>
  </author>
  <url>http://github.com/santry/blog_tags/commit/6a65eb26014ce012d9b921bfda286f8457265ab2</url>
  <id>6a65eb26014ce012d9b921bfda286f8457265ab2</id>
  <committed-date>2006-11-01T14:32:16-08:00</committed-date>
  <authored-date>2006-11-01T14:32:16-08:00</authored-date>
  <message>Added a LICENSE and content to the README
Updated next and previous to exclude virtual pages and pages that don't have the requested sorting attribute set

git-svn-id: http://seansantry.com/svn/radiant/plugins/blogtags/trunk@5 53b936e0-3221-0410-8748-df35822c787b</message>
  <tree>5b361ccb92da58b1aadfd4cb5ca3959be969712e</tree>
  <committer>
    <name>santry</name>
    <email>santry@53b936e0-3221-0410-8748-df35822c787b</email>
  </committer>
</commit>
