From c03193f8c5fc1c112a52f326704918dc755c018e Mon Sep 17 00:00:00 2001 From: Ryan McGeary Date: Fri, 18 Jul 2008 21:08:45 -0400 Subject: [PATCH] Added example rails helper --- index.html | 40 ++++++++++++++++++++-------------------- 1 file changed, 20 insertions(+), 20 deletions(-) diff --git a/index.html b/index.html index 8808f27..2b47901 100644 --- a/index.html +++ b/index.html @@ -48,15 +48,12 @@ timestamps (e.g. "4 minutes ago" or "about 1 day ago"). Download, view the examples, and enjoy.

-

You opened this page sometime before now (turn on javascript, loser). (This will update every minute. Wait for it.)

-

This page was last modified sometime before now [browser might not support document.lastModified].

-

Ryan was born Dec 18, 1978.

@@ -65,35 +62,27 @@

First, load jQuery and the plugin:

-
 <script src="jquery.min.js" type="text/javascript"></script>
 <script src="jquery.timeago.js" type="text/javascript"></script>
-

Now, let's attach it to your timestamps on DOM ready:

-
 jQuery(document).ready(function() {
   jQuery('abbr[class*=timeago]').timeago();
 });
-

This will turn all abbr elements with a class of timeago and an ISO 8601 timestamp in the title:

-
 <abbr class="timeago" title="2008-07-17T09:24:17Z">July 17, 2008</abbr>
-

into something like this:

-
 <abbr class="timeago" title="2008-07-17T09:24:17Z">time ago</abbr>
-

which yields: July 17, 2008. As time passes, the timestamps will automatically update.

@@ -106,6 +95,14 @@ jQuery(document).ready(function() {
  • You get to use microformats like the cool kids.
  • +

    Where?

    +

    Download the "stable" release.

    +

    + The code is hosted on + GitHub: http://github.com/rmm5t/timeago. + Go on, live on the edge. +

    +

    Who?

    Timeago was built by Ryan McGeary @@ -116,18 +113,21 @@ jQuery(document).ready(function() { in Ruby on Rails.

    -

    Where?

    -

    Download the "stable" release.

    -

    - The code is hosted on - GitHub: http://github.com/rmm5t/timeago. - Go on, live on the edge. -

    -

    When?

    -

    +

    Timeago was conceived on July 17, 2008. (Yup, that's powered by timeago too)

    + +

    What else?

    +

    + Need a Rails helper to make those fancy microformat abbr tags? Fine, here ya go: +

    +
    +def timeago(time, options = {})
    +  options[:class] ||= "timeago"
    +  content_tag(:abbr, time.to_s, options.merge(:title => time.getutc.iso8601)) if time
    +end
    +