hobo 1.0.0 → 1.0.1

Sign up to get free protection for your applications and to get access to all the features.
data/CHANGES.txt CHANGED
@@ -14,6 +14,15 @@ likely to cause conflicts, so it is highly recommended that you have
14
14
  your code backed up and in a change control system such as git or
15
15
  subversion.
16
16
 
17
+ === Hobo 1.0.1 ===
18
+
19
+ This version contains two speedups: one fix that reduces the number of
20
+ database accesses by Matt Jones and one that speeds up compilation of
21
+ DRYML by Petteri Räty.
22
+
23
+ This version also contains several bug fixes. See the [github
24
+ log](http://github.com/tablatom/hobo/tree/v1.0.1) for more details.
25
+
17
26
  === Hobo 1.0.0 ===
18
27
 
19
28
  Drumm-roll! Trumpets! Fanfare!
data/bin/hobo CHANGED
@@ -7,6 +7,11 @@ require 'rbconfig'
7
7
 
8
8
  RUBY = File.join(Config::CONFIG['bindir'], Config::CONFIG['ruby_install_name']).sub(/.*\s.*/m, '"\&"')
9
9
 
10
+ if RUBY.empty?
11
+ puts "ruby not found"
12
+ exit 2
13
+ end
14
+
10
15
  Signal.trap("INT") { puts; exit }
11
16
 
12
17
  hobo_src = File.join(File.dirname(__FILE__), "../hobo_files/plugin")
@@ -87,11 +92,17 @@ if run_rails
87
92
  opts = []
88
93
  if rails_version
89
94
  opts << "_#{rails_version}_"
90
- # else
91
- # if `rails -v`.split[1].split(".").slice(0,2)!=['2', '3']
92
- # puts "Rails 2.3 required!"
93
- # exit 2
94
- # end
95
+ else
96
+ v=`#{RUBY} -S rails -v`.split[1].split(".")
97
+ unless v.length>=3
98
+ puts "rails not found!"
99
+ exit 2
100
+ end
101
+ unless v[0]=='2' && ['2', '3'].include?(v[1])
102
+ puts "Rails 2.2 or 2.3 required!"
103
+ puts "Rails 3 requires Hobo 1.1 or later."
104
+ exit 2
105
+ end
95
106
  end
96
107
  opts << "-d #{database_type}" if database_type
97
108
  system("#{RUBY} -S rails #{opts * ' '} #{app_path}")
@@ -207,7 +207,7 @@ end
207
207
  </section>
208
208
  <% end -%>
209
209
  </section>
210
- <% end # of main collection -%>
210
+ <% end -%>
211
211
  </section>
212
212
  <% if aside_collections -%>
213
213
  </section>
data/lib/hobo.rb CHANGED
@@ -16,7 +16,7 @@ class HoboError < RuntimeError; end
16
16
 
17
17
  module Hobo
18
18
 
19
- VERSION = "1.0.0"
19
+ VERSION = "1.0.1"
20
20
 
21
21
  class PermissionDeniedError < RuntimeError; end
22
22
 
@@ -133,12 +133,11 @@ module Hobo
133
133
  tag_renderer.send(name, options)
134
134
  end
135
135
 
136
- NO_SEARCH_RESULTS_HTML = "<p>Your search returned no matches.</p>"
137
136
  def site_search(query)
138
137
  results_hash = Hobo.find_by_search(query)
139
138
  all_results = results_hash.values.flatten.select { |r| r.viewable_by?(current_user) }
140
139
  if all_results.empty?
141
- render :text => NO_SEARCH_RESULTS_HTML
140
+ render :text => "<p>"+ ht(:"hobo.live_search.no_results", :default=>["Your search returned no matches."]) + "</p>"
142
141
  else
143
142
  # TODO: call one tag that renders all the search results with headings for each model
144
143
  render_tags(all_results, :search_card, :for_type => true)
@@ -72,7 +72,7 @@ module Hobo::Dryml
72
72
  # compile the build instructions
73
73
  @builder.build(local_names, auto_taglibs, mtime)
74
74
 
75
- logger.info(" DRYML: Compiled #{template_path} in %.2fs" % (Time.now - now)) if parsed
75
+ logger.info(" DRYML: Compiled #{template_path} in #{'%.2fs' % (Time.now - now)}") if parsed
76
76
  end
77
77
 
78
78
 
@@ -319,9 +319,25 @@ module Hobo::Dryml
319
319
  res
320
320
  end
321
321
 
322
+ def self.descendents(el,&block)
323
+ return if el.elements.empty?
324
+ el.elements.each do |child|
325
+ block.call(child)
326
+ descendents(child,&block)
327
+ end
328
+ end
329
+
330
+ # Using REXML::XPath is slow
331
+ def self.descendent_select(el)
332
+ result = []
333
+ descendents(el) { |desc|
334
+ result << desc if yield(desc)
335
+ }
336
+ result
337
+ end
322
338
 
323
339
  def param_names_in_definition(el)
324
- REXML::XPath.match(el, ".//*[@param]").map do |e|
340
+ self.class.descendent_select(el) { |el| el.attribute 'param' }.map do |e|
325
341
  name = get_param_name(e)
326
342
  dryml_exception("invalid param name: #{name.inspect}", e) unless
327
343
  is_code_attribute?(name) || name =~ RUBY_NAME_RX || name =~ /#\{/
@@ -486,7 +502,7 @@ module Hobo::Dryml
486
502
 
487
503
 
488
504
  def call_name(el)
489
- dryml_exception("invalid tag name", el) unless el.dryml_name =~ /^#{DRYML_NAME}(\.#{DRYML_NAME})*$/
505
+ dryml_exception("invalid tag name (remember to use '-' rather than '_')", el) unless el.dryml_name =~ /^#{DRYML_NAME}(\.#{DRYML_NAME})*$/
490
506
 
491
507
  name = Hobo::Dryml.unreserve(ruby_name(el.dryml_name))
492
508
  if call_to_self_from_type_specific_def?(el)
@@ -777,7 +793,7 @@ module Hobo::Dryml
777
793
  def tag_attributes(el)
778
794
  attributes = el.attributes
779
795
  items = attributes.map do |n,v|
780
- dryml_exception("invalid attribute name '#{n}'", el) unless n =~ DRYML_NAME_RX
796
+ dryml_exception("invalid attribute name '#{n}' (remember to use '-' rather than '_')", el) unless n =~ DRYML_NAME_RX
781
797
 
782
798
  next if n.in?(SPECIAL_ATTRIBUTES) || n =~ /^without-/
783
799
  next if el.attributes['part'] && n == 'id' # The id is rendered on the <div class="part-wrapper"> instead
@@ -24,6 +24,7 @@ module Hobo
24
24
  # TODO: figure out how to merge with parent, if desired
25
25
  if self.const_defined?(:Lifecycle)
26
26
  lifecycle = self::Lifecycle
27
+ state_field_class = self::LifecycleStateField
27
28
  else
28
29
  # First call
29
30
 
data/lib/hobo/model.rb CHANGED
@@ -57,11 +57,12 @@ module Hobo
57
57
 
58
58
  WillPaginate::Finder::ClassMethods.class_eval do
59
59
  def paginate_with_hobo_metadata(*args, &block)
60
- returning paginate_without_hobo_metadata(*args, &block) do |collection|
61
- collection.member_class = self
62
- collection.origin = try.proxy_owner
63
- collection.origin_attribute = try.proxy_reflection._?.name
64
- end
60
+ # using 'returning' here triggers a full load
61
+ collection = paginate_without_hobo_metadata(*args, &block)
62
+ collection.member_class = self
63
+ collection.origin = try.proxy_owner
64
+ collection.origin_attribute = try.proxy_reflection._?.name
65
+ collection
65
66
  end
66
67
  alias_method_chain :paginate, :hobo_metadata
67
68
 
@@ -72,7 +72,12 @@ module Hobo
72
72
 
73
73
  Rails.logger.info "..translate(#{key}, #{options.inspect}) to #{I18n.locale}" if defined?(HOBO_VERBOSE_TRANSLATIONS)
74
74
 
75
- I18n.translate(key.to_sym, options)+(key_prefix ? key_prefix:"")
75
+ translation = I18n.translate(key.to_sym, options)
76
+ if translation.respond_to? :to_str
77
+ key_prefix ? translation.to_str+key_prefix : translation
78
+ else
79
+ "translation invalid: #{key}"
80
+ end
76
81
  end
77
82
 
78
83
  # if somebody includes us, give them ht as an instance method
@@ -1,4 +1,3 @@
1
- <!-- Core Rapid tags and tags that don't belong anywhere else. -->
2
1
 
3
2
  <!-- Renders a table with one row per field, where each row contains a `<th>` with the field name, and a `<td>` with (by default)
4
3
  a `<view>` of the field.
@@ -310,7 +309,7 @@ Or a new page if the context is a class:
310
309
 
311
310
  * to: Use this item as the target instead of the current context.
312
311
 
313
- * params, query-params: These are appended to the target as a query string after a "?".
312
+ * params, query-params: These are appended to the target as a query string after a "?". Params are passed as a ruby hash. Example: `params="&{id=>17, name=>'joe'}"`
314
313
 
315
314
  * href, name: If either of these attributes are present, the smart features of this tag are turned off.
316
315
 
@@ -613,8 +612,8 @@ The context should be a user object. If `this == current_user` the "you" form is
613
612
  <def tag="dev-user-changer">
614
613
  <set user="&Hobo::User.default_user_model"/>
615
614
  <select-menu if="&user && RAILS_ENV == 'development'"
616
- first-option="Guest" options="&user.all(:limit => 30).*.login"
617
- onchange="location.href = '#{dev_support_path}/set_current_user?login=' + this.options[this.selectedIndex].value"
615
+ first-option="#{ht('hobo.dev_user_changer.guest', {:default=>'Guest'})}" options="&user.all(:limit => 30).*.login"
616
+ onchange="location.href = '#{dev_support_path}/set_current_user?login=' + encodeURIComponent(this.options[this.selectedIndex].value)"
618
617
  selected="#{current_user.login}"
619
618
  class="dev-user-changer"
620
619
  merge-attrs/>
@@ -70,13 +70,13 @@ This is a simple tag - just look at the source if you need to know more detail.
70
70
  <ul class="navigation account-nav" param>
71
71
  <li if="&RAILS_ENV == 'development'" param="dev-user-changer"><dev-user-changer/></li>
72
72
  <if test="&logged_in?">
73
- <li class='nav-item' param="logged-in-as"><a to="&current_user">Logged in as <name/></a></li>
74
- <li class='nav-item' param="account"><a action="account">Account</a></li>
75
- <li class='nav-item' param="log-out"><a href="&logout_url">Log out</a></li>
73
+ <li class='nav-item' param="logged-in-as"><a to="&current_user"><ht key="hobo.actions.logged_in_as" name="#{name}">Logged in as <name/></ht></a></li>
74
+ <li class='nav-item' param="account"><a action="account"><ht key="hobo.actions.account">Account</ht></a></li>
75
+ <li class='nav-item' param="log-out"><a href="&logout_url"><ht key="hobo.actions.logout">Log out</ht></a></li>
76
76
  </if>
77
77
  <else>
78
- <li class='nav-item' param="log-in"><a href="&login_url">Log in</a></li>
79
- <li if="&signup_url" class="nav-item" param="sign-up"><a href="&signup_url">Sign up</a></li>
78
+ <li class='nav-item' param="log-in"><a href="&login_url"><ht key="hobo.actions.login">Log in</ht></a></li>
79
+ <li if="&signup_url" class="nav-item" param="sign-up"><a href="&signup_url"><ht key="hobo.actions.signup">Sign up</ht></a></li>
80
80
  </else>
81
81
  </ul>
82
82
  </do>
@@ -243,7 +243,7 @@ The flash is output in a `<div class="flash notice">`, where `notice` is the `ty
243
243
 
244
244
  <!-- Renders `<flash-message>` for every flash type given in the `names` attribute (comma separated), or for all flash messages that have been set if `names` is not given -->
245
245
  <def tag="flash-messages" attrs="names"><%=
246
- scope.flash_rendered = true
246
+ scope.flash_rendered = true if scope.respond_to? :flash_rendered
247
247
  names = names.nil? ? flash.keys : comma_split(names)
248
248
  names.map { |name| flash_message :type => name }.join
249
249
  %></def>
@@ -15,7 +15,7 @@ An [worked example](/tutorials/agility#improve_the_project_page_with_a_searchabl
15
15
  <div class="search">
16
16
  <form param="search-form" method="get" action="">
17
17
  <hidden-fields for-query-string skip="page, search"/>
18
- <span>Search</span>
18
+ <span><ht key="hobo.table_plus.search">Search</ht></span>
19
19
  <input class="search" type="search" name="search" value="&params[:search]"/>
20
20
  <submit label="Go" class="search-button" param="search-submit"/>
21
21
  </form>
@@ -43,7 +43,7 @@ An [worked example](/tutorials/agility#improve_the_project_page_with_a_searchabl
43
43
  <th if="&all_parameters[:controls]" class="controls"></th>
44
44
  </field-heading-row>
45
45
  </table>
46
- <do param="empty-message" if="empty?">No <collection-name lowercase/> to display</do>
46
+ <do param="empty-message" if="empty?"><ht key="hobo.table_plus.empty" model="#{name.downcase}">No <collection-name lowercase/> to display</ht></do>
47
47
 
48
48
 
49
49
  <page-nav param if="&this.respond_to?(:page_count) || this.respond_to?(:total_pages)"/>
@@ -101,7 +101,7 @@ This tag assumes the controller has a `reorder` action. This action is added aut
101
101
  <% name ||= collection_name.pluralize -%>
102
102
  <section class="#{name.gsub(' ', '-').dasherize} preview-with-more" param="default">
103
103
  <h3 param="heading"><%= name.titleize %></h3>
104
- <a param="more">More <type-name plural lowercase/>...</a>
104
+ <a param="more"><ht key="hobo.live_search.more">More</ht> <type-name plural lowercase/>...</a>
105
105
  <collection param/>
106
106
  <a action="new" if="&can_create?(this.new)" param="new-link">New <%= this.member_class.view_hints.model_name %></a>
107
107
  </section>
@@ -125,11 +125,11 @@ This tag assumes the controller has a `reorder` action. This action is added aut
125
125
  <!-- Provides an ajax-powered *find-as-you-type* live search field which is hooked up to Hobo's site-side search feature. At the moment this tag is not very flexible. It is not easy to use if for anything other than Hobo's site-wide search. -->
126
126
  <def tag="live-search">
127
127
  <div class="search">
128
- <label for="search-field">Search</label><input type="search" class="live-search"/>
128
+ <label for="search-field"><ht key="hobo.live_search.label">Search</ht></label><input type="search" class="live-search"/>
129
129
  <spinner id="search-spinner"/>
130
130
  </div>
131
131
  <section class="hidden" id="search-results-panel">
132
- <h2>Search Results</h2><div param="close-button">close</div>
132
+ <h2><ht key="hobo.live_search.results_label">Search Results</ht></h2><div param="close-button"><ht key="hobo.live_search.close_button">close</ht></div>
133
133
  <section id="search-results">&nbsp;</section>
134
134
  </section>
135
135
  </def>
@@ -102,7 +102,9 @@
102
102
  </def>
103
103
 
104
104
  <def tag="gem-version-requirement">
105
- <%= this.requirements.map{|l| l.first+l.second.to_s}.join(",") -%>
105
+ <unless test="this.nil?"><%=
106
+ this.requirements.map{|l| l.first+l.second.to_s}.join(",")
107
+ -%></unless>
106
108
  </def>
107
109
 
108
110
  <!-- inside `<with-gems>`, returns the version required -->
@@ -123,7 +125,7 @@
123
125
  <!-- inside `<with-gems>`, returns the gem dependencies -->
124
126
  <def tag="gem-dependencies">
125
127
  <repeat with="&this.dependencies">
126
- <%= this.name -%><gem-version-requirement:requirement />
128
+ <%= this.name -%><gem-version-requirement with="&this.requirement || this.version_requirements" />
127
129
  </repeat>
128
130
  </def>
129
131
 
@@ -20,7 +20,7 @@ Will lookup the "my.app"-key for your locale and replaces the "My Application" c
20
20
 
21
21
  Will look up both the "my"- and "app"-key for your locale, and replaces the "My Application" with the "my"-key contents (interpolated using the "app"-key.
22
22
 
23
- sample.en.yml-file:
23
+ sample.no.yml-file:
24
24
 
25
25
  "no":
26
26
  my: "Mitt {{app}}"
metadata CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
5
5
  segments:
6
6
  - 1
7
7
  - 0
8
- - 0
9
- version: 1.0.0
8
+ - 1
9
+ version: 1.0.1
10
10
  platform: ruby
11
11
  authors:
12
12
  - Tom Locke
@@ -14,7 +14,7 @@ autorequire:
14
14
  bindir: bin
15
15
  cert_chain: []
16
16
 
17
- date: 2010-02-23 00:00:00 +11:00
17
+ date: 2010-06-01 00:00:00 +01:00
18
18
  default_executable: hobo
19
19
  dependencies:
20
20
  - !ruby/object:Gem::Dependency
@@ -55,8 +55,8 @@ dependencies:
55
55
  segments:
56
56
  - 1
57
57
  - 0
58
- - 0
59
- version: 1.0.0
58
+ - 1
59
+ version: 1.0.1
60
60
  type: :runtime
61
61
  version_requirements: *id003
62
62
  - !ruby/object:Gem::Dependency
@@ -69,8 +69,8 @@ dependencies:
69
69
  segments:
70
70
  - 1
71
71
  - 0
72
- - 0
73
- version: 1.0.0
72
+ - 1
73
+ version: 1.0.1
74
74
  type: :runtime
75
75
  version_requirements: *id004
76
76
  description: