hobo 1.4.0.pre8 → 2.0.0.pre1
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGES-1.4.txt +87 -3
- data/TODO-1.4.txt +3 -11
- data/VERSION +1 -1
- data/app/helpers/hobo_route_helper.rb +61 -20
- data/lib/generators/hobo/admin_subsite/USAGE +3 -11
- data/lib/generators/hobo/admin_subsite/admin_subsite_generator.rb +4 -1
- data/lib/generators/hobo/admin_subsite/templates/{site.css.erb → site.scss.erb} +0 -0
- data/lib/generators/hobo/assets/assets_generator.rb +2 -2
- data/lib/generators/hobo/assets/templates/{application.css → application.scss} +0 -0
- data/lib/generators/hobo/assets/templates/{front.css → front.scss} +0 -0
- data/lib/generators/hobo/model/templates/model_injection.rb.erb +1 -0
- data/lib/generators/hobo/plugin.rb +3 -1
- data/lib/generators/hobo/routes/router.rb +115 -0
- data/lib/generators/hobo/routes/templates/hobo_routes.rb.erb +42 -3
- data/lib/generators/hobo/setup_wizard/setup_wizard_generator.rb +35 -2
- data/lib/generators/hobo/subsite.rb +1 -1
- data/lib/generators/hobo/subsite/USAGE +3 -11
- data/lib/generators/hobo/subsite/subsite_generator.rb +3 -0
- data/lib/generators/hobo/subsite/templates/{site.css.erb → site.scss.erb} +0 -0
- data/lib/generators/hobo/subsite_taglib/subsite_taglib_generator.rb +4 -1
- data/lib/generators/hobo/user_mailer/templates/activation.erb +1 -1
- data/lib/generators/hobo/user_mailer/templates/forgot_password.erb +1 -1
- data/lib/generators/hobo/user_mailer/templates/invite.erb +1 -1
- data/lib/generators/hobo/user_model/templates/model_injection.rb.erb +1 -0
- data/lib/hobo.rb +2 -2
- data/lib/hobo/controller.rb +3 -11
- data/lib/hobo/controller/model.rb +89 -89
- data/lib/hobo/engine.rb +12 -0
- data/lib/hobo/extensions/active_record/permissions.rb +15 -24
- data/lib/hobo/model.rb +3 -0
- data/lib/hobo/model/permissions.rb +1 -1
- data/lib/hobo/rapid/generators/rapid/cards.dryml.erb +10 -3
- data/lib/hobo/rapid/generators/rapid/forms.dryml.erb +9 -2
- data/lib/hobo/rapid/generators/rapid/pages.dryml.erb +11 -4
- data/lib/hobo/routes.rb +2 -0
- data/test/doctest/hobo/hobo_helper.rdoctest +23 -20
- data/test/doctest/hobo/lifecycles.rdoctest +1 -0
- data/test/doctest/hobo/model.rdoctest +4 -0
- data/test/doctest/hobo/multi_model_forms.rdoctest +2 -0
- data/test/doctest/hobo/scopes.rdoctest +18 -5
- data/test/doctest/prepare_testapp.rb +4 -2
- data/test/irt/generators/admin_subsite.irt +2 -6
- data/test/irt/generators/assets.irt +1 -7
- data/test/irt/generators/front_controller.irt +1 -3
- data/test/irt/generators/model.irt +1 -2
- data/test/irt/generators/partials/_account_user_model_tests.rb +1 -3
- data/test/irt/generators/partials/_accounts_users_controller_tests.rb +1 -3
- data/test/irt/generators/partials/_default_user_model_tests.rb +1 -3
- data/test/irt/generators/partials/_default_users_controller_tests.rb +1 -3
- data/test/irt/generators/partials/_house_controller_tests.rb +1 -3
- data/test/irt/generators/partials/_user_mailer_tests.rb +1 -3
- data/test/irt/generators/subsite.irt +5 -6
- data/test/irt/generators/user_mailer.irt +2 -0
- metadata +12 -18
- data/lib/generators/hobo/rapid/templates/themes/clean-sidemenu/public/images/100-ACD3E6-DBE1E5-H.png +0 -0
- data/lib/generators/hobo/rapid/templates/themes/clean-sidemenu/public/images/100-DBE1E5-FCFEF5-H.png +0 -0
- data/lib/generators/hobo/rapid/templates/themes/clean-sidemenu/public/images/300-3B5F87-ACD3E6-H.png +0 -0
- data/lib/generators/hobo/rapid/templates/themes/clean-sidemenu/public/images/spinner.gif +0 -0
- data/lib/generators/hobo/rapid/templates/themes/clean-sidemenu/public/stylesheets/clean-sidemenu.css +0 -81
- data/lib/generators/hobo/rapid/templates/themes/clean-sidemenu/views/clean-sidemenu.dryml +0 -30
data/CHANGES-1.4.txt
CHANGED
@@ -200,6 +200,66 @@ The default doctype has been changed from `XHTML 1.0 TRANSITIONAL` to
|
|
200
200
|
`html`, also known as "standards mode" in Internet Explorer 8 and 9
|
201
201
|
and "html5" in other browsers.
|
202
202
|
|
203
|
+
## named routes' names changed to use standard Rails names
|
204
|
+
|
205
|
+
The names of named routes generated by Hobo have changed to more
|
206
|
+
closely match the default names generated by the Rails REST route
|
207
|
+
generator. The standard 7 REST routes have not changed, but some
|
208
|
+
additional routes such as nested routes and lifecycle routes have been
|
209
|
+
renamed.
|
210
|
+
|
211
|
+
For the moment you can ask Hobo to emit both the new style and old
|
212
|
+
style routes by not defining
|
213
|
+
`config.hobo.dont_emit_deprecated_routes`.
|
214
|
+
|
215
|
+
Note that paths and method names have not changed, only the named
|
216
|
+
route has changed, so this change should not be visible to the user or
|
217
|
+
impact controller code.
|
218
|
+
|
219
|
+
The route name is leftmost column in `rake routes`.
|
220
|
+
|
221
|
+
Here are some example changes:
|
222
|
+
|
223
|
+
create_task_path => create_tasks_path # tasks#create
|
224
|
+
create_task_for_story_path => create_story_tasks_path # tasks#create_for_story
|
225
|
+
foo_transition_path => transition_foo_path # foos lifecycle transition
|
226
|
+
foo_show2_path => show2_foo_path # show_action :show2 in foos_controller
|
227
|
+
|
228
|
+
Note that in the second example, create_story_tasks_path, the
|
229
|
+
controller method name is `create_for_story`. This is the same method
|
230
|
+
name that Hobo 1.0 and 1.3 use; the default Rails method name would be
|
231
|
+
just plain `create`.
|
232
|
+
|
233
|
+
There are several named routes used in the user_mailer views generated
|
234
|
+
in a new application. These must be fixed up when upgrading an old
|
235
|
+
application. For instance, user_activate_url must be changed to
|
236
|
+
activate_user_url in activation.erb.
|
237
|
+
|
238
|
+
In exchange for the pain of updating some of your named routes, we
|
239
|
+
receive the following benefits:
|
240
|
+
|
241
|
+
- polymorphic_url works with nested routes and in more situations
|
242
|
+
|
243
|
+
- url_for will work in more situations
|
244
|
+
|
245
|
+
- the `<a>` tag and the many tags which use it now accept all the
|
246
|
+
`url_for` options, such as host and port.
|
247
|
+
|
248
|
+
- hobo_routes.rb is easier to read and understand
|
249
|
+
|
250
|
+
- code reduction in Hobo
|
251
|
+
|
252
|
+
## `remote-method-button` and `update-button` broken
|
253
|
+
|
254
|
+
`remote-method-button`, `update-button` and similar buttons such as
|
255
|
+
`delete-button` were written early in the history of Hobo, before
|
256
|
+
standard form/part ajax was supported. These tags are easy to replace
|
257
|
+
with the much more flexible forms.
|
258
|
+
|
259
|
+
For backwards compatibility, most of these buttons have been updated
|
260
|
+
to 1.4. However, the little used `remote-method-button` and
|
261
|
+
`update-button` have not been converted to the 1.4 form.
|
262
|
+
|
203
263
|
## default field-list changed
|
204
264
|
|
205
265
|
The default for `<field-list>` has changed to `<feckless-fieldset>`.
|
@@ -224,10 +284,9 @@ app/helpers/hobo_deprecated_helper.rb
|
|
224
284
|
If your application depends on any of these, you can set
|
225
285
|
config.hobo.include_deprecated_helper.
|
226
286
|
|
227
|
-
## Rails 3.
|
287
|
+
## Rails 3.2 required
|
228
288
|
|
229
|
-
Hobo 1.4 currently requires Rails 3.
|
230
|
-
on Rails 3.2 before final release.
|
289
|
+
Hobo 1.4 currently requires Rails 3.2 for operation.
|
231
290
|
|
232
291
|
## Enhancements
|
233
292
|
|
@@ -587,6 +646,23 @@ The signature for the function update_response and friends has changed. This s
|
|
587
646
|
end
|
588
647
|
end
|
589
648
|
|
649
|
+
### default controller actions now use respond_with
|
650
|
+
|
651
|
+
All Hobo model controller actions now use [respond_with](http://apidock.com/rails/ActionController/MimeResponds/respond_with) where appropriate. This means that you can create an API interface for a controller simply by adding:
|
652
|
+
|
653
|
+
respond_to :html, :json, :xml
|
654
|
+
|
655
|
+
See [respond_to](http://apidock.com/rails/ActionController/MimeResponds/ClassMethods/respond_to) and Google for "respond_with" for more information.
|
656
|
+
|
657
|
+
Note that the JSON and XML interfaces will only use coarse grained
|
658
|
+
model-level permission checking rather than fine grained attribute
|
659
|
+
level permission checking.
|
660
|
+
|
661
|
+
### before-unload
|
662
|
+
|
663
|
+
`<form>` has gained a new option, before-unload, which adds an
|
664
|
+
onbeforeunload helper to the page.
|
665
|
+
|
590
666
|
## Editors
|
591
667
|
|
592
668
|
Editors are no longer special-cased, they now use the standard DRYML
|
@@ -668,6 +744,14 @@ environment no longer automatically imports ActionView::Helpers.
|
|
668
744
|
All application helpers are now available in the template
|
669
745
|
environment.
|
670
746
|
|
747
|
+
## Attribute Whitelist
|
748
|
+
|
749
|
+
Rails 3.2.3 and later changed the default for config.whitelist_attributes to true, so any newly generated Hobo apps will have this feature turned on. Hobo heavily depends on mass attribute assignation, so this may cause inconveniences.
|
750
|
+
|
751
|
+
Mass assignment protection is redundant in Hobo: your primary protection should come through the edit_permitted? function. If all of your models have properly defined edit_permitted? then it is safe to turn off config.whitelist_attributes.
|
752
|
+
|
753
|
+
If you choose not to turn off config.whitelist_attributes, any fields that are not in your attr_accessible declaration will not be available in forms. Hobo's generators will now assist in the creation of attr_accessible declarations.
|
754
|
+
|
671
755
|
# jQuery rewrite
|
672
756
|
|
673
757
|
FIXME: pull into separate document, along with interface specs
|
data/TODO-1.4.txt
CHANGED
@@ -2,22 +2,17 @@
|
|
2
2
|
|
3
3
|
## regressions
|
4
4
|
|
5
|
-
*
|
6
|
-
* remote-method-button, create-button, update-button,
|
7
|
-
transition-button: normal usages of these tags work, but they do
|
5
|
+
* remote-method-button, update-button: normal usages of these tags work, but they do
|
8
6
|
not work if you ask them to do AJAX
|
9
7
|
* live-search works, but it's not 'live'. You have to press return
|
10
8
|
to start the search
|
11
|
-
* remove-button, remote-method-button, create-button & update-button
|
12
|
-
used to display inline but now display as a block. In other
|
13
|
-
words, they now display one per line rather than several in a
|
14
|
-
single line.
|
15
9
|
* the rapid_summary tags have been moved out
|
16
10
|
of core Hobo into their own plugin,
|
17
11
|
https://github.com/Hobo/hobo_summary, which is not yet in a working state
|
18
12
|
|
19
13
|
## documentation
|
20
14
|
|
15
|
+
* touchpunch for mobile sortables
|
21
16
|
* document themes/plugins
|
22
17
|
* FAQ
|
23
18
|
* agility
|
@@ -50,9 +45,6 @@ you notice any such omissions, please let us know, it is easy to fix..
|
|
50
45
|
* multiple file support for AJAX uploads
|
51
46
|
* cache: redis support
|
52
47
|
* fixup deprecation warnings
|
53
|
-
* port to Rails 3.2 and/or 4.0
|
54
|
-
* nuke any remaining prototype code
|
55
|
-
* add a sane default for non-AJAX JSON requests.
|
56
48
|
* trawl the lighthouse && pull requests
|
57
49
|
* steal the tags from Portal
|
58
50
|
* fixup hobo-contrib
|
@@ -64,4 +56,4 @@ you notice any such omissions, please let us know, it is easy to fix..
|
|
64
56
|
* create a bootstrap theme
|
65
57
|
* add theme chooser to setup wizard
|
66
58
|
* add support for has-one
|
67
|
-
* convert old Hobo plugins: imaginary-dryml, hoboyui
|
59
|
+
* convert old Hobo plugins: imaginary-dryml, hoboyui, nice theme
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
|
1
|
+
2.0.0.pre1
|
@@ -1,5 +1,16 @@
|
|
1
1
|
module HoboRouteHelper
|
2
2
|
extend HoboHelperBase
|
3
|
+
def object_url(obj, *args)
|
4
|
+
new_ = object_url_new(obj, *args)
|
5
|
+
|
6
|
+
unless Rails.configuration.hobo.dont_emit_deprecated_routes
|
7
|
+
old_ = object_url_old(obj, *args)
|
8
|
+
debugger if old_ != new_
|
9
|
+
raise Hobo::Error.new("new style url #{new_} does not match old style url #{old_}. obj: #{obj.inspect}. args: #{args.inspect}. backtrace: #{caller.inspect}") if old_ != new_
|
10
|
+
end
|
11
|
+
new_
|
12
|
+
end
|
13
|
+
|
3
14
|
protected
|
4
15
|
def base_url
|
5
16
|
ENV['RAILS_RELATIVE_URL_ROOT'] || ''
|
@@ -20,7 +31,7 @@ module HoboRouteHelper
|
|
20
31
|
|
21
32
|
IMPLICIT_ACTIONS = [:index, :show, :create, :update, :destroy]
|
22
33
|
|
23
|
-
def
|
34
|
+
def object_url_old(obj, *args)
|
24
35
|
params = args.extract_options!
|
25
36
|
action = args.first._?.to_sym
|
26
37
|
options, params = params.partition_hash([:subsite, :method, :format])
|
@@ -78,29 +89,59 @@ module HoboRouteHelper
|
|
78
89
|
end
|
79
90
|
end
|
80
91
|
|
92
|
+
def object_url_new(obj, *args)
|
93
|
+
options = args.extract_options!
|
94
|
+
action = args.first._?.to_sym
|
95
|
+
options, params = options.partition_hash([:subsite, :method, :format])
|
96
|
+
options[:subsite] ||= self.subsite
|
97
|
+
|
98
|
+
if obj.respond_to?(:member_class)
|
99
|
+
if obj.respond_to?(:origin) && obj.origin
|
100
|
+
# Asking for URL of a collection, e.g. category/1/adverts or category/1/adverts/new
|
101
|
+
refl = obj.origin.class.reverse_reflection(obj.origin_attribute)
|
102
|
+
owner_name = refl.name.to_s
|
103
|
+
owner_name = owner_name.singularize if refl.macro == :has_many
|
104
|
+
poly = [owner_name, obj.member_class]
|
105
|
+
params[:"#{owner_name}_id"] = obj.origin
|
106
|
+
else
|
107
|
+
poly = [obj.member_class]
|
108
|
+
end
|
109
|
+
else
|
110
|
+
poly = [obj]
|
111
|
+
end
|
112
|
+
|
113
|
+
poly = [options[:subsite]] + poly if options[:subsite]
|
114
|
+
|
115
|
+
action ||= case options[:method].to_s
|
116
|
+
when 'put'; :update
|
117
|
+
when 'post'; :create
|
118
|
+
when 'delete'; :destroy
|
119
|
+
else; obj.is_a?(Class) ? :index : :show
|
120
|
+
end
|
121
|
+
|
122
|
+
params[:action] = action unless action.in?(IMPLICIT_ACTIONS)
|
123
|
+
|
124
|
+
begin
|
125
|
+
url = polymorphic_path(poly, params)
|
126
|
+
# validate URL, since polymorphic URL may return a URL for a
|
127
|
+
# different method
|
128
|
+
Rails.application.routes.recognize_path(url, {:method => options[:method]})
|
129
|
+
url
|
130
|
+
rescue NoMethodError => e # raised if polymorphic_url fails
|
131
|
+
nil
|
132
|
+
rescue ArgumentError => e # raised from polymorphic_url
|
133
|
+
nil
|
134
|
+
rescue ActionController::RoutingError => e # raised if recognize_path fails
|
135
|
+
nil
|
136
|
+
end
|
137
|
+
|
138
|
+
end
|
81
139
|
|
82
140
|
def linkable?(*args)
|
83
141
|
options = args.extract_options!
|
84
142
|
target = args.empty? || args.first.is_a?(Symbol) ? this : args.shift
|
85
143
|
action = args.first
|
86
|
-
|
87
|
-
|
88
|
-
if target.respond_to?(:member_class) && (origin = target.try.origin)
|
89
|
-
klass = origin.class
|
90
|
-
action = if action == :new
|
91
|
-
"new_#{target.origin_attribute.to_s.singularize}"
|
92
|
-
elsif action.nil?
|
93
|
-
target.origin_attribute
|
94
|
-
end
|
95
|
-
elsif target.is_a?(Class)
|
96
|
-
klass = target
|
97
|
-
action ||= :index
|
98
|
-
else
|
99
|
-
klass = target.class
|
100
|
-
action ||= :show
|
101
|
-
end
|
102
|
-
|
103
|
-
Hobo::Routes.linkable?(klass, action, options.reverse_merge(:subsite => subsite))
|
144
|
+
object_url_new(target, action, options)
|
104
145
|
end
|
105
146
|
|
106
147
|
def base_url_for(object, subsite, action)
|
@@ -173,7 +214,7 @@ module HoboRouteHelper
|
|
173
214
|
|
174
215
|
# Sign-up url for a given user record or user class
|
175
216
|
def signup_url(user_class=Hobo::Model::UserBase.default_user_model)
|
176
|
-
send("#{user_class.name.underscore}
|
217
|
+
send("signup_#{user_class.name.underscore.pluralize}_url") rescue nil
|
177
218
|
end
|
178
219
|
|
179
220
|
|
@@ -8,17 +8,9 @@ Description:
|
|
8
8
|
and two different sets of views for the same model.
|
9
9
|
|
10
10
|
The subsite will use app/views/taglibs/<subsite_name>_site.dryml
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
load both application.dryml and front_site.dryml.
|
15
|
-
|
16
|
-
It is thus recommended that you ensure that
|
17
|
-
<subsite_name>_site.dryml and application.dryml do not repeat
|
18
|
-
code, such as the inclusion of rapid or the setting of the theme.
|
19
|
-
One easy way of ensuring this is to use the --make-front-site
|
20
|
-
option. If you have already accounted for this, use
|
21
|
-
--make-front-site=false.
|
11
|
+
for common tags. The assets that the subsite will load are
|
12
|
+
specified in app/assets/javascripts/<subsite_name>.js and
|
13
|
+
app/assets/stylesheets/<subsite_name>.[s]css
|
22
14
|
|
23
15
|
The difference between hobo:admin_site and hobo:subsite is that
|
24
16
|
hobo:admin_site limits the subsite to use by administrators only.
|
@@ -5,6 +5,9 @@ module Hobo
|
|
5
5
|
# overrides the default
|
6
6
|
argument :name, :type => :string, :default => 'admin', :optional => true
|
7
7
|
|
8
|
+
class_option :theme, :type => :string, :desc => "Theme", :default => 'clean_admin'
|
9
|
+
class_option :ui_theme, :type => :string, :desc => "jQuery-UI Theme", :default => 'flick'
|
10
|
+
|
8
11
|
include Generators::Hobo::InviteOnly
|
9
12
|
include Generators::HoboSupport::EvalTemplate
|
10
13
|
|
@@ -14,7 +17,7 @@ module Hobo
|
|
14
17
|
|
15
18
|
def generate_admin_user_controller
|
16
19
|
invoke "hobo:controller", ["#{file_name}/#{options[:user_resource_name].pluralize.underscore}"], options
|
17
|
-
template "users_index.dryml", "app/views/#{file_name}/#{options[:user_resource_name].pluralize.underscore}/index.dryml"
|
20
|
+
template "users_index.dryml", "app/views/#{file_name}/#{options[:user_resource_name].pluralize.underscore}/index.dryml" if invite_only?
|
18
21
|
end
|
19
22
|
|
20
23
|
include Generators::Hobo::Subsite
|
File without changes
|
@@ -14,9 +14,9 @@ module Hobo
|
|
14
14
|
copy_file 'guest.rb', 'app/models/guest.rb'
|
15
15
|
|
16
16
|
FileUtils.mv 'app/assets/stylesheets/application.css', 'app/assets/stylesheets/application.css.orig'
|
17
|
-
copy_file 'application.
|
17
|
+
copy_file 'application.scss', 'app/assets/stylesheets/application.scss'
|
18
18
|
copy_file 'gitkeep', 'app/assets/stylesheets/application/.gitkeep'
|
19
|
-
copy_file 'front.
|
19
|
+
copy_file 'front.scss', 'app/assets/stylesheets/front.scss'
|
20
20
|
copy_file 'gitkeep', 'app/assets/stylesheets/front/.gitkeep'
|
21
21
|
|
22
22
|
FileUtils.mv 'app/assets/javascripts/application.js', 'app/assets/javascripts/application.js.orig'
|
File without changes
|
File without changes
|
@@ -68,7 +68,9 @@ module Generators
|
|
68
68
|
end
|
69
69
|
|
70
70
|
def inject_css_require(name, subsite, comments)
|
71
|
-
application_file = "app/assets/stylesheets/#{subsite}.
|
71
|
+
application_file = "app/assets/stylesheets/#{subsite}.scss"
|
72
|
+
application_file = "app/assets/stylesheets/#{subsite}.css" unless exists?(application_file)
|
73
|
+
raise Thor::Error, "Couldn't find #{subsite}.css!" unless exists?(application_file)
|
72
74
|
opts = {:before => /\*=(?!.*\*=).*?$/m}
|
73
75
|
|
74
76
|
raise Thor::Error, "Couldn't find #{subsite}.css!" unless exists?(application_file)
|
@@ -17,12 +17,121 @@ module Generators
|
|
17
17
|
@record = @records.singularize
|
18
18
|
end
|
19
19
|
|
20
|
+
def emit_hash(hash, prefix)
|
21
|
+
s = ""
|
22
|
+
hash.each do |key, val|
|
23
|
+
s << "#{prefix}#{key}"
|
24
|
+
unless val.blank?
|
25
|
+
s << " do\n"
|
26
|
+
val.each do |sub|
|
27
|
+
if sub.is_a?(Hash)
|
28
|
+
s << emit_hash(sub, prefix + " ")
|
29
|
+
else
|
30
|
+
s << "#{prefix} #{sub}\n"
|
31
|
+
end
|
32
|
+
end
|
33
|
+
s << "#{prefix}end\n"
|
34
|
+
else
|
35
|
+
s << "\n"
|
36
|
+
end
|
37
|
+
end
|
38
|
+
s
|
39
|
+
end
|
40
|
+
|
41
|
+
def resources_hash
|
42
|
+
collections = []
|
43
|
+
collections += index_actions
|
44
|
+
collections += lifecycle_collection_actions
|
45
|
+
collections << "post 'reorder'" if controller.public_method_defined?(:reorder)
|
46
|
+
members = []
|
47
|
+
members += show_actions
|
48
|
+
members += web_methods
|
49
|
+
members += lifecycle_member_actions
|
50
|
+
right = []
|
51
|
+
right << {"collection" => collections} unless collections.blank?
|
52
|
+
right << {"member" => members} unless members.blank?
|
53
|
+
{basic_resources => right}
|
54
|
+
end
|
55
|
+
|
56
|
+
def basic_resources
|
57
|
+
actions = %w(index new edit show create update destroy).select {|action| controller.public_method_defined?(action)}
|
58
|
+
if actions.length == 7
|
59
|
+
"resources :#{records}"
|
60
|
+
else
|
61
|
+
"resources :#{records}, :only => [#{actions.map{|a| ':'+a}.join(', ')}]"
|
62
|
+
end
|
63
|
+
end
|
64
|
+
|
65
|
+
def index_actions
|
66
|
+
controller.index_actions.map do |action|
|
67
|
+
"get '#{action}'"
|
68
|
+
end
|
69
|
+
end
|
70
|
+
|
71
|
+
def show_actions
|
72
|
+
controller.show_actions.map do |action|
|
73
|
+
"get '#{action}'"
|
74
|
+
end
|
75
|
+
end
|
76
|
+
|
77
|
+
def lifecycle_collection_actions
|
78
|
+
return [] unless defined? model::Lifecycle
|
79
|
+
model::Lifecycle.creators.values.where.routable_for?(@subsite).*.name.map do |creator|
|
80
|
+
["post '#{creator}', :action => 'do_#{creator}'",
|
81
|
+
"get '#{creator}'" ]
|
82
|
+
end.flatten
|
83
|
+
end
|
84
|
+
|
85
|
+
def lifecycle_member_actions
|
86
|
+
return [] unless defined? model::Lifecycle
|
87
|
+
model::Lifecycle.transitions.where.routable_for?(@subsite).*.name.map do |transition|
|
88
|
+
["put '#{transition}', :action => 'do_#{transition}'",
|
89
|
+
"get '#{transition}'"]
|
90
|
+
end.flatten
|
91
|
+
end
|
92
|
+
|
93
|
+
def web_methods
|
94
|
+
controller.web_methods.map do |action|
|
95
|
+
"post '#{action}'"
|
96
|
+
end
|
97
|
+
end
|
98
|
+
|
99
|
+
def owner_actions
|
100
|
+
controller.owner_actions.map do |owner, actions|
|
101
|
+
collection_refl = model.reverse_reflection(owner)
|
102
|
+
raise ::Hobo::Error, "Hob routing error -- can't find reverse association for #{model}##{owner} " +
|
103
|
+
"(e.g. the :has_many that corresponds to a :belongs_to)" if collection_refl.nil?
|
104
|
+
collection = collection_refl.name
|
105
|
+
owner_class = model.reflections[owner].klass.name.underscore
|
106
|
+
owner = owner.to_s.singularize if model.reflections[owner].macro == :has_many
|
107
|
+
collection_path = "#{owner_class.pluralize}/:#{owner}_id/#{collection}"
|
108
|
+
|
109
|
+
routes = []
|
110
|
+
routes << "get 'new', :on => :new, :action => 'new_for_#{owner}'" if actions.include?(:new)
|
111
|
+
collection_routes = []
|
112
|
+
collection_routes << "get 'index', :action => 'index_for_#{owner}'" if actions.include?(:index)
|
113
|
+
collection_routes << "post 'create', :action => 'create_for_#{owner}'" if actions.include?(:create)
|
114
|
+
routes << {"collection" => collection_routes} unless collection_routes.empty?
|
115
|
+
|
116
|
+
{ "resources :#{owner_class.pluralize}, :as => :#{owner}, :only => []" =>
|
117
|
+
[ "resources :#{collection}, :only => []" => routes]
|
118
|
+
}
|
119
|
+
end
|
120
|
+
end
|
121
|
+
|
122
|
+
def emit_resources
|
123
|
+
"# #{@resource_hash.inspect}\n"+
|
124
|
+
"# #{owner_actions.inspect}"
|
125
|
+
end
|
126
|
+
|
127
|
+
# deprecated
|
20
128
|
def index_action_routes
|
21
129
|
controller.index_actions.map do |action|
|
22
130
|
link( "get '#{records}/#{action}(.:format)', :as => '#{action}_#{records}'", action )
|
23
131
|
end.compact
|
24
132
|
end
|
25
133
|
|
134
|
+
# deprecated
|
26
135
|
def lifecycle_routes(subsite)
|
27
136
|
return [] unless defined? model::Lifecycle
|
28
137
|
routes = []
|
@@ -37,6 +146,7 @@ module Generators
|
|
37
146
|
routes.compact.uniq
|
38
147
|
end
|
39
148
|
|
149
|
+
# deprecated
|
40
150
|
def resource_routes
|
41
151
|
[
|
42
152
|
link("get '#{records}(.:format)' => '#{records}#index', :as => '#{records}'", 'index'),
|
@@ -49,6 +159,7 @@ module Generators
|
|
49
159
|
].compact
|
50
160
|
end
|
51
161
|
|
162
|
+
# deprecated
|
52
163
|
def owner_routes
|
53
164
|
routes = []
|
54
165
|
controller.owner_actions.each_pair do |owner, actions|
|
@@ -75,22 +186,26 @@ module Generators
|
|
75
186
|
routes.compact
|
76
187
|
end
|
77
188
|
|
189
|
+
# deprecated
|
78
190
|
def web_method_routes
|
79
191
|
controller.web_methods.map do |action|
|
80
192
|
link("post '#{records}/:id/#{action}(.:format)' => '#{records}##{action}', :as => '#{record}_#{action}'", action, :post)
|
81
193
|
end.compact
|
82
194
|
end
|
83
195
|
|
196
|
+
# deprecated
|
84
197
|
def show_action_routes
|
85
198
|
controller.show_actions.map do |action|
|
86
199
|
link("get '#{records}/:id/#{action}(.:format)' => '#{records}##{action}', :as => '#{record}_#{action}'", action)
|
87
200
|
end.compact
|
88
201
|
end
|
89
202
|
|
203
|
+
# deprecated
|
90
204
|
def reorder_routes
|
91
205
|
[ link("post '#{records}/reorder(.:format)', :as => 'reorder_#{records}'", 'reorder', :post) ].compact
|
92
206
|
end
|
93
207
|
|
208
|
+
# NOT deprecated
|
94
209
|
def user_routes
|
95
210
|
return [] unless controller < ::Hobo::Controller::UserBase
|
96
211
|
prefix = records == "users" ? "" : "#{record}_"
|