hanami 2.1.0.rc2 → 2.1.0.rc3

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 8a6835d72654251d1461ea2ad61c9fe56ad9b37b0ff333d23dc444e205b32ab1
4
- data.tar.gz: 3daf6e28931aa6abf0c3579d95c8e403c1ba12bbcb5879549825e03ae8e81556
3
+ metadata.gz: f126bd2f756323d71dfe0eedd34a45f998882fd1ef2e0afcc8d05c27de224e3a
4
+ data.tar.gz: c9b360c13dbb7ce88e935df753a4d9ec4234f02bc625c403664fb44617ff6261
5
5
  SHA512:
6
- metadata.gz: 4b79171920231066598260223766e9abaee75806c751bcf83ca9ddaa93ef2eabef1fabc3077674cb81f25e435fa8659a04f9c272200a4ed27fa02c271ac03531
7
- data.tar.gz: 04072a74f320abda02874ace16c616db0f3db9bb63de4d3b00746f3c1898c1dc58a143abd47915c9ef0a32b0a5eda860bd9264bccd375779d87bb101e4686dc1
6
+ metadata.gz: ef015d93dfbd94b0f0617cc0966f1d081e06859b2559de39c3b180dc9afc9d0e9034d53dc66117ea7305e80afd8f643a4204246dcba202da8f3c49b59c108426
7
+ data.tar.gz: bced4c311fbcf6ee66e3036cb70fd9f9edc7cb897f6ff26eca660b30a94629297ec5abc3dfb5c849d04f682f66d45e0c2aa55b46829b9ce7b5edeef80a3e9247
data/CHANGELOG.md CHANGED
@@ -2,7 +2,21 @@
2
2
 
3
3
  The web, with simplicity.
4
4
 
5
- ## Changed
5
+ ## v2.1.0.rc3 - 2024-02-16
6
+
7
+ ### Changed
8
+
9
+ - [Tim Riley] Return `nil` when setting content via `#content_for` on the app's view context. This
10
+ allows it to be used with tempalte output tags (such as ERB's `<%=`) that capture a block for the
11
+ given content. (#1369)
12
+
13
+ ## Fixed
14
+
15
+ - [Tim Riley] Ensure assets Rake task for Heroku works (#1368)
16
+
17
+ ## v2.1.0.rc2 - 2023-11-08
18
+
19
+ ### Changed
6
20
 
7
21
  - [Tim Riley] Enable `config.render_detailed_errors` in development mode only by default. (#1365)
8
22
  - [Tim Riley] Remove current_path from context (#1362)
data/hanami.gemspec CHANGED
@@ -38,7 +38,7 @@ Gem::Specification.new do |spec|
38
38
  spec.add_dependency "dry-monitor", "~> 1.0", ">= 1.0.1", "< 2"
39
39
  spec.add_dependency "dry-system", "~> 1.0", "< 2"
40
40
  spec.add_dependency "dry-logger", "~> 1.0", "< 2"
41
- spec.add_dependency "hanami-cli", "~> 2.1.rc"
41
+ spec.add_dependency "hanami-cli", "= 2.1.0.rc3"
42
42
  spec.add_dependency "hanami-utils", "~> 2.1.rc"
43
43
  spec.add_dependency "zeitwerk", "~> 2.6"
44
44
 
data/lib/hanami/app.rb CHANGED
@@ -161,11 +161,6 @@ module Hanami
161
161
  require_relative "providers/rack"
162
162
  register_provider(:rack, source: Hanami::Providers::Rack, namespace: true)
163
163
  end
164
-
165
- if Hanami.bundled?("hanami-assets")
166
- require_relative "providers/assets"
167
- register_provider(:assets, source: Providers::Assets.for_slice(self))
168
- end
169
164
  end
170
165
 
171
166
  def prepare_autoloader
data/lib/hanami/config.rb CHANGED
@@ -99,7 +99,6 @@ module Hanami
99
99
  rack.monitor
100
100
  routes
101
101
  settings
102
- assets
103
102
  ]
104
103
 
105
104
  # @!attribute [rw] no_auto_register_paths
@@ -309,10 +308,7 @@ module Hanami
309
308
 
310
309
  @assets = load_dependent_config("hanami-assets") {
311
310
  require_relative "config/assets"
312
-
313
- Hanami::Config::Assets.new(
314
- manifest_path: root.join("public", "assets.json")
315
- )
311
+ Hanami::Config::Assets.new
316
312
  }
317
313
 
318
314
  yield self if block_given?
@@ -143,7 +143,14 @@ module Hanami
143
143
  # @since 2.1.0
144
144
  def assets
145
145
  unless @assets
146
- raise Hanami::ComponentLoadError, "the hanami-assets gem is required to access assets"
146
+ msg =
147
+ if Hanami.bundled?("hanami-assets")
148
+ "Have you put files into your assets directory?"
149
+ else
150
+ "The hanami-assets gem is required to access assets."
151
+ end
152
+
153
+ raise Hanami::ComponentLoadError, "Assets not available. #{msg}"
147
154
  end
148
155
 
149
156
  @assets
@@ -159,7 +166,7 @@ module Hanami
159
166
  # @since 2.1.0
160
167
  def request
161
168
  unless @request
162
- raise Hanami::ComponentLoadError, "only views rendered from Hanami::Action instances have a request"
169
+ raise Hanami::ComponentLoadError, "Request not available. Only views rendered from Hanami::Action instances have a request."
163
170
  end
164
171
 
165
172
  @request
@@ -194,7 +201,7 @@ module Hanami
194
201
  # content_for(:page_title, "Hello world")
195
202
  #
196
203
  # @example In a template
197
- # <% content_for :page_title do %>
204
+ # <%= content_for :page_title do %>
198
205
  # <h1>Hello world</h1>
199
206
  # <% end %>
200
207
  #
@@ -211,8 +218,10 @@ module Hanami
211
218
  def content_for(key, value = nil)
212
219
  if block_given?
213
220
  @content_for[key] = yield
221
+ nil
214
222
  elsif value
215
223
  @content_for[key] = value
224
+ nil
216
225
  else
217
226
  @content_for[key]
218
227
  end
@@ -11,47 +11,47 @@ module Hanami
11
11
  #
12
12
  # Inject these helpers in a view
13
13
  #
14
- # @since 0.1.0
14
+ # @since 2.1.0
15
15
  #
16
16
  # @see http://www.rubydoc.info/gems/hanami-helpers/Hanami/Helpers/HtmlHelper
17
17
  module AssetsHelper
18
- # @since 0.1.0
18
+ # @since 2.1.0
19
19
  # @api private
20
20
  NEW_LINE_SEPARATOR = "\n"
21
21
 
22
- # @since 0.1.0
22
+ # @since 2.1.0
23
23
  # @api private
24
24
  WILDCARD_EXT = ".*"
25
25
 
26
- # @since 0.1.0
26
+ # @since 2.1.0
27
27
  # @api private
28
28
  JAVASCRIPT_EXT = ".js"
29
29
 
30
- # @since 0.1.0
30
+ # @since 2.1.0
31
31
  # @api private
32
32
  STYLESHEET_EXT = ".css"
33
33
 
34
- # @since 0.1.0
34
+ # @since 2.1.0
35
35
  # @api private
36
36
  JAVASCRIPT_MIME_TYPE = "text/javascript"
37
37
 
38
- # @since 0.1.0
38
+ # @since 2.1.0
39
39
  # @api private
40
40
  STYLESHEET_MIME_TYPE = "text/css"
41
41
 
42
- # @since 0.1.0
42
+ # @since 2.1.0
43
43
  # @api private
44
44
  FAVICON_MIME_TYPE = "image/x-icon"
45
45
 
46
- # @since 0.1.0
46
+ # @since 2.1.0
47
47
  # @api private
48
48
  STYLESHEET_REL = "stylesheet"
49
49
 
50
- # @since 0.1.0
50
+ # @since 2.1.0
51
51
  # @api private
52
52
  FAVICON_REL = "shortcut icon"
53
53
 
54
- # @since 0.1.0
54
+ # @since 2.1.0
55
55
  # @api private
56
56
  DEFAULT_FAVICON = "favicon.ico"
57
57
 
@@ -85,7 +85,7 @@ module Hanami
85
85
  # name of the algorithm, then a hyphen, then the hash value of the file.
86
86
  # If more than one algorithm is used, they"ll be separated by a space.
87
87
  #
88
- # @param sources [Array<String>] one or more assets by name or absolute URL
88
+ # @param source_paths [Array<String, #url>] one or more assets by name or absolute URL
89
89
  #
90
90
  # @return [Hanami::View::HTML::SafeString] the markup
91
91
  #
@@ -93,7 +93,7 @@ module Hanami
93
93
  # `subresource_integrity` modes are on and the javascript file is missing
94
94
  # from the manifest
95
95
  #
96
- # @since 0.1.0
96
+ # @since 2.1.0
97
97
  #
98
98
  # @see Hanami::Assets::Helpers#path
99
99
  #
@@ -189,7 +189,7 @@ module Hanami
189
189
  # name of the algorithm, then a hyphen, then the hashed value of the file.
190
190
  # If more than one algorithm is used, they"ll be separated by a space.
191
191
  #
192
- # @param sources [Array<String>] one or more assets by name or absolute URL
192
+ # @param source_paths [Array<String, #url>] one or more assets by name or absolute URL
193
193
  #
194
194
  # @return [Hanami::View::HTML::SafeString] the markup
195
195
  #
@@ -197,7 +197,7 @@ module Hanami
197
197
  # `subresource_integrity` modes are on and the stylesheet file is missing
198
198
  # from the manifest
199
199
  #
200
- # @since 0.1.0
200
+ # @since 2.1.0
201
201
  #
202
202
  # @see Hanami::Assets::Helpers#path
203
203
  #
@@ -282,7 +282,7 @@ module Hanami
282
282
  # If the "CDN mode" is on, the `src` is an absolute URL of the
283
283
  # application CDN.
284
284
  #
285
- # @param source [String] asset name or absolute URL
285
+ # @param source [String, #url] asset name, absolute URL, or asset object
286
286
  # @param options [Hash] HTML 5 attributes
287
287
  #
288
288
  # @return [Hanami::View::HTML::SafeString] the markup
@@ -291,7 +291,7 @@ module Hanami
291
291
  # `subresource_integrity` modes are on and the image file is missing
292
292
  # from the manifest
293
293
  #
294
- # @since 0.1.0
294
+ # @since 2.1.0
295
295
  #
296
296
  # @see Hanami::Assets::Helpers#path
297
297
  #
@@ -353,7 +353,7 @@ module Hanami
353
353
  # If the "CDN mode" is on, the `href` is an absolute URL of the
354
354
  # application CDN.
355
355
  #
356
- # @param source [String] asset name
356
+ # @param source [String, #url] asset name or asset object
357
357
  # @param options [Hash] HTML 5 attributes
358
358
  #
359
359
  # @return [Hanami::View::HTML::SafeString] the markup
@@ -362,7 +362,7 @@ module Hanami
362
362
  # `subresource_integrity` modes are on and the favicon is file missing
363
363
  # from the manifest
364
364
  #
365
- # @since 0.1.0
365
+ # @since 2.1.0
366
366
  #
367
367
  # @see Hanami::Assets::Helpers#path
368
368
  #
@@ -424,7 +424,7 @@ module Hanami
424
424
  # If the "CDN mode" is on, the `src` is an absolute URL of the
425
425
  # application CDN.
426
426
  #
427
- # @param source [String] asset name or absolute URL
427
+ # @param source [String, #url] asset name, absolute URL or asset object
428
428
  # @param options [Hash] HTML 5 attributes
429
429
  #
430
430
  # @return [Hanami::View::HTML::SafeString] the markup
@@ -436,7 +436,7 @@ module Hanami
436
436
  # @raise [ArgumentError] if source isn"t specified both as argument or
437
437
  # tag inside the given block
438
438
  #
439
- # @since 0.1.0
439
+ # @since 2.1.0
440
440
  #
441
441
  # @see Hanami::Assets::Helpers#path
442
442
  #
@@ -526,7 +526,7 @@ module Hanami
526
526
  # If the "CDN mode" is on, the `src` is an absolute URL of the
527
527
  # application CDN.
528
528
  #
529
- # @param source [String] asset name or absolute URL
529
+ # @param source [String, #url] asset name, absolute URL or asset object
530
530
  # @param options [Hash] HTML 5 attributes
531
531
  #
532
532
  # @return [Hanami::View::HTML::SafeString] the markup
@@ -538,7 +538,7 @@ module Hanami
538
538
  # @raise [ArgumentError] if source isn"t specified both as argument or
539
539
  # tag inside the given block
540
540
  #
541
- # @since 0.1.0
541
+ # @since 2.1.0
542
542
  #
543
543
  # @see Hanami::Assets::Helpers#path
544
544
  #
@@ -626,7 +626,7 @@ module Hanami
626
626
  #
627
627
  # If CDN mode is on, it returns the absolute URL of the asset.
628
628
  #
629
- # @param source [String] the asset name
629
+ # @param source_path [String, #url] the asset name or asset object
630
630
  #
631
631
  # @return [String] the asset path
632
632
  #
@@ -634,7 +634,7 @@ module Hanami
634
634
  # `subresource_integrity` modes are on and the asset is missing
635
635
  # from the manifest
636
636
  #
637
- # @since 0.1.0
637
+ # @since 2.1.0
638
638
  #
639
639
  # @example Basic Usage
640
640
  #
@@ -666,6 +666,7 @@ module Hanami
666
666
  #
667
667
  # # "https://assets.bookshelf.org/assets/application-28a6b886de2372ee3922fcaf3f78f2d8.js"
668
668
  def asset_url(source_path)
669
+ return source_path.url if source_path.respond_to?(:url)
669
670
  return source_path if _absolute_url?(source_path)
670
671
 
671
672
  _context.assets[source_path].url
@@ -673,7 +674,7 @@ module Hanami
673
674
 
674
675
  private
675
676
 
676
- # @since 0.1.0
677
+ # @since 2.1.0
677
678
  # @api private
678
679
  def _safe_tags(*source_paths, &blk)
679
680
  ::Hanami::View::HTML::SafeString.new(
@@ -684,7 +685,7 @@ module Hanami
684
685
  # @since 2.1.0
685
686
  # @api private
686
687
  def _typed_path(source, ext)
687
- source = "#{source}#{ext}" if _append_extension?(source, ext)
688
+ source = "#{source}#{ext}" if source.is_a?(String) && _append_extension?(source, ext)
688
689
  asset_url(source)
689
690
  end
690
691
 
@@ -696,7 +697,7 @@ module Hanami
696
697
  _context.assets[source_path].sri
697
698
  end
698
699
 
699
- # @since 0.1.0
700
+ # @since 2.1.0
700
701
  # @api private
701
702
  def _absolute_url?(source)
702
703
  ABSOLUTE_URL_MATCHER.match(source)
@@ -710,7 +711,7 @@ module Hanami
710
711
  _context.assets.crossorigin?(source)
711
712
  end
712
713
 
713
- # @since 0.1.0
714
+ # @since 2.1.0
714
715
  # @api private
715
716
  def _source_options(src, options, &blk)
716
717
  options ||= {}