{"id":20513657,"url":"https://github.com/theopencms/notifications","last_synced_at":"2025-06-16T11:33:59.733Z","repository":{"id":71919656,"uuid":"84729217","full_name":"TheOpenCMS/notifications","owner":"TheOpenCMS","description":"Gem provides a way to render `HTML` or `JSON` notifications in a Rails app","archived":false,"fork":false,"pushed_at":"2017-06-18T10:12:16.000Z","size":14,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-03-05T23:14:13.906Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"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/TheOpenCMS.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.txt","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":"2017-03-12T13:51:02.000Z","updated_at":"2017-03-12T13:51:16.000Z","dependencies_parsed_at":null,"dependency_job_id":"327b5b01-a6e7-4ee8-8721-edd943f0568f","html_url":"https://github.com/TheOpenCMS/notifications","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/TheOpenCMS/notifications","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/TheOpenCMS%2Fnotifications","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/TheOpenCMS%2Fnotifications/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/TheOpenCMS%2Fnotifications/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/TheOpenCMS%2Fnotifications/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/TheOpenCMS","download_url":"https://codeload.github.com/TheOpenCMS/notifications/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/TheOpenCMS%2Fnotifications/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":260150876,"owners_count":22966394,"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":[],"created_at":"2024-11-15T21:12:27.300Z","updated_at":"2025-06-16T11:33:59.707Z","avatar_url":"https://github.com/TheOpenCMS.png","language":"Ruby","funding_links":[],"categories":[],"sub_categories":[],"readme":"```ruby\nThis gem is a part of TheOpenCMS project. https://github.com/TheOpenCMS\n```\n\n## Notifications\n\nJust add JSON on HTML notifications in your Rails app\n\n```ruby\ngem 'notifications'\n```\n\n## How it works\n\nThis gem helps you to get rid of this bunch of a code\n\n```ruby\n\u003c%= form_for(@resource) do |f| %\u003e\n  \u003c% if @resource.errors.any? %\u003e\n    \u003cdiv id=\"error_explanation\"\u003e\n      \u003ch2\u003e\u003c%= pluralize(@resource.errors.count, \"error\") %\u003e prohibited this resource from being saved:\u003c/h2\u003e\n\n      \u003cul\u003e\n      \u003c% @resource.errors.full_messages.each do |msg| %\u003e\n        \u003cli\u003e\u003c%= msg %\u003e\u003c/li\u003e\n      \u003c% end %\u003e\n      \u003c/ul\u003e\n    \u003c/div\u003e\n  \u003c% end %\u003e\n\n  # ....\n\n\u003c% end %\u003e\n```\n\nand replace it with the following code:\n\n```slim\n  - form_for(@post) do |f|\n    = render partial: 'notifications/form', locals: { object: @post }\n```\n\nand this code to render Flash messages:\n\n```slim\nbody\n  = render partial: 'notifications/flash'\n  = yield\n```\n\n## How to use\n\n*Note:* `toastr` is an external dependency for `format: :json` case. Download and and install it yourself. `vendors/toastr` is just a demo path to assets\n\n*application.css*\n\n```css\n/*\n  //= require notifications/base\n*/\n```\n\n*application.js*\n\n```js\n//= require notifications/base\n```\n\n*application_initializer.js*\n\n```coffee\n$ -\u003e\n  do Notifications.init\n```\n\n### Format `html` or `json`\n\nYou can select a way how to render notifications. There are 2 options: `format: :html` and `format: :json`\n\n```slim\n= render partial: 'notifications/flash', locals: { format: :html }\n= render partial: 'notifications/form', locals: { object: @post, format: :json }\n```\n\n### Default notifications format\n\n*initializers/notifications.rb*\n\n```ruby\nNotifications.configure do |config|\n  config.default_type = :json # :html\nend\n```\n\n### Errors' localization\n\nTo avoid this case\n\n```\nTitle: не может быть пустым\n```\n\nDo the following steps:\n\n*models/user.rb*\n\n```ruby\nclass Post \u003c ActiveRecord::Base\n  include ::Notifications::LocalizedErrors\nend\n```\n\n*config/locales/ru.yml*\n\n```yml\nactiverecord:\n  models:\n    post: Публикация\n  attributes:\n    post:\n      title: \"Загловок\"\n```\n\nNow errors messages will look so:\n\n```\nЗагловок: не может быть пустым\n```\n\n### MIT License\n\nCopyright (c) 2013-[Current Year] Ilya N. Zykin\n\nPermission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the \"Software\"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:\n\nThe above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.\n\nTHE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftheopencms%2Fnotifications","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ftheopencms%2Fnotifications","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftheopencms%2Fnotifications/lists"}