All Projects → Bunlong → rails-livestamp

Bunlong / rails-livestamp

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

Programming Languages

ruby
36898 projects - #4 most used programming language
shell
77523 projects

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 )

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].