{"id":13878363,"url":"https://github.com/marcoroth/turbo_power-rails","last_synced_at":"2025-05-14T20:11:01.672Z","repository":{"id":57963865,"uuid":"529268980","full_name":"marcoroth/turbo_power-rails","owner":"marcoroth","description":"Power-pack for Turbo Streams","archived":false,"fork":false,"pushed_at":"2024-12-15T12:26:41.000Z","size":205,"stargazers_count":315,"open_issues_count":13,"forks_count":8,"subscribers_count":5,"default_branch":"main","last_synced_at":"2025-05-12T01:06:18.062Z","etag":null,"topics":["hacktoberfest","hotwire","rails","ruby","turbo","turbostreams"],"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/marcoroth.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.txt","code_of_conduct":"CODE_OF_CONDUCT.md","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},"funding":{"github":"marcoroth"}},"created_at":"2022-08-26T13:29:31.000Z","updated_at":"2025-05-02T23:12:07.000Z","dependencies_parsed_at":"2023-02-08T07:01:42.871Z","dependency_job_id":"268b1cf1-9f9f-4650-aa53-27ca39f4dc09","html_url":"https://github.com/marcoroth/turbo_power-rails","commit_stats":{"total_commits":101,"total_committers":6,"mean_commits":"16.833333333333332","dds":0.09900990099009899,"last_synced_commit":"92901b578021d86d7e9e5db9dca3b1b17d91612e"},"previous_names":[],"tags_count":15,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/marcoroth%2Fturbo_power-rails","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/marcoroth%2Fturbo_power-rails/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/marcoroth%2Fturbo_power-rails/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/marcoroth%2Fturbo_power-rails/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/marcoroth","download_url":"https://codeload.github.com/marcoroth/turbo_power-rails/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":254219374,"owners_count":22034397,"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":["hacktoberfest","hotwire","rails","ruby","turbo","turbostreams"],"created_at":"2024-08-06T08:01:47.402Z","updated_at":"2025-05-14T20:11:01.651Z","avatar_url":"https://github.com/marcoroth.png","language":"Ruby","funding_links":["https://github.com/sponsors/marcoroth"],"categories":["Ruby","**Awesome Hotwire** [![Awesome](https://cdn.rawgit.com/sindresorhus/awesome/d7305f38d29fed78fa85652e3a63e154dd8e8829/media/badge.svg)](https://github.com/sindresorhus/awesome)"],"sub_categories":["Turbo"],"readme":"\u003cp align=\"center\"\u003e\n  \u003cpicture\u003e\n    \u003csource media=\"(prefers-color-scheme: dark)\" srcset=\"assets/hero-dark.png\"\u003e\n    \u003cimg src=\"assets/hero.png\" height=\"340px\"\u003e\n  \u003c/picture\u003e\n\u003c/p\u003e\n\n\u003ch1 align=\"center\"\u003eTurboPower for Rails\u003c/h1\u003e\n\n\u003cp align=\"center\"\u003e\n  \u003ca href=\"https://github.com/marcoroth/turbo_power\"\u003e\n    \u003cimg src=\"https://github.com/marcoroth/turbo_power-rails/actions/workflows/tests.yml/badge.svg\"\u003e\n  \u003c/a\u003e\n  \u003ca href=\"https://rubygems.org/gems/turbo_power\"\u003e\n    \u003cimg alt=\"GEM Version\" src=\"https://img.shields.io/gem/v/turbo_power?color=38C160\u0026logo=ruby\u0026logoColor=FE1616\"\u003e\n  \u003c/a\u003e\n  \u003ca href=\"https://rubygems.org/gems/turbo_power\"\u003e\n    \u003cimg alt=\"Gem Downloads\" src=\"https://img.shields.io/gem/dt/turbo_power?color=38C160\u0026logo=ruby\u0026logoColor=FE1616\"\u003e\n  \u003c/a\u003e\n\u003c/p\u003e\n\n## Getting Started\n\nTurboPower Rails is a power-pack for Turbo Streams. This gem provides server-side Ruby helpers for the NPM package [`turbo_power`](https://github.com/marcoroth/turbo_power).\n\n## Important Note\n\nThis is very much a work in progress right now. This requires the NPM package `@hotwired/turbo \u003e= 7.2.0` or `@hotwired/turbo-rails \u003e= 7.2.0` and the gem `turbo-rails \u003e= 1.3.0`.\n\n**Also:** I can't guarantee that the current API stays that way, there might be even more ways to improve it.\n\n\n## Installation\n\nInstall the gem and add to the application's Gemfile by executing:\n\n```shell\nbundle add turbo_power\n```\n\nInstall the JavaScript package:\n\n```shell\nyarn add turbo_power\n```\n\nInitialize TurboPower in `application.js`:\n\n```diff\n// application.js\nimport * as Turbo from '@hotwired/turbo'\n\n+import TurboPower from 'turbo_power'\n+TurboPower.initialize(Turbo.StreamActions)\n```\n\n### Installation on a stock Rails 7 install with importmaps\n\n1. `./bin/importmap pin turbo_power`\n\n2. You'll then have to make sure the following files are modified as such:\n\n**config/importmaps.rb**\n```diff\npin \"application\", preload: true\n- pin \"@hotwired/turbo-rails\", to: \"turbo.min.js\", preload: true\n+ pin \"@hotwired/turbo\", to: \"turbo.min.js\", preload: true\npin \"@hotwired/stimulus\", to: \"stimulus.min.js\", preload: true\npin \"@hotwired/stimulus-loading\", to: \"stimulus-loading.js\", preload: true\n- pin \"@hotwired/turbo\", to: \"https://ga.jspm.io/npm:@hotwired/turbo@7.2.0/dist/turbo.es2017-esm.js\"\npin \"turbo_power\", to: \"https://ga.jspm.io/npm:turbo_power@0.1.6/dist/index.js\"\n```\n\n**app/javascript/application.js**\n```diff\n- import '@hotwired/turbo-rails'\n+ import { Turbo } from '@hotwired/turbo'\nimport 'controllers'\n+ import TurboPower from 'turbo_power'\n+ TurboPower.initialize(Turbo.StreamActions)\n```\n\n**Note:** These modifications will continue to work when upgrading Turbo via the [turbo-rails](https://github.com/hotwired/turbo-rails) gem. You can [read more](https://github.com/marcoroth/turbo_power-rails/issues/2) for the reasoning behind these adjustments.\n\n\n## Custom Actions\n\n### DOM Actions\n\n* `turbo_stream.graft(targets, parent, **attributes)`\n* [`turbo_stream.morph(targets, html = nil, **attributes, \u0026block)`](https://github.com/marcoroth/turbo-morph)\n* `turbo_stream.inner_html(targets, html = nil, **attributes, \u0026block)`\n* `turbo_stream.insert_adjacent_html(targets, html = nil, position: 'beforeend', **attributes, \u0026block)`\n* `turbo_stream.insert_adjacent_text(targets, text, position: 'beforebegin', **attributes)`\n* `turbo_stream.outer_html(targets, html = nil, **attributes, \u0026block)`\n* `turbo_stream.text_content(targets, text, **attributes)`\n* `turbo_stream.set_meta(name, content, **attributes)`\n\n\n### Attribute Actions\n\n* `turbo_stream.add_css_class(targets, classes, **attributes)`\n* `turbo_stream.remove_attribute(targets, attribute, **attributes)`\n* `turbo_stream.remove_css_class(targets, classes, **attributes)`\n* `turbo_stream.set_attribute(targets, attribute, value, **attributes)`\n* `turbo_stream.set_dataset_attribute(targets, attribute, value, **attributes)`\n* `turbo_stream.set_property(targets, name, value, **attributes)`\n* `turbo_stream.set_style(targets, name, value, **attributes)`\n* `turbo_stream.set_styles(targets, styles, **attributes)`\n* `turbo_stream.set_value(targets, value, **attributes)`\n* `turbo_stream.toggle_css_class(targets, classes, **attributes)`\n* `turbo_stream.replace_css_class(targets, from, to, **attributes)`\n\n\n### Event Actions\n\n* `turbo_stream.dispatch_event(targets, name, detail: {}, **attributes)`\n\n\n### Form Actions\n\n* `turbo_stream.reset_form(targets, **attributes)`\n\n\n### Storage Actions\n\n* `turbo_stream.clear_storage(type, **attributes)`\n* `turbo_stream.clear_local_storage(**attributes)`\n* `turbo_stream.clear_session_storage(**attributes)`\n* `turbo_stream.remove_storage_item(key, type, **attributes)`\n* `turbo_stream.remove_local_storage_item(key, **attributes)`\n* `turbo_stream.remove_session_storage_item(key, **attributes)`\n* `turbo_stream.set_storage_item(key, value, type, **attributes)`\n* `turbo_stream.set_local_storage_item(key, value, **attributes)`\n* `turbo_stream.set_session_storage_item(key, value, **attributes)`\n\n\n### Browser Actions\n\n* `turbo_stream.reload(**attributes)`\n* `turbo_stream.scroll_into_view(**attributes)`\n  * `turbo_stream.scroll_into_view(targets)`\n  * `turbo_stream.scroll_into_view(targets, align_to_top)`\n  * `turbo_stream.scroll_into_view(targets, behavior:,  block:, inline:)`\n* `turbo_stream.set_focus(targets, **attributes)`\n* `turbo_stream.set_title(title, **attributes)`\n\n\n### Document Actions\n\n* `turbo_stream.set_cookie(cookie, **attributes)`\n* `turbo_stream.set_cookie_item(key, value, **attributes)`\n\n\n### Browser History Actions\n\n* `turbo_stream.history_back(**attributes)`\n* `turbo_stream.history_forward(**attributes)`\n* `turbo_stream.history_go(delta = 0, **attributes)`\n* `turbo_stream.push_state(url, title = \"\", state = {}, **attributes)`\n* `turbo_stream.replace_state(url, title = \"\", state = {}, **attributes)`\n\n\n### Debug Actions\n\n* `turbo_stream.console_log(message, level = :log, **attributes)`\n* `turbo_stream.console_table(data, columns, **attributes)`\n\n\n### Notification Actions\n\n* `turbo_stream.notification(title, **options)`\n\n\n### Turbo Actions\n\n* `turbo_stream.redirect_to(url, turbo_action = nil, turbo_frame = nil, **attributes)`\n* `turbo_stream.turbo_clear_cache()`\n\n\n### Turbo Progress Bar Actions\n\n* `turbo_stream.turbo_progress_bar_show(**attributes)`\n* `turbo_stream.turbo_progress_bar_hide(**attributes)`\n* `turbo_stream.turbo_progress_bar_set_value(value, **attributes)`\n\n\n### Turbo Frame Actions\n\n* `turbo_stream.turbo_frame_reload(frame_id, **attributes)`\n* `turbo_stream.turbo_frame_set_src(frame_id, src, **attributes)`\n\n\n## Development\n\nAfter checking out the repo, run `bin/setup` to install dependencies. Then, run `rake test` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.\n\nTo install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and the created tag, and push the `.gem` file to [rubygems.org](https://rubygems.org).\n\n## Contributing\n\nBug reports and pull requests are welcome on GitHub at https://github.com/marcoroth/turbo_power-rails. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [code of conduct](https://github.com/marcoroth/turbo_power-rails/blob/master/CODE_OF_CONDUCT.md).\n\n## License\n\nThe gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).\n\n## Code of Conduct\n\nEveryone interacting in the TurboPower project's codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/marcoroth/turbo_power-rails/blob/master/CODE_OF_CONDUCT.md).\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmarcoroth%2Fturbo_power-rails","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmarcoroth%2Fturbo_power-rails","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmarcoroth%2Fturbo_power-rails/lists"}