├── .all-contributorsrc ├── .dir-locals.el ├── .github ├── FUNDING.yml ├── ISSUE_TEMPLATE │ ├── bug_report.md │ └── feature_request.md ├── PULL_REQUEST_TEMPLATE.md └── workflows │ ├── prettier-standard.yml │ ├── standardrb.yml │ └── tests.yml ├── .gitignore ├── .standard.yml ├── Appraisals ├── CHANGELOG.md ├── Gemfile ├── Gemfile.lock ├── MIT-LICENSE ├── README.md ├── Rakefile ├── app ├── assets │ └── javascripts │ │ └── .keep └── channels │ └── futurism │ └── channel.rb ├── bin ├── rails ├── standardize └── test ├── config └── routes.rb ├── dist └── .keep ├── futurism.gemspec ├── gemfiles ├── rails_5_2.gemfile ├── rails_6_0.gemfile ├── rails_6_1.gemfile ├── rails_7_0.gemfile └── rails_7_1.gemfile ├── javascript ├── elements │ ├── futurism_element.js │ ├── futurism_li.js │ ├── futurism_table_row.js │ ├── futurism_utils.js │ └── index.js ├── futurism_channel.js ├── index.js └── utils │ └── crypto.js ├── lib ├── futurism.rb ├── futurism │ ├── configuration.rb │ ├── engine.rb │ ├── helpers.rb │ ├── importmap.rb │ ├── message_verifier.rb │ ├── options_transformer.rb │ ├── resolver │ │ ├── controller.rb │ │ ├── controller │ │ │ ├── instrumentation.rb │ │ │ └── renderer.rb │ │ └── resources.rb │ ├── shims │ │ └── deep_transform_values.rb │ └── version.rb └── tasks │ └── futurism_tasks.rake ├── package.json ├── rollup.config.js ├── test ├── cable │ └── channel_test.rb ├── dummy │ ├── .ruby-version │ ├── Rakefile │ ├── app │ │ ├── assets │ │ │ ├── config │ │ │ │ └── manifest.js │ │ │ ├── images │ │ │ │ └── .keep │ │ │ └── stylesheets │ │ │ │ ├── application.css │ │ │ │ ├── posts.css │ │ │ │ └── scaffold.css │ │ ├── channels │ │ │ └── application_cable │ │ │ │ ├── channel.rb │ │ │ │ └── connection.rb │ │ ├── controllers │ │ │ ├── application_controller.rb │ │ │ ├── concerns │ │ │ │ └── .keep │ │ │ ├── home_controller.rb │ │ │ └── posts_controller.rb │ │ ├── helpers │ │ │ ├── application_helper.rb │ │ │ └── posts_helper.rb │ │ ├── javascript │ │ │ └── packs │ │ │ │ └── application.js │ │ ├── jobs │ │ │ └── application_job.rb │ │ ├── models │ │ │ ├── action_item.rb │ │ │ ├── application_record.rb │ │ │ ├── concerns │ │ │ │ └── .keep │ │ │ └── post.rb │ │ └── views │ │ │ ├── layouts │ │ │ └── application.html.erb │ │ │ └── posts │ │ │ ├── _card.html.erb │ │ │ ├── _form.html.erb │ │ │ ├── _post.html.erb │ │ │ ├── edit.html.erb │ │ │ ├── index.html.erb │ │ │ ├── new.html.erb │ │ │ └── show.html.erb │ ├── bin │ │ ├── rails │ │ ├── rake │ │ └── setup │ ├── config.ru │ ├── config │ │ ├── application.rb │ │ ├── boot.rb │ │ ├── cable.yml │ │ ├── database.yml │ │ ├── environment.rb │ │ ├── environments │ │ │ ├── development.rb │ │ │ ├── production.rb │ │ │ └── test.rb │ │ ├── initializers │ │ │ ├── application_controller_renderer.rb │ │ │ ├── backtrace_silencers.rb │ │ │ ├── content_security_policy.rb │ │ │ ├── cookies_serializer.rb │ │ │ ├── filter_parameter_logging.rb │ │ │ ├── inflections.rb │ │ │ ├── mime_types.rb │ │ │ └── wrap_parameters.rb │ │ ├── locales │ │ │ └── en.yml │ │ ├── puma.rb │ │ ├── routes.rb │ │ └── spring.rb │ ├── db │ │ ├── development.sqlite3 │ │ ├── migrate │ │ │ ├── 20200711122838_create_posts.rb │ │ │ └── 2021042923813_create_action_items.rb │ │ ├── schema.rb │ │ └── test.sqlite3 │ ├── lib │ │ └── assets │ │ │ └── .keep │ ├── log │ │ └── .keep │ └── public │ │ ├── 404.html │ │ ├── 422.html │ │ ├── 500.html │ │ ├── apple-touch-icon-precomposed.png │ │ ├── apple-touch-icon.png │ │ └── favicon.ico ├── futurism_test.rb ├── helper │ └── helper_test.rb ├── integration │ └── navigation_test.rb ├── resolver │ ├── controller │ │ ├── instrumentation_test.rb │ │ └── renderer_test.rb │ └── controller_test.rb ├── support │ └── helpers.rb └── test_helper.rb └── yarn.lock /.all-contributorsrc: -------------------------------------------------------------------------------- 1 | { 2 | "files": [ 3 | "README.md" 4 | ], 5 | "imageSize": 100, 6 | "commit": false, 7 | "contributors": [ 8 | { 9 | "login": "julianrubisch", 10 | "name": "Julian Rubisch", 11 | "avatar_url": "https://avatars0.githubusercontent.com/u/4352208?v=4", 12 | "profile": "http://www.julianrubisch.at", 13 | "contributions": [ 14 | "code" 15 | ] 16 | }, 17 | { 18 | "login": "darkrubyist", 19 | "name": "darkrubyist", 20 | "avatar_url": "https://avatars2.githubusercontent.com/u/11207292?v=4", 21 | "profile": "https://github.com/darkrubyist", 22 | "contributions": [ 23 | "code", 24 | "doc" 25 | ] 26 | }, 27 | { 28 | "login": "ParamagicDev", 29 | "name": "Konnor Rogers", 30 | "avatar_url": "https://avatars2.githubusercontent.com/u/26425882?v=4", 31 | "profile": "https://ParamagicDev.github.io/portfolio", 32 | "contributions": [ 33 | "code" 34 | ] 35 | }, 36 | { 37 | "login": "andrewmcodes", 38 | "name": "Andrew Mason", 39 | "avatar_url": "https://avatars1.githubusercontent.com/u/18423853?v=4", 40 | "profile": "https://www.andrewm.codes", 41 | "contributions": [ 42 | "maintenance" 43 | ] 44 | }, 45 | { 46 | "login": "excid3", 47 | "name": "Chris Oliver", 48 | "avatar_url": "https://avatars1.githubusercontent.com/u/67093?v=4", 49 | "profile": "http://gorails.com", 50 | "contributions": [ 51 | "code", 52 | "review" 53 | ] 54 | }, 55 | { 56 | "login": "leastbad", 57 | "name": "leastbad", 58 | "avatar_url": "https://avatars2.githubusercontent.com/u/38150464?v=4", 59 | "profile": "https://github.com/leastbad", 60 | "contributions": [ 61 | "code", 62 | "review" 63 | ] 64 | }, 65 | { 66 | "login": "mepatterson", 67 | "name": "M. E. Patterson", 68 | "avatar_url": "https://avatars0.githubusercontent.com/u/74207?v=4", 69 | "profile": "http://code.digimonkey.com", 70 | "contributions": [ 71 | "bug" 72 | ] 73 | }, 74 | { 75 | "login": "fractaledmind", 76 | "name": "Stephen Margheim", 77 | "avatar_url": "https://avatars3.githubusercontent.com/u/5077225?v=4", 78 | "profile": "http://fractaledmind.com", 79 | "contributions": [ 80 | "code" 81 | ] 82 | }, 83 | { 84 | "login": "sas1ni69", 85 | "name": "Hassanin Ahmed", 86 | "avatar_url": "https://avatars2.githubusercontent.com/u/1064205?v=4", 87 | "profile": "http://hass.codes", 88 | "contributions": [ 89 | "code" 90 | ] 91 | }, 92 | { 93 | "login": "marcoroth", 94 | "name": "Marco Roth", 95 | "avatar_url": "https://avatars2.githubusercontent.com/u/6411752?v=4", 96 | "profile": "https://marcoroth.dev", 97 | "contributions": [ 98 | "code" 99 | ] 100 | }, 101 | { 102 | "login": "vieditcom", 103 | "name": "Viedit com", 104 | "avatar_url": "https://avatars1.githubusercontent.com/u/49990587?v=4", 105 | "profile": "https://viedit.com", 106 | "contributions": [ 107 | "doc" 108 | ] 109 | }, 110 | { 111 | "login": "scottbarrow", 112 | "name": "Scott Barrow", 113 | "avatar_url": "https://avatars2.githubusercontent.com/u/5571736?v=4", 114 | "profile": "http://scottbarrow.ca", 115 | "contributions": [ 116 | "code" 117 | ] 118 | }, 119 | { 120 | "login": "domchristie", 121 | "name": "Dom Christie", 122 | "avatar_url": "https://avatars0.githubusercontent.com/u/111734?v=4", 123 | "profile": "http://domchristie.co.uk", 124 | "contributions": [ 125 | "review" 126 | ] 127 | }, 128 | { 129 | "login": "rickychilcott", 130 | "name": "Ricky Chilcott", 131 | "avatar_url": "https://avatars1.githubusercontent.com/u/445759?v=4", 132 | "profile": "http://www.rickychilcott.com", 133 | "contributions": [ 134 | "review" 135 | ] 136 | }, 137 | { 138 | "login": "mansakondo", 139 | "name": "mansakondo", 140 | "avatar_url": "https://avatars.githubusercontent.com/u/47113995?v=4", 141 | "profile": "https://github.com/mansakondo", 142 | "contributions": [ 143 | "code" 144 | ] 145 | } 146 | ], 147 | "contributorsPerLine": 7, 148 | "projectName": "futurism", 149 | "projectOwner": "julianrubisch", 150 | "repoType": "github", 151 | "repoHost": "https://github.com", 152 | "skipCi": true 153 | } 154 | -------------------------------------------------------------------------------- /.dir-locals.el: -------------------------------------------------------------------------------- 1 | ;;; Directory Local Variables 2 | ;;; For more information see (info "(emacs) Directory Variables") 3 | 4 | ((nil 5 | (prettier-js-command . "prettier-standard")) 6 | (ruby-mode 7 | (flycheck-checker . ruby-standard))) 8 | 9 | -------------------------------------------------------------------------------- /.github/FUNDING.yml: -------------------------------------------------------------------------------- 1 | github: julianrubisch 2 | -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE/bug_report.md: -------------------------------------------------------------------------------- 1 | --- 2 | name: Bug report 3 | about: Create a report to help us improve 4 | --- 5 | 6 | # Bug Report 7 | 8 | _Please help us help you by filling out any applicable information in this template and removing the rest!_ 9 | 10 | ## Describe the bug 11 | 12 | A clear and concise description of what the bug is. 13 | 14 | ## To Reproduce 15 | 16 | Steps to reproduce the behavior 17 | 18 | ## Expected behavior 19 | 20 | A clear and concise description of what you expected to happen. 21 | 22 | ## Screenshots or reproduction 23 | 24 | If applicable, add screenshots (errors, example of the behavior, etc.) to help explain your problem or post a link to a repository that replicates the issue. 25 | 26 | ## Versions 27 | 28 | ### Futurism 29 | 30 | - Gem: [e.g. 0.3.1] 31 | - Node package: [e.g. 0.3.1] 32 | 33 | ### External tools 34 | 35 | - Ruby: [e.g. 2.6.4] 36 | - Rails: [e.g. 6.0.0] 37 | - CableReady: [e.g. 4.3.0] 38 | - Node: [e.g. 12.4.0] 39 | 40 | ### Browser 41 | 42 | - Browser [e.g. chrome, safari] 43 | - Version [e.g. 22] 44 | -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE/feature_request.md: -------------------------------------------------------------------------------- 1 | --- 2 | name: Feature request 3 | about: Suggest an idea for this project 4 | --- 5 | 6 | # Feature Request 7 | 8 | _Please help us help you by filling out any applicable information in this template and removing the rest!_ 9 | 10 | ## Is your feature request related to a problem? 11 | 12 | A clear and concise description of what the problem is. If this is a bug, please open a bug report instead of a feature request! 13 | 14 | ## Describe the solution you'd like 15 | 16 | A clear and concise description of what you want to happen. Please also include alternative solutions or features you've considered. 17 | 18 | ## Additional context 19 | 20 | Add any other context or screenshots about the feature request here. 21 | 22 | ## PR link 23 | 24 | If you have opened a pull request to address the issue, please link it here. 25 | -------------------------------------------------------------------------------- /.github/PULL_REQUEST_TEMPLATE.md: -------------------------------------------------------------------------------- 1 | # Type of PR (feature, enhancement, bug fix, etc.) 2 | 3 | ## Description 4 | 5 | Please include a summary of the change and which issue is fixed. 6 | 7 | Fixes # (issue) 8 | 9 | ## Why should this be added 10 | 11 | Explain value. 12 | 13 | ## Checklist 14 | 15 | - [ ] My code follows the style guidelines of this project 16 | - [ ] Checks (StandardRB & Prettier-Standard) are passing 17 | -------------------------------------------------------------------------------- /.github/workflows/prettier-standard.yml: -------------------------------------------------------------------------------- 1 | name: Prettier-Standard 2 | 3 | on: 4 | pull_request: 5 | branches: 6 | - '*' 7 | push: 8 | branches: 9 | - master 10 | 11 | jobs: 12 | prettier: 13 | name: Prettier-Standard Check Action 14 | runs-on: ubuntu-latest 15 | steps: 16 | - uses: actions/checkout@master 17 | - name: Setup Node 18 | uses: actions/setup-node@v1 19 | with: 20 | node-version: '12.x' 21 | - name: Run prettier-standard check 22 | run: npx prettier-standard --lint 23 | working-directory: javascript 24 | -------------------------------------------------------------------------------- /.github/workflows/standardrb.yml: -------------------------------------------------------------------------------- 1 | name: StandardRB 2 | 3 | on: 4 | pull_request: 5 | branches: 6 | - '*' 7 | push: 8 | branches: 9 | - master 10 | 11 | jobs: 12 | standard: 13 | name: StandardRB Check Action 14 | runs-on: ubuntu-latest 15 | steps: 16 | - uses: actions/checkout@master 17 | - name: Set up Ruby 3 18 | uses: ruby/setup-ruby@v1 19 | with: 20 | ruby-version: 3.0.3 21 | bundler-cache: true 22 | - name: Install sqlite headers 23 | run: | 24 | sudo apt-get update 25 | sudo apt-get install libsqlite3-dev 26 | - name: Bundle install 27 | run: | 28 | gem install bundler 29 | bundle config path vendor/bundle 30 | bundle install --jobs 4 --retry 3 31 | - name: Run StandardRB 32 | run: bundle exec standardrb --format progress 33 | -------------------------------------------------------------------------------- /.github/workflows/tests.yml: -------------------------------------------------------------------------------- 1 | name: Tests 2 | 3 | on: 4 | pull_request: 5 | branches: 6 | - '*' 7 | push: 8 | branches: 9 | - master 10 | 11 | jobs: 12 | ruby_test: 13 | name: Ruby Test Action 14 | runs-on: ubuntu-latest 15 | strategy: 16 | matrix: 17 | ruby-version: ['3.1.4', '3.2.2', '3.3.0'] 18 | rails-version: ['6_1', '7_0', '7_1'] 19 | env: 20 | BUNDLE_GEMFILE: ${{ github.workspace }}/gemfiles/rails_${{ matrix.rails-version }}.gemfile 21 | steps: 22 | - uses: actions/checkout@master 23 | - name: Set up Ruby ${{ matrix.ruby-version }} 24 | uses: ruby/setup-ruby@v1 25 | with: 26 | ruby-version: ${{ matrix.ruby-version }} 27 | - uses: actions/cache@v1 28 | with: 29 | path: vendor/bundle 30 | key: ${{ runner.os }}-gems-${{ hashFiles('**/Gemfile.lock') }} 31 | restore-keys: | 32 | ${{ runner.os }}-gems- 33 | - name: Install sqlite headers 34 | run: | 35 | sudo apt-get update 36 | sudo apt-get install libsqlite3-dev 37 | - name: Bundle install 38 | run: | 39 | gem install bundler 40 | gem update --system 41 | bundle config path vendor/bundle 42 | bundle install --jobs 4 --retry 3 43 | - name: Run ruby tests 44 | run: | 45 | bundle exec rake test 46 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | .DS_Store 2 | .bundle/ 3 | log/*.log 4 | pkg/ 5 | test/dummy/log/*.log 6 | test/dummy/tmp/ 7 | *~ 8 | node_modules 9 | gemfiles/*.lock 10 | 11 | dist/** 12 | !dist/.keep 13 | 14 | app/assets/javascripts/** 15 | !app/assets/javascripts/.keep -------------------------------------------------------------------------------- /.standard.yml: -------------------------------------------------------------------------------- 1 | ignore: 2 | - "test/dummy/**/*" 3 | -------------------------------------------------------------------------------- /Appraisals: -------------------------------------------------------------------------------- 1 | if RUBY_VERSION >= "2.7" 2 | appraise "rails-7-0" do 3 | gem "rails", "7.0.1" 4 | gem "sqlite3", "~> 1.4" 5 | end 6 | end 7 | 8 | appraise "rails-6-1" do 9 | gem "rails", "~> 6.1" 10 | gem "sqlite3", "~> 1.4" 11 | end 12 | 13 | appraise "rails-6-0" do 14 | gem "rails", "~> 6.0" 15 | gem "sqlite3", "~> 1.4" 16 | end 17 | 18 | if RUBY_VERSION < "3.0" 19 | appraise "rails-5-2" do 20 | gem "rails", "~> 5.2" 21 | gem "sqlite3", "~> 1.3", "< 1.4" 22 | gem "action-cable-testing" 23 | end 24 | end 25 | -------------------------------------------------------------------------------- /CHANGELOG.md: -------------------------------------------------------------------------------- 1 | # Changelog 2 | 3 | ## [Unreleased](https://github.com/stimulusreflex/futurism/tree/HEAD) 4 | 5 | [Full Changelog](https://github.com/stimulusreflex/futurism/compare/v1.2.0.pre9...HEAD) 6 | 7 | **Merged pull requests:** 8 | 9 | - Update GH action [\#121](https://github.com/stimulusreflex/futurism/pull/121) ([nachiket87](https://github.com/nachiket87)) 10 | 11 | ## [v1.2.0.pre9](https://github.com/stimulusreflex/futurism/tree/v1.2.0.pre9) (2021-11-22) 12 | 13 | [Full Changelog](https://github.com/stimulusreflex/futurism/compare/v1.2.0.pre8...v1.2.0.pre9) 14 | 15 | ## [v1.2.0.pre8](https://github.com/stimulusreflex/futurism/tree/v1.2.0.pre8) (2021-11-10) 16 | 17 | [Full Changelog](https://github.com/stimulusreflex/futurism/compare/v1.2.0.pre7...v1.2.0.pre8) 18 | 19 | **Closed issues:** 20 | 21 | - Introduce `unless` to bypass futurism completely [\#118](https://github.com/stimulusreflex/futurism/issues/118) 22 | 23 | **Merged pull requests:** 24 | 25 | - Bypass futurism [\#119](https://github.com/stimulusreflex/futurism/pull/119) ([julianrubisch](https://github.com/julianrubisch)) 26 | 27 | ## [v1.2.0.pre7](https://github.com/stimulusreflex/futurism/tree/v1.2.0.pre7) (2021-11-05) 28 | 29 | [Full Changelog](https://github.com/stimulusreflex/futurism/compare/v1.2.0.pre6...v1.2.0.pre7) 30 | 31 | ## [v1.2.0.pre6](https://github.com/stimulusreflex/futurism/tree/v1.2.0.pre6) (2021-10-27) 32 | 33 | [Full Changelog](https://github.com/stimulusreflex/futurism/compare/v1.2.0.pre5...v1.2.0.pre6) 34 | 35 | ## [v1.2.0.pre5](https://github.com/stimulusreflex/futurism/tree/v1.2.0.pre5) (2021-10-14) 36 | 37 | [Full Changelog](https://github.com/stimulusreflex/futurism/compare/v1.2.0.pre4...v1.2.0.pre5) 38 | 39 | ## [v1.2.0.pre4](https://github.com/stimulusreflex/futurism/tree/v1.2.0.pre4) (2021-10-07) 40 | 41 | [Full Changelog](https://github.com/stimulusreflex/futurism/compare/v1.2.0.pre3...v1.2.0.pre4) 42 | 43 | **Merged pull requests:** 44 | 45 | - fix: run polyfill before eventListeners [\#116](https://github.com/stimulusreflex/futurism/pull/116) ([ParamagicDev](https://github.com/ParamagicDev)) 46 | 47 | ## [v1.2.0.pre3](https://github.com/stimulusreflex/futurism/tree/v1.2.0.pre3) (2021-10-04) 48 | 49 | [Full Changelog](https://github.com/stimulusreflex/futurism/compare/v1.2.0.pre2...v1.2.0.pre3) 50 | 51 | **Closed issues:** 52 | 53 | - Custom built in elements appear to be broken on mobile safari \(again\) [\#114](https://github.com/stimulusreflex/futurism/issues/114) 54 | 55 | ## [v1.2.0.pre2](https://github.com/stimulusreflex/futurism/tree/v1.2.0.pre2) (2021-10-01) 56 | 57 | [Full Changelog](https://github.com/stimulusreflex/futurism/compare/v1.2.0.pre1...v1.2.0.pre2) 58 | 59 | **Merged pull requests:** 60 | 61 | - Bump nokogiri from 1.11.4 to 1.12.5 [\#112](https://github.com/stimulusreflex/futurism/pull/112) ([dependabot[bot]](https://github.com/apps/dependabot)) 62 | 63 | ## [v1.2.0.pre1](https://github.com/stimulusreflex/futurism/tree/v1.2.0.pre1) (2021-09-14) 64 | 65 | [Full Changelog](https://github.com/stimulusreflex/futurism/compare/v1.1.0...v1.2.0.pre1) 66 | 67 | **Merged pull requests:** 68 | 69 | - Adapt to new wire format [\#109](https://github.com/stimulusreflex/futurism/pull/109) ([julianrubisch](https://github.com/julianrubisch)) 70 | 71 | ## [v1.1.0](https://github.com/stimulusreflex/futurism/tree/v1.1.0) (2021-09-14) 72 | 73 | [Full Changelog](https://github.com/stimulusreflex/futurism/compare/v1.0.1...v1.1.0) 74 | 75 | **Closed issues:** 76 | 77 | - Pass contextual arguments to the futurize yield block [\#104](https://github.com/stimulusreflex/futurism/issues/104) 78 | 79 | **Merged pull requests:** 80 | 81 | - Contextual placeholder arguments [\#108](https://github.com/stimulusreflex/futurism/pull/108) ([julianrubisch](https://github.com/julianrubisch)) 82 | - Delete .DS\_Store [\#107](https://github.com/stimulusreflex/futurism/pull/107) ([dorianmariefr](https://github.com/dorianmariefr)) 83 | 84 | ## [v1.0.1](https://github.com/stimulusreflex/futurism/tree/v1.0.1) (2021-08-25) 85 | 86 | [Full Changelog](https://github.com/stimulusreflex/futurism/compare/v1.0.0...v1.0.1) 87 | 88 | ## [v1.0.0](https://github.com/stimulusreflex/futurism/tree/v1.0.0) (2021-08-25) 89 | 90 | [Full Changelog](https://github.com/stimulusreflex/futurism/compare/v0.8.0...v1.0.0) 91 | 92 | **Closed issues:** 93 | 94 | - Fully support any GlobalId-able entity [\#91](https://github.com/stimulusreflex/futurism/issues/91) 95 | - Name collision if your project uses `Element` [\#90](https://github.com/stimulusreflex/futurism/issues/90) 96 | - Better Error Handling if routes are not "recognized" [\#89](https://github.com/stimulusreflex/futurism/issues/89) 97 | - Optionally allow broadcasting after each partial is generated [\#79](https://github.com/stimulusreflex/futurism/issues/79) 98 | - Make placeholder block optional [\#76](https://github.com/stimulusreflex/futurism/issues/76) 99 | - Retry [\#75](https://github.com/stimulusreflex/futurism/issues/75) 100 | - Include js-based embeds into posts [\#67](https://github.com/stimulusreflex/futurism/issues/67) 101 | - Better Error Handling [\#63](https://github.com/stimulusreflex/futurism/issues/63) 102 | 103 | **Merged pull requests:** 104 | 105 | - Broadcast\_each [\#106](https://github.com/stimulusreflex/futurism/pull/106) ([julianrubisch](https://github.com/julianrubisch)) 106 | - Bump path-parse from 1.0.6 to 1.0.7 in /javascript [\#105](https://github.com/stimulusreflex/futurism/pull/105) ([dependabot[bot]](https://github.com/apps/dependabot)) 107 | - Eager load if no placeholder block is present [\#103](https://github.com/stimulusreflex/futurism/pull/103) ([julianrubisch](https://github.com/julianrubisch)) 108 | - Bump glob-parent from 5.1.1 to 5.1.2 in /javascript [\#102](https://github.com/stimulusreflex/futurism/pull/102) ([dependabot[bot]](https://github.com/apps/dependabot)) 109 | - Bump nokogiri from 1.11.3 to 1.11.4 [\#101](https://github.com/stimulusreflex/futurism/pull/101) ([dependabot[bot]](https://github.com/apps/dependabot)) 110 | - Bump handlebars from 4.7.6 to 4.7.7 in /javascript [\#100](https://github.com/stimulusreflex/futurism/pull/100) ([dependabot[bot]](https://github.com/apps/dependabot)) 111 | - Bump lodash from 4.17.19 to 4.17.21 in /javascript [\#99](https://github.com/stimulusreflex/futurism/pull/99) ([dependabot[bot]](https://github.com/apps/dependabot)) 112 | - Bump actionpack from 6.1.3.1 to 6.1.3.2 [\#98](https://github.com/stimulusreflex/futurism/pull/98) ([dependabot[bot]](https://github.com/apps/dependabot)) 113 | - Better errors [\#97](https://github.com/stimulusreflex/futurism/pull/97) ([rickychilcott](https://github.com/rickychilcott)) 114 | - Bump rexml from 3.2.4 to 3.2.5 [\#96](https://github.com/stimulusreflex/futurism/pull/96) ([dependabot[bot]](https://github.com/apps/dependabot)) 115 | - Use rails convention to underscore collection class names [\#95](https://github.com/stimulusreflex/futurism/pull/95) ([rickychilcott](https://github.com/rickychilcott)) 116 | - Support GlobalId objects [\#94](https://github.com/stimulusreflex/futurism/pull/94) ([rickychilcott](https://github.com/rickychilcott)) 117 | - Better recognize urls [\#93](https://github.com/stimulusreflex/futurism/pull/93) ([rickychilcott](https://github.com/rickychilcott)) 118 | - Rename Element to WrappingFuturismElement [\#92](https://github.com/stimulusreflex/futurism/pull/92) ([rickychilcott](https://github.com/rickychilcott)) 119 | - Retry to resolve an element [\#81](https://github.com/stimulusreflex/futurism/pull/81) ([julianrubisch](https://github.com/julianrubisch)) 120 | 121 | ## [v0.8.0](https://github.com/stimulusreflex/futurism/tree/v0.8.0) (2021-04-23) 122 | 123 | [Full Changelog](https://github.com/stimulusreflex/futurism/compare/v0.7.2...v0.8.0) 124 | 125 | **Closed issues:** 126 | 127 | - Adapt for Turbo [\#82](https://github.com/stimulusreflex/futurism/issues/82) 128 | - Use locate\_many to avoid N+1 [\#78](https://github.com/stimulusreflex/futurism/issues/78) 129 | - Discussion: Futurism Improvements [\#64](https://github.com/stimulusreflex/futurism/issues/64) 130 | 131 | **Merged pull requests:** 132 | 133 | - Add turbo events \#82 [\#88](https://github.com/stimulusreflex/futurism/pull/88) ([julianrubisch](https://github.com/julianrubisch)) 134 | - docs: add mansakondo as a contributor [\#87](https://github.com/stimulusreflex/futurism/pull/87) ([allcontributors[bot]](https://github.com/apps/allcontributors)) 135 | - Make collection rendering work with any Ruby class [\#86](https://github.com/stimulusreflex/futurism/pull/86) ([mansakondo](https://github.com/mansakondo)) 136 | - Bump y18n from 4.0.0 to 4.0.1 in /javascript [\#85](https://github.com/stimulusreflex/futurism/pull/85) ([dependabot[bot]](https://github.com/apps/dependabot)) 137 | - Bump activerecord from 6.0.3.4 to 6.1.3 [\#84](https://github.com/stimulusreflex/futurism/pull/84) ([dependabot[bot]](https://github.com/apps/dependabot)) 138 | - Bump actionpack from 6.0.3.4 to 6.1.3 [\#83](https://github.com/stimulusreflex/futurism/pull/83) ([dependabot[bot]](https://github.com/apps/dependabot)) 139 | - Use locate\_many to avoid N+1 [\#80](https://github.com/stimulusreflex/futurism/pull/80) ([julianrubisch](https://github.com/julianrubisch)) 140 | - Bump nokogiri from 1.10.10 to 1.11.0 [\#74](https://github.com/stimulusreflex/futurism/pull/74) ([dependabot[bot]](https://github.com/apps/dependabot)) 141 | - Update Appraisals [\#73](https://github.com/stimulusreflex/futurism/pull/73) ([julianrubisch](https://github.com/julianrubisch)) 142 | 143 | ## [v0.7.2](https://github.com/stimulusreflex/futurism/tree/v0.7.2) (2020-12-07) 144 | 145 | [Full Changelog](https://github.com/stimulusreflex/futurism/compare/v0.7.1...v0.7.2) 146 | 147 | **Merged pull requests:** 148 | 149 | - Allow rendered partials to use the `partial_counter` variable [\#71](https://github.com/stimulusreflex/futurism/pull/71) ([julianrubisch](https://github.com/julianrubisch)) 150 | 151 | ## [v0.7.1](https://github.com/stimulusreflex/futurism/tree/v0.7.1) (2020-11-30) 152 | 153 | [Full Changelog](https://github.com/stimulusreflex/futurism/compare/v0.7.0...v0.7.1) 154 | 155 | **Closed issues:** 156 | 157 | - Overriding the controller [\#68](https://github.com/stimulusreflex/futurism/issues/68) 158 | 159 | **Merged pull requests:** 160 | 161 | - Lazily load default controller [\#70](https://github.com/stimulusreflex/futurism/pull/70) ([rickychilcott](https://github.com/rickychilcott)) 162 | 163 | ## [v0.7.0](https://github.com/stimulusreflex/futurism/tree/v0.7.0) (2020-11-29) 164 | 165 | [Full Changelog](https://github.com/stimulusreflex/futurism/compare/v0.6.0...v0.7.0) 166 | 167 | **Merged pull requests:** 168 | 169 | - Pass url on each request and parse to build params hash [\#69](https://github.com/stimulusreflex/futurism/pull/69) ([rickychilcott](https://github.com/rickychilcott)) 170 | 171 | ## [v0.6.0](https://github.com/stimulusreflex/futurism/tree/v0.6.0) (2020-10-12) 172 | 173 | [Full Changelog](https://github.com/stimulusreflex/futurism/compare/v0.5.4...v0.6.0) 174 | 175 | **Closed issues:** 176 | 177 | - ApplicationController context [\#54](https://github.com/stimulusreflex/futurism/issues/54) 178 | - PG::InvalidParameterValue - ERROR: payload string too long [\#51](https://github.com/stimulusreflex/futurism/issues/51) 179 | 180 | **Merged pull requests:** 181 | 182 | - Add instructions to setup local environment [\#65](https://github.com/stimulusreflex/futurism/pull/65) ([rickychilcott](https://github.com/rickychilcott)) 183 | - Allow passing in controller [\#62](https://github.com/stimulusreflex/futurism/pull/62) ([rickychilcott](https://github.com/rickychilcott)) 184 | 185 | ## [v0.5.4](https://github.com/stimulusreflex/futurism/tree/v0.5.4) (2020-10-09) 186 | 187 | [Full Changelog](https://github.com/stimulusreflex/futurism/compare/v0.5.3...v0.5.4) 188 | 189 | ## [v0.5.3](https://github.com/stimulusreflex/futurism/tree/v0.5.3) (2020-10-09) 190 | 191 | [Full Changelog](https://github.com/stimulusreflex/futurism/compare/v0.5.2...v0.5.3) 192 | 193 | **Merged pull requests:** 194 | 195 | - Add skip\_in\_test flag [\#61](https://github.com/stimulusreflex/futurism/pull/61) ([julianrubisch](https://github.com/julianrubisch)) 196 | 197 | ## [v0.5.2](https://github.com/stimulusreflex/futurism/tree/v0.5.2) (2020-10-06) 198 | 199 | [Full Changelog](https://github.com/stimulusreflex/futurism/compare/v0.5.1...v0.5.2) 200 | 201 | **Implemented enhancements:** 202 | 203 | - Question: eager trigger futurism [\#42](https://github.com/stimulusreflex/futurism/issues/42) 204 | - Restore placeholders before turbolinks caches [\#23](https://github.com/stimulusreflex/futurism/issues/23) 205 | 206 | **Merged pull requests:** 207 | 208 | - docs: add domchristie as a contributor [\#60](https://github.com/stimulusreflex/futurism/pull/60) ([allcontributors[bot]](https://github.com/apps/allcontributors)) 209 | - docs: add rickychilcott as a contributor [\#58](https://github.com/stimulusreflex/futurism/pull/58) ([allcontributors[bot]](https://github.com/apps/allcontributors)) 210 | - Reset before turbolinks caching [\#57](https://github.com/stimulusreflex/futurism/pull/57) ([julianrubisch](https://github.com/julianrubisch)) 211 | - 42 eager loading [\#56](https://github.com/stimulusreflex/futurism/pull/56) ([julianrubisch](https://github.com/julianrubisch)) 212 | 213 | ## [v0.5.1](https://github.com/stimulusreflex/futurism/tree/v0.5.1) (2020-09-27) 214 | 215 | [Full Changelog](https://github.com/stimulusreflex/futurism/compare/v0.5.0...v0.5.1) 216 | 217 | **Merged pull requests:** 218 | 219 | - Fix global ID locating of new records [\#55](https://github.com/stimulusreflex/futurism/pull/55) ([julianrubisch](https://github.com/julianrubisch)) 220 | 221 | ## [v0.5.0](https://github.com/stimulusreflex/futurism/tree/v0.5.0) (2020-09-22) 222 | 223 | [Full Changelog](https://github.com/stimulusreflex/futurism/compare/v0.4.1...v0.5.0) 224 | 225 | **Closed issues:** 226 | 227 | - Deep transform locals hash [\#38](https://github.com/stimulusreflex/futurism/issues/38) 228 | 229 | **Merged pull requests:** 230 | 231 | - 38 deep transform locals hash [\#53](https://github.com/stimulusreflex/futurism/pull/53) ([julianrubisch](https://github.com/julianrubisch)) 232 | - Bump actionview from 6.0.3.2 to 6.0.3.3 [\#52](https://github.com/stimulusreflex/futurism/pull/52) ([dependabot[bot]](https://github.com/apps/dependabot)) 233 | 234 | ## [v0.4.1](https://github.com/stimulusreflex/futurism/tree/v0.4.1) (2020-09-09) 235 | 236 | [Full Changelog](https://github.com/stimulusreflex/futurism/compare/v0.4.0...v0.4.1) 237 | 238 | **Implemented enhancements:** 239 | 240 | - Allow passing data attributes into html\_options [\#43](https://github.com/stimulusreflex/futurism/issues/43) 241 | - Identify channel \(cf StimulusReflex\) [\#34](https://github.com/stimulusreflex/futurism/issues/34) 242 | 243 | **Fixed bugs:** 244 | 245 | - ActiveStorage image url isn't correct on localhost [\#39](https://github.com/stimulusreflex/futurism/issues/39) 246 | 247 | **Merged pull requests:** 248 | 249 | - Add Gotcha hint to README \#39 [\#50](https://github.com/stimulusreflex/futurism/pull/50) ([julianrubisch](https://github.com/julianrubisch)) 250 | - docs: add scottbarrow as a contributor [\#49](https://github.com/stimulusreflex/futurism/pull/49) ([allcontributors[bot]](https://github.com/apps/allcontributors)) 251 | - 43 data attributes html options [\#48](https://github.com/stimulusreflex/futurism/pull/48) ([julianrubisch](https://github.com/julianrubisch)) 252 | - Add data attributes from html options [\#47](https://github.com/stimulusreflex/futurism/pull/47) ([scottbarrow](https://github.com/scottbarrow)) 253 | - 34 identify channel [\#46](https://github.com/stimulusreflex/futurism/pull/46) ([julianrubisch](https://github.com/julianrubisch)) 254 | - docs: add vieditcom as a contributor [\#45](https://github.com/stimulusreflex/futurism/pull/45) ([allcontributors[bot]](https://github.com/apps/allcontributors)) 255 | - Update README.md [\#44](https://github.com/stimulusreflex/futurism/pull/44) ([vieditcom](https://github.com/vieditcom)) 256 | 257 | ## [v0.4.0](https://github.com/stimulusreflex/futurism/tree/v0.4.0) (2020-08-24) 258 | 259 | [Full Changelog](https://github.com/stimulusreflex/futurism/compare/v0.3.3...v0.4.0) 260 | 261 | **Merged pull requests:** 262 | 263 | - Fix partial shorthand bug [\#41](https://github.com/stimulusreflex/futurism/pull/41) ([leastbad](https://github.com/leastbad)) 264 | - docs: add leastbad as a contributor [\#40](https://github.com/stimulusreflex/futurism/pull/40) ([allcontributors[bot]](https://github.com/apps/allcontributors)) 265 | - Refactor element - use SGIDs where possible to minimize over-the-wire size [\#37](https://github.com/stimulusreflex/futurism/pull/37) ([julianrubisch](https://github.com/julianrubisch)) 266 | 267 | ## [v0.3.3](https://github.com/stimulusreflex/futurism/tree/v0.3.3) (2020-07-30) 268 | 269 | [Full Changelog](https://github.com/stimulusreflex/futurism/compare/v0.3.2...v0.3.3) 270 | 271 | **Fixed bugs:** 272 | 273 | - Generated URLs start with /cable [\#20](https://github.com/stimulusreflex/futurism/issues/20) 274 | 275 | **Merged pull requests:** 276 | 277 | - 20 fix generated urls [\#35](https://github.com/stimulusreflex/futurism/pull/35) ([julianrubisch](https://github.com/julianrubisch)) 278 | 279 | ## [v0.3.2](https://github.com/stimulusreflex/futurism/tree/v0.3.2) (2020-07-27) 280 | 281 | [Full Changelog](https://github.com/stimulusreflex/futurism/compare/v0.3.1...v0.3.2) 282 | 283 | **Implemented enhancements:** 284 | 285 | - Allow to pass locals when rendering a collection [\#27](https://github.com/stimulusreflex/futurism/issues/27) 286 | 287 | **Merged pull requests:** 288 | 289 | - Update bug report template to feature 'Futurism' [\#33](https://github.com/stimulusreflex/futurism/pull/33) ([marcoroth](https://github.com/marcoroth)) 290 | - Allow to specify :as when rendering a collection [\#32](https://github.com/stimulusreflex/futurism/pull/32) ([marcoroth](https://github.com/marcoroth)) 291 | - docs: add marcoroth as a contributor [\#31](https://github.com/stimulusreflex/futurism/pull/31) ([allcontributors[bot]](https://github.com/apps/allcontributors)) 292 | - docs: add sas1ni69 as a contributor [\#30](https://github.com/stimulusreflex/futurism/pull/30) ([allcontributors[bot]](https://github.com/apps/allcontributors)) 293 | - uses AR Collection klass method [\#29](https://github.com/stimulusreflex/futurism/pull/29) ([sas1ni69](https://github.com/sas1ni69)) 294 | - Allow to pass locals when rendering a collection [\#28](https://github.com/stimulusreflex/futurism/pull/28) ([marcoroth](https://github.com/marcoroth)) 295 | 296 | ## [v0.3.1](https://github.com/stimulusreflex/futurism/tree/v0.3.1) (2020-07-25) 297 | 298 | [Full Changelog](https://github.com/stimulusreflex/futurism/compare/v0.3.0...v0.3.1) 299 | 300 | **Implemented enhancements:** 301 | 302 | - Emit futurism:appeared event after morphing is done [\#19](https://github.com/stimulusreflex/futurism/issues/19) 303 | 304 | **Closed issues:** 305 | 306 | - NoMethodError - undefined method `map' for nil:NilClass [\#22](https://github.com/stimulusreflex/futurism/issues/22) 307 | 308 | **Merged pull requests:** 309 | 310 | - enable passing of html\_options hash [\#26](https://github.com/stimulusreflex/futurism/pull/26) ([leastbad](https://github.com/leastbad)) 311 | - docs: add fractaledmind as a contributor [\#25](https://github.com/stimulusreflex/futurism/pull/25) ([allcontributors[bot]](https://github.com/apps/allcontributors)) 312 | - Dispatch futurism:appear method [\#24](https://github.com/stimulusreflex/futurism/pull/24) ([fractaledmind](https://github.com/fractaledmind)) 313 | - docs: add mepatterson as a contributor [\#21](https://github.com/stimulusreflex/futurism/pull/21) ([allcontributors[bot]](https://github.com/apps/allcontributors)) 314 | - add LI support to Rails helper [\#17](https://github.com/stimulusreflex/futurism/pull/17) ([leastbad](https://github.com/leastbad)) 315 | 316 | ## [v0.3.0](https://github.com/stimulusreflex/futurism/tree/v0.3.0) (2020-07-22) 317 | 318 | [Full Changelog](https://github.com/stimulusreflex/futurism/compare/v0.2.0...v0.3.0) 319 | 320 | **Merged pull requests:** 321 | 322 | - Allow futurizing collections via partial render [\#18](https://github.com/stimulusreflex/futurism/pull/18) ([julianrubisch](https://github.com/julianrubisch)) 323 | 324 | ## [v0.2.0](https://github.com/stimulusreflex/futurism/tree/v0.2.0) (2020-07-21) 325 | 326 | [Full Changelog](https://github.com/stimulusreflex/futurism/compare/v0.1.4...v0.2.0) 327 | 328 | **Merged pull requests:** 329 | 330 | - docs: add leastbad as a contributor [\#16](https://github.com/stimulusreflex/futurism/pull/16) ([allcontributors[bot]](https://github.com/apps/allcontributors)) 331 | - list element [\#15](https://github.com/stimulusreflex/futurism/pull/15) ([leastbad](https://github.com/leastbad)) 332 | - Allow to use arbitrary partials [\#12](https://github.com/stimulusreflex/futurism/pull/12) ([julianrubisch](https://github.com/julianrubisch)) 333 | 334 | ## [v0.1.4](https://github.com/stimulusreflex/futurism/tree/v0.1.4) (2020-07-18) 335 | 336 | [Full Changelog](https://github.com/stimulusreflex/futurism/compare/v0.1.2...v0.1.4) 337 | 338 | **Merged pull requests:** 339 | 340 | - Add safari polyfill [\#14](https://github.com/stimulusreflex/futurism/pull/14) ([julianrubisch](https://github.com/julianrubisch)) 341 | - docs: add excid3 as a contributor [\#13](https://github.com/stimulusreflex/futurism/pull/13) ([allcontributors[bot]](https://github.com/apps/allcontributors)) 342 | - Extract JS code to dedicated npm package [\#11](https://github.com/stimulusreflex/futurism/pull/11) ([julianrubisch](https://github.com/julianrubisch)) 343 | - docs: add andrewmcodes as a contributor [\#10](https://github.com/stimulusreflex/futurism/pull/10) ([allcontributors[bot]](https://github.com/apps/allcontributors)) 344 | 345 | ## [v0.1.2](https://github.com/stimulusreflex/futurism/tree/v0.1.2) (2020-07-12) 346 | 347 | [Full Changelog](https://github.com/stimulusreflex/futurism/compare/v0.1.1...v0.1.2) 348 | 349 | **Merged pull requests:** 350 | 351 | - Testing [\#8](https://github.com/stimulusreflex/futurism/pull/8) ([julianrubisch](https://github.com/julianrubisch)) 352 | - docs: add ParamagicDev as a contributor [\#7](https://github.com/stimulusreflex/futurism/pull/7) ([allcontributors[bot]](https://github.com/apps/allcontributors)) 353 | - feat\(active\_record\): Add ActiveRecord for testing. [\#6](https://github.com/stimulusreflex/futurism/pull/6) ([ParamagicDev](https://github.com/ParamagicDev)) 354 | - docs: add darkrubyist as a contributor [\#5](https://github.com/stimulusreflex/futurism/pull/5) ([allcontributors[bot]](https://github.com/apps/allcontributors)) 355 | - docs: add darkrubyist as a contributor [\#4](https://github.com/stimulusreflex/futurism/pull/4) ([allcontributors[bot]](https://github.com/apps/allcontributors)) 356 | - docs: add julianrubisch as a contributor [\#3](https://github.com/stimulusreflex/futurism/pull/3) ([allcontributors[bot]](https://github.com/apps/allcontributors)) 357 | - Fix pipeline errors [\#2](https://github.com/stimulusreflex/futurism/pull/2) ([julianrubisch](https://github.com/julianrubisch)) 358 | - Created a futurism\_utils file to DRY HTMLElement code [\#1](https://github.com/stimulusreflex/futurism/pull/1) ([dark88888](https://github.com/dark88888)) 359 | 360 | ## [v0.1.1](https://github.com/stimulusreflex/futurism/tree/v0.1.1) (2020-07-09) 361 | 362 | [Full Changelog](https://github.com/stimulusreflex/futurism/compare/v0.1.0...v0.1.1) 363 | 364 | ## [v0.1.0](https://github.com/stimulusreflex/futurism/tree/v0.1.0) (2020-07-09) 365 | 366 | [Full Changelog](https://github.com/stimulusreflex/futurism/compare/354945a121c4647ce3f6cbfa16ebd846dee62a3e...v0.1.0) 367 | 368 | 369 | 370 | \* *This Changelog was automatically generated by [github_changelog_generator](https://github.com/github-changelog-generator/github-changelog-generator)* 371 | -------------------------------------------------------------------------------- /Gemfile: -------------------------------------------------------------------------------- 1 | source "https://rubygems.org" 2 | git_source(:github) { |repo| "https://github.com/#{repo}.git" } 3 | 4 | # Declare your gem's dependencies in futurism.gemspec. 5 | # Bundler will treat runtime dependencies like base dependencies, and 6 | # development dependencies will be added by default to the :development group. 7 | gemspec 8 | 9 | # Declare any dependencies that are still in development here instead of in 10 | # your gemspec. These might include edge Rails or gems from your path or 11 | # Git. Remember to move these dependencies to your gemspec before releasing 12 | # your gem to rubygems.org. 13 | 14 | # To use a debugger 15 | # gem 'byebug', group: [:development, :test] 16 | -------------------------------------------------------------------------------- /Gemfile.lock: -------------------------------------------------------------------------------- 1 | PATH 2 | remote: . 3 | specs: 4 | futurism (1.4.2) 5 | cable_ready (>= 5.0) 6 | rack (>= 2, < 4) 7 | rails (>= 5.2) 8 | 9 | GEM 10 | remote: https://rubygems.org/ 11 | specs: 12 | actioncable (7.1.5.1) 13 | actionpack (= 7.1.5.1) 14 | activesupport (= 7.1.5.1) 15 | nio4r (~> 2.0) 16 | websocket-driver (>= 0.6.1) 17 | zeitwerk (~> 2.6) 18 | actionmailbox (7.1.5.1) 19 | actionpack (= 7.1.5.1) 20 | activejob (= 7.1.5.1) 21 | activerecord (= 7.1.5.1) 22 | activestorage (= 7.1.5.1) 23 | activesupport (= 7.1.5.1) 24 | mail (>= 2.7.1) 25 | net-imap 26 | net-pop 27 | net-smtp 28 | actionmailer (7.1.5.1) 29 | actionpack (= 7.1.5.1) 30 | actionview (= 7.1.5.1) 31 | activejob (= 7.1.5.1) 32 | activesupport (= 7.1.5.1) 33 | mail (~> 2.5, >= 2.5.4) 34 | net-imap 35 | net-pop 36 | net-smtp 37 | rails-dom-testing (~> 2.2) 38 | actionpack (7.1.5.1) 39 | actionview (= 7.1.5.1) 40 | activesupport (= 7.1.5.1) 41 | nokogiri (>= 1.8.5) 42 | racc 43 | rack (>= 2.2.4) 44 | rack-session (>= 1.0.1) 45 | rack-test (>= 0.6.3) 46 | rails-dom-testing (~> 2.2) 47 | rails-html-sanitizer (~> 1.6) 48 | actiontext (7.1.5.1) 49 | actionpack (= 7.1.5.1) 50 | activerecord (= 7.1.5.1) 51 | activestorage (= 7.1.5.1) 52 | activesupport (= 7.1.5.1) 53 | globalid (>= 0.6.0) 54 | nokogiri (>= 1.8.5) 55 | actionview (7.1.5.1) 56 | activesupport (= 7.1.5.1) 57 | builder (~> 3.1) 58 | erubi (~> 1.11) 59 | rails-dom-testing (~> 2.2) 60 | rails-html-sanitizer (~> 1.6) 61 | activejob (7.1.5.1) 62 | activesupport (= 7.1.5.1) 63 | globalid (>= 0.3.6) 64 | activemodel (7.1.5.1) 65 | activesupport (= 7.1.5.1) 66 | activerecord (7.1.5.1) 67 | activemodel (= 7.1.5.1) 68 | activesupport (= 7.1.5.1) 69 | timeout (>= 0.4.0) 70 | activestorage (7.1.5.1) 71 | actionpack (= 7.1.5.1) 72 | activejob (= 7.1.5.1) 73 | activerecord (= 7.1.5.1) 74 | activesupport (= 7.1.5.1) 75 | marcel (~> 1.0) 76 | activesupport (7.1.5.1) 77 | base64 78 | benchmark (>= 0.3) 79 | bigdecimal 80 | concurrent-ruby (~> 1.0, >= 1.0.2) 81 | connection_pool (>= 2.2.5) 82 | drb 83 | i18n (>= 1.6, < 2) 84 | logger (>= 1.4.2) 85 | minitest (>= 5.1) 86 | mutex_m 87 | securerandom (>= 0.3) 88 | tzinfo (~> 2.0) 89 | appraisal (2.5.0) 90 | bundler 91 | rake 92 | thor (>= 0.14.0) 93 | ast (2.4.2) 94 | base64 (0.2.0) 95 | benchmark (0.4.0) 96 | bigdecimal (3.1.8) 97 | builder (3.3.0) 98 | cable_ready (5.0.5) 99 | actionpack (>= 5.2) 100 | actionview (>= 5.2) 101 | activesupport (>= 5.2) 102 | observer (~> 0.1) 103 | railties (>= 5.2) 104 | thread-local (>= 1.1.0) 105 | concurrent-ruby (1.3.4) 106 | connection_pool (2.4.1) 107 | crass (1.0.6) 108 | date (3.4.1) 109 | drb (2.2.1) 110 | erubi (1.13.0) 111 | globalid (1.2.1) 112 | activesupport (>= 6.1) 113 | i18n (1.14.6) 114 | concurrent-ruby (~> 1.0) 115 | io-console (0.7.2) 116 | irb (1.14.0) 117 | rdoc (>= 4.0.0) 118 | reline (>= 0.4.2) 119 | json (2.7.1) 120 | language_server-protocol (3.17.0.3) 121 | lint_roller (1.1.0) 122 | logger (1.6.2) 123 | loofah (2.23.1) 124 | crass (~> 1.0.2) 125 | nokogiri (>= 1.12.0) 126 | mail (2.8.1) 127 | mini_mime (>= 0.1.1) 128 | net-imap 129 | net-pop 130 | net-smtp 131 | marcel (1.0.4) 132 | mini_mime (1.1.5) 133 | minitest (5.25.4) 134 | mutex_m (0.3.0) 135 | net-imap (0.4.19) 136 | date 137 | net-protocol 138 | net-pop (0.1.2) 139 | net-protocol 140 | net-protocol (0.2.2) 141 | timeout 142 | net-smtp (0.5.0) 143 | net-protocol 144 | nio4r (2.7.3) 145 | nokogiri (1.18.8-arm64-darwin) 146 | racc (~> 1.4) 147 | nokogiri (1.18.8-x86_64-linux-gnu) 148 | racc (~> 1.4) 149 | observer (0.1.2) 150 | parallel (1.24.0) 151 | parser (3.3.0.5) 152 | ast (~> 2.4.1) 153 | racc 154 | psych (5.1.2) 155 | stringio 156 | racc (1.8.1) 157 | rack (3.1.12) 158 | rack-session (2.0.0) 159 | rack (>= 3.0.0) 160 | rack-test (2.1.0) 161 | rack (>= 1.3) 162 | rackup (2.1.0) 163 | rack (>= 3) 164 | webrick (~> 1.8) 165 | rails (7.1.5.1) 166 | actioncable (= 7.1.5.1) 167 | actionmailbox (= 7.1.5.1) 168 | actionmailer (= 7.1.5.1) 169 | actionpack (= 7.1.5.1) 170 | actiontext (= 7.1.5.1) 171 | actionview (= 7.1.5.1) 172 | activejob (= 7.1.5.1) 173 | activemodel (= 7.1.5.1) 174 | activerecord (= 7.1.5.1) 175 | activestorage (= 7.1.5.1) 176 | activesupport (= 7.1.5.1) 177 | bundler (>= 1.15.0) 178 | railties (= 7.1.5.1) 179 | rails-dom-testing (2.2.0) 180 | activesupport (>= 5.0.0) 181 | minitest 182 | nokogiri (>= 1.6) 183 | rails-html-sanitizer (1.6.1) 184 | loofah (~> 2.21) 185 | nokogiri (>= 1.15.7, != 1.16.7, != 1.16.6, != 1.16.5, != 1.16.4, != 1.16.3, != 1.16.2, != 1.16.1, != 1.16.0.rc1, != 1.16.0) 186 | railties (7.1.5.1) 187 | actionpack (= 7.1.5.1) 188 | activesupport (= 7.1.5.1) 189 | irb 190 | rackup (>= 1.0.0) 191 | rake (>= 12.2) 192 | thor (~> 1.0, >= 1.2.2) 193 | zeitwerk (~> 2.6) 194 | rainbow (3.1.1) 195 | rake (13.1.0) 196 | rdoc (6.7.0) 197 | psych (>= 4.0.0) 198 | regexp_parser (2.9.0) 199 | reline (0.5.9) 200 | io-console (~> 0.5) 201 | rexml (3.3.9) 202 | rubocop (1.60.2) 203 | json (~> 2.3) 204 | language_server-protocol (>= 3.17.0) 205 | parallel (~> 1.10) 206 | parser (>= 3.3.0.2) 207 | rainbow (>= 2.2.2, < 4.0) 208 | regexp_parser (>= 1.8, < 3.0) 209 | rexml (>= 3.2.5, < 4.0) 210 | rubocop-ast (>= 1.30.0, < 2.0) 211 | ruby-progressbar (~> 1.7) 212 | unicode-display_width (>= 2.4.0, < 3.0) 213 | rubocop-ast (1.30.0) 214 | parser (>= 3.2.1.0) 215 | rubocop-performance (1.20.2) 216 | rubocop (>= 1.48.1, < 2.0) 217 | rubocop-ast (>= 1.30.0, < 2.0) 218 | ruby-progressbar (1.13.0) 219 | securerandom (0.4.0) 220 | sqlite3 (1.7.2-arm64-darwin) 221 | sqlite3 (1.7.2-x86_64-linux) 222 | standard (1.34.0) 223 | language_server-protocol (~> 3.17.0.2) 224 | lint_roller (~> 1.0) 225 | rubocop (~> 1.60) 226 | standard-custom (~> 1.0.0) 227 | standard-performance (~> 1.3) 228 | standard-custom (1.0.2) 229 | lint_roller (~> 1.0) 230 | rubocop (~> 1.50) 231 | standard-performance (1.3.1) 232 | lint_roller (~> 1.1) 233 | rubocop-performance (~> 1.20.2) 234 | standardrb (1.0.1) 235 | standard 236 | stringio (3.1.1) 237 | thor (1.3.1) 238 | thread-local (1.1.0) 239 | timeout (0.4.3) 240 | tzinfo (2.0.6) 241 | concurrent-ruby (~> 1.0) 242 | unicode-display_width (2.5.0) 243 | webrick (1.8.2) 244 | websocket-driver (0.7.6) 245 | websocket-extensions (>= 0.1.0) 246 | websocket-extensions (0.1.5) 247 | zeitwerk (2.6.16) 248 | 249 | PLATFORMS 250 | arm64-darwin-21 251 | arm64-darwin-22 252 | x86_64-linux 253 | 254 | DEPENDENCIES 255 | appraisal 256 | bundler (~> 2.0) 257 | futurism! 258 | nokogiri 259 | rake (~> 13.0) 260 | sqlite3 261 | standardrb 262 | 263 | BUNDLED WITH 264 | 2.2.32 265 | -------------------------------------------------------------------------------- /MIT-LICENSE: -------------------------------------------------------------------------------- 1 | Copyright 2020 Julian Rubisch 2 | 3 | Permission is hereby granted, free of charge, to any person obtaining 4 | a copy of this software and associated documentation files (the 5 | "Software"), to deal in the Software without restriction, including 6 | without limitation the rights to use, copy, modify, merge, publish, 7 | distribute, sublicense, and/or sell copies of the Software, and to 8 | permit persons to whom the Software is furnished to do so, subject to 9 | the following conditions: 10 | 11 | The above copyright notice and this permission notice shall be 12 | included in all copies or substantial portions of the Software. 13 | 14 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 15 | EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 16 | MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 17 | NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE 18 | LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION 19 | OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION 20 | WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 21 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Futurism 2 | [![Twitter follow](https://img.shields.io/twitter/follow/julian_rubisch?style=social)](https://twitter.com/julian_rubisch) 3 | 4 | [![All Contributors](https://img.shields.io/badge/all_contributors-15-orange.svg?style=flat-square)](#contributors-) 5 | 6 | Lazy-load Rails partials via CableReady 7 | 8 | :rotating_light: *BREAKING CHANGE: With v1.0, futurism has been transferred to the [stimulusreflex](https://github.com/stimulusreflex) organization. Please update your npm package to `@stimulus_reflex/futurism` accordingly* :rotating_light: 9 | 10 | birmingham-museums-trust-GrvC6MI-z4w-unsplash 11 | Photo by Birmingham Museums Trust on Unsplash 12 | 13 | ## Table of Contents 14 | 15 | - [Table of Contents](#table-of-contents) 16 | - [Facts](#facts) 17 | - [Browser Support](#browser-support) 18 | - [Usage](#usage) 19 | - [API](#api) 20 | - [Resource](#resource) 21 | - [Explicit Partial](#explicit-partial) 22 | - [HTML Options](#html-options) 23 | - [Eager Loading](#eager-loading) 24 | - [Bypassing](#bypassing) 25 | - [Broadcast Partials Individually](#broadcast-partials-individually) 26 | - [Contextual Placeholder Arguments](#contextual-placeholder-arguments) 27 | - [Events](#events) 28 | - [Instrumentation](#instrumentation) 29 | - [Installation](#installation) 30 | - [Manual Installation](#manual-installation) 31 | - [Authentication](#authentication) 32 | - [Testing](#testing) 33 | - [Gotchas](#gotchas) 34 | - [Contributing](#contributing) 35 | - [License](#license) 36 | - [Contributors](#contributors) 37 | 38 | ## Facts 39 | - only one dependency: CableReady 40 | - bundle size (without CableReady) is around [~2.46kB](https://bundlephobia.com/result?p=@stimulus_reflex/futurism@0.7.2) 41 | 42 | ### Browser Support 43 | 44 | - Chrome v67+ (v54+ via Polyfill) 45 | - Firefox v63+ 46 | - Edge v79+ 47 | - Safari v10.1+ via Polyfill 48 | - iOS Safari & Chrome v10.3+ via Polyfill 49 | 50 | [Caniuse](https://www.caniuse.com/#search=custom%20elements) 51 | 52 | ## Usage 53 | with a helper in your template 54 | 55 | ```erb 56 | <%= futurize @posts, extends: :div do %> 57 | 58 | <% end %> 59 | ``` 60 | 61 | custom ``s (in the form of a `
` or a `` are rendered. Those custom elements have an `IntersectionObserver` attached that will send a signed global id to an ActionCable channel (`FuturismChannel`) which will then replace the placeholders with the actual resource partial. 62 | 63 | With that method, you could lazy load every class that has to_partial_path defined (ActiveModel has by default). 64 | 65 | You can pass the placeholder as a block: 66 | 67 | ```erb 68 | <%= futurize @posts, extends: :tr do %> 69 | 70 | <% end %> 71 | ``` 72 | 73 | ![aa601dec1930151f71dbf0d6b02b61c9](https://user-images.githubusercontent.com/4352208/87131629-f768a480-c294-11ea-89a9-ea0a76ee06ef.gif) 74 | 75 | You can also omit the placeholder, which falls back to [eager loading](#eager-loading). 76 | 77 | ## API 78 | 79 | Currently there are two ways to call `futurize`, designed to wrap `render`'s behavior: 80 | 81 | ### Resource 82 | 83 | You can pass a single `ActiveRecord` or an `ActiveRecord::Relation` to `futurize`, just as you would call `render`: 84 | 85 | ```erb 86 | <%= futurize @posts, extends: :tr do %> 87 | 88 | <% end %> 89 | ``` 90 | 91 | #### Partial Path 92 | 93 | Remember that you can override the partial path in you models, like so: 94 | 95 | ```rb 96 | class Post < ApplicationRecord 97 | def to_partial_path 98 | "home/post" 99 | end 100 | end 101 | ``` 102 | 103 | That way you get maximal flexibility when just specifying a single resource. 104 | 105 | ### Explicit Partial 106 | 107 | Call `futurize` with a `partial` keyword: 108 | 109 | ```erb 110 | <%= futurize partial: "items/card", locals: {card: @card}, extends: :div do %> 111 |
112 | <% end %> 113 | ``` 114 | 115 | You can also use the shorthand syntax: 116 | 117 | ```erb 118 | <%= futurize "items/card", card: @card, extends: :div do %> 119 |
120 | <% end %> 121 | ``` 122 | 123 | #### Collections 124 | 125 | Collection rendering is also possible: 126 | 127 | ```erb 128 | <%= futurize partial: "items/card", collection: @cards, extends: :div do %> 129 |
130 | <% end %> 131 | ``` 132 | 133 | #### Specifying Controller to Render 134 | 135 | You can also pass in the controller that will be used to render the partial. 136 | 137 | ```erb 138 | <%= futurize partial: "items/card", collection: @cards, controller: MyController, extends: :div do %> 139 |
140 | <% end %> 141 | ``` 142 | 143 | By default (i.e. not passing in a value), futurize will use `ApplicationController`, but you may override by setting the Futurism default controller in an initializer, for example `config/initializers/futurism.rb`. 144 | 145 | ```ruby 146 | Futurism.default_controller = "MyController" # to avoid the controller from trying to autoload at boot, provide as a string 147 | ``` 148 | 149 | ### HTML Options 150 | 151 | You can pass a hash of attribute/value pairs which will be mixed into the HTML markup for the placeholder element. This is important for layouts that require elements to have dimensionality. For example, many scripts calculate size based on element height and width. This option ensures that your elements have integrity, even if they are gone before you see them. 152 | 153 | ```erb 154 | <%= futurize @posts, extends: :tr, html_options: {style: "width: 50px; height: 50px;"} do %> 155 | 156 | <% end %> 157 | ``` 158 | 159 | This will output the following: 160 | 161 | ```html 162 | 163 | 164 | 165 | ``` 166 | 167 | ### Eager Loading 168 | It may sound surprising to support eager loading in a lazy loading library :joy:, but there's a quite simple use case: 169 | 170 | Suppose you have some hidden interactive portion of your page, like a tab or dropdown. You don't want its content to block the initial page load, but once that is done, you occasionally don't want to wait for the element to become visible and trigger the `IntersectionObserver`, you want to lazy load its contents right after it's added to the DOM. 171 | 172 | Futurism makes that dead simple: 173 | 174 | ```erb 175 | <%= futurize 'some_tab', eager: true, extends: :tr do %> 176 |
177 | <% end %> 178 | ``` 179 | 180 | ### Bypassing 181 | 182 | In some rare cases, e.g. when combined with CableReady's async `updates_for` mechanism, you'll want to bypass futurism entirely and fall back to native `rendering`. You can do this by passing an `unless` option: 183 | 184 | ```erb 185 | <%= futurize 'some_tab', unless: bypass_futurism?, extends: :tr do %> 186 |
187 | <% end %> 188 | ``` 189 | 190 | Internally, this works the same as [bypassing futurism in tests](#testing) 191 | 192 | 193 | ### Broadcast Partials Individually 194 | Futurism's default behavior is to `broadcast` partials as they are generated in batches: 195 | 196 | On the client side, `IntersectionObserver` events are triggered in a debounced fashion, so several `render`s are performed on the server for each of those events. By default, futurism will group those to a single `broadcast` call (to save server CPU time). 197 | 198 | For collections, however, you can opt into individual broadcasts by specifying `broadcast_each: true` in your helper usage: 199 | 200 | ```erb 201 | <%= futurize @posts, broadcast_each: true, extends: :tr do %> 202 |
203 | <% end %> 204 | ``` 205 | 206 | ### Contextual Placeholder Arguments 207 | 208 | For individual models or arbitrary collections, you can pass `record` and `index` to the placeholder block as arguments: 209 | 210 | ```erb 211 | <%= futurize @post, extends: :div do |post| %> 212 |
<%= post.title %>
213 | <% end %> 214 | ``` 215 | 216 | ```erb 217 | <%= futurize @posts, extends: :tr do |post, index| %> 218 | <%= index + 1 %><%= post.title %> 219 | <% end %> 220 | ``` 221 | 222 | ```erb 223 | <%= futurize partial: "users/user", collection: users, extends: "tr" do |user, index| %> 224 | <%= index + 1 %><%= user.name %> 225 | <% end > 226 | ``` 227 | 228 | ## Events 229 | 230 | Once your futurize element has been rendered, the `futurism:appeared` custom event will be called. 231 | 232 | ## Instrumentation 233 | 234 | Futurism includes support for instrumenting rendering events. 235 | 236 | To enable ActiveSupport notifications, use the `instrumentation` option: 237 | 238 | ```ruby 239 | Futurism.instrumentation = true 240 | ``` 241 | 242 | Then subscribe to the `render.futurism` event: 243 | 244 | ```ruby 245 | ActiveSupport::Notifications.subscribe("render.futurism") do |*args| 246 | event = ActiveSupport::Notifications::Event.new(*args) 247 | event.name # => "render.futurism" 248 | event.payload[:channel] # => "Futurism::Channel" # ActionCable channel to broadcast 249 | event.payload[:controller] # => "posts" # The controller that invokes `futurize` call 250 | event.payload[:action] # => "show" # The action that invokes `futurize` call 251 | event.payload[:partial] # => "posts/card" # The partial that was rendered 252 | end 253 | ``` 254 | 255 | This is useful for performance monitoring, specifically for tracking the source of `futurize` calls. 256 | 257 | ## Installation 258 | Add this line to your application's Gemfile: 259 | 260 | ```ruby 261 | gem 'futurism' 262 | ``` 263 | 264 | And then execute: 265 | ```bash 266 | $ bundle 267 | ``` 268 | 269 | To copy over the javascript files to your application, run 270 | 271 | ```bash 272 | $ bin/rails futurism:install 273 | ``` 274 | 275 | **! Note that the installer will run `yarn add @stimulus_reflex/futurism` for you !** 276 | 277 | ### Manual Installation 278 | After `bundle`, install the Javascript library: 279 | 280 | There are a few ways to install the Futurism JavaScript client, depending on your application setup. 281 | 282 | #### ESBuild / Webpacker 283 | 284 | ```sh 285 | yarn add @stimulus_reflex/futurism 286 | ``` 287 | 288 | #### Import maps: 289 | 290 | ```ruby 291 | # config/importmap.rb 292 | # ... 293 | pin '@stimulus_reflex/futurism', to: 'futurism.min.js', preload: true 294 | ``` 295 | 296 | #### Rails Asset pipeline (Sprockets): 297 | 298 | ```html+erb 299 | 300 | <%= javascript_include_tag "futurism.umd.min.js", "data-turbo-track": "reload" %> 301 | ``` 302 | 303 | In your `app/javascript/channels/index.js`, add the following 304 | 305 | ```js 306 | import * as Futurism from '@stimulus_reflex/futurism' 307 | 308 | import consumer from './consumer' 309 | 310 | Futurism.initializeElements() 311 | Futurism.createSubscription(consumer) 312 | ``` 313 | 314 | ## Authentication 315 | For authentication, you can rely on ActionCable identifiers, for example, if you use Devise: 316 | 317 | ```ruby 318 | module ApplicationCable 319 | class Connection < ActionCable::Connection::Base 320 | identified_by :current_user 321 | 322 | def connect 323 | self.current_user = env["warden"].user || reject_unauthorized_connection 324 | end 325 | end 326 | end 327 | ``` 328 | 329 | The [Stimulus Reflex Docs](https://docs.stimulusreflex.com/authentication) have an excellent section about all sorts of authentication. 330 | 331 | ## Testing 332 | In Rails system tests there is a chance that flaky errors will occur due to Capybara not waiting for the placeholder elements to be replaced. To overcome this, add the flag 333 | 334 | ```ruby 335 | Futurism.skip_in_test = true 336 | ``` 337 | 338 | to an initializer, for example `config/initializers/futurism.rb`. 339 | 340 | ## Gotchas 341 | 342 | ### ActiveStorage URLs aren't correct in development 343 | 344 | Out of the box, Rails will prefix generated urls with `http://example.org` rather than `http://localhost`, much like ActionMailer. To amend this, add 345 | 346 | ```ruby 347 | # config/environments/development.rb 348 | config.action_controller.default_url_options = {host: "localhost", port: 3000} 349 | 350 | # config/environments/production.rb 351 | config.action_controller.default_url_options = {host: "mysite.com"} 352 | ``` 353 | 354 | to your environments. 355 | 356 | ### Choosing the parent for Futurism::Channel 357 | 358 | By default Futurism::CHannel will inherit from ApplicationCable::Channel, you can change this by setting 359 | 360 | ```ruby 361 | Futurism.configure do |config| 362 | config.parent_channel = "CustomFuturismChannel" 363 | end 364 | 365 | ``` 366 | in config/initializers. 367 | 368 | ## Contributing 369 | 370 | ### Get local environment setup 371 | 372 | Below are a set of instructions that may help you get a local development environment working 373 | 374 | ```shell 375 | # Get the gem/npm package source locally 376 | git clone futurism 377 | cd futurism/javascript 378 | yarn install # install all of the npm package's dependencies 379 | yarn link # set the local machine's futurism npm package's lookup to this local path 380 | 381 | # Setup a sample project, use the information below directly or use your own project 382 | git clone https://github.com/leastbad/stimulus_reflex_harness.git 383 | cd stimulus_reflex_harness 384 | git checkout futurism 385 | # Edit Gemfile to point point to local gem (e.g. `gem "futurism", path: "../futurism"`) 386 | # yarn link @stimulus_reflex/futurism 387 | 388 | 389 | # Do your work, Submit PR, Profit! 390 | 391 | 392 | # To stop using your local version of futurism 393 | # change your Gemfile back to the published (e.g. `gem "futurism"`) 394 | cd path/to/futurism/javascript 395 | # Stop using the local npm package 396 | yarn unlink 397 | 398 | # Instruct your project to reinstall the published version of the npm package 399 | cd path/to/project 400 | yarn install --force 401 | ``` 402 | 403 | ### 📦 Releasing 404 | 405 | 1. Make sure that you run `yarn` and `bundle` to pick up the latest. 406 | 2. Bump version number at `lib/futurism/version.rb`. Pre-release versions use `.preN` 407 | 3. Run `rake build` and `yarn build` 408 | 4. Commit and push changes to github `git commit -m "Bump version to x.x.x"` 409 | 5. Run `rake release` 410 | 6. Run `yarn publish --no-git-tag-version` 411 | 7. Yarn will prompt you for the new version. Pre-release versions use `-preN` 412 | 8. Commit and push changes to GitHub 413 | 9. Create a new release on GitHub ([here](https://github.com/stimulusreflex/futurism/releases)) and generate the changelog for the stable release for it 414 | 415 | ## License 416 | The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT). 417 | 418 | ## Contributors ✨ 419 | 420 | Thanks goes to these wonderful people ([emoji key](https://allcontributors.org/docs/en/emoji-key)): 421 | 422 | 423 | 424 | 425 | 426 | 427 | 428 | 429 | 430 | 431 | 432 | 433 | 434 | 435 | 436 | 437 | 438 | 439 | 440 | 441 | 442 | 443 | 444 | 445 | 446 | 447 |

Julian Rubisch

💻

darkrubyist

💻 📖

Konnor Rogers

💻

Andrew Mason

🚧

Chris Oliver

💻 👀

leastbad

💻 👀

M. E. Patterson

🐛

Stephen Margheim

💻

Hassanin Ahmed

💻

Marco Roth

💻

Viedit com

📖

Scott Barrow

💻

Dom Christie

👀

Ricky Chilcott

👀

mansakondo

💻
448 | 449 | 450 | 451 | 452 | 453 | 454 | This project follows the [all-contributors](https://github.com/all-contributors/all-contributors) specification. Contributions of any kind welcome! 455 | -------------------------------------------------------------------------------- /Rakefile: -------------------------------------------------------------------------------- 1 | begin 2 | require "bundler/setup" 3 | rescue LoadError 4 | puts "You must `gem install bundler` and `bundle install` to run rake tasks" 5 | end 6 | 7 | require "rdoc/task" 8 | 9 | RDoc::Task.new(:rdoc) do |rdoc| 10 | rdoc.rdoc_dir = "rdoc" 11 | rdoc.title = "Futurism" 12 | rdoc.options << "--line-numbers" 13 | rdoc.rdoc_files.include("README.md") 14 | rdoc.rdoc_files.include("lib/**/*.rb") 15 | end 16 | 17 | load "rails/tasks/statistics.rake" 18 | 19 | require "bundler/gem_tasks" 20 | 21 | require "rake/testtask" 22 | 23 | Rake::TestTask.new(:test) do |t| 24 | t.libs << "test" 25 | t.pattern = "test/**/*_test.rb" 26 | t.verbose = false 27 | end 28 | 29 | task default: :test 30 | -------------------------------------------------------------------------------- /app/assets/javascripts/.keep: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/stimulusreflex/futurism/17ff67492c4404ffd19d834691e59b08314cfc51/app/assets/javascripts/.keep -------------------------------------------------------------------------------- /app/channels/futurism/channel.rb: -------------------------------------------------------------------------------- 1 | module Futurism 2 | class Channel < Futurism.configuration.parent_channel.constantize 3 | include CableReady::Broadcaster 4 | 5 | def stream_name 6 | ids = connection.identifiers.map { |identifier| send(identifier).try(:id) || send(identifier) } 7 | [ 8 | params[:channel], 9 | ids.select(&:present?).join(";") 10 | ].select(&:present?).join(":") 11 | end 12 | 13 | def subscribed 14 | stream_from stream_name 15 | end 16 | 17 | def receive(data) 18 | resources = data.fetch_values("signed_params", "sgids", "signed_controllers", "urls", "broadcast_each") { |_key| Array.new(data["signed_params"].length, nil) }.transpose 19 | 20 | resolver = Resolver::Resources.new(resource_definitions: resources, connection: connection, params: @params) 21 | resolver.resolve do |selector, html, broadcast_each| 22 | cable_ready[stream_name].outer_html( 23 | selector: selector, 24 | html: html 25 | ) 26 | 27 | cable_ready.broadcast if broadcast_each 28 | end 29 | 30 | cable_ready.broadcast 31 | end 32 | end 33 | end 34 | -------------------------------------------------------------------------------- /bin/rails: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env ruby 2 | # This command will automatically be run when you run "rails" with Rails gems 3 | # installed from the root of your application. 4 | 5 | ENGINE_ROOT = File.expand_path('..', __dir__) 6 | ENGINE_PATH = File.expand_path('../lib/futurism/engine', __dir__) 7 | APP_PATH = File.expand_path('../test/dummy/config/application', __dir__) 8 | 9 | # Set up gems listed in the Gemfile. 10 | ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../Gemfile', __dir__) 11 | require 'bundler/setup' if File.exist?(ENV['BUNDLE_GEMFILE']) 12 | 13 | require "rails" 14 | # Pick the frameworks you want: 15 | require "active_model/railtie" 16 | require "active_job/railtie" 17 | # require "active_record/railtie" 18 | # require "active_storage/engine" 19 | require "action_controller/railtie" 20 | # require "action_mailer/railtie" 21 | require "action_view/railtie" 22 | require "action_cable/engine" 23 | # require "sprockets/railtie" 24 | require "rails/test_unit/railtie" 25 | require 'rails/engine/commands' 26 | -------------------------------------------------------------------------------- /bin/standardize: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | bundle exec standardrb --fix 4 | 5 | npx prettier-standard lib/templates/**/*.js 6 | -------------------------------------------------------------------------------- /bin/test: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env ruby 2 | $: << File.expand_path("../test", __dir__) 3 | 4 | require "bundler/setup" 5 | require "rails/plugin/test" 6 | -------------------------------------------------------------------------------- /config/routes.rb: -------------------------------------------------------------------------------- 1 | Rails.application.routes.draw do 2 | end 3 | -------------------------------------------------------------------------------- /dist/.keep: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/stimulusreflex/futurism/17ff67492c4404ffd19d834691e59b08314cfc51/dist/.keep -------------------------------------------------------------------------------- /futurism.gemspec: -------------------------------------------------------------------------------- 1 | $:.push File.expand_path("lib", __dir__) 2 | 3 | # Maintain your gem's version: 4 | require "futurism/version" 5 | 6 | # Describe your gem and declare its dependencies: 7 | Gem::Specification.new do |spec| 8 | spec.name = "futurism" 9 | spec.version = Futurism::VERSION 10 | spec.authors = ["Julian Rubisch"] 11 | spec.email = ["julian@julianrubisch.at"] 12 | spec.homepage = "https://github.com/stimulusreflex/futurism" 13 | spec.summary = "Lazy-load Rails partials via CableReady" 14 | spec.description = "Uses custom html elements with attached IntersectionObserver to automatically lazy load partials via websockets" 15 | spec.license = "MIT" 16 | 17 | spec.files = Dir[ 18 | "lib/**/*.rb", 19 | "lib/**/*.rake", 20 | "app/**/*.rb", 21 | "app/assets/javascripts/*", 22 | "bin/*", 23 | "[A-Z]*" 24 | ] 25 | 26 | spec.add_development_dependency "appraisal" 27 | spec.add_development_dependency "bundler", "~> 2.0" 28 | spec.add_development_dependency "rake", "~> 13.0" 29 | spec.add_development_dependency "nokogiri" 30 | spec.add_development_dependency "standardrb" 31 | spec.add_development_dependency "sqlite3" 32 | 33 | spec.add_dependency "rack", ">= 2", "< 4" 34 | 35 | spec.add_dependency "rails", ">= 5.2" 36 | spec.add_dependency "cable_ready", ">= 5.0" 37 | end 38 | -------------------------------------------------------------------------------- /gemfiles/rails_5_2.gemfile: -------------------------------------------------------------------------------- 1 | # This file was generated by Appraisal 2 | 3 | source "https://rubygems.org" 4 | 5 | gem "appraisal", branch: "fix-bundle-env", git: "https://github.com/excid3/appraisal.git" 6 | gem "rails", "~> 5.2" 7 | gem "sqlite3", "~> 1.3", "< 1.4" 8 | gem "action-cable-testing" 9 | 10 | gemspec path: "../" 11 | -------------------------------------------------------------------------------- /gemfiles/rails_6_0.gemfile: -------------------------------------------------------------------------------- 1 | # This file was generated by Appraisal 2 | 3 | source "https://rubygems.org" 4 | 5 | gem "rails", "~> 6.0" 6 | gem "sqlite3", "~> 1.4" 7 | 8 | gemspec path: "../" 9 | -------------------------------------------------------------------------------- /gemfiles/rails_6_1.gemfile: -------------------------------------------------------------------------------- 1 | # This file was generated by Appraisal 2 | 3 | source "https://rubygems.org" 4 | 5 | gem "rails", "~> 6.1" 6 | gem "sqlite3", "~> 1.4" 7 | 8 | gemspec path: "../" 9 | -------------------------------------------------------------------------------- /gemfiles/rails_7_0.gemfile: -------------------------------------------------------------------------------- 1 | # This file was generated by Appraisal 2 | 3 | source "https://rubygems.org" 4 | 5 | gem "rails", "7.0.8" 6 | gem "sqlite3", "~> 1.4" 7 | 8 | gemspec path: "../" 9 | -------------------------------------------------------------------------------- /gemfiles/rails_7_1.gemfile: -------------------------------------------------------------------------------- 1 | # This file was generated by Appraisal 2 | 3 | source "https://rubygems.org" 4 | 5 | gem "rails", "7.1.3" 6 | gem "sqlite3", "~> 1.4" 7 | 8 | gemspec path: "../" 9 | -------------------------------------------------------------------------------- /javascript/elements/futurism_element.js: -------------------------------------------------------------------------------- 1 | /* global HTMLElement */ 2 | 3 | import { 4 | extendElementWithIntersectionObserver, 5 | extendElementWithEagerLoading 6 | } from './futurism_utils' 7 | 8 | export default class FuturismElement extends HTMLElement { 9 | connectedCallback () { 10 | extendElementWithIntersectionObserver(this) 11 | extendElementWithEagerLoading(this) 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /javascript/elements/futurism_li.js: -------------------------------------------------------------------------------- 1 | /* global HTMLLIElement */ 2 | 3 | import { 4 | extendElementWithIntersectionObserver, 5 | extendElementWithEagerLoading 6 | } from './futurism_utils' 7 | 8 | export default class FuturismLI extends HTMLLIElement { 9 | connectedCallback () { 10 | extendElementWithIntersectionObserver(this) 11 | extendElementWithEagerLoading(this) 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /javascript/elements/futurism_table_row.js: -------------------------------------------------------------------------------- 1 | /* global HTMLTableRowElement */ 2 | 3 | import { 4 | extendElementWithIntersectionObserver, 5 | extendElementWithEagerLoading 6 | } from './futurism_utils' 7 | 8 | export default class FuturismTableRow extends HTMLTableRowElement { 9 | connectedCallback () { 10 | extendElementWithIntersectionObserver(this) 11 | extendElementWithEagerLoading(this) 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /javascript/elements/futurism_utils.js: -------------------------------------------------------------------------------- 1 | /* global IntersectionObserver, CustomEvent, setTimeout */ 2 | 3 | const dispatchAppearEvent = (entry, observer = null) => { 4 | if (!window.Futurism?.subscription) { 5 | return () => { 6 | setTimeout(() => dispatchAppearEvent(entry, observer)(), 1) 7 | } 8 | } 9 | 10 | const target = entry.target ? entry.target : entry 11 | 12 | const evt = new CustomEvent('futurism:appear', { 13 | bubbles: true, 14 | detail: { 15 | target, 16 | observer 17 | } 18 | }) 19 | 20 | return () => { 21 | target.dispatchEvent(evt) 22 | } 23 | } 24 | 25 | // from https://advancedweb.hu/how-to-implement-an-exponential-backoff-retry-strategy-in-javascript/#rejection-based-retrying 26 | const wait = ms => new Promise(resolve => setTimeout(resolve, ms)) 27 | 28 | const callWithRetry = async (fn, depth = 0) => { 29 | try { 30 | return await fn() 31 | } catch (e) { 32 | if (depth > 10) { 33 | throw e 34 | } 35 | await wait(1.15 ** depth * 2000) 36 | 37 | return callWithRetry(fn, depth + 1) 38 | } 39 | } 40 | 41 | const observerCallback = (entries, observer) => { 42 | entries.forEach(async entry => { 43 | if (!entry.isIntersecting) return 44 | 45 | await callWithRetry(dispatchAppearEvent(entry, observer)) 46 | }) 47 | } 48 | 49 | export const extendElementWithIntersectionObserver = element => { 50 | Object.assign(element, { 51 | observer: new IntersectionObserver(observerCallback.bind(element), {}) 52 | }) 53 | 54 | if (!element.hasAttribute('keep')) { 55 | element.observer.observe(element) 56 | } 57 | } 58 | 59 | export const extendElementWithEagerLoading = element => { 60 | if (element.dataset.eager === 'true') { 61 | if (element.observer) element.observer.disconnect() 62 | callWithRetry(dispatchAppearEvent(element)) 63 | } 64 | } 65 | -------------------------------------------------------------------------------- /javascript/elements/index.js: -------------------------------------------------------------------------------- 1 | /* global customElements, sessionStorage */ 2 | 3 | import FuturismElement from './futurism_element' 4 | import FuturismTableRow from './futurism_table_row' 5 | import FuturismLI from './futurism_li' 6 | 7 | import { sha256 } from '../utils/crypto' 8 | 9 | const polyfillCustomElements = () => { 10 | const isSafari = /^((?!chrome|android).)*safari/i.test(navigator.userAgent) 11 | 12 | if (customElements) { 13 | if (isSafari) { 14 | document.write( 15 | '