{"id":15064576,"url":"https://github.com/atrox/sweetify","last_synced_at":"2025-04-10T12:23:01.998Z","repository":{"id":59156981,"uuid":"58264003","full_name":"Atrox/sweetify","owner":"Atrox","description":"SweetAlert flash messages for Ruby on Rails","archived":false,"fork":false,"pushed_at":"2019-05-05T15:23:59.000Z","size":9,"stargazers_count":21,"open_issues_count":2,"forks_count":7,"subscribers_count":6,"default_branch":"master","last_synced_at":"2025-02-03T01:11:46.472Z","etag":null,"topics":["flash-messages","rails","sweetalert"],"latest_commit_sha":null,"homepage":"https://rubygems.org/gems/sweetify","language":"Ruby","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"bsd-3-clause","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/Atrox.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2016-05-07T11:57:53.000Z","updated_at":"2024-12-30T17:01:04.000Z","dependencies_parsed_at":"2022-09-13T20:11:03.827Z","dependency_job_id":null,"html_url":"https://github.com/Atrox/sweetify","commit_stats":null,"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Atrox%2Fsweetify","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Atrox%2Fsweetify/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Atrox%2Fsweetify/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Atrox%2Fsweetify/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Atrox","download_url":"https://codeload.github.com/Atrox/sweetify/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":239241528,"owners_count":19605938,"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":["flash-messages","rails","sweetalert"],"created_at":"2024-09-25T00:20:49.181Z","updated_at":"2025-02-17T05:31:30.887Z","avatar_url":"https://github.com/Atrox.png","language":"Ruby","readme":"# Sweetify - SweetAlert for Rails\n\n[![Gem](https://img.shields.io/gem/v/sweetify.svg?style=flat-square)](https://rubygems.org/gems/sweetify)\n\nThis gem allows you to use [SweetAlert](http://t4t5.github.io/sweetalert/) or [SweetAlert2](https://github.com/limonte/sweetalert2) for your flash messages.\n_See the examples below, to see how to use it_\n\n## Installation\n**Note: This package does not provide the client-side files of SweetAlert. You have to provide them yourself.**\n\nAdd this line to your application's Gemfile:\n\n```ruby\ngem 'sweetify'\n```\n\nAnd then execute:\n```bash\n$ bundle\n```\n\nNext up, create the file `sweetify.rb` in your initializers to specify the library you are using (SweetAlert or SweetAlert2):\n```ruby\n# possible options: 'sweetalert', 'sweetalert2' - default is 'sweetalert2'\nSweetify.sweetalert_library = 'sweetalert2'\n```\n\nNext add the following line to the bottom of your application's layout file:\n```html\n...\n\n\u003c%= render 'sweetify/alert' %\u003e\n\n\u003c/body\u003e\n\u003c/html\u003e\n```\n\n**You have to restart your rails server after installing the gem**\n\n## Usage\nYou can now easily create alerts in your controllers with any of the following methods provided by **Sweetify**:\n```ruby\n# Base Method, no type specified\nsweetalert(text, title = '', opts = {})\n\n# Additional methods with the type already defined\nsweetalert_info(text, title = '', opts = {})\nsweetalert_success(text, title = '', opts = {})\nsweetalert_error(text, title = '', opts = {})\nsweetalert_warning(text, title = '', opts = {})\n```\n\n## Example Usage\n```ruby\n# POST /resource\ndef create\n    sweetalert_success('Your resource is created and available.', 'Successfully created', persistent: 'Awesome!')\n    redirect_to resource_path\nend\n```\n\nThat would look like this after the redirect:\n\n![Example Alert](http://i.imgur.com/3WMvk0y.png)\n\n\n## Options\n**By default, all alerts will dismiss after a sensible default number of seconds.**\n\nDefault Options set by **Sweetify**:\n```ruby\n{\n    showConfirmButton: false,\n    timer:             2000,\n    allowOutsideClick: true,\n    confirmButtonText: 'OK'\n}\n```\n\nThe following special options provided by **Sweetify** are available:\n```ruby\n# Shows the alert with a button, but will still close automatically\nsweetalert('Text', 'Title', button: true)\nsweetalert('Text', 'Title', button: 'Awesome!') # Custom text for the button\n\n# Shows the alert with a button and only closes if the button is pressed\nsweetalert('Text', 'Title', persistent: true)\nsweetalert('Text', 'Title', persistent: 'Awesome!') # Custom text for the button\n```\n\nYou also can use any other available option that [SweetAlert accepts](http://t4t5.github.io/sweetalert/):\n```ruby\nsweetalert_info('Here is a custom image', 'Sweet!', imageUrl: 'images/thumbs-up.jpg', timer: 5000)\n```\n\n\n## Contributing\nEveryone is encouraged to help improve this project. Here are a few ways you can help:\n\n- [Report bugs](https://github.com/atrox/sweetify/issues)\n- Fix bugs and [submit pull requests](https://github.com/atrox/sweetify/pulls)\n- Write, clarify, or fix documentation\n- Suggest or add new features","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fatrox%2Fsweetify","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fatrox%2Fsweetify","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fatrox%2Fsweetify/lists"}