outro_rails 0.1.1 → 0.1.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 59bd1b6132a33453ad21b45a5b217c08df5a52bd860a538af18255a464916c00
4
- data.tar.gz: 3096b3ab4acd40c8e1a3d557831ba8b2888a3db958597f83336c368dfc0dd6f4
3
+ metadata.gz: 9bdd0f00d9a9bb3bbbc48093a20dc2a393fb8d5e1e7550bac61d78ee06443701
4
+ data.tar.gz: d01f6eede0c71eb2bc87cd6d0e2b454f36ca106e83e56fc5d4f3b0de2791a8c4
5
5
  SHA512:
6
- metadata.gz: 6d6b2bc029e0b97ccc479c807591f74e465e40f5f4df827be705b093890e5a895b775c1ccf4594ce407810da677ac633485187c29ceec581f9d349107c500ce9
7
- data.tar.gz: 06f1d6bfbc3d57cffbe5d88a588d2a5cebf5891ff8906e97c009eabd5d4f6473f6da82a5e6bf671ccac92e372feb2689fb0041778aed36f57ad8c900aec52d03
6
+ metadata.gz: 3f9bf6e7922a4dadd3a2a2d85875c532b1f450bdaaec94eb701de80d76f0aeee31e2d564d7635f3c6a0f73b752799cd80b9ae872c15c76d6b24d3979fbab4dcb
7
+ data.tar.gz: 9924863f7d1c9608c753f9934b8de317ff72818ad29a9184ae73d686355418d32f8ce443a110f0face0b5aca90a364a0231b05f6a44e30e4561a61b0954fb5cb
data/README.md CHANGED
@@ -18,7 +18,7 @@ then `bundle install`.
18
18
  Copy the engine's migrations into your app and run them:
19
19
 
20
20
  ```sh
21
- bin/rails outro:install:migrations
21
+ bin/rails outro_rails:install:migrations
22
22
  bin/rails db:migrate
23
23
  ```
24
24
 
@@ -41,6 +41,13 @@ bin/rails outro_rails:seed
41
41
 
42
42
  Seeding is idempotent, so it's safe to re-run at any time.
43
43
 
44
+ Add the javascript and css files to your layout:
45
+
46
+ ```html
47
+ <%= stylesheet_link_tag "outro_rails/outro_rails", 'data-turbo-track': 'reload' %>
48
+ <%= javascript_include_tag "outro_rails/outro_rails", 'data-turbo-track': 'reload', defer: true %>
49
+ ```
50
+
44
51
  ## Usage
45
52
  To view the chord library and music theory tools, mount the engine in your
46
53
  routes.rb:
@@ -144,6 +151,57 @@ This renders the chart's metadata, an instrument toggle, a transpose-to-key
144
151
  picker, the chart body with recognized chords highlighted, and a
145
152
  diagram for every chord the body references.
146
153
 
154
+ ### Using Your Own Layout
155
+
156
+ By default the engine renders its pages in its own layout,
157
+ `outro_rails/application`. To render them inside your application's layout
158
+ instead, set `OutroRails.layout` in an initializer:
159
+
160
+ ```ruby
161
+ # config/initializers/outro_rails.rb
162
+ OutroRails.layout = "application"
163
+ ```
164
+
165
+ The value is any layout name your app can resolve, so a dedicated layout
166
+ works too (`"outro"` for `app/views/layouts/outro.html.erb`). Setting it to
167
+ `false` renders engine pages with no layout at all.
168
+
169
+ There are two things to check in the layout you point it at.
170
+
171
+ #### 1. Prefix your app's route helpers with `main_app`
172
+
173
+ Views rendered by an engine controller resolve route helpers against the
174
+ *engine's* router, not your app's. Reach your own routes through the `main_app`
175
+ proxy:
176
+
177
+ ```erb
178
+ <!-- app/views/layouts/application.html.erb -->
179
+ <header>
180
+ <%= link_to "Home", main_app.root_path %>
181
+ <%= link_to "Songs", main_app.songs_path %>
182
+ <%= link_to "Chords", outro_rails.chords_path %>
183
+ </header>
184
+ ```
185
+
186
+ #### 2. Make your helpers available
187
+
188
+ `OutroRails::ApplicationController` inherits from `ActionController::Base`,
189
+ not from your `ApplicationController`, so your `ApplicationHelper` is not
190
+ mixed in. If your layout calls a helper you defined, it will raise `NameError`
191
+ when the engine renders it.
192
+
193
+ Attach your helpers to the engine's controller in an initializer, inside a
194
+ `to_prepare`:
195
+
196
+ ```ruby
197
+ # config/initializers/outro_rails.rb
198
+ OutroRails.layout = "application"
199
+
200
+ Rails.application.config.to_prepare do
201
+ OutroRails::ApplicationController.helper(::ApplicationHelper)
202
+ end
203
+ ```
204
+
147
205
  ### Authorizing Chart Edits
148
206
 
149
207
  The chart's own content (artist, title, body, key, ...) is edited through
@@ -2,5 +2,6 @@
2
2
 
3
3
  module OutroRails
4
4
  class ApplicationController < ActionController::Base
5
+ layout -> { OutroRails.layout }
5
6
  end
6
7
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module OutroRails
4
- VERSION = "0.1.1"
4
+ VERSION = "0.1.2"
5
5
  end
data/lib/outro_rails.rb CHANGED
@@ -9,6 +9,8 @@ require "outro_rails/instruments"
9
9
  require "outro_rails/chord_chart_attribute"
10
10
 
11
11
  module OutroRails
12
+ mattr_accessor :layout, default: "outro_rails/application"
13
+
12
14
  mattr_accessor :chord_chart_voicing_authorization,
13
15
  default: ->(chord_chart:, controller:) { true }
14
16
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: outro_rails
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.1
4
+ version: 0.1.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - endtoendpaper