hobo 0.8.2 → 0.8.3

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.
Files changed (41) hide show
  1. data/CHANGES.txt +131 -0
  2. data/Manifest +1 -2
  3. data/Rakefile +3 -3
  4. data/dryml_generators/rapid/cards.dryml.erb +1 -1
  5. data/dryml_generators/rapid/forms.dryml.erb +3 -1
  6. data/dryml_generators/rapid/pages.dryml.erb +8 -5
  7. data/hobo.gemspec +8 -8
  8. data/lib/active_record/association_collection.rb +5 -2
  9. data/lib/active_record/association_reflection.rb +14 -5
  10. data/lib/hobo.rb +1 -1
  11. data/lib/hobo/controller.rb +6 -5
  12. data/lib/hobo/dryml.rb +4 -4
  13. data/lib/hobo/dryml/taglib.rb +7 -3
  14. data/lib/hobo/dryml/template_environment.rb +7 -7
  15. data/lib/hobo/hobo_helper.rb +31 -15
  16. data/lib/hobo/include_in_save.rb +9 -1
  17. data/lib/hobo/lifecycles.rb +0 -7
  18. data/lib/hobo/lifecycles/creator.rb +1 -1
  19. data/lib/hobo/lifecycles/lifecycle.rb +8 -3
  20. data/lib/hobo/mass_assignment.rb +64 -0
  21. data/lib/hobo/model.rb +41 -17
  22. data/lib/hobo/model_controller.rb +76 -25
  23. data/lib/hobo/model_router.rb +10 -13
  24. data/lib/hobo/user.rb +13 -13
  25. data/rails_generators/hobo_model/hobo_model_generator.rb +4 -0
  26. data/rails_generators/hobo_model/templates/model.rb +1 -1
  27. data/rails_generators/hobo_rapid/hobo_rapid_generator.rb +0 -2
  28. data/rails_generators/hobo_rapid/templates/hobo-rapid.js +180 -43
  29. data/rails_generators/hobo_rapid/templates/themes/clean/public/stylesheets/clean.css +25 -4
  30. data/rails_generators/hobo_rapid/templates/themes/clean/public/stylesheets/rapid-ui.css +0 -2
  31. data/taglibs/core.dryml +8 -5
  32. data/taglibs/rapid.dryml +9 -5
  33. data/taglibs/rapid_document_tags.dryml +1 -1
  34. data/taglibs/rapid_editing.dryml +1 -1
  35. data/taglibs/rapid_forms.dryml +108 -32
  36. data/taglibs/rapid_generics.dryml +2 -2
  37. data/taglibs/rapid_lifecycles.dryml +0 -18
  38. data/taglibs/rapid_user_pages.dryml +8 -41
  39. metadata +7 -7
  40. data/rails_generators/hobo_rapid/templates/nicEditorIcons.gif +0 -0
  41. data/rails_generators/hobo_rapid/templates/nicedit.js +0 -91
@@ -1,3 +1,134 @@
1
+ === Hobo 0.8.3 ===
2
+
3
+ Hobo models -- improvements to logic for validating passwords. Closes #281
4
+
5
+ Hobo users -- simpler definition of account_active?
6
+
7
+ This assumes the user has the default lifecycle or similar. If the lifecycle is cusomtised this method can be overridden
8
+
9
+ Lifecycles -- Make current creator/transition available as lifecycle.active_step
10
+
11
+ Lifecycles -- user a safer name for methods to test if the lifecycle is in a given state
12
+
13
+ Now record.lifecycle.is_active? instead of record.lifecycle.active?
14
+
15
+ Lifecycles -- become method should not polute AR namespace (use lifecycle.become)
16
+
17
+ Models -- to_param should always return a string. Closes #280
18
+
19
+ Rapid -- <login-page> -- "remember me" is now on by default
20
+
21
+ Fixed typo in <forgot-password-page>. Thanks to Jakub Suder
22
+
23
+ Fixes and Clean theme improvements for site-wide live-search. Closes #290
24
+
25
+ Removing hobo_spec - test will live in hobo/test, hobofields/test as is normal
26
+
27
+ Adding close button (also, keyboard = ESC) to live-search popup
28
+
29
+ Models -- classes for polymorphic assciations (e.g. Tagging::ble) are now automatically created instead of blowing up when
30
+ calling reflection.klass. Closes #83
31
+
32
+ Removed nicedit - we've moved to a plugin based system for rich editors now (see github.com/tablatom/hoboyui)
33
+
34
+ Rapid -- the select menus in <select-many> now observe conditions applied to the has_many :through
35
+
36
+ Rapid -- fix to double-escaping of names in <select-one>
37
+
38
+ merge-attrs on <section-group>
39
+
40
+ Rapid -- added if-present attribute to <name> to supress the nil-view if there is no name
41
+
42
+ Used in <name-one> to ensure the input box is blank
43
+
44
+ Improved support for validation in multi-model-forms
45
+
46
+ Added support for owner actions where the owner is a has_many :through (was only for :belongs_to owners)
47
+
48
+ Rapid -- improvements to index-for-owner page
49
+
50
+ Rapid -- renamed <card> parameter from 'description' to 'content'
51
+
52
+ Rapid -- adding multipart attribute to <form>. Usage: <form multipart>
53
+
54
+ Model Controller -- fix to :redirect option for hobo actions
55
+
56
+ DRYML -- fix to dom_id helper when this_parent is a collection
57
+
58
+ Model Controller -- improved remember_page_path to also remember the query string
59
+
60
+ Rapid - fix to <remote-method-button> -- the confirm attribute was incorrectly changing the button into an ajax button
61
+
62
+ Rapid -- <select-menu> now supports an array of label/value pairs, like the options_for_select helper
63
+
64
+ Model Controller -- Now remembers the previous page path in the session and uses this to fix a problem with
65
+ <after-submit stay-here/> (occured after a validation error)
66
+
67
+ New tag <input-all> for situations where you want input for every item in an existing collection (without the +/- buttons that
68
+ <input-many> has)
69
+
70
+ HoboSupport -- enum.rest now returns [] for an empty enumerable (was nil)
71
+
72
+ Rapid + DRYML -- recfactoring the way DRYML keep track of which form field names.
73
+
74
+ It's now possible to track these for a sub-object by setting a new scoped variable form_field_names
75
+
76
+ Rapid -- enhancements to <name-one>:
77
+
78
+ - sensible defaults for complete-target and completer
79
+ (you can now use <name-one> as a drop-in replacement for <select-one>
80
+
81
+ - The <name> of the referenced object is included in the input box if there is one
82
+
83
+ Rapid -- improved grammar (use of 'a' or 'an') in <select-many>
84
+
85
+ Model controller autocompleter enhancement -- you can ommit the name of the autocompleter, in which case it defaults to the
86
+ model's name_attribute
87
+
88
+ Hobo Model -- more robust handling of date hashes
89
+
90
+ Support in Rapid and javascript for <input-many>
91
+
92
+ It's now very easy to embed form fields for items in a has_many collection.
93
+ These use javascript + and - buttons, but this does not use ajax.
94
+
95
+ Hobo models -- improved support for mass assignment to has_many associations.
96
+
97
+ Any has_many association can now be assigned a hash. The keys are *only* for ordering purposes.
98
+ The values are themsleves hashes of attributes.
99
+ New records are created for any such hash that has no :id key
100
+
101
+ Hobo model -- fix to has_one extension (was discarding the block)
102
+
103
+ DRYML - New behaviour for context_map (repeat):
104
+ this_field is now the index (0 based) when iterating over a collection.
105
+ New helpers (HoboHelper) first_item? and last_item?
106
+
107
+ DRYML - fix to loading of nested taglibs
108
+
109
+ Rapid user pages -- don't show forgot-password link if the route is not present
110
+
111
+ <empty-collection-message> should use <div> instead of <p>, otherwise block level elements won't be allowed inside and Firefox
112
+ will sometimes treat them as if they are outside
113
+
114
+ Rapid page generators -- added param to <field-names-where-true> on <show-page>
115
+
116
+ DRYML - fix to using <extend> in a taglib included by a taglib
117
+
118
+ Migration generator -- convert spaces to _ when responding to rename questions
119
+
120
+ Rapid user pages -- made forgot-password link a param
121
+
122
+ hobo_model generator -- formatting improvement
123
+
124
+ Model Controller -- new :redirect option for controller actions
125
+
126
+ Use the rails 'pick_template' mechanism to determine the correct template path when rendering a DRYML view
127
+
128
+ Rapid generators -- adding missing <error-messages/> tags to lifecycle forms
129
+
130
+
131
+
1
132
  === Hobo 0.8.2 ===
2
133
 
3
134
  Hobo models -- improvement to name-in-URL (#to_param)
data/Manifest CHANGED
@@ -45,6 +45,7 @@ lib/hobo/lifecycles/lifecycle.rb
45
45
  lib/hobo/lifecycles/state.rb
46
46
  lib/hobo/lifecycles/transition.rb
47
47
  lib/hobo/lifecycles.rb
48
+ lib/hobo/mass_assignment.rb
48
49
  lib/hobo/model.rb
49
50
  lib/hobo/model_controller.rb
50
51
  lib/hobo/model_router.rb
@@ -96,8 +97,6 @@ rails_generators/hobo_rapid/templates/hobo-rapid.css
96
97
  rails_generators/hobo_rapid/templates/hobo-rapid.js
97
98
  rails_generators/hobo_rapid/templates/IE7.js
98
99
  rails_generators/hobo_rapid/templates/lowpro.js
99
- rails_generators/hobo_rapid/templates/nicedit.js
100
- rails_generators/hobo_rapid/templates/nicEditorIcons.gif
101
100
  rails_generators/hobo_rapid/templates/reset.css
102
101
  rails_generators/hobo_rapid/templates/themes/clean/public/images/fieldbg.gif
103
102
  rails_generators/hobo_rapid/templates/themes/clean/public/images/pencil.png
data/Rakefile CHANGED
@@ -42,11 +42,11 @@ Echoe.new('hobo') do |p|
42
42
  p.project = "hobo"
43
43
 
44
44
  p.changelog = "CHANGES.txt"
45
- p.version = "0.8.2"
45
+ p.version = "0.8.3"
46
46
 
47
47
  p.dependencies = [
48
- 'hobosupport >=0.8.2',
49
- 'hobofields >=0.8.2',
48
+ 'hobosupport >=0.8.3',
49
+ 'hobofields >=0.8.3',
50
50
  'rails >=2.1',
51
51
  'mislav-will_paginate >=2.2.1']
52
52
 
@@ -37,7 +37,7 @@ has_body = (!show_link && content_attribute) || creator_link || creator_attri
37
37
  <% if has_body -%>
38
38
  <body: param>
39
39
  <% if !show_link && content_attribute -%>
40
- <view:<%= content_attribute %> param="description"/>
40
+ <view:<%= content_attribute %> param="content"/>
41
41
  <% end -%>
42
42
  <% if creator_link -%>
43
43
  <a:<%= creator_attribute %> param="creator-link"/>
@@ -7,7 +7,7 @@ cancel_to_index_page = !cancel_to_index_page && linkable?(:index)
7
7
  -%>
8
8
  <def tag="form" for="<%= model.name %>">
9
9
  <form merge param="default">
10
- <error-messages/>
10
+ <error-messages param/>
11
11
  <field-list fields="<%= form_fields * ', ' %>" param/>
12
12
  <div param="actions">
13
13
  <submit label="Save" param/><or-cancel param="cancel"/>
@@ -20,6 +20,7 @@ cancel_to_index_page = !cancel_to_index_page && linkable?(:index)
20
20
  <def tag="<%= creator.name.dasherize %>-form" polymorphic/>
21
21
  <def tag="<%= creator.name.dasherize %>-form" for="<%= model.name %>">
22
22
  <form lifecycle="<%= creator.name %>">
23
+ <error-messages param/>
23
24
  <field-list fields="<%= creator.parameters * ', ' %>" param/>
24
25
  <div param="actions">
25
26
  <submit label="<%= creator.name.titleize %>" param/><or-cancel param="cancel"/>
@@ -32,6 +33,7 @@ cancel_to_index_page = !cancel_to_index_page && linkable?(:index)
32
33
  <def tag="<%= transition.name.dasherize %>-form" polymorphic/>
33
34
  <def tag="<%= transition.name.dasherize %>-form" for="<%= model.name %>">
34
35
  <form lifecycle="<%= transition.name %>">
36
+ <error-messages param/>
35
37
  <input type="hidden" name="key" value="&this.lifecycle.provided_key" if="&this.lifecycle.provided_key"/>
36
38
  <field-list fields="<%= transition.parameters * ', ' %>" param/>
37
39
  <div param="actions">
@@ -97,7 +97,7 @@ end
97
97
  <h2 param="heading"><name/></h2>
98
98
  <% if boolean_fields.any? -%>
99
99
 
100
- <field-names-where-true fields="<%= boolean_fields * ', ' %>"/>
100
+ <field-names-where-true fields="<%= boolean_fields * ', ' %>" param/>
101
101
  <% end -%>
102
102
  <% if creator_link -%>
103
103
 
@@ -176,8 +176,10 @@ name_attribute = model.name_attribute
176
176
  <%
177
177
  collection_name = model.reverse_reflection(owner).name.to_s
178
178
  owner_model = model.reflections[owner].klass
179
- owner_tag = linkable?(owner_model, :show) ? "a" : "name"
180
- owner = owner.to_s
179
+ linkable_owner = linkable?(owner_model, :show)
180
+ owner_tag = linkable_owner ? "a" : "name"
181
+
182
+ owner = model.reflections[owner].macro == :has_many ? owner.to_s.singularize : owner.to_s
181
183
  -%>
182
184
  <% if :index.in? actions -%>
183
185
  <%
@@ -185,13 +187,14 @@ new_link = :new.in?(actions)
185
187
  -%>
186
188
  <def tag="index-for-<%= owner.dasherize %>-page" polymorphic/>
187
189
  <def tag="index-for-<%= owner.dasherize %>-page" for="<%= model.name %>">
188
- <page merge title="<%= model_name :title, :plural %> for #{name :with => @<%= owner %>}">
190
+ <page merge title="<%= model_name :title, :plural %> for #{name :with => @<%= owner %>, :no_wrapper => true}">
189
191
  <body: class="index-for-owner-page <%= owner.dasherize %> <%= model_class %>" param/>
190
192
 
191
193
  <content: param>
192
194
  <header param="content-header">
193
- <div param="back-to">Back to <a with="&@<%= owner %>"/></div>
195
+ <% if linkable_owner %><div param="back-to">Back to <a with="&@<%= owner %>"/></div><% end %>
194
196
  <h2 param="heading"><%= model_name :title, :plural %></h2>
197
+ <h3 param="subheading">For: <<%= owner_tag %> with="&@<%= owner %>"/></h3>
195
198
 
196
199
  <p param="count" if>There <count prefix="are"/></p>
197
200
  </header>
@@ -1,18 +1,18 @@
1
1
 
2
- # Gem::Specification for Hobo-0.8.2
2
+ # Gem::Specification for Hobo-0.8.3
3
3
  # Originally generated by Echoe
4
4
 
5
5
  --- !ruby/object:Gem::Specification
6
6
  name: hobo
7
7
  version: !ruby/object:Gem::Version
8
- version: 0.8.2
8
+ version: 0.8.3
9
9
  platform: ruby
10
10
  authors:
11
11
  - Tom Locke
12
12
  autorequire:
13
13
  bindir: bin
14
14
 
15
- date: 2008-09-14 00:00:00 +01:00
15
+ date: 2008-10-15 00:00:00 +01:00
16
16
  default_executable:
17
17
  dependencies:
18
18
  - !ruby/object:Gem::Dependency
@@ -23,7 +23,7 @@ dependencies:
23
23
  requirements:
24
24
  - - ">="
25
25
  - !ruby/object:Gem::Version
26
- version: 0.8.2
26
+ version: 0.8.3
27
27
  version:
28
28
  - !ruby/object:Gem::Dependency
29
29
  name: hobofields
@@ -33,7 +33,7 @@ dependencies:
33
33
  requirements:
34
34
  - - ">="
35
35
  - !ruby/object:Gem::Version
36
- version: 0.8.2
36
+ version: 0.8.3
37
37
  version:
38
38
  - !ruby/object:Gem::Dependency
39
39
  name: rails
@@ -104,6 +104,7 @@ extra_rdoc_files:
104
104
  - lib/hobo/lifecycles/state.rb
105
105
  - lib/hobo/lifecycles/transition.rb
106
106
  - lib/hobo/lifecycles.rb
107
+ - lib/hobo/mass_assignment.rb
107
108
  - lib/hobo/model.rb
108
109
  - lib/hobo/model_controller.rb
109
110
  - lib/hobo/model_router.rb
@@ -174,6 +175,7 @@ files:
174
175
  - lib/hobo/lifecycles/state.rb
175
176
  - lib/hobo/lifecycles/transition.rb
176
177
  - lib/hobo/lifecycles.rb
178
+ - lib/hobo/mass_assignment.rb
177
179
  - lib/hobo/model.rb
178
180
  - lib/hobo/model_controller.rb
179
181
  - lib/hobo/model_router.rb
@@ -225,8 +227,6 @@ files:
225
227
  - rails_generators/hobo_rapid/templates/hobo-rapid.js
226
228
  - rails_generators/hobo_rapid/templates/IE7.js
227
229
  - rails_generators/hobo_rapid/templates/lowpro.js
228
- - rails_generators/hobo_rapid/templates/nicedit.js
229
- - rails_generators/hobo_rapid/templates/nicEditorIcons.gif
230
230
  - rails_generators/hobo_rapid/templates/reset.css
231
231
  - rails_generators/hobo_rapid/templates/themes/clean/public/images/fieldbg.gif
232
232
  - rails_generators/hobo_rapid/templates/themes/clean/public/images/pencil.png
@@ -296,7 +296,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
296
296
  version:
297
297
  required_rubygems_version: !ruby/object:Gem::Requirement
298
298
  requirements:
299
- - - "="
299
+ - - ">="
300
300
  - !ruby/object:Gem::Version
301
301
  version: "1.2"
302
302
  version:
@@ -34,7 +34,8 @@ module ActiveRecord
34
34
 
35
35
 
36
36
  def proxy_respond_to_with_automatic_scopes?(method, include_priv = false)
37
- proxy_respond_to_without_automatic_scopes?(method, include_priv) || create_automatic_scope(method)
37
+ proxy_respond_to_without_automatic_scopes?(method, include_priv) ||
38
+ (@reflection.klass.create_automatic_scope(method) if @reflection.klass.respond_to?(:create_automatic_scope))
38
39
  end
39
40
  alias_method_chain :proxy_respond_to?, :automatic_scopes
40
41
 
@@ -42,7 +43,9 @@ module ActiveRecord
42
43
  private
43
44
 
44
45
  def set_reverse_association(object)
45
- if @owner.new_record? && (refl = @owner.class.reverse_reflection(@reflection.name))
46
+ if @owner.new_record? &&
47
+ (refl = @owner.class.reverse_reflection(@reflection.name)) &&
48
+ refl.macro == :belongs_to
46
49
  bta = ActiveRecord::Associations::BelongsToAssociation.new(object, refl)
47
50
  bta.replace(@owner)
48
51
  object.instance_variable_set("@#{refl.name}", bta)
@@ -2,10 +2,19 @@ class ActiveRecord::Reflection::AssociationReflection
2
2
 
3
3
  alias_method :association_name, :name
4
4
 
5
- def safe_class
6
- klass
7
- rescue NameError
8
- nil
5
+ def klass_with_create_polymorphic_class
6
+ if options[:polymorphic]
7
+ begin
8
+ klass_without_create_polymorphic_class
9
+ rescue NameError => e
10
+ name = "#{active_record.name}::#{class_name}"
11
+ Object.class_eval "class #{name}; end"
12
+ active_record.const_get class_name
13
+ end
14
+ else
15
+ klass_without_create_polymorphic_class
16
+ end
9
17
  end
10
-
18
+ alias_method_chain :klass, :create_polymorphic_class
19
+
11
20
  end
@@ -26,7 +26,7 @@ class HoboError < RuntimeError; end
26
26
 
27
27
  module Hobo
28
28
 
29
- VERSION = "0.8.2"
29
+ VERSION = "0.8.3"
30
30
 
31
31
  class RawJs < String; end
32
32
 
@@ -133,14 +133,15 @@ module Hobo
133
133
  tag_renderer.send(name, options)
134
134
  end
135
135
 
136
-
136
+ NO_SEARCH_RESULTS_HTML = "<p>Your search returned no matches.</p>"
137
137
  def site_search(query)
138
- results = Hobo.find_by_search(query).select{|r| Hobo.can_view?(current_user, r, nil)}
139
- if results.empty?
140
- render :text => "<p>Your search returned no matches.</p>"
138
+ results_hash = Hobo.find_by_search(query)
139
+ all_results = results_hash.values.flatten.select { |r| Hobo.can_view?(current_user, r, nil) }
140
+ if all_results.empty?
141
+ render :text => NO_SEARCH_RESULTS_HTML
141
142
  else
142
143
  # TODO: call one tag that renders all the search results with headings for each model
143
- render_tags(results.map {|r|r.last}.flatten, :search_card, :for_type => true)
144
+ render_tags(all_results, :search_card, :for_type => true)
144
145
  end
145
146
  end
146
147
 
@@ -79,16 +79,16 @@ module Hobo
79
79
  make_renderer_class("", page, local_names, DEFAULT_IMPORTS, included_taglibs)
80
80
  @tag_page_renderer_classes[controller_class.name].new(page, view)
81
81
  else
82
- template_path = "app/views/" + page + ".dryml"
83
- src_file = File.join(RAILS_ROOT, template_path)
84
- mtime = File.mtime(src_file)
82
+ template_path = view.finder.pick_template(page, "dryml")
83
+
84
+ mtime = File.mtime(template_path)
85
85
  renderer_class = @renderer_classes[page]
86
86
 
87
87
  # do we need to recompile?
88
88
  if (!renderer_class or # nothing cached?
89
89
  (local_names - renderer_class.compiled_local_names).any? or # any new local names?
90
90
  renderer_class.load_time < mtime) # cache out of date?
91
- renderer_class = make_renderer_class(File.read(src_file), template_path, local_names,
91
+ renderer_class = make_renderer_class(File.read(template_path), template_path, local_names,
92
92
  DEFAULT_IMPORTS, included_taglibs)
93
93
  renderer_class.load_time = mtime
94
94
  @renderer_classes[page] = renderer_class
@@ -67,13 +67,17 @@ module Hobo
67
67
  @module = Module.new do
68
68
 
69
69
  @tag_attrs = {}
70
- @tag_aliases = {}
70
+ @tag_aliases = []
71
71
 
72
72
  class << self
73
73
 
74
74
  def included(base)
75
75
  @tag_aliases.each do |tag, feature|
76
- base.send(:alias_method_chain, tag, feature)
76
+ if base.respond_to? :alias_method_chain_on_include
77
+ base.alias_method_chain_on_include tag, feature
78
+ else
79
+ base.send(:alias_method_chain, tag, feature)
80
+ end
77
81
  end
78
82
  end
79
83
 
@@ -83,7 +87,7 @@ module Hobo
83
87
  attr_reader :tag_attrs
84
88
 
85
89
  def alias_method_chain_on_include(tag, feature)
86
- @tag_aliases[tag] = feature
90
+ @tag_aliases << [tag, feature]
87
91
  end
88
92
 
89
93
  end
@@ -136,7 +136,7 @@ module Hobo::Dryml
136
136
  def dom_id(object=nil, attribute=nil)
137
137
  if object.nil?
138
138
  # nothing passed -- use context
139
- if this_parent && this_field
139
+ if this_parent && this_field && !this_parent.respond_to?(:member_class)
140
140
  object, attribute = this_parent, this_field
141
141
  else
142
142
  object = this
@@ -316,17 +316,17 @@ module Hobo::Dryml
316
316
  def with_form_context
317
317
  @_form_this = this
318
318
  @_form_field_path = []
319
- @_form_field_names = []
320
319
  @_form_field_paths_by_object = { @_form_this => [] }
321
- res = yield
322
- field_names = @_form_field_names
323
- @_form_this = @_form_field_path = @_form_field_names = @_form_field_paths_by_object = nil
324
- [res, field_names]
320
+ res = scope.new_scope :in_form => true, :form_field_names => [] do
321
+ yield
322
+ end
323
+ @_form_this = @_form_field_path = @_form_field_paths_by_object = nil
324
+ res
325
325
  end
326
326
 
327
327
 
328
328
  def register_form_field(name)
329
- @_form_field_names << name
329
+ scope.form_field_names << name
330
330
  end
331
331
 
332
332