roda 3.28.0 → 3.33.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG +40 -0
- data/README.rdoc +15 -1
- data/doc/conventions.rdoc +17 -8
- data/doc/release_notes/3.29.0.txt +15 -0
- data/doc/release_notes/3.30.0.txt +14 -0
- data/doc/release_notes/3.31.0.txt +11 -0
- data/doc/release_notes/3.32.0.txt +42 -0
- data/doc/release_notes/3.33.0.txt +8 -0
- data/lib/roda.rb +3 -0
- data/lib/roda/plugins/_symbol_regexp_matchers.rb +2 -0
- data/lib/roda/plugins/assets.rb +26 -5
- data/lib/roda/plugins/caching.rb +2 -0
- data/lib/roda/plugins/common_logger.rb +1 -1
- data/lib/roda/plugins/content_security_policy.rb +2 -0
- data/lib/roda/plugins/default_headers.rb +2 -0
- data/lib/roda/plugins/exception_page.rb +9 -5
- data/lib/roda/plugins/hash_matcher.rb +1 -1
- data/lib/roda/plugins/header_matchers.rb +5 -1
- data/lib/roda/plugins/indifferent_params.rb +4 -0
- data/lib/roda/plugins/partials.rb +33 -6
- data/lib/roda/plugins/path.rb +42 -15
- data/lib/roda/plugins/placeholder_string_matchers.rb +2 -0
- data/lib/roda/plugins/public.rb +25 -17
- data/lib/roda/plugins/relative_path.rb +73 -0
- data/lib/roda/plugins/render.rb +17 -5
- data/lib/roda/plugins/render_each.rb +11 -3
- data/lib/roda/plugins/run_append_slash.rb +1 -1
- data/lib/roda/plugins/symbol_matchers.rb +2 -2
- data/lib/roda/version.rb +1 -1
- metadata +13 -214
- data/Rakefile +0 -108
- data/doc/release_notes/1.0.0.txt +0 -329
- data/doc/release_notes/1.1.0.txt +0 -226
- data/doc/release_notes/1.2.0.txt +0 -406
- data/doc/release_notes/1.3.0.txt +0 -109
- data/doc/release_notes/2.0.0.txt +0 -75
- data/doc/release_notes/2.1.0.txt +0 -124
- data/doc/release_notes/2.10.0.txt +0 -27
- data/doc/release_notes/2.11.0.txt +0 -70
- data/doc/release_notes/2.12.0.txt +0 -40
- data/doc/release_notes/2.13.0.txt +0 -10
- data/doc/release_notes/2.14.0.txt +0 -44
- data/doc/release_notes/2.15.0.txt +0 -53
- data/doc/release_notes/2.16.0.txt +0 -48
- data/doc/release_notes/2.17.0.txt +0 -62
- data/doc/release_notes/2.18.0.txt +0 -69
- data/doc/release_notes/2.19.0.txt +0 -30
- data/doc/release_notes/2.2.0.txt +0 -97
- data/doc/release_notes/2.20.0.txt +0 -5
- data/doc/release_notes/2.21.0.txt +0 -17
- data/doc/release_notes/2.22.0.txt +0 -41
- data/doc/release_notes/2.23.0.txt +0 -29
- data/doc/release_notes/2.24.0.txt +0 -65
- data/doc/release_notes/2.25.0.txt +0 -14
- data/doc/release_notes/2.26.0.txt +0 -13
- data/doc/release_notes/2.27.0.txt +0 -56
- data/doc/release_notes/2.28.0.txt +0 -17
- data/doc/release_notes/2.29.0.txt +0 -156
- data/doc/release_notes/2.3.0.txt +0 -109
- data/doc/release_notes/2.4.0.txt +0 -55
- data/doc/release_notes/2.5.0.txt +0 -23
- data/doc/release_notes/2.5.1.txt +0 -4
- data/doc/release_notes/2.6.0.txt +0 -21
- data/doc/release_notes/2.7.0.txt +0 -75
- data/doc/release_notes/2.8.0.txt +0 -44
- data/doc/release_notes/2.9.0.txt +0 -6
- data/spec/all.rb +0 -1
- data/spec/assets/css/app.scss +0 -1
- data/spec/assets/css/no_access.css +0 -1
- data/spec/assets/css/raw.css +0 -1
- data/spec/assets/js/head/app.js +0 -1
- data/spec/composition_spec.rb +0 -31
- data/spec/define_roda_method_spec.rb +0 -274
- data/spec/env_spec.rb +0 -11
- data/spec/freeze_spec.rb +0 -37
- data/spec/integration_spec.rb +0 -209
- data/spec/matchers_spec.rb +0 -832
- data/spec/opts_spec.rb +0 -42
- data/spec/plugin/_after_hook_spec.rb +0 -19
- data/spec/plugin/all_verbs_spec.rb +0 -29
- data/spec/plugin/assets_preloading_spec.rb +0 -98
- data/spec/plugin/assets_spec.rb +0 -745
- data/spec/plugin/backtracking_array_spec.rb +0 -42
- data/spec/plugin/branch_locals_spec.rb +0 -106
- data/spec/plugin/caching_spec.rb +0 -337
- data/spec/plugin/chunked_spec.rb +0 -201
- data/spec/plugin/class_level_routing_spec.rb +0 -164
- data/spec/plugin/class_matchers_spec.rb +0 -40
- data/spec/plugin/common_logger_spec.rb +0 -85
- data/spec/plugin/content_for_spec.rb +0 -162
- data/spec/plugin/content_security_policy_spec.rb +0 -175
- data/spec/plugin/cookies_spec.rb +0 -51
- data/spec/plugin/csrf_spec.rb +0 -111
- data/spec/plugin/default_headers_spec.rb +0 -82
- data/spec/plugin/default_status_spec.rb +0 -95
- data/spec/plugin/delay_build_spec.rb +0 -23
- data/spec/plugin/delegate_spec.rb +0 -23
- data/spec/plugin/delete_empty_headers_spec.rb +0 -27
- data/spec/plugin/direct_call_spec.rb +0 -28
- data/spec/plugin/disallow_file_uploads_spec.rb +0 -25
- data/spec/plugin/drop_body_spec.rb +0 -24
- data/spec/plugin/early_hints_spec.rb +0 -19
- data/spec/plugin/empty_root_spec.rb +0 -14
- data/spec/plugin/environments_spec.rb +0 -42
- data/spec/plugin/error_email_spec.rb +0 -97
- data/spec/plugin/error_handler_spec.rb +0 -216
- data/spec/plugin/error_mail_spec.rb +0 -93
- data/spec/plugin/exception_page_spec.rb +0 -168
- data/spec/plugin/flash_spec.rb +0 -121
- data/spec/plugin/h_spec.rb +0 -11
- data/spec/plugin/halt_spec.rb +0 -119
- data/spec/plugin/hash_matcher_spec.rb +0 -27
- data/spec/plugin/hash_routes_spec.rb +0 -535
- data/spec/plugin/head_spec.rb +0 -52
- data/spec/plugin/header_matchers_spec.rb +0 -98
- data/spec/plugin/heartbeat_spec.rb +0 -74
- data/spec/plugin/hooks_spec.rb +0 -152
- data/spec/plugin/indifferent_params_spec.rb +0 -14
- data/spec/plugin/json_parser_spec.rb +0 -141
- data/spec/plugin/json_spec.rb +0 -83
- data/spec/plugin/mail_processor_spec.rb +0 -451
- data/spec/plugin/mailer_spec.rb +0 -282
- data/spec/plugin/match_affix_spec.rb +0 -43
- data/spec/plugin/match_hook_spec.rb +0 -79
- data/spec/plugin/middleware_spec.rb +0 -237
- data/spec/plugin/middleware_stack_spec.rb +0 -81
- data/spec/plugin/module_include_spec.rb +0 -48
- data/spec/plugin/multi_route_spec.rb +0 -268
- data/spec/plugin/multi_run_spec.rb +0 -87
- data/spec/plugin/multi_view_spec.rb +0 -50
- data/spec/plugin/multibyte_string_matcher_spec.rb +0 -44
- data/spec/plugin/named_templates_spec.rb +0 -96
- data/spec/plugin/not_allowed_spec.rb +0 -69
- data/spec/plugin/not_found_spec.rb +0 -128
- data/spec/plugin/optimized_string_matchers_spec.rb +0 -43
- data/spec/plugin/padrino_render_spec.rb +0 -34
- data/spec/plugin/param_matchers_spec.rb +0 -69
- data/spec/plugin/params_capturing_spec.rb +0 -33
- data/spec/plugin/partials_spec.rb +0 -43
- data/spec/plugin/pass_spec.rb +0 -29
- data/spec/plugin/path_matchers_spec.rb +0 -42
- data/spec/plugin/path_rewriter_spec.rb +0 -45
- data/spec/plugin/path_spec.rb +0 -222
- data/spec/plugin/placeholder_string_matchers_spec.rb +0 -126
- data/spec/plugin/precompile_templates_spec.rb +0 -61
- data/spec/plugin/public_spec.rb +0 -85
- data/spec/plugin/render_each_spec.rb +0 -82
- data/spec/plugin/render_locals_spec.rb +0 -114
- data/spec/plugin/render_spec.rb +0 -912
- data/spec/plugin/request_aref_spec.rb +0 -51
- data/spec/plugin/request_headers_spec.rb +0 -39
- data/spec/plugin/response_request_spec.rb +0 -43
- data/spec/plugin/route_block_args_spec.rb +0 -86
- data/spec/plugin/route_csrf_spec.rb +0 -305
- data/spec/plugin/run_append_slash_spec.rb +0 -77
- data/spec/plugin/run_handler_spec.rb +0 -53
- data/spec/plugin/sessions_spec.rb +0 -452
- data/spec/plugin/shared_vars_spec.rb +0 -45
- data/spec/plugin/sinatra_helpers_spec.rb +0 -537
- data/spec/plugin/slash_path_empty_spec.rb +0 -22
- data/spec/plugin/static_routing_spec.rb +0 -192
- data/spec/plugin/static_spec.rb +0 -30
- data/spec/plugin/status_303_spec.rb +0 -28
- data/spec/plugin/status_handler_spec.rb +0 -158
- data/spec/plugin/streaming_spec.rb +0 -246
- data/spec/plugin/strip_path_prefix_spec.rb +0 -24
- data/spec/plugin/symbol_matchers_spec.rb +0 -51
- data/spec/plugin/symbol_status_spec.rb +0 -25
- data/spec/plugin/symbol_views_spec.rb +0 -32
- data/spec/plugin/timestamp_public_spec.rb +0 -85
- data/spec/plugin/type_routing_spec.rb +0 -348
- data/spec/plugin/typecast_params_spec.rb +0 -1370
- data/spec/plugin/unescape_path_spec.rb +0 -22
- data/spec/plugin/view_options_spec.rb +0 -170
- data/spec/plugin_spec.rb +0 -71
- data/spec/redirect_spec.rb +0 -41
- data/spec/request_spec.rb +0 -97
- data/spec/response_spec.rb +0 -199
- data/spec/route_spec.rb +0 -39
- data/spec/session_middleware_spec.rb +0 -129
- data/spec/session_spec.rb +0 -37
- data/spec/spec_helper.rb +0 -137
- data/spec/version_spec.rb +0 -14
- data/spec/views/_test.erb +0 -1
- data/spec/views/a.erb +0 -1
- data/spec/views/a.rdoc +0 -2
- data/spec/views/about.erb +0 -1
- data/spec/views/about.str +0 -1
- data/spec/views/about/_test.css.gz +0 -0
- data/spec/views/about/_test.erb +0 -1
- data/spec/views/about/_test.erb.gz +0 -0
- data/spec/views/about/comp_test.erb +0 -1
- data/spec/views/b.erb +0 -1
- data/spec/views/c.erb +0 -1
- data/spec/views/comp_layout.erb +0 -1
- data/spec/views/comp_test.erb +0 -1
- data/spec/views/content-yield.erb +0 -1
- data/spec/views/each.str +0 -1
- data/spec/views/home.erb +0 -2
- data/spec/views/home.str +0 -2
- data/spec/views/iv.erb +0 -1
- data/spec/views/layout-alternative.erb +0 -2
- data/spec/views/layout-yield.erb +0 -3
- data/spec/views/layout.erb +0 -2
- data/spec/views/layout.str +0 -2
- data/spec/views/multiple-layout.erb +0 -1
- data/spec/views/multiple.erb +0 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 0f9ede53406b16bff69c2115f7d35e808835e300ca866a5caadde9b9fad9d206
|
4
|
+
data.tar.gz: f78eb239a3d15e83879b8a7272f07959a00b6d94e93595f6871841144d3d718b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 45e3020a3509bacc5f39107659fca5e64ba25c322c18af6a62b976308f5bac2ac44a18d54bc82d9b1d4260e260883208ce8210ac2fb660e09b63b65401abfed6
|
7
|
+
data.tar.gz: 5a00af14f4d6e01c472a23b59f5a51eec66fc55c2d8d34069de869d7ff487913ff6ab1d21023b8207f5fdf18ad6354f30520b3cf89d2491de4b330c1ae30f10a
|
data/CHANGELOG
CHANGED
@@ -1,3 +1,43 @@
|
|
1
|
+
= 3.33.0 (2020-06-16)
|
2
|
+
|
3
|
+
* Add :brotli option to public plugin to supplement it to serve brotli-compressed files like :gzip does for gzipped files (hmdne) (#194)
|
4
|
+
|
5
|
+
* Add url method to path plugin, similar to path but returning the entire URL (jeremyevans)
|
6
|
+
|
7
|
+
= 3.32.0 (2020-05-15)
|
8
|
+
|
9
|
+
* Make :dependencies option in assets plugin work correctly with render plugin template caching (jeremyevans) (#191)
|
10
|
+
|
11
|
+
* Support render method :dependencies option for specifying which files to check for modification (jgarth, jeremyevans) (#192)
|
12
|
+
|
13
|
+
* Add each_partial to the partials plugin for rendering a partial for each element in an enumerable (jeremyevans)
|
14
|
+
|
15
|
+
* Make render_each in render_each plugin handle template names with directories and extensions (jeremyevans)
|
16
|
+
|
17
|
+
= 3.31.0 (2020-04-15)
|
18
|
+
|
19
|
+
* Add :relative option to path method in path plugin, for generating a method returning relative paths (jeremyevans)
|
20
|
+
|
21
|
+
* Add relative_path plugin, for turning absolute paths to paths relative to the current request (jeremyevans)
|
22
|
+
|
23
|
+
= 3.30.0 (2020-03-13)
|
24
|
+
|
25
|
+
* Support :relative_paths assets plugin option to use relative paths for the assets (jeremyevans)
|
26
|
+
|
27
|
+
* Make run_append_slash and run_handler plugins work when used together (janko) (#185)
|
28
|
+
|
29
|
+
* Make :header matcher in header_matchers plugin work for Content-Type and Content-Length (jeremyevans) (#184)
|
30
|
+
|
31
|
+
= 3.29.0 (2020-02-14)
|
32
|
+
|
33
|
+
* Remove specs and old release notes from the gem to reduce gem size by over 35% (jeremyevans)
|
34
|
+
|
35
|
+
* Raise RodaError if trying to load a plugin that is not a module (jeremyevans)
|
36
|
+
|
37
|
+
* Include SCRIPT_NAME when logging in common logger plugin (jeremyevans)
|
38
|
+
|
39
|
+
* Handle invalid POST data when using the exception_page plugin (jeremyevans)
|
40
|
+
|
1
41
|
= 3.28.0 (2020-01-15)
|
2
42
|
|
3
43
|
* Add session_created_at and session_updated_at methods to the sessions plugin (jeremyevans)
|
data/README.rdoc
CHANGED
@@ -137,6 +137,16 @@ in your application. It is recommended to freeze the app in production and
|
|
137
137
|
during testing. The +.app+ is an optimization, which saves a few method calls
|
138
138
|
for every request.
|
139
139
|
|
140
|
+
== Running the Application
|
141
|
+
|
142
|
+
Running a Roda application is similar to running any other rack-based application
|
143
|
+
that uses a +config.ru+ file. You can start a basic server using +rackup+:
|
144
|
+
|
145
|
+
$ rackup
|
146
|
+
|
147
|
+
Ruby web servers such as Unicorn and Puma also ship with their own programs
|
148
|
+
that you can use to run a Roda application.
|
149
|
+
|
140
150
|
== The Routing Tree
|
141
151
|
|
142
152
|
Roda is called a routing tree web toolkit because the way most sites are structured,
|
@@ -408,6 +418,10 @@ You can provide an array to specify multiple request methods and match on any of
|
|
408
418
|
{method: :post} # matches POST
|
409
419
|
{method: ['post', 'patch']} # matches POST and PATCH
|
410
420
|
|
421
|
+
=== true
|
422
|
+
|
423
|
+
If +true+ is given directly as a matcher, it always matches.
|
424
|
+
|
411
425
|
=== false, nil
|
412
426
|
|
413
427
|
If +false+ or +nil+ is given directly as a matcher, it doesn't match anything.
|
@@ -1097,7 +1111,7 @@ Roda's plugin system is based on the plugin system used by
|
|
1097
1111
|
|
1098
1112
|
Roda fully supports the currently supported versions of Ruby (MRI) and JRuby. It may
|
1099
1113
|
support unsupported versions of Ruby or JRuby, but such support may be dropped in any
|
1100
|
-
minor version
|
1114
|
+
minor version if keeping it becomes a support issue. The minimum Ruby version
|
1101
1115
|
required to run the current version of Roda is 1.9.2.
|
1102
1116
|
|
1103
1117
|
== License
|
data/doc/conventions.rdoc
CHANGED
@@ -15,6 +15,8 @@ For a small application, the following directory layout is recommended:
|
|
15
15
|
Rakefile
|
16
16
|
app_name.rb
|
17
17
|
assets/
|
18
|
+
config.ru
|
19
|
+
db.rb
|
18
20
|
migrate/
|
19
21
|
models.rb
|
20
22
|
models/
|
@@ -25,6 +27,8 @@ For a small application, the following directory layout is recommended:
|
|
25
27
|
+app_name.rb+ should contain the Roda application, and should reflect the name of your application.
|
26
28
|
So, if your application is named +FooBar+, you should use +foo_bar.rb+.
|
27
29
|
|
30
|
+
+config.ru+ should contain the code the webserver uses to determine which application to run.
|
31
|
+
|
28
32
|
+views/+ should contain your template files. This assumes you are using the +render+ plugin
|
29
33
|
and server-side rendering. If you are creating a single page application and just serving
|
30
34
|
JSON, then you won't need a +views+ directory. For small applications, all view files should be
|
@@ -36,7 +40,11 @@ Again, for pure JSON applications, you won't need a +public+ directory.
|
|
36
40
|
+assets/+ should contain the source files for your CSS and javascript assets. If you are
|
37
41
|
not using the +assets+ plugin, you won't need an +assets+ directory.
|
38
42
|
|
39
|
-
+
|
43
|
+
+db.rb+ should contain the minimum code to setup a database connection, without loading any of
|
44
|
+
the applications models. This can be required in cases where you don't want the models loaded,
|
45
|
+
such as when running migrations. This file should be required by +models.rb+.
|
46
|
+
|
47
|
+
+models.rb+ should contain all code related to your ORM. This file should be required
|
40
48
|
by +app_name.rb+. This keeps your model code separate from your web code, making it easier
|
41
49
|
to use outside of your web code. It allows you to get an IRB shell for accessing your models
|
42
50
|
via <tt>irb -r ./models</tt>, without loading the Roda application.
|
@@ -46,7 +54,7 @@ via irb -r ./models, without loading the Roda application.
|
|
46
54
|
+migrate/+ should create your database migration files, if you are using an ORM that uses
|
47
55
|
migrations.
|
48
56
|
|
49
|
-
+spec/+ should contain your specifications/tests. For a small application, it's recommended
|
57
|
+
+spec/+ (or +test/+ should contain your specifications/tests. For a small application, it's recommended
|
50
58
|
to a have a single file for your model tests, and a single file for your web/integration tests.
|
51
59
|
|
52
60
|
+Rakefile+ should contain the rake tasks for the application. The convention is that the
|
@@ -83,7 +91,8 @@ The routes used by the +hash_routes+ or +multi_run+ should be stored in routing
|
|
83
91
|
directory, with one file per prefix.
|
84
92
|
|
85
93
|
For specs/tests, you should have +spec/models/+ and +spec/web/+, with one file per model in +spec/models/+
|
86
|
-
and one file per prefix in +spec/web/+.
|
94
|
+
and one file per prefix in +spec/web/+. Substitute +spec+ with +test+ if that is what you are using as the
|
95
|
+
name of the directory.
|
87
96
|
|
88
97
|
You should have a separate view subdirectory per prefix. If you are using +hash_routes+ and +view_options+ plugins,
|
89
98
|
use +set_view_subdir+ in your routing files to specify the subdirectory to use, so it doesn't need to be
|
@@ -105,7 +114,7 @@ subdirectories in the +routes/+ directory, and nested subdirectories in the +vie
|
|
105
114
|
For a small application, the convention in Roda is to layout your Roda application file (+app_name.rb+) like this:
|
106
115
|
|
107
116
|
require 'roda'
|
108
|
-
|
117
|
+
require_relative 'models'
|
109
118
|
|
110
119
|
class AppName < Roda
|
111
120
|
SOME_CONSTANT = 1
|
@@ -138,24 +147,24 @@ used in your route block or views.
|
|
138
147
|
For larger applications, there are some slight changes to the Roda application file layout:
|
139
148
|
|
140
149
|
require 'roda'
|
141
|
-
|
150
|
+
require_relative 'models'
|
142
151
|
|
143
152
|
class AppName < Roda
|
144
153
|
SOME_CONSTANT = 1
|
145
154
|
|
146
155
|
use SomeMiddleware
|
147
156
|
|
148
|
-
plugin :render, escape: true
|
157
|
+
plugin :render, escape: true, layout: './layout'
|
149
158
|
plugin :assets
|
150
159
|
plugin :view_options
|
151
160
|
plugin :hash_routes
|
152
|
-
Dir['
|
161
|
+
Dir['routes/*.rb'].each{|f| require_relative f}
|
153
162
|
|
154
163
|
route do |r|
|
155
164
|
r.hash_routes
|
156
165
|
end
|
157
166
|
|
158
|
-
Dir['
|
167
|
+
Dir['helpers/*.rb'].each{|f| require_relative f}
|
159
168
|
end
|
160
169
|
|
161
170
|
After loading the +view_options+ and +hash_routes+ plugin, you require all of your
|
@@ -0,0 +1,15 @@
|
|
1
|
+
= Improvements
|
2
|
+
|
3
|
+
* The common_logger plugin now includes the SCRIPT_NAME when
|
4
|
+
logging, for greater compatibility with typical web server
|
5
|
+
logs.
|
6
|
+
|
7
|
+
* The exception_page plugin now handles invalid POST data.
|
8
|
+
Previously, invalid POST data would cause the exception page
|
9
|
+
display to raise an exception.
|
10
|
+
|
11
|
+
* An error is now raised if trying to load a plugin that is not a
|
12
|
+
module or a recognized plugin symbol.
|
13
|
+
|
14
|
+
* Specs and older release notes are no longer shipped in the
|
15
|
+
gem, reducing gem size by over 35%.
|
@@ -0,0 +1,14 @@
|
|
1
|
+
= New Features
|
2
|
+
|
3
|
+
* A :relative_paths plugin option has been added to the assets
|
4
|
+
plugin. This option makes the paths to the asset files in the
|
5
|
+
link and script tags relative paths instead of absolute paths.
|
6
|
+
|
7
|
+
= Other Improvements
|
8
|
+
|
9
|
+
* The :header matcher in the header_matchers plugin now works
|
10
|
+
correctly for the Content-Type and Content-Length headers, which
|
11
|
+
are not prefixed with HTTP_ in the rack environment.
|
12
|
+
|
13
|
+
* The run_append_slash and run_handler plugins now work correctly
|
14
|
+
when used together.
|
@@ -0,0 +1,11 @@
|
|
1
|
+
= New Features
|
2
|
+
|
3
|
+
* A relative_path plugin has been added, adding a relative_path
|
4
|
+
method that will take an absolute path and make it relative to the
|
5
|
+
current request by prepending an appropriate prefix. This is
|
6
|
+
helpful when using Roda as a static site generator to generate a
|
7
|
+
site that can be hosted at any subpath or directly from the
|
8
|
+
filesystem.
|
9
|
+
|
10
|
+
* In the path plugin, the path method now accepts a :relative
|
11
|
+
option for generating relative paths instead of absolute paths.
|
@@ -0,0 +1,42 @@
|
|
1
|
+
= New Features
|
2
|
+
|
3
|
+
* render_each in the render_each plugin now automatically handles
|
4
|
+
template names with subdirectories and extensions. Previously, these
|
5
|
+
caused issues unless the :local option was provided. So now you
|
6
|
+
can use:
|
7
|
+
|
8
|
+
render_each(foos, "items/foo")
|
9
|
+
|
10
|
+
instead of:
|
11
|
+
|
12
|
+
render_each(foos, "items/foo", :local=>:foo)
|
13
|
+
|
14
|
+
* each_partial has been added to the partials plugin. It operates
|
15
|
+
similarly to render_each, but uses the convention for partial
|
16
|
+
template naming. So this:
|
17
|
+
|
18
|
+
each_partial(foos, "items/foo")
|
19
|
+
|
20
|
+
is the same as:
|
21
|
+
|
22
|
+
render_each(foos, "items/_foo", :local=>:foo)
|
23
|
+
|
24
|
+
= Other Improvements
|
25
|
+
|
26
|
+
* The :dependencies option in the assets plugin now works correctly
|
27
|
+
with compiled templates in the render plugin in uncached mode
|
28
|
+
(the default in development). Previously, modifying a dependency
|
29
|
+
file would not result in recompiling the asset template when
|
30
|
+
requesting the main file.
|
31
|
+
|
32
|
+
* Method visibility issues in the following plugins have been fixed:
|
33
|
+
|
34
|
+
* content_security_policy
|
35
|
+
* default_headers
|
36
|
+
* indifferent_params
|
37
|
+
* placeholder_string_matchers
|
38
|
+
* symbol_matchers
|
39
|
+
|
40
|
+
Previously, these plugins made private methods public by mistake
|
41
|
+
when overriding them. Additionally, Roda.freeze no longer changes
|
42
|
+
the visibility of the set_default_headers private method.
|
@@ -0,0 +1,8 @@
|
|
1
|
+
= New Features
|
2
|
+
|
3
|
+
* The path plugin now supports a url method, allowing for returning
|
4
|
+
the entire URL instead of just the path for class-based paths.
|
5
|
+
|
6
|
+
* The public plugin now supports a :brotli option that will directly
|
7
|
+
serve brotli-compressed files (with .br extension) similar to how the
|
8
|
+
:gzip option directly serves gzipped files (with the .gz extension).
|
data/lib/roda.rb
CHANGED
@@ -197,6 +197,8 @@ class Roda
|
|
197
197
|
if instance_method(:set_default_headers).owner == ResponseMethods &&
|
198
198
|
instance_method(:default_headers).owner == ResponseMethods
|
199
199
|
|
200
|
+
private
|
201
|
+
|
200
202
|
def set_default_headers
|
201
203
|
@headers['Content-Type'] ||= 'text/html'
|
202
204
|
end
|
@@ -269,6 +271,7 @@ class Roda
|
|
269
271
|
def plugin(plugin, *args, &block)
|
270
272
|
raise RodaError, "Cannot add a plugin to a frozen Roda class" if frozen?
|
271
273
|
plugin = RodaPlugins.load_plugin(plugin) if plugin.is_a?(Symbol)
|
274
|
+
raise RodaError, "Invalid plugin type: #{plugin.class.inspect}" unless plugin.is_a?(Module)
|
272
275
|
plugin.load_dependencies(self, *args, &block) if plugin.respond_to?(:load_dependencies)
|
273
276
|
include(plugin::InstanceMethods) if defined?(plugin::InstanceMethods)
|
274
277
|
extend(plugin::ClassMethods) if defined?(plugin::ClassMethods)
|
data/lib/roda/plugins/assets.rb
CHANGED
@@ -291,6 +291,8 @@ class Roda
|
|
291
291
|
# non-compiled mode, but will write the metadata to the file if compile_assets is called.
|
292
292
|
# :public :: Path to your public folder, in which compiled files are placed (default: 'public'). Relative
|
293
293
|
# paths will be considered relative to the application's :root option.
|
294
|
+
# :relative_paths :: Use relative paths instead of absolute paths when setting up link and script tags for
|
295
|
+
# assets.
|
294
296
|
# :sri :: Enables subresource integrity when setting up references to compiled assets. The value should be
|
295
297
|
# :sha256, :sha384, or :sha512 depending on which hash algorithm you want to use. This changes the
|
296
298
|
# hash algorithm that Roda will use when naming compiled asset files. The default is :sha256, you
|
@@ -323,10 +325,14 @@ class Roda
|
|
323
325
|
|
324
326
|
# Load the render, caching, and h plugins, since the assets plugin
|
325
327
|
# depends on them.
|
326
|
-
def self.load_dependencies(app,
|
328
|
+
def self.load_dependencies(app, opts = OPTS)
|
327
329
|
app.plugin :render
|
328
330
|
app.plugin :caching
|
329
331
|
app.plugin :h
|
332
|
+
|
333
|
+
if opts[:relative_paths]
|
334
|
+
app.plugin :relative_path
|
335
|
+
end
|
330
336
|
end
|
331
337
|
|
332
338
|
# Setup the options for the plugin. See the Assets module RDoc
|
@@ -399,6 +405,11 @@ class Roda
|
|
399
405
|
opts[s] ||= {}
|
400
406
|
end
|
401
407
|
|
408
|
+
expanded_deps = opts[:expanded_dependencies] = {}
|
409
|
+
opts[:dependencies].each do |file, deps|
|
410
|
+
expanded_deps[File.expand_path(file)] = Array(deps)
|
411
|
+
end
|
412
|
+
|
402
413
|
if headers = opts[:headers]
|
403
414
|
opts[:css_headers] = headers.merge(opts[:css_headers])
|
404
415
|
opts[:js_headers] = headers.merge(opts[:js_headers])
|
@@ -406,7 +417,7 @@ class Roda
|
|
406
417
|
opts[:css_headers]['Content-Type'] ||= "text/css; charset=UTF-8".freeze
|
407
418
|
opts[:js_headers]['Content-Type'] ||= "application/javascript; charset=UTF-8".freeze
|
408
419
|
|
409
|
-
[:css_headers, :js_headers, :css_opts, :js_opts, :dependencies].each do |s|
|
420
|
+
[:css_headers, :js_headers, :css_opts, :js_opts, :dependencies, :expanded_dependencies].each do |s|
|
410
421
|
opts[s].freeze
|
411
422
|
end
|
412
423
|
[:headers, :css, :js].each do |s|
|
@@ -621,8 +632,10 @@ class Roda
|
|
621
632
|
stype = ltype.to_s
|
622
633
|
|
623
634
|
url_prefix = request.script_name if self.class.opts[:add_script_name]
|
635
|
+
relative_paths = o[:relative_paths]
|
624
636
|
|
625
|
-
if o[:compiled]
|
637
|
+
paths = if o[:compiled]
|
638
|
+
relative_paths = false if o[:compiled_asset_host]
|
626
639
|
if ukey = _compiled_assets_hash(type, true)
|
627
640
|
["#{o[:compiled_asset_host]}#{url_prefix}/#{o[:"compiled_#{stype}_prefix"]}.#{ukey}.#{stype}"]
|
628
641
|
else
|
@@ -642,6 +655,14 @@ class Roda
|
|
642
655
|
"#{url_prefix}/#{o[:"#{stype}_prefix"]}#{mtime}#{prefix}#{f}#{o[:"#{stype}_suffix"]}"
|
643
656
|
end
|
644
657
|
end
|
658
|
+
|
659
|
+
if relative_paths
|
660
|
+
paths.map! do |path|
|
661
|
+
"#{relative_prefix}#{path}"
|
662
|
+
end
|
663
|
+
end
|
664
|
+
|
665
|
+
paths
|
645
666
|
end
|
646
667
|
|
647
668
|
# Return a string containing html tags for the given asset type.
|
@@ -716,7 +737,7 @@ class Roda
|
|
716
737
|
content = if file.end_with?(".#{type}")
|
717
738
|
::File.read(file)
|
718
739
|
else
|
719
|
-
render_asset_file(file, :template_opts=>o[:"#{type}_opts"])
|
740
|
+
render_asset_file(file, :template_opts=>o[:"#{type}_opts"], :dependencies=>o[:expanded_dependencies][file])
|
720
741
|
end
|
721
742
|
|
722
743
|
o[:postprocessor] ? o[:postprocessor].call(file, type, content) : content
|
@@ -746,7 +767,7 @@ class Roda
|
|
746
767
|
# other files, check the modification times of all dependencies and
|
747
768
|
# return the maximum.
|
748
769
|
def asset_last_modified(file)
|
749
|
-
if deps = self.class.assets_opts[:
|
770
|
+
if deps = self.class.assets_opts[:expanded_dependencies][file]
|
750
771
|
([file] + Array(deps)).map{|f| ::File.stat(f).mtime}.max
|
751
772
|
else
|
752
773
|
::File.stat(file).mtime
|
data/lib/roda/plugins/caching.rb
CHANGED
@@ -52,7 +52,7 @@ class Roda
|
|
52
52
|
|
53
53
|
env = @_request.env
|
54
54
|
|
55
|
-
opts[:common_logger_meth].call("#{env['HTTP_X_FORWARDED_FOR'] || env["REMOTE_ADDR"] || "-"} - #{env["REMOTE_USER"] || "-"} [#{Time.now.strftime("%d/%b/%Y:%H:%M:%S %z")}] \"#{env["REQUEST_METHOD"]} #{env["PATH_INFO"]}#{"?#{env["QUERY_STRING"]}" if ((qs = env["QUERY_STRING"]) && !qs.empty?)} #{env["HTTP_VERSION"]}\" #{result[0]} #{((length = result[1]['Content-Length']) && (length unless length == '0')) || '-'} #{elapsed_time}\n")
|
55
|
+
opts[:common_logger_meth].call("#{env['HTTP_X_FORWARDED_FOR'] || env["REMOTE_ADDR"] || "-"} - #{env["REMOTE_USER"] || "-"} [#{Time.now.strftime("%d/%b/%Y:%H:%M:%S %z")}] \"#{env["REQUEST_METHOD"]} #{env["SCRIPT_NAME"]}#{env["PATH_INFO"]}#{"?#{env["QUERY_STRING"]}" if ((qs = env["QUERY_STRING"]) && !qs.empty?)} #{env["HTTP_VERSION"]}\" #{result[0]} #{((length = result[1]['Content-Length']) && (length unless length == '0')) || '-'} #{elapsed_time}\n")
|
56
56
|
end
|
57
57
|
|
58
58
|
# Create timer instance used for timing
|
@@ -31,6 +31,8 @@ class Roda
|
|
31
31
|
if owner == Base::ResponseMethods || (owner == response_class && app.opts[:set_default_headers_overridder] == response_class)
|
32
32
|
app.opts[:set_default_headers_overridder] = response_class
|
33
33
|
response_class.class_eval(<<-END, __FILE__, __LINE__+1)
|
34
|
+
private
|
35
|
+
|
34
36
|
def set_default_headers
|
35
37
|
h = @headers
|
36
38
|
#{headers.map{|k,v| "h[#{k.inspect}] ||= #{v.inspect}"}.join('; ')}
|
@@ -244,10 +244,10 @@ END
|
|
244
244
|
|
245
245
|
frames = exception.backtrace.map.with_index do |line, i|
|
246
246
|
frame = {:id=>i}
|
247
|
-
if line =~
|
247
|
+
if line =~ /\A(.*?):(\d+)(?::in `(.*)')?\Z/
|
248
248
|
filename = frame[:filename] = $1
|
249
249
|
lineno = frame[:lineno] = $2.to_i
|
250
|
-
frame[:function] = $
|
250
|
+
frame[:function] = $3
|
251
251
|
|
252
252
|
begin
|
253
253
|
lineno -= 1
|
@@ -261,12 +261,16 @@ END
|
|
261
261
|
end
|
262
262
|
|
263
263
|
frame
|
264
|
-
else
|
265
|
-
nil
|
266
264
|
end
|
267
265
|
end.compact
|
268
266
|
|
269
267
|
r = @_request
|
268
|
+
begin
|
269
|
+
post_data = r.POST
|
270
|
+
missing_post = "No POST data"
|
271
|
+
rescue
|
272
|
+
missing_post = "Invalid POST data"
|
273
|
+
end
|
270
274
|
info = lambda do |title, id, var, none|
|
271
275
|
<<END
|
272
276
|
<h3 id="#{id}">#{title}</h3>
|
@@ -363,7 +367,7 @@ END1
|
|
363
367
|
<h2>Request information</h2>
|
364
368
|
|
365
369
|
#{info.call('GET', 'get-info', r.GET, 'No GET data')}
|
366
|
-
#{info.call('POST', 'post-info',
|
370
|
+
#{info.call('POST', 'post-info', post_data, missing_post)}
|
367
371
|
#{info.call('Cookies', 'cookie-info', r.cookies, 'No cookie data')}
|
368
372
|
#{info.call('Rack ENV', 'env-info', r.env, 'No Rack env?')}
|
369
373
|
</div>
|