README.md in futurism-0.4.0 vs README.md in futurism-0.4.1

- old
+ new

@@ -1,17 +1,36 @@ # Futurism [![Twitter follow](https://img.shields.io/twitter/follow/julian_rubisch?style=social)](https://twitter.com/julian_rubisch) <!-- ALL-CONTRIBUTORS-BADGE:START - Do not remove or modify this section --> -[![All Contributors](https://img.shields.io/badge/all_contributors-10-orange.svg?style=flat-square)](#contributors-) +[![All Contributors](https://img.shields.io/badge/all_contributors-12-orange.svg?style=flat-square)](#contributors-) <!-- ALL-CONTRIBUTORS-BADGE:END --> Lazy-load Rails partials via CableReady :rotating_light: *Futurism is still in pre-1.0 state. As much as I hope to keep the API backwards-compatible, I cannot guarantee it* :rotating_light: <img src="https://user-images.githubusercontent.com/4352208/88374198-9e6f3500-cd99-11ea-804b-0216ed320eff.jpg" alt="birmingham-museums-trust-GrvC6MI-z4w-unsplash" width="50%" align="center"/> <span>Photo by <a href="https://unsplash.com/@birminghammuseumstrust?utm_source=unsplash&amp;utm_medium=referral&amp;utm_content=creditCopyText">Birmingham Museums Trust</a> on <a href="https://unsplash.com/s/photos/futurism?utm_source=unsplash&amp;utm_medium=referral&amp;utm_content=creditCopyText">Unsplash</a></span> +## Table of Contents + +- [Table of Contents](#table-of-contents) +- [Facts](#facts) + - [Browser Support](#browser-support) +- [Usage](#usage) +- [API](#api) + - [Resource](#resource) + - [Explicit Partial](#explicit-partial) + - [HTML Options](#html-options) +- [Events](#events) +- [Installation](#installation) + - [Manual Installation](#manual-installation) +- [Authentication](#authentication) +- [Gotchas](#gotchas) +- [Contributing](#contributing) +- [License](#license) +- [Contributors](#contributors) + ## Facts - only one dependency: CableReady - bundle size (without CableReady) is around [~1.04kB](https://bundlephobia.com/result?p=@minthesize/futurism@0.1.3) ### Browser Support @@ -153,18 +172,51 @@ ``` In your `app/javascript/channels/index.js`, add the following ```js -import * as Futurism from '@minthesize/futurism'' +import * as Futurism from '@minthesize/futurism' import consumer from './consumer' Futurism.initializeElements() Futurism.createSubscription(consumer) ``` +## Authentication +For authentication, you can rely on ActionCable identifiers, for example, if you use Devise: + +```ruby +module ApplicationCable + class Connection < ActionCable::Connection::Base + identified_by :current_user + + def connect + self.current_user = env["warden"].user || reject_unauthorized_connection + end + end +end +``` + +The [Stimulus Reflex Docs](https://docs.stimulusreflex.com/authentication) have an excellent section about all sorts of authentication. + +## Gotchas + +### ActiveStorage URLs aren't correct in development + +Out of the box, Rails will prefix generated urls with `http://example.org` rather than `http://localhost`, much like ActionMailer. To amend this, add + +```ruby + # config/environments/development.rb + config.action_controller.default_url_options = {host: "localhost", port: 3000} + + # config/environments/production.rb + config.action_controller.default_url_options = {host: "mysite.com"} +``` + +to your environments. + ## Contributing ## License The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT). @@ -187,9 +239,11 @@ </tr> <tr> <td align="center"><a href="http://fractaledmind.com"><img src="https://avatars3.githubusercontent.com/u/5077225?v=4" width="100px;" alt=""/><br /><sub><b>Stephen Margheim</b></sub></a><br /><a href="https://github.com/julianrubisch/futurism/commits?author=fractaledmind" title="Code">💻</a></td> <td align="center"><a href="http://hass.codes"><img src="https://avatars2.githubusercontent.com/u/1064205?v=4" width="100px;" alt=""/><br /><sub><b>Hassanin Ahmed</b></sub></a><br /><a href="https://github.com/julianrubisch/futurism/commits?author=sas1ni69" title="Code">💻</a></td> <td align="center"><a href="https://marcoroth.dev"><img src="https://avatars2.githubusercontent.com/u/6411752?v=4" width="100px;" alt=""/><br /><sub><b>Marco Roth</b></sub></a><br /><a href="https://github.com/julianrubisch/futurism/commits?author=marcoroth" title="Code">💻</a></td> + <td align="center"><a href="https://viedit.com"><img src="https://avatars1.githubusercontent.com/u/49990587?v=4" width="100px;" alt=""/><br /><sub><b>Viedit com</b></sub></a><br /><a href="https://github.com/julianrubisch/futurism/commits?author=vieditcom" title="Documentation">📖</a></td> + <td align="center"><a href="http://scottbarrow.ca"><img src="https://avatars2.githubusercontent.com/u/5571736?v=4" width="100px;" alt=""/><br /><sub><b>Scott Barrow</b></sub></a><br /><a href="https://github.com/julianrubisch/futurism/commits?author=scottbarrow" title="Code">💻</a></td> </tr> </table> <!-- markdownlint-enable --> <!-- prettier-ignore-end -->