forked from jeremyevans/roda
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path2.1.0.txt
124 lines (98 loc) · 4.4 KB
/
2.1.0.txt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
= New Plugins
* A view_options plugin has been added, for branch/route specific
setting of view and layout options and locals. This allows for
DRYer code when you want to change the view or layout settings
for an entire routing branch. Options and locals set at the
branch or route level have higher priority than those set at
the plugin level, but lower priority than those provided as
arguments to the render/view methods. Example:
class App < Roda
plugin :view_options
route do |r|
r.on 'albums' do
layout_options :template=>'layouts/3_columns'
layout_locals :heading=>'Albums'
view_options :ext=>'haml'
view_locals :name=>'Foo'
# ...
end
end
end
The view_options plugin is also a superset of the previous
view_subdirs plugin, and attempts to load view_subdirs will
now load view_options. In addition to set_view_subdir, the
view_options plugin now supports append_view_subdir, which
will append a subdirectory to an existing subdirectory, which
makes it simpler to deal with nested view file hierarchies.
* A static plugin has been added for easily serving static files
using Rack::Static. Example:
class App < Roda
plugin :static, ['/js', '/css']
# or:
plugin :static, ['/js', '/css'], :root=>'pub'
end
= Other New Features
* Roda now supports a :root option for the application that sets
the root directory. This is useful if the application's files
are not stored in the process's working directory, which is
common for processes containing of multiple Roda applications.
By setting the :root option, plugins that use the file system
will default to making relative paths relative to the :root
option instead of the process's working directory. The
assets, render, and static plugins currently support the :root
option. Example:
class App < Roda
opts[:root] = File.dirname(__FILE__)
end
* Roda now supports an :add_script_name option for the application,
which makes plugins automatically prepend the SCRIPT_NAME for the
request's environment to any paths created. This allows Roda
applications to work transparently whenever they are mounted
inside of another rack application.
The assets and path plugins currently recognize the
:add_script_name option. Example:
class App < Roda
opts[:add_script_name] = true
end
* The path plugin now adds a Roda#path method, which creates paths
based on the type of argument used. You can register classes
with the path plugin by providing Roda.path with a class, which
will cause Roda#path to recognize them and handle them accordingly.
Example:
class App < Roda
plugin :path
path(Track){|track| "/albums/#{track.album_id}/tracks/#{track.number}"}
route do
r.get 'tracks/:id' do |track_id|
r.redirect(path(Track[track_id]))
end
end
end
= Other Improvements
* add_file in the mailer plugin now adds the files after the email
body instead of before. This fixes some issues where the email
body would end up empty, due to issues with the mail gem's API.
add_file now accepts a block, and the block is called after the
file has been attached. Among other things, this allows you to
change the content_type for an attached file:
add_file 'path/to/file' do
response.mail.attachments.last.content_type = 'text/foo'
end
* r.multi_route in the multi_route plugin now works if there are
no named routes defined.
* A render plugin :locals option is now respected, setting defaults
to use for locals in views. Additionally, a :locals option in
the :layout_opts option is now respected for setting locals in
layouts. If both the render plugin option is set and :locals is
passed to render/view, the two will be merged together.
Previously, providing a :locals option to render/view would cause
the plugin level option to be ignored.
= Backwards Compatibility
* Using the render plugin :layout=>nil option now removes any
layout template set previously using :layout. Previously, the
layout template would still be kept, but it would not be used
by default.
* Accessing attachments after adding a file using add_file in the
mailer plugin no longer works, as the adding is now delayed until
after the body is set. You should now pass a block to add_file
if you want to access the attachment after it has been added.