hobo 1.3.0 → 1.3.1

Sign up to get free protection for your applications and to get access to all the features.
data/VERSION CHANGED
@@ -1 +1 @@
1
- 1.3.0
1
+ 1.3.1
@@ -495,6 +495,9 @@ module Hobo
495
495
  response_block(&b)
496
496
  end
497
497
 
498
+ def hobo_edit(*args, &b)
499
+ hobo_show(*args, &b)
500
+ end
498
501
 
499
502
  def hobo_new(record=nil, &b)
500
503
  self.this = record || model.user_new(current_user)
@@ -8,6 +8,17 @@ module ActiveRecord
8
8
  end
9
9
  end
10
10
 
11
+ module SpawnMethods
12
+ def merge_with_origin(r)
13
+ merged = merge_without_origin(r)
14
+ merged.origin ||= r.respond_to?(:origin) && r.origin
15
+ merged.origin_attribute ||= r.respond_to?(:origin_attribute) && r.origin_attribute
16
+ merged
17
+ end
18
+
19
+ alias_method_chain :merge, :origin
20
+ end
21
+
11
22
  module Associations
12
23
  class AssociationCollection
13
24
 
data/lib/hobo/helper.rb CHANGED
@@ -127,7 +127,11 @@ module Hobo
127
127
 
128
128
 
129
129
  def recognize_page_path
130
- Rails.application.routes.recognize_path(params[:page_path]||request.fullpath)
130
+ if params[:page_path]
131
+ Rails.application.routes.recognize_path(params[:page_path].gsub(/^#{Rails.configuration.action_controller.relative_url_root}/,''))
132
+ else
133
+ params
134
+ end
131
135
  end
132
136
 
133
137
  def url_for_page_path(options={})
@@ -436,13 +440,6 @@ module Hobo
436
440
  this_parent.class.try.attribute_help(this_field.to_sym) || ""
437
441
  end
438
442
 
439
-
440
- # --- default Helpers --- #
441
-
442
- def your_default
443
- this == current_user ? "Your" : (this.name.ends_with?('s') ? "#{this.name}'" : "#{this.name}'s")
444
- end
445
-
446
443
  # --- Debugging Helpers ---- #
447
444
 
448
445
  def abort_with(*args)
data/lib/hobo/model.rb CHANGED
@@ -57,35 +57,6 @@ module Hobo
57
57
  alias_method_chain :replace, :hobo_metadata
58
58
  end
59
59
 
60
- WillPaginate::ActiveRecord::Pagination.class_eval do
61
-
62
- def apply_hobo_metadata(collection)
63
- klass = Object.instance_method(:class).bind(self).call
64
- is_relation = klass <= ActiveRecord::Relation
65
- is_association_proxy = klass <= ActiveRecord::Associations::AssociationProxy
66
- collection.member_class = (is_relation || is_association_proxy) ? member_class : self
67
- collection.origin = try.proxy_owner
68
- collection.origin_attribute = try.proxy_reflection._?.name
69
- collection
70
- end
71
-
72
- # NOTE: as of will_paginate 3.0.0, the standard paginate method calls the page method.
73
- # However, it converts an association proxy into a relation first (via adding a limit clause),
74
- # which causes the proxy_owner and proxy_reflection methods to disappear.
75
- def paginate_with_hobo_metadata(*args, &block)
76
- collection = paginate_without_hobo_metadata(*args, &block)
77
- apply_hobo_metadata(collection)
78
- end
79
- alias_method_chain :paginate, :hobo_metadata
80
-
81
- def page_with_hobo_metadata(*args, &block)
82
- collection = page_without_hobo_metadata(*args, &block)
83
- apply_hobo_metadata(collection)
84
- end
85
- alias_method_chain :page, :hobo_metadata
86
-
87
- end
88
-
89
60
  end
90
61
  end
91
62
 
@@ -324,7 +324,10 @@ module Hobo
324
324
  words = query.split
325
325
  args = []
326
326
  word_queries = words.map do |word|
327
- field_query = '(' + fields.map { |field| "(#{@klass.table_name}.#{field} #{match_keyword} ?)" }.join(" OR ") + ')'
327
+ field_query = '(' + fields.map { |field|
328
+ field = "#{@klass.table_name}.#{field}" unless field =~ /\./
329
+ "(#{field} #{match_keyword} ?)"
330
+ }.join(" OR ") + ')'
328
331
  args += ["%#{word}%"] * fields.length
329
332
  field_query
330
333
  end
@@ -120,7 +120,7 @@ This will use `<input/>` as the tag in each table cell instead of `<view/>`
120
120
  <with-field-names merge-attrs="&all_attributes & attrs_for(:with_fields)">
121
121
  <th param="#{scope.field_name}-heading"><%= this.member_class.human_attribute_name(scope.field_name) if scope %></th>
122
122
  </with-field-names>
123
- <th if="&all_parameters[:controls]" class="controls"/>
123
+ <th if="&all_parameters[:controls]" class="controls" param="controls-heading"/>
124
124
  </tr>
125
125
  </thead>
126
126
  <tbody param>
@@ -180,11 +180,11 @@ Provides a short hand way of displaying images in public/images
180
180
  res << "var pluralisations = {#{names * ', '}}; "
181
181
  end
182
182
  base = [base_url, subsite].compact.join("/")
183
- res << "urlBase = '#{base}'; hoboPagePath = '#{request.fullpath}'"
183
+ res << "urlBase = '#{base}'; hoboPagePath = '#{CGI.escape(request.fullpath)}'"
184
184
  if protect_against_forgery?
185
185
  res << "; formAuthToken = { name: '#{request_forgery_protection_token}', value: '#{form_authenticity_token}' }"
186
186
  end
187
- res
187
+ res.html_safe
188
188
  %></script>
189
189
  </def>
190
190
 
@@ -597,7 +597,7 @@ with :it locale and summary="choice" (key "tags.count.choice")
597
597
  when this.is_a?(Class)
598
598
  this.model_name.human(:count=>c)
599
599
  when (attr = this.try.origin_attribute)
600
- this_parent.class.human_attribute_name(attr, :count=>c)
600
+ (this_parent || this.origin).class.human_attribute_name(attr, :count=>c)
601
601
  else
602
602
  this.member_class.model_name.human(:count=>c)
603
603
  end
@@ -758,13 +758,14 @@ Notes
758
758
 
759
759
  - `<your>Posts</your>`: "your Posts" or "Jim's Posts"
760
760
  -->
761
- <def tag="your" attrs="key, capitalize"><%=
761
+ <def tag="your" attrs="key, capitalize, name"><%=
762
762
  key ||= 'default'
763
+ name ||= name(:no_wrapper => true)
763
764
  # prepare symbolized attributes for merging
764
765
  attrs = {}
765
766
  attributes.each_pair{|k,v| attrs[k.to_sym] = v}
766
- d = "#{your_default} #{all_parameters.default}"
767
- options = {:default=>[d], :count=>(attrs[:count]||1), :name=>name(:no_wrapper => true)}
767
+ d = "#{h name}'#{'s' unless name.ends_with?('s')} #{all_parameters.default}"
768
+ options = {:default=>[d], :count=>(attrs[:count]||1), :name=>name}
768
769
  your_key = key.split('.').last
769
770
  unless key.eql?(your_key) || attrs.has_key?(your_key.to_sym)
770
771
  options[your_key.to_sym] = t(key, :count=>options[:count], :default=>your_key.titleize)
@@ -776,7 +777,7 @@ Notes
776
777
  options[:default].unshift :"tags.your.default.other_user"
777
778
  t("tags.your.#{your_key}.other_user", options.merge(attrs))
778
779
  end
779
- capitalize ? s.sub(/^./){|c| c.upcase} : s
780
+ (capitalize ? s.sub(/^./){|c| c.upcase} : s).html_safe
780
781
  %></def>
781
782
 
782
783
  <!-- Capitalised version of `<a-or-an>` -->
@@ -773,7 +773,7 @@ If you wish to set `min-chars` to 0, you will require this [patch to controls.js
773
773
  min_chars ||= 1
774
774
  value = name(:no_wrapper => true, :if_present => true)
775
775
  -%>
776
- <wrap tag="span" class="field-with-errors" when="&!this_parent.errors[this_field].empty?">
776
+ <wrap tag="span" class="field-with-errors" when="&!this_parent.nil? && !this_parent.errors[this_field].empty?">
777
777
  <input type="text" name="#{param_name_for_this}"
778
778
  class="autocompleter #{type_and_field._?.dasherize} #{css_data :complete_on, typed_id(complete_target), completer} #{css_data :min_chars, min_chars} #{'nil-value' if value==''}"
779
779
  value="#{value=='' ? nil_value : value}"
@@ -14,11 +14,21 @@ All of the [standard ajax attributes](/api_taglibs/rapid_forms) are also support
14
14
 
15
15
  Transitions with parameters are implemented using a form. HTML does not allow forms to be nested, so a transitions with parameters should not be placed inside of a form.
16
16
 
17
+ ### Invalid transitions
18
+
19
+ If the transition could not be found, the user does not have permissions for the transition or the object is not in the correct state for the transition, the transition-button displays nothing. You can use an `<else>` to display an appropriate message.
20
+
21
+ <transition-button transition="mogrify"/><else>Cannot mogrify</else>
22
+
17
23
  -->
18
24
  <def tag="transition-button" attrs="transition, update, label"><%=
19
25
  if transition.is_a?(String)
20
26
  transition = this.lifecycle.find_transition(transition, current_user)
21
27
  end
28
+ if transition.nil?
29
+ Dryml.last_if = false
30
+ return ""
31
+ end
22
32
  transition_name = transition.name
23
33
  has_params = !transition.options[:params].blank?
24
34
  ajax_attributes, html_attributes = attributes.partition_hash(Hobo::Rapid::Helper::AJAX_ATTRS)
@@ -43,6 +53,28 @@ Transitions with parameters are implemented using a form. HTML does not allow f
43
53
  </def>
44
54
 
45
55
 
56
+ <!-- Displays a link to a lifecycle transition page if the transition is valid. If the transition is valid, this is equivalent to:
57
+
58
+ <a action="&transition" ...
59
+
60
+ If the transition is invalid, you may use the `<else>` tag to display an appropriate message:
61
+
62
+ <transition-link transition="mogrify">Mogrify</transition-link>
63
+ <else>Cannot mogrify</else>
64
+
65
+ ### Attributes
66
+
67
+ All attributes and parameters for the `<a>` tag are also valid.
68
+
69
+ - `transition` - the name of the transition to invoke. Required
70
+ -->
71
+ <def tag="transition-link" attrs="transition"><%
72
+ trans = this.lifecycle.find_transition(transition, current_user) %>
73
+ <if test="&trans">
74
+ <a action="&transition" merge/>
75
+ </if>
76
+ </def>
77
+
46
78
  <!-- Renders a div containing transition buttons for every transition available to the current user.
47
79
 
48
80
  For example, you could use this on a `Friendship` card: the person invited to have friendship would automatically see 'Accept' and 'Decline' buttons, while the person initiating the invite would see 'Retract'.
metadata CHANGED
@@ -1,104 +1,135 @@
1
- --- !ruby/object:Gem::Specification
1
+ --- !ruby/object:Gem::Specification
2
2
  name: hobo
3
- version: !ruby/object:Gem::Version
3
+ version: !ruby/object:Gem::Version
4
+ version: 1.3.1
4
5
  prerelease:
5
- version: 1.3.0
6
6
  platform: ruby
7
- authors:
7
+ authors:
8
8
  - Tom Locke
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
-
13
- date: 2011-11-14 00:00:00 -05:00
14
- default_executable:
15
- dependencies:
16
- - !ruby/object:Gem::Dependency
12
+ date: 2012-10-12 00:00:00.000000000 Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
17
15
  name: hobo_support
18
- prerelease: false
19
- requirement: &id001 !ruby/object:Gem::Requirement
16
+ requirement: !ruby/object:Gem::Requirement
20
17
  none: false
21
- requirements:
22
- - - "="
23
- - !ruby/object:Gem::Version
24
- version: 1.3.0
18
+ requirements:
19
+ - - '='
20
+ - !ruby/object:Gem::Version
21
+ version: 1.3.1
25
22
  type: :runtime
26
- version_requirements: *id001
27
- - !ruby/object:Gem::Dependency
28
- name: hobo_fields
29
23
  prerelease: false
30
- requirement: &id002 !ruby/object:Gem::Requirement
24
+ version_requirements: !ruby/object:Gem::Requirement
25
+ none: false
26
+ requirements:
27
+ - - '='
28
+ - !ruby/object:Gem::Version
29
+ version: 1.3.1
30
+ - !ruby/object:Gem::Dependency
31
+ name: hobo_fields
32
+ requirement: !ruby/object:Gem::Requirement
31
33
  none: false
32
- requirements:
33
- - - "="
34
- - !ruby/object:Gem::Version
35
- version: 1.3.0
34
+ requirements:
35
+ - - '='
36
+ - !ruby/object:Gem::Version
37
+ version: 1.3.1
36
38
  type: :runtime
37
- version_requirements: *id002
38
- - !ruby/object:Gem::Dependency
39
- name: dryml
40
39
  prerelease: false
41
- requirement: &id003 !ruby/object:Gem::Requirement
40
+ version_requirements: !ruby/object:Gem::Requirement
41
+ none: false
42
+ requirements:
43
+ - - '='
44
+ - !ruby/object:Gem::Version
45
+ version: 1.3.1
46
+ - !ruby/object:Gem::Dependency
47
+ name: dryml
48
+ requirement: !ruby/object:Gem::Requirement
42
49
  none: false
43
- requirements:
44
- - - "="
45
- - !ruby/object:Gem::Version
46
- version: 1.3.0
50
+ requirements:
51
+ - - '='
52
+ - !ruby/object:Gem::Version
53
+ version: 1.3.1
47
54
  type: :runtime
48
- version_requirements: *id003
49
- - !ruby/object:Gem::Dependency
50
- name: will_paginate
51
55
  prerelease: false
52
- requirement: &id004 !ruby/object:Gem::Requirement
56
+ version_requirements: !ruby/object:Gem::Requirement
57
+ none: false
58
+ requirements:
59
+ - - '='
60
+ - !ruby/object:Gem::Version
61
+ version: 1.3.1
62
+ - !ruby/object:Gem::Dependency
63
+ name: will_paginate
64
+ requirement: !ruby/object:Gem::Requirement
53
65
  none: false
54
- requirements:
55
- - - ">="
56
- - !ruby/object:Gem::Version
66
+ requirements:
67
+ - - ! '>='
68
+ - !ruby/object:Gem::Version
57
69
  version: 3.0.0
58
70
  type: :runtime
59
- version_requirements: *id004
60
- - !ruby/object:Gem::Dependency
61
- name: rubydoctest
62
71
  prerelease: false
63
- requirement: &id005 !ruby/object:Gem::Requirement
72
+ version_requirements: !ruby/object:Gem::Requirement
64
73
  none: false
65
- requirements:
66
- - - ">="
67
- - !ruby/object:Gem::Version
68
- version: "0"
74
+ requirements:
75
+ - - ! '>='
76
+ - !ruby/object:Gem::Version
77
+ version: 3.0.0
78
+ - !ruby/object:Gem::Dependency
79
+ name: rubydoctest
80
+ requirement: !ruby/object:Gem::Requirement
81
+ none: false
82
+ requirements:
83
+ - - ! '>='
84
+ - !ruby/object:Gem::Version
85
+ version: '0'
69
86
  type: :development
70
- version_requirements: *id005
71
- - !ruby/object:Gem::Dependency
72
- name: shoulda
73
87
  prerelease: false
74
- requirement: &id006 !ruby/object:Gem::Requirement
88
+ version_requirements: !ruby/object:Gem::Requirement
75
89
  none: false
76
- requirements:
77
- - - ">="
78
- - !ruby/object:Gem::Version
79
- version: "0"
90
+ requirements:
91
+ - - ! '>='
92
+ - !ruby/object:Gem::Version
93
+ version: '0'
94
+ - !ruby/object:Gem::Dependency
95
+ name: shoulda
96
+ requirement: !ruby/object:Gem::Requirement
97
+ none: false
98
+ requirements:
99
+ - - ! '>='
100
+ - !ruby/object:Gem::Version
101
+ version: '0'
80
102
  type: :development
81
- version_requirements: *id006
82
- - !ruby/object:Gem::Dependency
83
- name: irt
84
103
  prerelease: false
85
- requirement: &id007 !ruby/object:Gem::Requirement
104
+ version_requirements: !ruby/object:Gem::Requirement
86
105
  none: false
87
- requirements:
88
- - - ">="
89
- - !ruby/object:Gem::Version
106
+ requirements:
107
+ - - ! '>='
108
+ - !ruby/object:Gem::Version
109
+ version: '0'
110
+ - !ruby/object:Gem::Dependency
111
+ name: irt
112
+ requirement: !ruby/object:Gem::Requirement
113
+ none: false
114
+ requirements:
115
+ - - ! '>='
116
+ - !ruby/object:Gem::Version
90
117
  version: 0.7.5
91
118
  type: :development
92
- version_requirements: *id007
119
+ prerelease: false
120
+ version_requirements: !ruby/object:Gem::Requirement
121
+ none: false
122
+ requirements:
123
+ - - ! '>='
124
+ - !ruby/object:Gem::Version
125
+ version: 0.7.5
93
126
  description: The web app builder for Rails
94
127
  email: tom@tomlocke.com
95
- executables:
128
+ executables:
96
129
  - hobo
97
130
  extensions: []
98
-
99
131
  extra_rdoc_files: []
100
-
101
- files:
132
+ files:
102
133
  - CHANGES-1.1.txt
103
134
  - CHANGES.txt
104
135
  - LICENSE.txt
@@ -318,33 +349,30 @@ files:
318
349
  - test/permissions/models/models.rb
319
350
  - test/permissions/models/schema.rb
320
351
  - test/permissions/test_permissions.rb
321
- has_rdoc: true
322
352
  homepage: http://hobocentral.net
323
353
  licenses: []
324
-
325
354
  post_install_message:
326
- rdoc_options:
355
+ rdoc_options:
327
356
  - --charset=UTF-8
328
- require_paths:
357
+ require_paths:
329
358
  - lib
330
- required_ruby_version: !ruby/object:Gem::Requirement
359
+ required_ruby_version: !ruby/object:Gem::Requirement
331
360
  none: false
332
- requirements:
333
- - - ">="
334
- - !ruby/object:Gem::Version
335
- version: "0"
336
- required_rubygems_version: !ruby/object:Gem::Requirement
361
+ requirements:
362
+ - - ! '>='
363
+ - !ruby/object:Gem::Version
364
+ version: '0'
365
+ required_rubygems_version: !ruby/object:Gem::Requirement
337
366
  none: false
338
- requirements:
339
- - - ">="
340
- - !ruby/object:Gem::Version
367
+ requirements:
368
+ - - ! '>='
369
+ - !ruby/object:Gem::Version
341
370
  version: 1.3.6
342
371
  requirements: []
343
-
344
372
  rubyforge_project: hobo
345
- rubygems_version: 1.6.2
373
+ rubygems_version: 1.8.24
346
374
  signing_key:
347
375
  specification_version: 3
348
376
  summary: The web app builder for Rails
349
377
  test_files: []
350
-
378
+ has_rdoc: