Bunlong / rails-livestamp

rails-livestamp is a simple jQuery plugin that provides auto-updating timeago text to your timestamped HTML elements.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

rails-livestamp Gem Version Gem Total Downloads

The rails-livestamp is a simple jQuery plugin that provides auto-updating timeago text to your timestamped HTML elements, which will update automatically as time goes by. ISO 8601 timestamps are also supported.

Installation

Add this line to your application's Gemfile:

gem 'rails-livestamp', '~> 1.1.3'

And then execute:

$ bundle

Or install it yourself as:

$ gem install rails-livestamp

To use rails-livestamp add this require statement to your application.js file:

//= require rails-livestamp

Usage

No extra JavaScript required! Just use a <span> with the data-livestamp attribute set to the desired Unix timestamp (in seconds), like this:

If you use ERB:

You discovered rails-livestamp <span data-livestamp="#{Time.now.to_i}"></span>.

If you use HAML:

You discovered rails-livestamp 
%span{"data-livestamp" => "#{Time.now.to_i}"}.

And you will see something like this:

You discovered rails-livestamp a minutes ago. 

Wait half a minute - the livestamp will update automatically.

More Documentation.

See the livestamp documentation.

License

MIT License

Copyright (c) 2015 - Present, Matt Bradley ( Livestamp.js Maintainer ), Bunlong VAN ( Maintainer )

About

rails-livestamp is a simple jQuery plugin that provides auto-updating timeago text to your timestamped HTML elements.

License:MIT License


Languages

Language:Ruby 94.4%Language:Shell 5.6%