hobo 0.6.4 → 0.7.0

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 (71) hide show
  1. data/bin/hobo +4 -6
  2. data/hobo_files/plugin/CHANGES.txt +170 -0
  3. data/hobo_files/plugin/generators/hobo_front_controller/templates/index.dryml +9 -9
  4. data/hobo_files/plugin/generators/hobo_front_controller/templates/search.dryml +9 -9
  5. data/hobo_files/plugin/generators/hobo_migration/hobo_migration_generator.rb +7 -2
  6. data/hobo_files/plugin/generators/hobo_rapid/hobo_rapid_generator.rb +4 -4
  7. data/hobo_files/plugin/generators/hobo_rapid/templates/{hobo_rapid.css → hobo-rapid.css} +0 -0
  8. data/hobo_files/plugin/generators/hobo_rapid/templates/{hobo_rapid.js → hobo-rapid.js} +66 -47
  9. data/hobo_files/plugin/generators/hobo_rapid/templates/lowpro.js +130 -44
  10. data/hobo_files/plugin/generators/hobo_rapid/templates/{hobo_base.css → reset.css} +0 -5
  11. data/hobo_files/plugin/generators/hobo_rapid/templates/themes/clean/public/images/pencil.png +0 -0
  12. data/hobo_files/plugin/generators/hobo_rapid/templates/themes/clean/public/images/small_close.png +0 -0
  13. data/hobo_files/plugin/generators/hobo_rapid/templates/themes/clean/public/stylesheets/application.css +45 -0
  14. data/hobo_files/plugin/generators/hobo_rapid/templates/themes/clean/public/stylesheets/rapid_ui.css +167 -0
  15. data/hobo_files/plugin/generators/hobo_rapid/templates/themes/clean/views/application.dryml +10 -0
  16. data/hobo_files/plugin/generators/hobo_rapid/templates/themes/default/public/images/{bkg_bodytop.gif → bkg-bodytop.gif} +0 -0
  17. data/hobo_files/plugin/generators/hobo_rapid/templates/themes/default/public/images/{bkg_corner_01.gif → bkg-corner-01.gif} +0 -0
  18. data/hobo_files/plugin/generators/hobo_rapid/templates/themes/default/public/images/{bkg_corner_02.gif → bkg-corner-02.gif} +0 -0
  19. data/hobo_files/plugin/generators/hobo_rapid/templates/themes/default/public/images/{bkg_corner_03.gif → bkg-corner-03.gif} +0 -0
  20. data/hobo_files/plugin/generators/hobo_rapid/templates/themes/default/public/images/{bkg_corner_04.gif → bkg-corner-04.gif} +0 -0
  21. data/hobo_files/plugin/generators/hobo_rapid/templates/themes/default/public/images/{bkg_shadow_bottom.gif → bkg-shadow-bottom.gif} +0 -0
  22. data/hobo_files/plugin/generators/hobo_rapid/templates/themes/default/public/images/{bkg_shadow_left.gif → bkg-shadow-left.gif} +0 -0
  23. data/hobo_files/plugin/generators/hobo_rapid/templates/themes/default/public/images/{bkg_shadow_right.gif → bkg-shadow-right.gif} +0 -0
  24. data/hobo_files/plugin/generators/hobo_rapid/templates/themes/default/public/images/{bkg_shadow_top.gif → bkg-shadow-top.gif} +0 -0
  25. data/hobo_files/plugin/generators/hobo_rapid/templates/themes/default/public/images/{header_blue.gif → header-blue.gif} +0 -0
  26. data/hobo_files/plugin/generators/hobo_rapid/templates/themes/default/public/images/{header_dblue.gif → header-dblue.gif} +0 -0
  27. data/hobo_files/plugin/generators/hobo_rapid/templates/themes/default/public/images/{header_green.gif → header-green.gif} +0 -0
  28. data/hobo_files/plugin/generators/hobo_rapid/templates/themes/default/public/images/{header_purple.gif → header-purple.gif} +0 -0
  29. data/hobo_files/plugin/generators/hobo_rapid/templates/themes/default/public/images/{header_red.gif → header-red.gif} +0 -0
  30. data/hobo_files/plugin/generators/hobo_rapid/templates/themes/default/public/images/{txt_list_img_dblue.gif → txt-list-img-dblue.gif} +0 -0
  31. data/hobo_files/plugin/generators/hobo_rapid/templates/themes/default/public/images/{txt_list_img_green.gif → txt-list-img-green.gif} +0 -0
  32. data/hobo_files/plugin/generators/hobo_rapid/templates/themes/default/public/images/{txt_list_img_purple.gif → txt-list-img-purple.gif} +0 -0
  33. data/hobo_files/plugin/generators/hobo_rapid/templates/themes/default/public/images/{txt_list_img_red.gif → txt-list-img-red.gif} +0 -0
  34. data/hobo_files/plugin/generators/hobo_rapid/templates/themes/default/public/images/{window_corner_01.gif → window-corner-01.gif} +0 -0
  35. data/hobo_files/plugin/generators/hobo_rapid/templates/themes/default/public/images/{window_corner_02.gif → window-corner-02.gif} +0 -0
  36. data/hobo_files/plugin/generators/hobo_rapid/templates/themes/default/public/images/{window_corner_03.gif → window-corner-03.gif} +0 -0
  37. data/hobo_files/plugin/generators/hobo_rapid/templates/themes/default/public/images/{window_corner_04.gif → window-corner-04.gif} +0 -0
  38. data/hobo_files/plugin/generators/hobo_rapid/templates/themes/default/public/images/{window_shadow_bottom.gif → window-shadow-bottom.gif} +0 -0
  39. data/hobo_files/plugin/generators/hobo_rapid/templates/themes/default/public/images/{window_shadow_left.gif → window-shadow-left.gif} +0 -0
  40. data/hobo_files/plugin/generators/hobo_rapid/templates/themes/default/public/images/{window_shadow_right.gif → window-shadow-right.gif} +0 -0
  41. data/hobo_files/plugin/generators/hobo_rapid/templates/themes/default/public/images/{window_shadow_top.gif → window-shadow-top.gif} +0 -0
  42. data/hobo_files/plugin/generators/hobo_rapid/templates/themes/default/public/stylesheets/application.css +69 -69
  43. data/hobo_files/plugin/generators/hobo_rapid/templates/themes/default/views/application.dryml +39 -53
  44. data/hobo_files/plugin/generators/hobo_user_model/templates/model.rb +1 -1
  45. data/hobo_files/plugin/lib/extensions.rb +0 -16
  46. data/hobo_files/plugin/lib/hobo/dryml/part_context.rb +1 -1
  47. data/hobo_files/plugin/lib/hobo/dryml/tag_parameters.rb +35 -0
  48. data/hobo_files/plugin/lib/hobo/dryml/taglib.rb +2 -2
  49. data/hobo_files/plugin/lib/hobo/dryml/template.rb +165 -236
  50. data/hobo_files/plugin/lib/hobo/dryml/template_environment.rb +158 -123
  51. data/hobo_files/plugin/lib/hobo/hobo_helper.rb +15 -4
  52. data/hobo_files/plugin/lib/hobo/model.rb +30 -11
  53. data/hobo_files/plugin/lib/hobo/model_controller.rb +13 -9
  54. data/hobo_files/plugin/lib/hobo/model_router.rb +27 -7
  55. data/hobo_files/plugin/lib/hobo/static_tags +0 -2
  56. data/hobo_files/plugin/lib/hobo/user.rb +3 -3
  57. data/hobo_files/plugin/lib/rexml.rb +10 -3
  58. data/hobo_files/plugin/tags/core.dryml +11 -16
  59. data/hobo_files/plugin/tags/rapid.dryml +147 -110
  60. data/hobo_files/plugin/tags/rapid_document_tags.dryml +22 -20
  61. data/hobo_files/plugin/tags/rapid_editing.dryml +41 -41
  62. data/hobo_files/plugin/tags/rapid_forms.dryml +51 -49
  63. data/hobo_files/plugin/tags/rapid_navigation.dryml +34 -34
  64. data/hobo_files/plugin/tags/rapid_pages.dryml +174 -174
  65. data/hobo_files/plugin/tags/rapid_plus.dryml +19 -19
  66. data/hobo_files/plugin/tags/rapid_support.dryml +5 -5
  67. data/hobo_files/plugin/tasks/dump_fixtures.rake +62 -53
  68. data/hobo_files/plugin/tasks/fix_dryml.rake +144 -0
  69. data/hobo_files/plugin/tasks/hobo_tasks.rake +0 -4
  70. metadata +43 -32
  71. data/hobo_files/plugin/lib/hobo/dryml/tag_module.rb +0 -9
data/bin/hobo CHANGED
@@ -57,10 +57,13 @@ end
57
57
  puts "\nGenerating Rails app...\n"
58
58
  system("rails #{app_path}")
59
59
 
60
+
60
61
  Dir.chdir(app_path) do
61
62
  gen = "ruby #{File.join('script', 'generate')}"
62
63
  plugin = "ruby #{File.join('script', 'plugin')}"
63
-
64
+
65
+ FileUtils.touch("public/stylesheets/application.css")
66
+
64
67
  puts "\nInstalling classic_pagination\n"
65
68
  command(plugin, "install svn://errtheblog.com/svn/plugins/classic_pagination")
66
69
 
@@ -93,8 +96,3 @@ Dir.chdir(app_path) do
93
96
  end
94
97
  end
95
98
 
96
- puts <<-END
97
- NOTE: If you intend to use the in-place-editors, the new form authenticity
98
- features (CSRF protection) are not supported. You'll need to comment out the
99
- 'protect_from_forgery' declaration in app/controllers/application.rb
100
- END
@@ -1,3 +1,173 @@
1
+ === Release 0.7 ===
2
+
3
+ Hobo 0.7 is tested against Rails 1.99.1 (aka Rais 2.0 RC2)
4
+
5
+ DRYML
6
+
7
+ Switched to dashes instead of underscores for tag and attributes
8
+ names. These are converted to underscores in the underlying ruby
9
+ code.
10
+
11
+ Unification of tempalte tags and non-template tags. There is now
12
+ only one type of tag and two different ways to call a tag:
13
+
14
+ <my-tag>content directly inside the tag</my-tag>
15
+
16
+ <my-tag>
17
+ <a-parameter:>Content inside a named parameter (note the colon)</a-parameter>
18
+ <another-parameter:>Some more content</another-parameter>
19
+ </my-tag>
20
+
21
+ Note that these styles cannot be mixed. If there is a parameter
22
+ inside a tag call, there must be only parameters (and whitespace,
23
+ which is not output)
24
+
25
+ In the first style, the call is implicitly equivalent to:
26
+
27
+ <my-tag>
28
+ <default:>content directly inside the tag</default>
29
+ </my-tag>
30
+
31
+ And by the same token, <tagbody/> is now written:
32
+
33
+ <do param="default"/>
34
+
35
+ The tagbody local variable is gone too. "if tagbody" is now
36
+ "if all_parameters.default?" and "tagbody.call" is now
37
+ "all_parameters.default"
38
+
39
+
40
+ A rake task hobo:fixdryml has been added which does a pretty good
41
+ job of converting Hobo 0.6 DRYML source-code to the new style. It
42
+ will change every file in app/views/**/*.dryml, and keeps a backup
43
+ copy of app/views in app_views_before_fixdryml. If you pass it CSS=y
44
+ and ID=y it will 'dasherize' css classes and IDs too, which is the
45
+ new Hobo concention. You can also pass DIR=... if you want to point
46
+ it somewhere other than app/views. It won't fix anything in erb
47
+ scriptlets, e.g. use of the tagbody local variable. Expect to do
48
+ some manual fixes after running the task (good job you've got that
49
+ thourough test suite eh?)
50
+
51
+ The add_classes helper now automatically dasherizes all class names.
52
+
53
+ New helper 'element'. Use in place of Rails' tag and content_tag
54
+ helper. It dasherizes attributes given as symbols.
55
+
56
+
57
+ Migration generator
58
+
59
+ Better support for STI. It no longer wants to generate tables for
60
+ the subclasses. Stil needed: a way of integrating fields declared in
61
+ the subclasses -- they are currently ignored by the generator.
62
+
63
+
64
+ Hobo Rapid
65
+
66
+ In place editiing (and Ajax in general) will now provide the form
67
+ authentication token (CSRF protection) if available. No need to
68
+ disable protect_from_forgery any more.
69
+
70
+
71
+ Stylesheets:
72
+
73
+ Removed list-style: none from hobo_abse.css
74
+
75
+
76
+ Javascript:
77
+
78
+ Dasherized all css classes and dom IDs used.
79
+
80
+ Upgraded to latest low_pro.js
81
+
82
+
83
+ New theme 'Clean'
84
+
85
+ New helper 'linkable?' can be given a record or class, and tells you
86
+ if Hobo has a route for it. Only works for 'show' and 'index'
87
+ actions so far.
88
+
89
+ Tag library
90
+
91
+ \\'/;p <a> now automatically knows not to generate (broken) links to
92
+ things that are not 'linkable?'. Outputs just the link content
93
+ instead.
94
+
95
+ We used to have <FieldList> and <field_list>. We now have
96
+ <field-list> and <labelled-item-list>
97
+
98
+ <UL> is now <ul>, and only has the iteration behaviour if you give
99
+ a <li:> parameter. Otherwise it's just like a static tag.
100
+
101
+ <Table> is now <table> and only has the special behaviour if you
102
+ give a 'fields' attribute or '<tr:>' parameter. Otherwise it's
103
+ just like a static tag.
104
+
105
+ <view> for dates and times no longer break when the context is
106
+ nil.
107
+
108
+ <count> - unless-none attribute is gone. user if-any
109
+
110
+ <theme-stylesheet> now takes a 'name' attribute
111
+
112
+ <delete-button> takes a 'subsite' attribute
113
+
114
+
115
+ Rake tasks
116
+
117
+ New task hobo:fixdryml (see DRYML section above)
118
+
119
+ dump_fixtures is now hobo:fixtures:dump
120
+
121
+
122
+
123
+
124
+ Hobo models
125
+
126
+ Automatically declares the field 'position :integer' if the model
127
+ acts_as_list.
128
+
129
+ never_show declarations are now inherited
130
+
131
+ Fix: def_scope was broken when the scope name ended '?'
132
+
133
+ Fix: Hobo broke the 'guard_protected_attributes' optional parameter
134
+ to attributes=. (this was breaking attachment_fu)
135
+
136
+ Fix: assigning Date and Time objects in mass-assignment was broken.
137
+
138
+
139
+ User model
140
+
141
+ Newly generated user models (hobo_user_model generator) now give
142
+ create permission to all by default (to enable signup).
143
+
144
+ logins_count renamed to login_count (Hobo manages this feild for you
145
+ if it exists).
146
+
147
+
148
+ Core extensions
149
+
150
+ Module#alias_tag_chain, which never should have been there is
151
+ gone. (It's not needed now that camel-case tags have gone).
152
+
153
+
154
+
155
+
156
+
157
+
158
+
159
+
160
+
161
+
162
+
163
+
164
+
165
+
166
+
167
+
168
+
169
+
170
+
1
171
  === Release 0.6.4 ===
2
172
 
3
173
  Fix: In-place-editors were not working with the new version of
@@ -1,26 +1,26 @@
1
- <Page title="<%= app_name %>">
1
+ <page title="<%= app_name %>">
2
2
 
3
- <content_header>
4
- <h1 class="front_page_title"><%= app_name %></h1>
3
+ <content-header:>
4
+ <h1 class="front-page-title"><%= app_name %></h1>
5
5
  <panel>
6
- <div style="margin-left: 40px; ">
6
+ <div>
7
7
  <h3>Congratulations! Your Hobo Rails App is up and running</h3>
8
8
  <ul>
9
9
  <li>To customise this page: edit app/views/<%= file_name %>/index.dryml </li>
10
10
  </ul>
11
11
  </div>
12
12
  </panel>
13
- </content_header>
13
+ </content-header>
14
14
 
15
15
 
16
- <content_body>
16
+ <content-body:>
17
17
  <repeat with="&Hobo.models">
18
18
  <panel>
19
19
  <header><h2><%%= this.name.titlecase.pluralize %></h2></header>
20
20
  <section>
21
21
  <if test="&this.count == 0">
22
22
  <p>There are no <%%= this.name.titleize.pluralize %></p>
23
- <if test="&can_create?(this)">
23
+ <if test="&can_create?">
24
24
  <p>Create a <a to="&this" action="new"/>.</p>
25
25
  </if>
26
26
  </if>
@@ -33,6 +33,6 @@
33
33
  </section>
34
34
  </panel>
35
35
  </repeat>
36
- </content_body>
36
+ </content-body>
37
37
 
38
- </Page>
38
+ </page>
@@ -1,19 +1,19 @@
1
- <Page title="Search">
2
- <body onload="Hobo.applyEvents(); Hobo.doSearch('search_field')"/>
1
+ <page title="Search">
2
+ <body: onload="Hobo.applyEvents(); Hobo.doSearch('search-field')"/>
3
3
 
4
- <content_body>
4
+ <content-body:>
5
5
  <panel class="red" style="margin-top: 40px">
6
6
  <h2>Search</h2>
7
- <div class='search' style='margin:10px'>
8
- <input type='text' id="search_field" class="search_bhv" style="width: 90%"/>
7
+ <div class="search">
8
+ <input type="text" id="search-field" class="search-bhv" style="width: 90%"/>
9
9
  <spinner id="search_spinner"/>
10
10
  </div>
11
11
  </panel>
12
12
 
13
- <panel class="hidden" id="search_results_panel">
13
+ <panel class="hidden" id="search-results-panel">
14
14
  <h2>Results</h2>
15
- <section id="search_results">&nbsp;</section>
15
+ <section id="search-results">&nbsp;</section>
16
16
  </panel>
17
- </content_body>
17
+ </content-body>
18
18
 
19
- </Page>
19
+ </page>
@@ -7,6 +7,12 @@ class HoboMigrationGenerator < Rails::Generator::Base
7
7
  "hobo_migration_#{i+1}"
8
8
  end
9
9
  end
10
+
11
+ def table_model_classes
12
+ ActiveRecord::Base.send(:subclasses).
13
+ reject {|c| c.name.starts_with?("CGI::") }.
14
+ select {|c| c.superclass == ActiveRecord::Base}
15
+ end
10
16
 
11
17
  def manifest
12
18
  connection = ActiveRecord::Base.connection
@@ -17,8 +23,7 @@ class HoboMigrationGenerator < Rails::Generator::Base
17
23
 
18
24
  ignore_model_names = Hobo::Migrations.ignore.every(:underscore)
19
25
 
20
- all_models = ActiveRecord::Base.send(:subclasses).reject {|c| c.name.starts_with?("CGI::") }
21
- models, ignore_models = all_models.partition do |m|
26
+ models, ignore_models = table_model_classes.partition do |m|
22
27
  m.name.underscore.not_in?(ignore_model_names) && m < Hobo::Model
23
28
  end
24
29
  ignore_tables = ignore_models.every(:table_name) | Hobo::Migrations.ignore_tables
@@ -10,10 +10,10 @@ class HoboRapidGenerator < Hobo::Generator
10
10
  end
11
11
 
12
12
  record do |m|
13
- m.file "hobo_rapid.js", "public/javascripts/hobo_rapid.js"
13
+ m.file "hobo-rapid.js", "public/javascripts/hobo-rapid.js"
14
14
  m.file "lowpro.js", "public/javascripts/lowpro.js"
15
- m.file "hobo_base.css", "public/stylesheets/hobo_base.css"
16
- m.file "hobo_rapid.css", "public/stylesheets/hobo_rapid.css"
15
+ m.file "reset.css", "public/stylesheets/reset.css"
16
+ m.file "hobo-rapid.css", "public/stylesheets/hobo-rapid.css"
17
17
  create_all(m, "themes/default/public", "public/hobothemes/default")
18
18
  create_all(m, "themes/default/views", "app/views/taglibs/themes/default")
19
19
  end
@@ -22,7 +22,7 @@ class HoboRapidGenerator < Hobo::Generator
22
22
  def import_tags
23
23
  path = File.join(RAILS_ROOT, "app/views/taglibs/application.dryml")
24
24
 
25
- tag = "<include src=\"plugins/hobo/tags/rapid\"/>\n\n<set_theme name=\"default\"/>\n"
25
+ tag = "<include src=\"plugins/hobo/tags/rapid\"/>\n\n<set-theme name=\"default\"/>\n"
26
26
 
27
27
  src = File.read(path)
28
28
  return if src.include?(tag)
@@ -24,19 +24,19 @@ var Hobo = {
24
24
 
25
25
  updatesForElement: function(el) {
26
26
  el = $(el)
27
- var updates = el.getAttribute("hobo_update")
27
+ var updates = el.getAttribute("hobo-update")
28
28
  return updates ? updates.split(/\s*,\s*/) : []
29
29
  },
30
30
 
31
31
  ajaxSetFieldForElement: function(el, val, options) {
32
32
  var updates = Hobo.updatesForElement(el)
33
33
  var params = Hobo.fieldSetParam(el, val)
34
- var p = el.getAttribute("hobo_ajax_params")
34
+ var p = el.getAttribute("hobo-ajax-params")
35
35
  if (p) params = params + "&" + p
36
36
 
37
37
  var opts = Object.merge(options || {}, { params: params})
38
38
  Hobo.ajaxRequest(Hobo.putUrl(el),
39
- el.getAttribute("hobo_ajax_message") || "Changing...",
39
+ el.getAttribute("hobo-ajax-message") || "Changing...",
40
40
  updates,
41
41
  opts)
42
42
  },
@@ -48,11 +48,11 @@ var Hobo = {
48
48
  updates.each(function(id_or_el) {
49
49
  var el = $(id_or_el)
50
50
  if (el) { // ignore update of parts that do not exist
51
- var dom_id
52
- dom_id = el.id
53
- if (!hoboParts[dom_id]) { throw "Update of dom-id that is not a part: " + dom_id }
54
- params.push("render["+i+"][part_context]=" + encodeURIComponent(hoboParts[dom_id]))
55
- params.push("render["+i+"][id]=" + dom_id)
51
+ var partDomId
52
+ partDomId = el.id
53
+ if (!hoboParts[partDomId]) { throw "Update of dom-id that is not a part: " + partDomId }
54
+ params.push("render["+i+"][part_context]=" + encodeURIComponent(hoboParts[partDomId]))
55
+ params.push("render["+i+"][id]=" + partDomId)
56
56
  i += 1
57
57
  }
58
58
  })
@@ -86,6 +86,10 @@ var Hobo = {
86
86
  var url = form.action
87
87
  }
88
88
  var params = []
89
+
90
+ if (typeof(formAuthToken) != "undefined") {
91
+ params.push(formAuthToken.name + "=" + formAuthToken.value)
92
+ }
89
93
 
90
94
  updateParams = Hobo.ajaxUpdateParams(updates, options.resultUpdate)
91
95
  if (updateParams != "") { params.push(updateParams) }
@@ -155,16 +159,16 @@ var Hobo = {
155
159
  var oldValue = Hobo.ipeOldValues[el.id]
156
160
  delete Hobo.ipeOldValues[el.id]
157
161
 
158
- var blank = el.getAttribute("hobo_blank_message")
162
+ var blank = el.getAttribute("hobo-blank-message")
159
163
  if (blank && newValue.strip().length == 0) {
160
164
  el.update(blank)
161
165
  } else {
162
166
  el.update(newValue)
163
167
  }
164
168
 
165
- var modelId = el.getAttribute('hobo_model_id')
169
+ var modelId = el.getAttribute('hobo-model-id')
166
170
  if (oldValue) {
167
- $$("*[hobo_model_id=" + modelId + "]").each(function(e) {
171
+ $$("*[hobo-model-id=" + modelId + "]").each(function(e) {
168
172
  if (e != el && e.innerHTML == oldValue) e.update(newValue)
169
173
  })
170
174
  }
@@ -182,28 +186,29 @@ var Hobo = {
182
186
  opts = {okButton: false,
183
187
  cancelLink: false,
184
188
  submitOnBlur: true,
185
- callback: function(form, val) {
186
- old = val
187
- return (Hobo.fieldSetParam(el, val) + "&" + updateParams)
188
- },
189
- onFailure: function(resp) { alert(resp.responseText); el.innerHTML = old },
190
189
  evalScripts: true,
191
190
  htmlResponse: false,
192
191
  ajaxOptions: { method: "put" },
193
192
  onEnterHover: null,
194
- onLeaveHover: null
193
+ onLeaveHover: null,
194
+ callback: function(form, val) {
195
+ old = val
196
+ return (Hobo.fieldSetParam(el, val) + "&" + updateParams)
197
+ },
198
+ onFailure: function(resp) {
199
+ alert(resp.responseText); el.innerHTML = old
200
+ },
201
+ onEnterEditMode: function() {
202
+ var blank_message = el.getAttribute("hobo-blank-message")
203
+ if (el.innerHTML.gsub("&nbsp;", " ") == blank_message) {
204
+ el.innerHTML = ""
205
+ } else {
206
+ Hobo.ipeOldValues[el.id] = el.innerHTML
207
+ }
208
+ }
195
209
  }
196
210
  Object.extend(opts, options)
197
- var ipe = new Ajax.InPlaceEditor(el, Hobo.putUrl(el), opts)
198
- ipe.onEnterEditMode = function() {
199
- var blank_message = el.getAttribute("hobo_blank_message")
200
- if (el.innerHTML.gsub("&nbsp;", " ") == blank_message) {
201
- el.innerHTML = ""
202
- } else {
203
- Hobo.ipeOldValues[el.id] = el.innerHTML
204
- }
205
- }
206
- return ipe
211
+ return new Ajax.InPlaceEditor(el, Hobo.putUrl(el), opts)
207
212
  },
208
213
 
209
214
  applyEvents: function(root) {
@@ -212,21 +217,21 @@ var Hobo = {
212
217
  return new Selector(p).findElements(root)
213
218
  }
214
219
 
215
- select(".in_place_textfield_bhv").each(function (el) {
220
+ select(".in-place-textfield-bhv").each(function (el) {
216
221
  ipe = Hobo._makeInPlaceEditor(el)
217
222
  ipe.getText = function() {
218
223
  return this.element.innerHTML.gsub(/<br\s*\/?>/, "\n").unescapeHTML()
219
224
  }
220
225
  })
221
226
 
222
- select(".in_place_textarea_bhv").each(function (el) {
227
+ select(".in-place-textarea-bhv").each(function (el) {
223
228
  ipe = Hobo._makeInPlaceEditor(el, {rows: 2})
224
229
  ipe.getText = function() {
225
230
  return this.element.innerHTML.gsub(/<br\s*\/?>/, "\n").unescapeHTML()
226
231
  }
227
232
  })
228
233
 
229
- select(".in_place_html_textarea_bhv").each(function (el) {
234
+ select(".in-place-html-textarea-bhv").each(function (el) {
230
235
  var options = {rows: 2, handleLineBreaks: false}
231
236
  if (typeof(tinyMCE) != "undefined") options["submitOnBlur"] = false
232
237
  var ipe = Hobo._makeInPlaceEditor(el, options)
@@ -250,22 +255,22 @@ var Hobo = {
250
255
  }
251
256
  })
252
257
 
253
- select("select.number_editor_bhv").each(function(el) {
258
+ select("select.number-editor-bhv").each(function(el) {
254
259
  el.onchange = function() {
255
260
  Hobo.ajaxSetFieldForElement(el, el.value)
256
261
  }
257
262
  })
258
263
 
259
- select(".autocomplete_bhv").each(function (el) {
264
+ select(".autocomplete-bhv").each(function (el) {
260
265
  options = {paramName: "query", minChars: 3, method: 'get' }
261
266
  if (el.hasClassName("autosubmit")) {
262
267
  options.afterUpdateElement = function(el, item) { el.form.onsubmit(); }
263
268
  }
264
- new Ajax.Autocompleter(el, el.id + "_completions", el.getAttribute("autocomplete_url"),
269
+ new Ajax.Autocompleter(el, el.id + "-completions", el.getAttribute("autocomplete-url"),
265
270
  options);
266
271
  });
267
272
 
268
- select(".search_bhv").each(function(el) {
273
+ select(".search-bhv").each(function(el) {
269
274
  new Form.Element.Observer(el, 1.0, function() { Hobo.doSearch(el) })
270
275
  });
271
276
  },
@@ -273,10 +278,10 @@ var Hobo = {
273
278
 
274
279
  doSearch: function(el) {
275
280
  el = $(el)
276
- var spinner = $(el.getAttribute("search_spinner") || "search_spinner")
277
- var search_results = $(el.getAttribute("search_results") || "search_results")
278
- var search_results_panel = $(el.getAttribute("search_results_panel") || "search_results_panel")
279
- var url = el.getAttribute("search_url") || (urlBase + "/search")
281
+ var spinner = $(el.getAttribute("search-spinner") || "search-spinner")
282
+ var search_results = $(el.getAttribute("search-results") || "search-results")
283
+ var search_results_panel = $(el.getAttribute("search-results-panel") || "search-results-panel")
284
+ var url = el.getAttribute("search-url") || (urlBase + "/search")
280
285
 
281
286
  el.focus();
282
287
  var value = $F(el)
@@ -311,7 +316,11 @@ var Hobo = {
311
316
 
312
317
  fieldSetParam: function(el, val) {
313
318
  spec = Hobo.parseFieldId(el)
314
- return spec.name + '[' + spec.field + ']=' + encodeURIComponent(val)
319
+ res = spec.name + '[' + spec.field + ']=' + encodeURIComponent(val)
320
+ if (typeof(formAuthToken) != "undefined") {
321
+ res = res + "&" + formAuthToken.name + "=" + formAuthToken.value
322
+ }
323
+ return res
315
324
  },
316
325
 
317
326
  fadeObjectElement: function(el) {
@@ -343,7 +352,7 @@ var Hobo = {
343
352
 
344
353
 
345
354
  parseFieldId: function(el) {
346
- id = el.getAttribute("hobo_model_id")
355
+ id = el.getAttribute("hobo-model-id")
347
356
  if (!id) return
348
357
  m = id.match(/^([a-z_]+)_([0-9]+)_([a-z_]+)$/)
349
358
  if (m) return { name: m[1], id: m[2], field: m[3] }
@@ -360,7 +369,7 @@ var Hobo = {
360
369
  objectElementFor: function(el) {
361
370
  var m
362
371
  while(el.getAttribute) {
363
- id = el.getAttribute("hobo_model_id");
372
+ id = el.getAttribute("hobo-model-id");
364
373
  if (id) m = id.match(/^([a-z_]+)_([0-9]+)(_[a-z0-9_]*)?$/);
365
374
  if (m) break;
366
375
  el = el.parentNode;
@@ -370,13 +379,13 @@ var Hobo = {
370
379
 
371
380
 
372
381
  showSpinner: function(message) {
373
- if(t = $('ajax_progress_text')) Element.update(t, message);
374
- if(e = $('ajax_progress')) e.style.display = "block";
382
+ if(t = $('ajax-progress-text')) Element.update(t, message);
383
+ if(e = $('ajax-progress')) e.style.display = "block";
375
384
  },
376
385
 
377
386
 
378
387
  hideSpinner: function() {
379
- if(e = $('ajax_progress')) e.style.display = "none";
388
+ if(e = $('ajax-progress')) e.style.display = "none";
380
389
  },
381
390
 
382
391
 
@@ -426,6 +435,7 @@ Element.findContaining = function(el, tag) {
426
435
  return null;
427
436
  }
428
437
 
438
+ // Add an afterEnterEditMode hook to in-place-editor
429
439
  origEnterEditMode = Ajax.InPlaceEditor.prototype.enterEditMode
430
440
  Ajax.InPlaceEditor.prototype.enterEditMode = function(evt) {
431
441
  origEnterEditMode.bind(this)(evt)
@@ -433,6 +443,15 @@ Ajax.InPlaceEditor.prototype.enterEditMode = function(evt) {
433
443
  return false
434
444
  }
435
445
 
446
+ // Fix Safari in-place-editor bug
447
+ Ajax.InPlaceEditor.prototype.removeForm = function() {
448
+ if (!this._form) return;
449
+
450
+ if (this._form.parentNode) { try { Element.remove(this._form); } catch (e) {}}
451
+ this._form = null;
452
+ this._controls = { };
453
+ }
454
+
436
455
  // Silence errors from IE :-(
437
456
  Field.scrollFreeActivate = function(field) {
438
457
  setTimeout(function() {
@@ -460,7 +479,7 @@ HasManyThroughInput = Behavior.create({
460
479
  var select = this.element.down('select')
461
480
  var selected = select.options[select.selectedIndex]
462
481
  if (selected.style.display != "none" & selected.value != "") {
463
- var newItem = strToDom(this.element.down('.item_proto').innerHTML)
482
+ var newItem = strToDom(this.element.down('.item-proto').innerHTML)
464
483
  this.element.down('.items').appendChild(newItem);
465
484
  newItem.down('span').innerHTML = selected.innerHTML
466
485
  newItem.down('input[type=hidden]').value = selected.innerHTML
@@ -472,7 +491,7 @@ HasManyThroughInput = Behavior.create({
472
491
  onclick : function(e) {
473
492
  var el = Event.element(e);
474
493
  Event.stop(e);
475
- if (el.match(".remove_item")) { this.removeOne(el.parentNode) }
494
+ if (el.match(".remove-item")) { this.removeOne(el.parentNode) }
476
495
  },
477
496
 
478
497
  removeOne : function(el) {
@@ -487,5 +506,5 @@ HasManyThroughInput = Behavior.create({
487
506
  })
488
507
 
489
508
  Event.addBehavior({
490
- 'div.has_many_through.input' : HasManyThroughInput()
509
+ 'div.has-many-through.input' : HasManyThroughInput()
491
510
  });