{"id":18836665,"url":"https://github.com/dapi/gritter_notices","last_synced_at":"2025-08-21T02:31:58.626Z","repository":{"id":56875346,"uuid":"1490596","full_name":"dapi/gritter_notices","owner":"dapi","description":"Show growl-like  flash messages and saved user notices with Gritter","archived":false,"fork":false,"pushed_at":"2014-03-15T04:49:59.000Z","size":232,"stargazers_count":78,"open_issues_count":1,"forks_count":11,"subscribers_count":2,"default_branch":"master","last_synced_at":"2024-12-10T05:42:07.878Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"http://dapi.ru/flash-delayedjob","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/dapi.png","metadata":{"files":{"readme":"README.rdoc","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}},"created_at":"2011-03-17T06:52:01.000Z","updated_at":"2024-10-18T14:04:13.000Z","dependencies_parsed_at":"2022-08-20T22:00:37.010Z","dependency_job_id":null,"html_url":"https://github.com/dapi/gritter_notices","commit_stats":null,"previous_names":[],"tags_count":7,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dapi%2Fgritter_notices","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dapi%2Fgritter_notices/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dapi%2Fgritter_notices/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dapi%2Fgritter_notices/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/dapi","download_url":"https://codeload.github.com/dapi/gritter_notices/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":229891226,"owners_count":18140252,"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-08T02:25:11.524Z","updated_at":"2024-12-19T18:18:03.130Z","avatar_url":"https://github.com/dapi.png","language":"Ruby","funding_links":[],"categories":[],"sub_categories":[],"readme":"= gritter_notices\n\n{\u003cimg src=\"http://travis-ci.org/dapi/gritter_notices.png\" /\u003e}[http://travis-ci.org/dapi/gritter_notices]\n\nИспользует модуль gritter для отображения flash сообщений, а также вводит механизм сохраняемых пользовательских сообщений (notice).\n\nУдобно применять для отправки пользователю flash-сообщений из фоновых задач.\n\nВизуально выглядит так: http://boedesign.com/demos/gritter/\n\nРабочий пример использования этого модуля: http://gritter-notices-example.heroku.com/\n\nМодуль родился и активно используется в проекте http://planposter.com\n\nhttp://dl.dropbox.com/u/155427/gritter_notices.png\n\n== Установка\n\nВключаем модуль в Gemfile, не забываем затем сделать bundle install:\n\n    gem 'gritter_notices'\n\nКопируем jQuery-плагин Gritter (https://github.com/jboesch/Gritter) в проект:\n\n    bundle exec rake gritter:install\n\n## Если хотим посылать персональные сообщения пользователям (помимо отображения flash)\n\nСоздаем таблицу `gritter_notices` где будут храниться сообщения:\n\n    bundle exec rails g gritter_notices\n    bundle exec rake db:migrate\n\nПодключаем notices в модель User:\n\n    class User \u003c ActiveRecord::Base\n      has_gritter_notices\n      ...\n\nГде-то в layout делаем так:\n\n* haml-пример:\n\n    %head\n       = include_gritter\n    %body\n       = gflash # session сообщения, добавляемые через gritter-овский gflash :success=\u003eтраляля\n       = gritter_flash_messages # Все остальные сообщения добавляемые через вызовы типа flash[:success] или user.notice_*\n\n* erb-пример:\n\n    \u003chead\u003e\n      \u003c%= include_gritter %\u003e\n      ...\n    \u003cbody\u003e\n       \u003c%= gflash  %\u003e\n       \u003c%= gritter_flash_messages %\u003e\n\nВ `gritter_flash_messages` можно передать \"белый список\" ключей flash в опции `:only`, в этом случае будут показываться сообщения только из этого списка.\n\nВместо `include_gritter` можно делать сразу `include_gritter_and_jquery`, подробнее тут: https://github.com/RobinBrouwer/gritter\n\n== Использование\n\nВ расширяемую модель добавляются метод `notice`. Агрументы:\n\n* Текстовое сообщение (String) или ключ к строке локали (Symbol)\n* Хеш опций прозрачно сохраняемых в модели и используемые при подстановке в `I18n::translate`.\n** В хеше опций пожно указать :scope для трансляции локали (по умолчанию `:gritter_notices`) и\n** `:level` из поддерживаемых gritter-ом - [:success, :warning, :notice, :error, :progress], по умолчанию :notice\n** :title\n** :sticky\n** другие опции, понимаемые gritter-ом\n\nПримеры использования:\n\n    user.notice 'Просто текстовое сообщение'\n    user.notice 'Текстовое сообщение', :level=\u003e:notice\n\nесли в локали указать\n\n    ru:\n      gritter_notices:\n        import_contacts: Импортиорваны контакты (%{count})\n\nто можно будет использовать ключ, вместо текстового сообщения:\n\n    user.notice :import_contacts, :count=\u003e123\n\nДля краткости можно :level указывать через подчеркивание после названия метода `notice`:\n\n    notice_success\n    notice_error\n    notice_warning\n    notice_progress\n    notice_notice    # синоним просто `notice`\n\nТакже есть алиас gritter_notice со всеми вышеперечисленными типами сообщений.\n\nДалее во view вызываем:\n\n   = gritter_flash_messages\n\nкоторый отображает и flash сообщения и накопившиеся `notices`.\n\n== Дополнительно\n\nПоддерживается  `universal_flash_messages` и `flash-message-conductor`, то есть сохранение во flash массивов сообщений, типа:\n\n   flash[:notice] = ['Сообщение1', 'Сообщение2']\n\nО плагине jQuery Gritter - http://ruseller.com/adds.php?rub=11\u0026id=2106\nТакже некоторая информация есть здесь: http://habrahabr.ru/blogs/ror/116754/\n\n== TODO\n\n1. Удалять gritter_notice только после того, как они закроются или их закроют\n\nКонтроллер gritter_notices с одной акцией delivered. Ставить ее запуск на onclose. Сделать настраиваемым текущее поведение:\n\n   1. notices помечаются доставленными, когда показываются во view (контроллер не используется)\n   2. notices помечаются удаленными, когда закрываются (сами или принудительно) onclose\n   3. обычные notices по методу 1, sticky notices по методу 2.\n\n2. Показывать push-сообщения\n3. Написать драйверы для других способов отображения (список ниже)\n\n== Другие способы отображения\n\n* https://github.com/wavded/humane-js\n* https://github.com/rubiety/message_block\n* http://plapier.github.com/sexy-css3-flashes/\n* https://github.com/jyoungblood/smoke.js\n* https://github.com/needim/noty\n* http://code.google.com/p/jquery-purr/\n* https://github.com/CodeSeven/toastr\n* http://nijikokun.github.com/bootstrap-notify/\n* https://github.com/leonid-shevtsov/unobtrusive_flash\n* Еще?\n\n== Примеры:\n\n   * http://gritter-notices-example.heroku.com/\n   код: http://github.com/dapi/gritter_notices_example\n   * http://planposter.com/\n\nДрузья, присылайте ссылки на ваши проекты использующие gritter_notices.\n\n== Нечто отдаленно подобное (альтернативы):\n\n Вместо flash_conductor-а\n https://github.com/mattpolito/flash-message-conductor\n https://rubygems.org/gems/glennr-flash-message-conductor\n https://github.com/QuBiT/universal_flash_messages\n https://github.com/snitko/frontend_notifier\n\n== Пишут о gritter_notices\n\n* http://dapi.ru/flash-delayedjob\n* http://pavlovnew.livejournal.com/20139.html\n* http://habrahabr.ru/blogs/ror/116754/\n\n== Credits\n* Robin Brouwer https://github.com/RobinBrouwer/gritter\n* Jordan Boesch http://boedesign.com/blog/2009/07/11/growl-for-jquery-gritter/\n\n== Contributing to gritter_notices\n\n* Check out the latest master to make sure the feature hasn't been implemented or the bug hasn't been fixed yet\n* Check out the issue tracker to make sure someone already hasn't requested it and/or contributed it\n* Fork the project\n* Start a feature/bugfix branch\n* Commit and push until you are happy with your contribution\n* Make sure to add tests for it. This is important so I don't break it in a future version unintentionally.\n* Please try not to mess with the Rakefile, version, or history. If you want to have your own version, or is otherwise necessary, that is fine, but please isolate to its own commit so I can cherry-pick around it.\n\n== Copyright\n\nCopyright (c) 2011 Danil Pismenny. See LICENSE.txt for\nfurther details.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdapi%2Fgritter_notices","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdapi%2Fgritter_notices","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdapi%2Fgritter_notices/lists"}