roda 3.52.0 → 3.53.0
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 +4 -4
- data/CHANGELOG +6 -0
- data/doc/release_notes/3.53.0.txt +14 -0
- data/lib/roda/plugins/additional_view_directories.rb +68 -0
- data/lib/roda/plugins/indifferent_params.rb +17 -5
- data/lib/roda/version.rb +1 -1
- metadata +5 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 90bdf6d366ffc4bff40aa51721176291fadb80f56d7904965fe46a1385fe4172
|
4
|
+
data.tar.gz: ab1bea5320b4049e918ebb23d1b081c26d5401000f11b02c5f85a1e1b30899c3
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 13bc3beb138174dc8cadfc309458bd1821cbe8b6f80f1cb704752979bf085710181d5fd9df71a3cc1fba2be3b258721f36c8758e202961f9389f23b7555ee78b
|
7
|
+
data.tar.gz: 7129008315908bf7ebd6c0115cd8eb531a6357617a5f9ce3a0ffae3703a5cd68793af0d43ac4703752e280a5cc6090234b60640fe25384c4fa8aabe8e04b94af
|
data/CHANGELOG
CHANGED
@@ -1,3 +1,9 @@
|
|
1
|
+
= 3.53.0 (2022-02-14)
|
2
|
+
|
3
|
+
* Make indifferent_params plugin support rack main branch (jeremyevans)
|
4
|
+
|
5
|
+
* Add additional_view_directories plugin, for checking multiple view directories for templates (jeremyevans) (#229)
|
6
|
+
|
1
7
|
= 3.52.0 (2022-01-14)
|
2
8
|
|
3
9
|
* Fix return value of Roda.freeze when multi_route plugin is used (jeremyevans) (#240)
|
@@ -0,0 +1,14 @@
|
|
1
|
+
= New Features
|
2
|
+
|
3
|
+
* An additional_view_directories plugin has been added, which allows
|
4
|
+
you to specify additional directories to look in for templates.
|
5
|
+
If the template path does not exist when using the default view
|
6
|
+
directory, then each additional view directory will be checked,
|
7
|
+
returning the first path that exists:
|
8
|
+
|
9
|
+
plugin :additional_view_directories, ['admin_views', 'public_views']
|
10
|
+
|
11
|
+
= Other Improvements
|
12
|
+
|
13
|
+
* The indifferent_params plugin now avoids a deprecation warning when
|
14
|
+
using the rack main branch, which will become Rack 3.
|
@@ -0,0 +1,68 @@
|
|
1
|
+
# frozen-string-literal: true
|
2
|
+
|
3
|
+
#
|
4
|
+
class Roda
|
5
|
+
module RodaPlugins
|
6
|
+
# The additional_view_directories plugin allows for specifying additional view
|
7
|
+
# directories to look in for templates. When rendering a template, it will
|
8
|
+
# first try the :views directory specified in the render plugin. If the template
|
9
|
+
# file to be rendered does not exist in that directory, it will try each additional
|
10
|
+
# view directory specified in this plugin, in order, using the path to the first
|
11
|
+
# template file that exists in the file system. If no such path is found, it
|
12
|
+
# uses the default path specified by the render plugin.
|
13
|
+
#
|
14
|
+
# Example:
|
15
|
+
#
|
16
|
+
# plugin :render, :views=>'dir'
|
17
|
+
# plugin :additional_view_directories, ['dir1', 'dir2', 'dir3']
|
18
|
+
#
|
19
|
+
# route do |r|
|
20
|
+
# # Will check the following in order, using path for first
|
21
|
+
# # template file that exists:
|
22
|
+
# # * dir/t.erb
|
23
|
+
# # * dir1/t.erb
|
24
|
+
# # * dir2/t.erb
|
25
|
+
# # * dir3/t.erb
|
26
|
+
# render :t
|
27
|
+
# end
|
28
|
+
module AdditionalViewDirectories
|
29
|
+
# Depend on the render plugin, since this plugin only makes
|
30
|
+
# sense when the render plugin is used.
|
31
|
+
def self.load_dependencies(app, view_dirs)
|
32
|
+
app.plugin :render
|
33
|
+
end
|
34
|
+
|
35
|
+
# Set the additional view directories to look in. Each additional view directory
|
36
|
+
# is also added as an allowed path.
|
37
|
+
def self.configure(app, view_dirs)
|
38
|
+
view_dirs = app.opts[:additional_view_directories] = view_dirs.map{|f| app.expand_path(f, nil)}.freeze
|
39
|
+
opts = app.opts[:render]
|
40
|
+
app.opts[:render] = opts.merge(:allowed_paths=>(opts[:allowed_paths] + view_dirs).uniq.freeze)
|
41
|
+
opts.freeze
|
42
|
+
end
|
43
|
+
|
44
|
+
module InstanceMethods
|
45
|
+
private
|
46
|
+
|
47
|
+
# If the template path does not exist, try looking for the template
|
48
|
+
# in each of the additional view directories, in order, returning
|
49
|
+
# the first path that exists. If no additional directory includes
|
50
|
+
# the template, return the original path.
|
51
|
+
def template_path(opts)
|
52
|
+
orig_path = super
|
53
|
+
|
54
|
+
unless File.file?(orig_path)
|
55
|
+
self.opts[:additional_view_directories].each do |view_dir|
|
56
|
+
path = super(opts.merge(:views=>view_dir))
|
57
|
+
return path if File.file?(path)
|
58
|
+
end
|
59
|
+
end
|
60
|
+
|
61
|
+
orig_path
|
62
|
+
end
|
63
|
+
end
|
64
|
+
end
|
65
|
+
|
66
|
+
register_plugin(:additional_view_directories, AdditionalViewDirectories)
|
67
|
+
end
|
68
|
+
end
|
@@ -52,17 +52,29 @@ class Roda
|
|
52
52
|
end
|
53
53
|
|
54
54
|
class Params < Rack::QueryParser::Params
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
55
|
+
# :nocov:
|
56
|
+
if Rack.release >= '2.3'
|
57
|
+
def initialize
|
58
|
+
@size = 0
|
59
|
+
@params = Hash.new(&INDIFFERENT_PROC)
|
60
|
+
end
|
61
|
+
else
|
62
|
+
# :nocov:
|
63
|
+
def initialize(limit = Rack::Utils.key_space_limit)
|
64
|
+
@limit = limit
|
65
|
+
@size = 0
|
66
|
+
@params = Hash.new(&INDIFFERENT_PROC)
|
67
|
+
end
|
59
68
|
end
|
60
69
|
end
|
61
70
|
|
62
71
|
end
|
63
72
|
|
64
73
|
module RequestMethods
|
65
|
-
|
74
|
+
# :nocov:
|
75
|
+
query_parser = Rack.release >= '2.3' ? QueryParser.new(QueryParser::Params, 32) : QueryParser.new(QueryParser::Params, 65536, 32)
|
76
|
+
# :nocov:
|
77
|
+
QUERY_PARSER = Rack::Utils.default_query_parser = query_parser
|
66
78
|
|
67
79
|
private
|
68
80
|
|
data/lib/roda/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: roda
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 3.
|
4
|
+
version: 3.53.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Jeremy Evans
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2022-
|
11
|
+
date: 2022-02-14 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rack
|
@@ -210,6 +210,7 @@ extra_rdoc_files:
|
|
210
210
|
- doc/release_notes/3.50.0.txt
|
211
211
|
- doc/release_notes/3.51.0.txt
|
212
212
|
- doc/release_notes/3.52.0.txt
|
213
|
+
- doc/release_notes/3.53.0.txt
|
213
214
|
- doc/release_notes/3.6.0.txt
|
214
215
|
- doc/release_notes/3.7.0.txt
|
215
216
|
- doc/release_notes/3.8.0.txt
|
@@ -269,6 +270,7 @@ files:
|
|
269
270
|
- doc/release_notes/3.50.0.txt
|
270
271
|
- doc/release_notes/3.51.0.txt
|
271
272
|
- doc/release_notes/3.52.0.txt
|
273
|
+
- doc/release_notes/3.53.0.txt
|
272
274
|
- doc/release_notes/3.6.0.txt
|
273
275
|
- doc/release_notes/3.7.0.txt
|
274
276
|
- doc/release_notes/3.8.0.txt
|
@@ -280,6 +282,7 @@ files:
|
|
280
282
|
- lib/roda/plugins/_before_hook.rb
|
281
283
|
- lib/roda/plugins/_optimized_matching.rb
|
282
284
|
- lib/roda/plugins/_symbol_regexp_matchers.rb
|
285
|
+
- lib/roda/plugins/additional_view_directories.rb
|
283
286
|
- lib/roda/plugins/all_verbs.rb
|
284
287
|
- lib/roda/plugins/assets.rb
|
285
288
|
- lib/roda/plugins/assets_preloading.rb
|