hobo 1.3.3 → 1.4.0.pre2
Sign up to get free protection for your applications and to get access to all the features.
- data/{CHANGES.txt → CHANGES-1.3.txt} +0 -0
- data/CHANGES-1.4.txt +678 -0
- data/Rakefile +13 -3
- data/TODO-1.4.txt +69 -0
- data/VERSION +1 -1
- data/app/helpers/hobo_debug_helper.rb +16 -0
- data/app/helpers/hobo_deprecated_helper.rb +45 -0
- data/app/helpers/hobo_helper_base.rb +8 -0
- data/app/helpers/hobo_permissions_helper.rb +136 -0
- data/app/helpers/hobo_route_helper.rb +196 -0
- data/{lib/hobo/helper/translations.rb → app/helpers/hobo_translations_helper.rb} +4 -7
- data/{lib/hobo/helper/translations/normalizer.rb → app/helpers/hobo_translations_normalizer_helper.rb} +3 -10
- data/app/helpers/hobo_type_helper.rb +24 -0
- data/app/helpers/hobo_view_hint_helper.rb +13 -0
- data/hobo.gemspec +3 -3
- data/lib/generators/hobo/admin_subsite/admin_subsite_generator.rb +0 -9
- data/lib/generators/hobo/admin_subsite/templates/application.dryml +2 -0
- data/lib/generators/hobo/admin_subsite/templates/gitkeep +0 -0
- data/lib/generators/hobo/admin_subsite/templates/site.css.erb +9 -0
- data/lib/generators/hobo/admin_subsite/templates/site.js.erb +10 -0
- data/lib/generators/hobo/assets/assets_generator.rb +16 -2
- data/lib/generators/hobo/assets/templates/application.css +9 -0
- data/lib/generators/hobo/assets/templates/application.dryml.erb +0 -5
- data/lib/generators/hobo/assets/templates/application.js +11 -0
- data/lib/generators/hobo/assets/templates/front.css +10 -0
- data/lib/generators/hobo/assets/templates/front.js +11 -0
- data/lib/generators/hobo/assets/templates/front_site.dryml.erb +6 -0
- data/lib/generators/hobo/assets/templates/gitkeep +0 -0
- data/lib/generators/hobo/dev_tweaks/dev_tweaks_generator.rb +31 -0
- data/lib/generators/hobo/i18n/templates/hobo.en.yml +1 -1
- data/lib/generators/hobo/install_plugin/USAGE +3 -0
- data/lib/generators/hobo/install_plugin/install_plugin_generator.rb +36 -0
- data/lib/generators/hobo/plugin.rb +112 -0
- data/lib/generators/hobo/setup_wizard/setup_wizard_generator.rb +31 -14
- data/lib/generators/hobo/subsite.rb +16 -2
- data/lib/generators/hobo/subsite/templates/gitkeep +0 -0
- data/lib/generators/hobo/subsite/templates/site.css.erb +9 -0
- data/lib/generators/hobo/subsite/templates/site.js.erb +10 -0
- data/lib/generators/hobo/subsite_taglib/templates/taglib.dryml.erb +0 -17
- data/lib/generators/hobo/test_framework/test_framework_generator.rb +1 -1
- data/lib/hobo.rb +3 -2
- data/lib/hobo/controller.rb +43 -24
- data/lib/hobo/controller/model.rb +63 -42
- data/lib/hobo/controller/user_base.rb +1 -3
- data/lib/hobo/engine.rb +1 -1
- data/lib/hobo/extensions/active_record/associations/association.rb +36 -0
- data/lib/hobo/extensions/active_record/associations/collection.rb +10 -19
- data/lib/hobo/extensions/active_record/associations/proxy.rb +3 -15
- data/lib/hobo/extensions/active_record/associations/scope.rb +2 -2
- data/lib/hobo/extensions/active_record/permissions.rb +32 -38
- data/lib/hobo/extensions/active_record/relation_with_origin.rb +5 -5
- data/lib/hobo/model.rb +12 -7
- data/lib/hobo/model/accessible_associations.rb +8 -15
- data/lib/hobo/model/lifecycles/creator.rb +1 -1
- data/lib/hobo/model/lifecycles/transition.rb +1 -1
- data/lib/hobo/model/permissions.rb +4 -4
- data/lib/hobo/model/scopes.rb +4 -17
- data/lib/hobo/model/scopes/automatic_scopes.rb +5 -13
- data/lib/hobo/rapid/helper.rb +1 -161
- data/lib/hobo/rapid/taglibs/rapid.dryml +3 -17
- data/test/doctest/hobo/hobo_helper.rdoctest +8 -44
- data/{doctests → test/doctest}/hobo/lifecycles.rdoctest +0 -0
- data/{doctests → test/doctest}/hobo/model.rdoctest +2 -4
- data/{doctests → test/doctest}/hobo/multi_model_forms.rdoctest +3 -24
- data/{doctests → test/doctest}/hobo/scopes.rdoctest +3 -53
- data/test/doctest/prepare_testapp.rb +11 -0
- data/test/irt/generators/admin_subsite.irt +1 -19
- data/test/irt/generators/assets.irt +4 -9
- data/test/irt/generators/controller.irt +0 -3
- data/test/irt/generators/front_controller.irt +0 -5
- data/test/irt/generators/{helper.rb → irt_helper.rb} +2 -2
- data/test/irt/generators/model.irt +1 -12
- data/test/irt/generators/partials/_account_user_model_tests.rb +0 -8
- data/test/irt/generators/partials/_accounts_users_controller_tests.rb +0 -2
- data/test/irt/generators/partials/_default_user_model_tests.rb +0 -8
- data/test/irt/generators/partials/_default_users_controller_tests.rb +0 -2
- data/test/irt/generators/partials/_house_controller_tests.rb +0 -2
- data/test/irt/generators/partials/_house_model_tests.rb +1 -9
- data/test/irt/generators/partials/_subsite_taglib_admin.rb +5 -2
- data/test/irt/generators/partials/_subsite_taglib_admin_invite_only.rb +1 -1
- data/test/irt/generators/partials/_subsite_taglib_noopt.rb +2 -2
- data/test/irt/generators/partials/_subsite_taglib_variables.rb +0 -15
- data/test/irt/generators/partials/_user_mailer_tests.rb +1 -3
- data/test/irt/generators/resource.irt +0 -3
- data/test/irt/generators/subsite.irt +6 -22
- data/test/irt/generators/subsite_taglib.irt +0 -18
- data/test/irt/generators/test_framework.irt +2 -5
- data/test/irt/generators/user_controller.irt +0 -3
- data/test/irt/generators/user_mailer.irt +0 -3
- data/test/irt/generators/user_model.irt +0 -3
- data/test/irt/generators/user_resource.irt +0 -3
- data/test/irt/readme.txt +6 -3
- metadata +116 -159
- data/app/controllers/dev_controller.rb +0 -25
- data/app/views/dev/summary.dryml +0 -102
- data/doctests/prepare_testapp.rb +0 -8
- data/lib/generators/hobo/admin_subsite/templates/admin.css +0 -20
- data/lib/generators/hobo/rapid/USAGE +0 -3
- data/lib/generators/hobo/rapid/rapid_generator.rb +0 -24
- data/lib/generators/hobo/rapid/templates/IE7.js +0 -2
- data/lib/generators/hobo/rapid/templates/blank.gif +0 -0
- data/lib/generators/hobo/rapid/templates/hobo-rapid.css +0 -94
- data/lib/generators/hobo/rapid/templates/hobo-rapid.js +0 -1015
- data/lib/generators/hobo/rapid/templates/ie7-recalc.js +0 -166
- data/lib/generators/hobo/rapid/templates/lowpro.js +0 -339
- data/lib/generators/hobo/rapid/templates/reset.css +0 -95
- data/lib/generators/hobo/rapid/templates/themes/clean/public/images/101-3B5F87-ACD3E6.png +0 -0
- data/lib/generators/hobo/rapid/templates/themes/clean/public/images/30-3E547A-242E42.png +0 -0
- data/lib/generators/hobo/rapid/templates/themes/clean/public/images/30-DBE1E5-FCFEF5.png +0 -0
- data/lib/generators/hobo/rapid/templates/themes/clean/public/images/300-ACD3E6-fff.png +0 -0
- data/lib/generators/hobo/rapid/templates/themes/clean/public/images/50-ACD3E6-fff.png +0 -0
- data/lib/generators/hobo/rapid/templates/themes/clean/public/images/fieldbg.gif +0 -0
- data/lib/generators/hobo/rapid/templates/themes/clean/public/images/pencil.png +0 -0
- data/lib/generators/hobo/rapid/templates/themes/clean/public/images/small_close.png +0 -0
- data/lib/generators/hobo/rapid/templates/themes/clean/public/images/spinner.gif +0 -0
- data/lib/generators/hobo/rapid/templates/themes/clean/public/stylesheets/clean.css +0 -327
- data/lib/generators/hobo/rapid/templates/themes/clean/public/stylesheets/rapid-ui.css +0 -102
- data/lib/generators/hobo/rapid/templates/themes/clean/views/clean.dryml +0 -10
- data/lib/hobo/helper.rb +0 -460
- data/lib/hobo/rapid/taglibs/rapid_core.dryml +0 -808
- data/lib/hobo/rapid/taglibs/rapid_document_tags.dryml +0 -56
- data/lib/hobo/rapid/taglibs/rapid_editing.dryml +0 -287
- data/lib/hobo/rapid/taglibs/rapid_forms.dryml +0 -1156
- data/lib/hobo/rapid/taglibs/rapid_generics.dryml +0 -48
- data/lib/hobo/rapid/taglibs/rapid_i18n.dryml +0 -173
- data/lib/hobo/rapid/taglibs/rapid_lifecycles.dryml +0 -96
- data/lib/hobo/rapid/taglibs/rapid_navigation.dryml +0 -108
- data/lib/hobo/rapid/taglibs/rapid_pages.dryml +0 -259
- data/lib/hobo/rapid/taglibs/rapid_plus.dryml +0 -247
- data/lib/hobo/rapid/taglibs/rapid_summary.dryml +0 -283
- data/lib/hobo/rapid/taglibs/rapid_support.dryml +0 -102
- data/lib/hobo/rapid/taglibs/rapid_user_pages.dryml +0 -182
- data/test/irt/generators/rapid.irt +0 -29
@@ -32,7 +32,7 @@ module Hobo
|
|
32
32
|
allowed = params.dup
|
33
33
|
params.each do |p|
|
34
34
|
if (refl = model.reflections[p]) && refl.macro == :belongs_to
|
35
|
-
allowed << refl.
|
35
|
+
allowed << refl.foreign_key.to_s
|
36
36
|
allowed << refl.options[:foreign_type] if refl.options[:polymorphic]
|
37
37
|
end
|
38
38
|
end
|
@@ -25,7 +25,7 @@ module Hobo
|
|
25
25
|
allowed = params.dup
|
26
26
|
params.each do |p|
|
27
27
|
if (refl = model.reflections[p]) && refl.macro == :belongs_to
|
28
|
-
allowed << refl.
|
28
|
+
allowed << refl.foreign_key.to_s
|
29
29
|
allowed << refl.options[:foreign_type] if refl.options[:polymorphic]
|
30
30
|
end
|
31
31
|
end
|
@@ -339,9 +339,9 @@ module Hobo
|
|
339
339
|
def with_attribute_or_belongs_to_keys(attribute)
|
340
340
|
if (refl = self.class.reflections[attribute.to_sym]) && refl.macro == :belongs_to
|
341
341
|
if refl.options[:polymorphic]
|
342
|
-
yield refl.
|
342
|
+
yield refl.foreign_key, refl.options[:foreign_type]
|
343
343
|
else
|
344
|
-
yield refl.
|
344
|
+
yield refl.foreign_key, nil
|
345
345
|
end
|
346
346
|
else
|
347
347
|
yield attribute.to_s, nil
|
@@ -387,7 +387,7 @@ module Hobo
|
|
387
387
|
|
388
388
|
if (refl = self.class.reflections[attr.to_sym]) && refl.macro == :belongs_to
|
389
389
|
# A belongs_to -- also unknownify the underlying fields
|
390
|
-
unknownify_attribute refl.
|
390
|
+
unknownify_attribute refl.foreign_key
|
391
391
|
unknownify_attribute refl.options[:foreign_type] if refl.options[:polymorphic]
|
392
392
|
else
|
393
393
|
# A regular field -- hack the dirty tracking methods
|
@@ -430,7 +430,7 @@ module Hobo
|
|
430
430
|
|
431
431
|
if (refl = self.class.reflections[attr]) && refl.macro == :belongs_to
|
432
432
|
# A belongs_to -- restore the underlying fields
|
433
|
-
deunknownify_attribute refl.
|
433
|
+
deunknownify_attribute refl.foreign_key
|
434
434
|
deunknownify_attribute(refl.options[:foreign_type], false) if refl.options[:polymorphic]
|
435
435
|
else
|
436
436
|
# A regular field -- restore the dirty tracking methods
|
data/lib/hobo/model/scopes.rb
CHANGED
@@ -2,12 +2,13 @@ module Hobo
|
|
2
2
|
module Model
|
3
3
|
module Scopes
|
4
4
|
|
5
|
+
::ActiveRecord::Associations::Builder::BelongsTo.valid_options << :scope
|
6
|
+
::ActiveRecord::Associations::Builder::HasMany.valid_options << :scope
|
7
|
+
::ActiveRecord::Associations::Builder::HasOne.valid_options << :scope
|
8
|
+
|
5
9
|
def self.included_in_class(klass)
|
6
10
|
klass.class_eval do
|
7
11
|
extend ClassMethods
|
8
|
-
metaclass.alias_method_chain :valid_keys_for_has_many_association, :scopes
|
9
|
-
metaclass.alias_method_chain :valid_keys_for_has_one_association, :scopes
|
10
|
-
metaclass.alias_method_chain :valid_keys_for_belongs_to_association, :scopes
|
11
12
|
end
|
12
13
|
end
|
13
14
|
|
@@ -17,20 +18,6 @@ module Hobo
|
|
17
18
|
|
18
19
|
include ApplyScopes
|
19
20
|
|
20
|
-
# --- monkey-patches to allow :scope key on has_many, has_one and belongs_to ---
|
21
|
-
|
22
|
-
def valid_keys_for_has_many_association_with_scopes
|
23
|
-
valid_keys_for_has_many_association_without_scopes + [:scope]
|
24
|
-
end
|
25
|
-
|
26
|
-
def valid_keys_for_has_one_association_with_scopes
|
27
|
-
valid_keys_for_has_one_association_without_scopes + [:scope]
|
28
|
-
end
|
29
|
-
|
30
|
-
def valid_keys_for_belongs_to_association_with_scopes
|
31
|
-
valid_keys_for_belongs_to_association_without_scopes + [:scope]
|
32
|
-
end
|
33
|
-
|
34
21
|
end
|
35
22
|
|
36
23
|
end
|
@@ -354,18 +354,18 @@ module Hobo
|
|
354
354
|
|
355
355
|
if reflection.options[:through]
|
356
356
|
join_table = reflection.through_reflection.klass.table_name
|
357
|
-
owner_fkey = reflection.through_reflection.
|
357
|
+
owner_fkey = reflection.through_reflection.foreign_key
|
358
358
|
conditions = reflection.options[:conditions].blank? ? '' : " AND #{reflection.through_reflection.klass.send(:sanitize_sql_for_conditions, reflection.options[:conditions])}"
|
359
359
|
|
360
360
|
if any
|
361
361
|
"EXISTS (SELECT * FROM #{join_table} WHERE #{join_table}.#{owner_fkey} = #{owner_primary_key}#{conditions})"
|
362
362
|
else
|
363
|
-
source_fkey = reflection.source_reflection.
|
363
|
+
source_fkey = reflection.source_reflection.foreign_key
|
364
364
|
"EXISTS (SELECT * FROM #{join_table} " +
|
365
365
|
"WHERE #{join_table}.#{source_fkey} = ? AND #{join_table}.#{owner_fkey} = #{owner_primary_key}#{conditions})"
|
366
366
|
end
|
367
367
|
else
|
368
|
-
foreign_key = reflection.
|
368
|
+
foreign_key = reflection.foreign_key
|
369
369
|
related = reflection.klass
|
370
370
|
conditions = reflection.options[:conditions].blank? ? '' : " AND #{reflection.klass.send(:sanitize_sql_for_conditions, reflection.options[:conditions])}"
|
371
371
|
|
@@ -401,15 +401,7 @@ module Hobo
|
|
401
401
|
|
402
402
|
|
403
403
|
def def_scope(&block)
|
404
|
-
|
405
|
-
@klass.scope _name, (lambda &block)
|
406
|
-
# this is tricky; ordinarily, we'd worry about subclasses that haven't yet been loaded.
|
407
|
-
# HOWEVER, they will pick up the scope setting via read_inheritable_attribute when they do
|
408
|
-
# load, so only the currently existing subclasses need to be fixed up.
|
409
|
-
_scope = @klass.scopes[_name]
|
410
|
-
@klass.send(:descendants).each do |k|
|
411
|
-
k.scopes[_name] = _scope
|
412
|
-
end
|
404
|
+
@klass.scope name.to_sym, (lambda &block)
|
413
405
|
end
|
414
406
|
|
415
407
|
|
@@ -419,7 +411,7 @@ module Hobo
|
|
419
411
|
|
420
412
|
|
421
413
|
def foreign_key_column(refl)
|
422
|
-
"#{@klass.table_name}.#{refl.
|
414
|
+
"#{@klass.table_name}.#{refl.foreign_key}"
|
423
415
|
end
|
424
416
|
|
425
417
|
end
|
data/lib/hobo/rapid/helper.rb
CHANGED
@@ -1,167 +1,7 @@
|
|
1
1
|
module Hobo
|
2
2
|
module Rapid
|
3
3
|
module Helper
|
4
|
-
|
5
|
-
def comma_split(x)
|
6
|
-
case x
|
7
|
-
when nil
|
8
|
-
[]
|
9
|
-
when String
|
10
|
-
x.strip.split(/\s*,\s*/)
|
11
|
-
else
|
12
|
-
x.compact.map{|e| comma_split(e)}.flatten
|
13
|
-
end
|
14
|
-
end
|
15
|
-
|
16
|
-
def rapid_build_callbacks(options)
|
17
|
-
callbacks = {}
|
18
|
-
options.each do |callback, code|
|
19
|
-
if AJAX_CALLBACKS.include?(callback.to_sym)
|
20
|
-
name = 'on' + callback.to_s.capitalize
|
21
|
-
callbacks[name] = "function(request){#{code}}"
|
22
|
-
end
|
23
|
-
end
|
24
|
-
callbacks
|
25
|
-
end
|
26
|
-
|
27
|
-
|
28
|
-
def options_for_hobo_ajax(options)
|
29
|
-
js_options = rapid_build_callbacks(options)
|
30
|
-
|
31
|
-
js_options['asynchronous'] = false if options[:type] == :synchronous
|
32
|
-
js_options['method'] = method_option_to_s(options[:method]) if options[:method]
|
33
|
-
js_options['evalScripts'] = false if options[:script] == false
|
34
|
-
js_options['form'] = options[:form] if options[:form]
|
35
|
-
js_options['params'] = make_params_js(options[:params]) if options[:params]
|
36
|
-
js_options['resultUpdate'] = js_result_updates(options[:result_update]) if options[:result_update]
|
37
|
-
js_options['resetForm'] = options[:reset_form] if options.has_key?(:reset_form)
|
38
|
-
js_options['refocusForm'] = options[:refocus_form] if options.has_key?(:refocus_form)
|
39
|
-
js_options['spinnerNextTo'] = js_str(options[:spinner_next_to]) if options.has_key?(:spinner_next_to)
|
40
|
-
js_options['message'] = js_str(options[:message]) if options[:message]
|
41
|
-
|
42
|
-
js_options.empty? ? nil : options_for_javascript(js_options)
|
43
|
-
end
|
44
|
-
|
45
|
-
|
46
|
-
def js_updates(updates)
|
47
|
-
return '[]' unless updates
|
48
|
-
updates = [updates] unless updates.is_a? Array
|
49
|
-
updates = comma_split(updates).map do |u|
|
50
|
-
if u.to_s == "self"
|
51
|
-
"Hobo.partFor(this)"
|
52
|
-
else
|
53
|
-
js_str(u)
|
54
|
-
end
|
55
|
-
end
|
56
|
-
"[#{updates * ', '}]"
|
57
|
-
end
|
58
|
-
|
59
|
-
|
60
|
-
def js_result_updates(updates)
|
61
|
-
return '[]' unless updates
|
62
|
-
updates = [updates] unless updates.is_a? Array
|
63
|
-
pairs = comma_split(updates).map &it.split(/\s*=\s*/)
|
64
|
-
'[' + pairs.map{|p| "{id: #{js_str(p[0])}, result: #{js_str(p[1])}}"}.join(", ") + ']'
|
65
|
-
end
|
66
|
-
|
67
|
-
|
68
|
-
def ajax_updater(url_or_form, update, options={})
|
69
|
-
options ||= {}
|
70
|
-
options = options.symbolize_keys
|
71
|
-
|
72
|
-
target = if url_or_form == :post_form
|
73
|
-
target = "this"
|
74
|
-
else
|
75
|
-
js_str(url_or_form)
|
76
|
-
end
|
77
|
-
js_options = options_for_hobo_ajax(options)
|
78
|
-
args = [target, js_updates(update), js_options].compact
|
79
|
-
|
80
|
-
confirm = options.delete(:confirm)
|
81
|
-
|
82
|
-
func = "Hobo.ajaxRequest(#{args * ', '})"
|
83
|
-
if confirm
|
84
|
-
"if (confirm(#{js_str(confirm)})) { #{func} }"
|
85
|
-
else
|
86
|
-
func
|
87
|
-
end
|
88
|
-
end
|
89
|
-
|
90
|
-
|
91
|
-
def a_or_an(word)
|
92
|
-
if word =~ /^[aeiouh]/
|
93
|
-
"an #{word}"
|
94
|
-
else
|
95
|
-
"a #{word}"
|
96
|
-
end
|
97
|
-
end
|
98
|
-
|
99
|
-
|
100
|
-
def no_break(s)
|
101
|
-
s = new_context { yield } if block_given?
|
102
|
-
s.gsub(' ', ' ')
|
103
|
-
end
|
104
|
-
|
105
|
-
# returns the number of items in the collection. See LH #889
|
106
|
-
def collection_count
|
107
|
-
this.try.to_int || this.try.total_entries || (this.try.loaded? && this.try.length) || this.try.count || this.try.length
|
108
|
-
end
|
109
|
-
|
110
|
-
|
111
|
-
def in_place_editor(attributes, this=nil)
|
112
|
-
blank_message = attributes.delete(:blank_message) ||
|
113
|
-
t('hobo.in_place_editor.click_to_edit', :default => '(click to edit)')
|
114
|
-
|
115
|
-
attributes = add_classes(attributes, "in-place-edit", model_id_class(this_parent, this_field))
|
116
|
-
attributes.update(:hobo_blank_message => blank_message,
|
117
|
-
:if_blank => blank_message,
|
118
|
-
:no_wrapper => false)
|
119
|
-
|
120
|
-
edit_text = this._?.to_s
|
121
|
-
attributes.update(:hobo_edit_text => edit_text) unless edit_text.nil?
|
122
|
-
|
123
|
-
if update = attributes.delete(:update)
|
124
|
-
attributes = add_classes(attributes, update_elements_class(update))
|
125
|
-
end
|
126
|
-
|
127
|
-
view(attributes)
|
128
|
-
end
|
129
|
-
|
130
|
-
|
131
|
-
|
132
|
-
AJAX_CALLBACKS = [ :success, :failure, :complete ]
|
133
|
-
|
134
|
-
AJAX_ATTRS = AJAX_CALLBACKS + [ :update, :type, :method,
|
135
|
-
:script, :form, :params, :confirm, :message,
|
136
|
-
:reset_form, :refocus_form, :result_update, :spinner_next_to ]
|
137
|
-
|
138
|
-
|
139
|
-
def through_collection_names(object=this)
|
140
|
-
object.class.reflections.values.select do |refl|
|
141
|
-
refl.macro == :has_many && refl.options[:through]
|
142
|
-
end.map {|x| x.options[:through]}
|
143
|
-
end
|
144
|
-
|
145
|
-
|
146
|
-
def non_through_collections(object=this)
|
147
|
-
names = object.class.reflections.values.select do |refl|
|
148
|
-
refl.macro == :has_many
|
149
|
-
end.*.name
|
150
|
-
|
151
|
-
names - through_collection_names
|
152
|
-
end
|
153
|
-
|
154
|
-
def standard_fields(model, include_timestamps=false)
|
155
|
-
fields = model.attr_order.*.to_s & model.content_columns.*.name
|
156
|
-
fields -= %w{created_at updated_at created_on updated_on deleted_at} unless include_timestamps
|
157
|
-
fields.reject! { |f| model.never_show? f }
|
158
|
-
fields
|
159
|
-
end
|
160
|
-
|
161
|
-
def current_time
|
162
|
-
Time.zone ? Time.zone.now : Time.now
|
163
|
-
end
|
164
|
-
|
4
|
+
# functions have moved to HoboRapidHelper
|
165
5
|
end
|
166
6
|
end
|
167
7
|
end
|
@@ -1,25 +1,11 @@
|
|
1
1
|
<!--
|
2
2
|
|
3
|
+
Hobo rapid has moved into its own gem.
|
4
|
+
|
3
5
|
The Rapid tag library makes web development go fast. The Rapid tag library is your friend.
|
4
6
|
|
5
7
|
(This taglib defines no tags - it just includes all the other taglibs. Move along. Nothing to see here.)
|
6
8
|
|
7
9
|
-->
|
8
10
|
|
9
|
-
<include
|
10
|
-
<include module="Hobo::Rapid::Helper"/>
|
11
|
-
<include module="Hobo::Helper::Translations"/>
|
12
|
-
|
13
|
-
<include src="rapid_core"/>
|
14
|
-
<include src="rapid_support"/>
|
15
|
-
<include src="rapid_document_tags"/>
|
16
|
-
<include src="rapid_pages"/>
|
17
|
-
<include src="rapid_editing"/>
|
18
|
-
<include src="rapid_forms"/>
|
19
|
-
<include src="rapid_navigation"/>
|
20
|
-
<include src="rapid_plus"/>
|
21
|
-
<include src="rapid_generics"/>
|
22
|
-
<include src="rapid_lifecycles"/>
|
23
|
-
<include src="rapid_summary"/>
|
24
|
-
<include src="rapid_user_pages"/>
|
25
|
-
<include src="rapid_i18n"/>
|
11
|
+
<% Rails.logger.warn '<include src="rapid" plugin="hobo"/> should be replaced with <include gem="hobo_rapid"/>' %>
|
@@ -1,19 +1,13 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
Various view helpers
|
1
|
+
doctest: prepare testapp environment
|
2
|
+
doctest_require: '../prepare_testapp'
|
4
3
|
|
5
|
-
|
6
|
-
doctest_require: 'active_support'
|
7
|
-
doctest_require: 'mocha'
|
8
|
-
doctest_require: '../../../hobo_support/lib/hobo_support'
|
9
|
-
doctest_require: '../../../hobo_fields/lib/hobo_fields'
|
10
|
-
doctest_require: '../../lib/hobo'
|
4
|
+
# Hobo::Helper
|
11
5
|
|
12
6
|
Create a mock view layer:
|
13
7
|
|
14
8
|
>>
|
15
9
|
class View
|
16
|
-
extend
|
10
|
+
extend HoboRouteHelper
|
17
11
|
class << self
|
18
12
|
protected_instance_methods.each {|m| public m }
|
19
13
|
|
@@ -22,19 +16,11 @@ Create a mock view layer:
|
|
22
16
|
def base_url; "" ;end
|
23
17
|
end
|
24
18
|
end
|
25
|
-
>> Rails.root = "test-app"
|
26
19
|
|
27
20
|
Useful stuff
|
28
21
|
|
29
22
|
>> def init_mocha; $stubba = Mocha::Central.new; end
|
30
|
-
>>
|
31
|
-
class Thing
|
32
|
-
class Mocks; extend Mocha::AutoVerify; end
|
33
|
-
def self.mock(hash)
|
34
|
-
Mocks.mock(hash.update(:class => self))
|
35
|
-
end
|
36
|
-
end
|
37
|
-
|
23
|
+
>> def mock; Mocha::Mockery.instance.named_mock 'mock'; end
|
38
24
|
|
39
25
|
## `object_url`
|
40
26
|
|
@@ -45,7 +31,9 @@ Note that `object_url` doesn't perform "reverse routing". It knows nothing about
|
|
45
31
|
Something to link to:
|
46
32
|
|
47
33
|
>> init_mocha
|
48
|
-
>>
|
34
|
+
>> class Thing; end
|
35
|
+
>> thing = Thing.new
|
36
|
+
>> thing.expects(:to_url_path).at_least_once.returns("things/1")
|
49
37
|
|
50
38
|
### Simple 'show' URLs
|
51
39
|
|
@@ -66,27 +54,3 @@ A URL to the 'edit' page:
|
|
66
54
|
=> "/things/1/edit"
|
67
55
|
|
68
56
|
|
69
|
-
### POST URLs for creating new items in collections:
|
70
|
-
|
71
|
-
>> collection = mock(:origin => thing, :origin_attribute => "parts")
|
72
|
-
>> Hobo::Routes.expects(:linkable?).with(Thing, :create_part, {:subsite => '', :method => :post}).returns(true)
|
73
|
-
>> View.object_url(collection, :method => :post)
|
74
|
-
=> "/things/1/parts"
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
File without changes
|
@@ -52,10 +52,8 @@ declaration:
|
|
52
52
|
|
53
53
|
end
|
54
54
|
|
55
|
-
$ rails generate hobo:migration -n -m
|
56
|
-
|
57
55
|
>> Rails::Generators.invoke 'hobo:migration', %w(-n -m)
|
58
|
-
>> Post.all
|
56
|
+
>> Post.connection.execute 'select * from posts' # Post.all was breaking : /
|
59
57
|
=> []
|
60
58
|
{.hidden}
|
61
59
|
|
@@ -133,7 +131,7 @@ object. In this case, you can provide your own name method instead:
|
|
133
131
|
$ rails generate hobo:migration -n -m
|
134
132
|
|
135
133
|
>> Rails::Generators.invoke 'hobo:migration', %w(-n -m)
|
136
|
-
>> Person.
|
134
|
+
>> Person.connection.execute 'select * from people'
|
137
135
|
=> []
|
138
136
|
{.hidden}
|
139
137
|
|
@@ -11,30 +11,9 @@ Contents
|
|
11
11
|
- contents
|
12
12
|
{:toc}
|
13
13
|
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
>> require 'action_pack'
|
18
|
-
>> require 'action_view'
|
19
|
-
>> require 'action_controller'
|
20
|
-
>> mysql_adapter = defined?(JRUBY_VERSION) ? 'jdbcmysql' : 'mysql'
|
21
|
-
>> mysql_user = 'root'; mysql_password = ''
|
22
|
-
>> mysql_login = "-u #{mysql_user} --password='#{mysql_password}'"
|
23
|
-
>> mysql_database = "hobo_fields_doctest"
|
24
|
-
>> system "mysqladmin #{mysql_login} --force drop #{mysql_database} 2> /dev/null"
|
25
|
-
>> system("mysqladmin #{mysql_login} create #{mysql_database}") or raise "could not create database"
|
26
|
-
>> ActiveRecord::Base.establish_connection(:adapter => mysql_adapter,
|
27
|
-
:database => mysql_database,
|
28
|
-
:host => "localhost",
|
29
|
-
:username => mysql_user,
|
30
|
-
:password => mysql_password)
|
31
|
-
>> $:.unshift File.expand_path('../../../../hobo_support/lib', __FILE__)
|
32
|
-
>> $:.unshift File.expand_path('../../../../hobo_fields/lib', __FILE__)
|
33
|
-
>> $:.unshift File.expand_path('../../../../dryml/lib', __FILE__)
|
34
|
-
>> $:.unshift File.expand_path('../../../lib', __FILE__)
|
35
|
-
>> gem 'will_paginate', ">= 3.0.pre"
|
36
|
-
>> require 'will_paginate'
|
37
|
-
>> require 'hobo'
|
14
|
+
doctest: prepare testapp environment
|
15
|
+
doctest_require: '../prepare_testapp'
|
16
|
+
|
38
17
|
>> ActiveRecord::Base.logger = ActiveSupport::BufferedLogger.new(StringIO.new(''))
|
39
18
|
>>
|
40
19
|
def migrate(renames={})
|