{"id":13880369,"url":"https://github.com/jgraichen/rails-timeago","last_synced_at":"2025-05-14T21:10:58.103Z","repository":{"id":2541600,"uuid":"3519159","full_name":"jgraichen/rails-timeago","owner":"jgraichen","description":"A Rails helper for time tags that can be used with the jQuery Timeago plugin.","archived":false,"fork":false,"pushed_at":"2025-04-21T06:06:37.000Z","size":369,"stargazers_count":212,"open_issues_count":2,"forks_count":37,"subscribers_count":11,"default_branch":"main","last_synced_at":"2025-04-21T07:29:38.833Z","etag":null,"topics":["jquery-timeago","rails","ruby","timeago","timeago-tags"],"latest_commit_sha":null,"homepage":"","language":"Ruby","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/jgraichen.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2012-02-22T21:22:45.000Z","updated_at":"2025-04-21T06:06:39.000Z","dependencies_parsed_at":"2024-06-18T15:16:36.715Z","dependency_job_id":"f1b8fc6c-1991-4646-84a1-1d860ff360c0","html_url":"https://github.com/jgraichen/rails-timeago","commit_stats":{"total_commits":197,"total_committers":22,"mean_commits":8.954545454545455,"dds":0.6192893401015229,"last_synced_commit":"2defbd9b668113f6520fabbc9fbad077387ca717"},"previous_names":[],"tags_count":44,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jgraichen%2Frails-timeago","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jgraichen%2Frails-timeago/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jgraichen%2Frails-timeago/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jgraichen%2Frails-timeago/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/jgraichen","download_url":"https://codeload.github.com/jgraichen/rails-timeago/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":254227631,"owners_count":22035671,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["jquery-timeago","rails","ruby","timeago","timeago-tags"],"created_at":"2024-08-06T08:02:59.084Z","updated_at":"2025-05-14T21:10:53.086Z","avatar_url":"https://github.com/jgraichen.png","language":"Ruby","readme":"# rails-timeago\n\n[![Gem Version](https://img.shields.io/gem/v/rails-timeago?logo=ruby)](https://rubygems.org/gems/rails-timeago)\n[![Build Status](https://img.shields.io/github/actions/workflow/status/jgraichen/rails-timeago/test.yml?logo=github)](https://github.com/jgraichen/rails-timeago/actions/workflows/test.yml)\n\n**rails-timeago** provides a timeago_tag helper to create time tags usable for\n[jQuery Timeago](https://github.com/rmm5t/jquery-timeago) plugin.\n\n## Installation\n\nAdd this line to your `Gemfile`:\n\n```ruby\ngem 'rails-timeago', '~\u003e 2.0'\n```\n\nAnd then execute:\n\n    $ bundle\n\nOr install it yourself as:\n\n    $ gem install rails-timeago\n\n### Use bundled JavaScript with Sprockets\n\n*Note:* The bundled JavaScript can only be used with sprockets. Rails-webpacker cannot load scripts bundled with the gem. If you use rails-webpacker you need to install, load, and setup jquery-timeago on your own.\n\nTo use bundled jQuery Timeago plugin add this require statement to your `application.js` file:\n\n    //= require rails-timeago\n\nThis will also convert all matching time tags on page load.\n\nUse the following to also include all available locale files:\n\n    //= require rails-timeago-all\n\nIf using a recent Rails with `rails-ujs`, jQuery might not be present anymore. You need to add `jquery-rails` to your `Gemfile` and load it, e.g.:\n\n    //= require jquery\n    //= require rails-timeago\n    //= require rails-timeago-all\n\n## Usage\n\nUse the timeago_tag helper like any other regular tag helper:\n\n```erb\n\u003c%= timeago_tag Time.zone.now limit: 10.days.ago %\u003e\n```\n\n\n### Available options:\n\n**date_only**\nOnly print date as tag content instead of full time.\n(default: `true`)\n\n**format**\nA time format for localize method used to format static time.\n(default: `default`)\n\n**limit**\nSet a limit for time ago tags. All dates before given limit will not be converted.\n(default: `4.days.ago`)\n\n**force**\nForce time ago tag ignoring limit option.\n(default: `false`)\n\n**default**\nString that will be returned if time is `nil`.\n(default: `'-'`)\n\n**title**\nA string or block that will be used to create a title attribute for timeago tags. It set to nil or false no title attribute will be set.\n(default: `proc { |time, options| I18n.l time, format: options[:format] }`)\n\nAll other options will be given as options to the time tag helper.\nThe above options can be assigned globally as defaults using\n\n```ruby\nRails::Timeago.default_options limit: proc { 20.days.ago }\n```\n\nA global limit should always be given as a block that will be evaluated each time the rails `timeago_tag` helper is called. That avoids the limit becoming smaller the longer the application runs.\n\n## I18n\n\n**rails-timeago 2** ships with a modified version of jQuery timeago that allows to include all locale files at once and set the locale via an option or per element via the `lang` attribute:\n\n```erb\n\u003c%= timeago_tag Time.zone.now, lang: :de %\u003e\n```\n\nThe following snippet will print a script tag that set the jQuery timeago locale according to your `I18n.locale`:\n\n```erb\n\u003c%= timeago_script_tag %\u003e\n```\n\nArguments are passed to Rails' `javascript_tag` helper, e.g. to assign a CSP nonce: `timeago_script_tag(nonce: true)`.\n\nJust insert it in your application layout's html head. If you use another I18n framework for JavaScript you can also directly set `jQuery.timeago.settings.lang`. For example:\n\n```js\njQuery.timeago.settings.lang = $('html').attr('lang')\n````\n\nDo not forget to require the needed locale files by either require `rails-timeago-all` in your `application.js` file or require specific locale files:\n\n```js\n//= require locales/jquery.timeago.de.js\n//= require locales/jquery.timeago.ru.js\n```\n\n*Note:* English is included in jQuery timeago library, but can be easily override by include an own file that defines `jQuery.timeago.settings.strings[\"en\"]`. See a locale file for more details.\n\n**rails-timeago** includes locale files for the following locales taken from [jQuery Timeago](https://github.com/rmm5t/jquery-timeago).\n\nYour customized jQuery locale files must be changed to work with **rails-timeago 2**. Instead of defining your locale strings as `jQuery.timeago.settings.strings` you need to define them like this:\n\n```js\njQuery.timeago.settings.strings[\"en\"] = {\n    ...\n}\n```\n\n## License\n\n[MIT License](http://www.opensource.org/licenses/mit-license.php)\n\nCopyright (c) 2014, Jan Graichen\n","funding_links":[],"categories":["Ruby"],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjgraichen%2Frails-timeago","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fjgraichen%2Frails-timeago","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjgraichen%2Frails-timeago/lists"}