hobo 2.0.0.pre3 → 2.0.0.pre4
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGES-1.4.txt +44 -9
- data/CHANGES-2.0.markdown +954 -0
- data/VERSION +1 -1
- data/lib/generators/hobo/front_controller/front_controller_generator.rb +3 -0
- data/lib/generators/hobo/front_controller/templates/index.dryml +1 -1
- data/lib/generators/hobo/routes/templates/hobo_routes.rb.erb +2 -2
- data/lib/generators/hobo/setup_wizard/setup_wizard_generator.rb +6 -0
- data/lib/generators/hobo/user_mailer/templates/activation.erb +1 -1
- data/lib/generators/hobo/user_mailer/templates/forgot_password.erb +1 -1
- data/lib/generators/hobo/user_mailer/templates/invite.erb +1 -1
- data/lib/hobo/controller/model.rb +1 -1
- data/lib/hobo/controller.rb +0 -1
- data/lib/hobo/model/accessible_associations.rb +1 -1
- data/lib/hobo/rapid/generators/rapid/cards.dryml.erb +2 -1
- data/lib/hobo/rapid/generators/rapid/forms.dryml.erb +1 -0
- data/lib/hobo/rapid/generators/rapid/pages.dryml.erb +1 -0
- data/lib/hobo.rb +6 -2
- data/test/doctest/hobo/scopes.rdoctest +1 -0
- metadata +9 -8
data/CHANGES-1.4.txt
CHANGED
@@ -60,6 +60,8 @@ version strings for the hobo_* gems with `:git => "git://github.com/tablatom/hob
|
|
60
60
|
## Updating a Hobo 1.3 application
|
61
61
|
{.nomove}
|
62
62
|
|
63
|
+
Many of the changes required in upgrading a Hobo 1.3 application are necessitated by the switch from Rails 3.0 to 3.2. [Railscasts has a good guide to upgrading to Rails 3.1](railscasts.com/episodes/282-upgrading-to-rails-3-1).
|
64
|
+
|
63
65
|
There are several changes that need to be made to your application to
|
64
66
|
upgrade from Hobo 1.3 to Hobo 2.0. Most of these changes are
|
65
67
|
required by the addition of the asset pipeline which was introduced in
|
@@ -90,16 +92,28 @@ You will also have to ensure that you are using Hobo's fork of will_paginate:
|
|
90
92
|
|
91
93
|
### config/
|
92
94
|
|
93
|
-
|
95
|
+
Most the changes in config/ are due to the assets pipeline. See
|
94
96
|
http://guides.rubyonrails.org/asset_pipeline.html#upgrading-from-old-versions-of-rails
|
95
97
|
|
98
|
+
In addition, you will probably want to add:
|
99
|
+
|
100
|
+
config.hobo.dont_emit_deprecated_routes = true
|
101
|
+
|
102
|
+
to your config/application.rb. See the [named routes section in this document](#named_routes_names_changed_to_use_standard_rails_names) for more details.
|
103
|
+
|
104
|
+
You will also want to add
|
105
|
+
|
106
|
+
config.watchable_dirs[File.join(config.root, 'app/view')] = ['dryml']
|
107
|
+
|
108
|
+
to your config/environments/development.rb
|
109
|
+
|
96
110
|
### application.dryml or front_site.dryml
|
97
111
|
|
98
112
|
Replace
|
99
113
|
|
100
114
|
<set-theme name="clean"/>
|
101
115
|
{.dryml}
|
102
|
-
|
116
|
+
|
103
117
|
with
|
104
118
|
|
105
119
|
<include gem='hobo_rapid'/>
|
@@ -133,13 +147,26 @@ included via the pipeline and can be deleted rather than moved:
|
|
133
147
|
javascripts/controls.js,dryml-support.js,hobo-rapid.js,ie7-recalc.js,prototype.js,blank.gif,dragdrop.js,effects.js,IE7.js,lowpro.js,rails.js
|
134
148
|
stylesheets/reset.css,hobo-rapid.css
|
135
149
|
|
136
|
-
|
137
|
-
|
138
|
-
|
139
|
-
|
140
|
-
|
141
|
-
|
142
|
-
|
150
|
+
You can organize your app/assets directory however you like, but you
|
151
|
+
probably should arrange it the way Hobo does, the install_plugin
|
152
|
+
generator expects it.
|
153
|
+
|
154
|
+
If you generate a new Hobo 2.0 application with the front site named "front" and an additional admin subsite named admin, it will put these in app/assets/javascripts:
|
155
|
+
|
156
|
+
application.js
|
157
|
+
application/
|
158
|
+
front.js
|
159
|
+
front/
|
160
|
+
admin.js
|
161
|
+
admin/
|
162
|
+
|
163
|
+
Application.js loads any rails plugins and then everything in the
|
164
|
+
application/ directory. Front.js loads application.js, then any hobo
|
165
|
+
plugins you've installed and then everything in the front/ directory.
|
166
|
+
Admin.js behaves similarly. Hobo views in the front subsite load
|
167
|
+
front.js and Hobo views in the admin subsite load admin.js.
|
168
|
+
|
169
|
+
app/assets/stylesheets is organized in a similar manner.
|
143
170
|
|
144
171
|
# Changes from Hobo 1.3 & hobo-jquery 1.3
|
145
172
|
|
@@ -516,6 +543,14 @@ itself, and passes the element as an argument.
|
|
516
543
|
});
|
517
544
|
});
|
518
545
|
|
546
|
+
### remove-class
|
547
|
+
|
548
|
+
`remove-class` is a new attribute that can be used if you're extending or parameterizing a part to remove a class or several classes from the element you're extending or parameterizing.
|
549
|
+
|
550
|
+
<new-page>
|
551
|
+
<form: remove-class="form-horizontal"/>
|
552
|
+
</new-page>
|
553
|
+
|
519
554
|
### before callback
|
520
555
|
{.todo}
|
521
556
|
|
@@ -0,0 +1,954 @@
|
|
1
|
+
Hobo 2.0 Changes
|
2
|
+
{: .document-title}
|
3
|
+
|
4
|
+
Documents the changes made in Hobo 2.0 and the changes required to
|
5
|
+
migrate applications to Hobo 2.0
|
6
|
+
|
7
|
+
Contents
|
8
|
+
{: .contents-heading}
|
9
|
+
|
10
|
+
- contents
|
11
|
+
{:toc}
|
12
|
+
|
13
|
+
# Installation
|
14
|
+
|
15
|
+
Meta tags: note for collaborators. A meta-tag looks like this {.done}. It's added after a paragraph with no blank spaces. The tags that we support are: {.ruby} {.javascript} {.dryml} and {.diff} for code highlighting. {.todo}, {.done}, {.check}, {.part} and {.nomove} indicate documentation progress moving into the Hobo manuals. {.check} means that it's probably done. {.part} means that it's partly done. {.nomove} means that this section only needs to exist in this CHANGES document. Finally, {.hidden} is used for paragraphs like this one that shouldn't show up on the website.
|
16
|
+
{.hidden}
|
17
|
+
|
18
|
+
## Creating a new application
|
19
|
+
{.part}
|
20
|
+
|
21
|
+
Final hobo 2.0 gems have not yet been released, so the standard instructions
|
22
|
+
of "gem install hobo; hobo new foo" do not yet work.
|
23
|
+
|
24
|
+
If you're on Linux you'll have to install a javascript runtime.
|
25
|
+
On Ubuntu 11.10 you can get one by typing `apt-get install
|
26
|
+
nodejs-dev`. Other Linuxes should be similar. Windows & OS X users
|
27
|
+
should already have a javascript scripting host installed. The list
|
28
|
+
of compatible javascript runtimes is
|
29
|
+
[here](https://github.com/sstephenson/execjs).
|
30
|
+
|
31
|
+
To install prerelease versions of Hobo, you have three options: gems
|
32
|
+
from rubygems, gems from source or pointing your Gemfile at hobo
|
33
|
+
source.
|
34
|
+
|
35
|
+
### Via gems from rubygems.org
|
36
|
+
|
37
|
+
gem install hobo --pre
|
38
|
+
hobo new foo
|
39
|
+
|
40
|
+
### Via gems from source
|
41
|
+
|
42
|
+
git clone git://github.com/tablatom/hobo
|
43
|
+
cd hobo
|
44
|
+
rake gems[install]
|
45
|
+
cd wherever-you-want-to-generate-your-app
|
46
|
+
hobo new foo
|
47
|
+
|
48
|
+
Once you've generated an app, you may wish to go in and replace the
|
49
|
+
version strings for the hobo_* gems with `:git => "git://github.com/tablatom/hobo"`
|
50
|
+
|
51
|
+
### Via source path
|
52
|
+
|
53
|
+
(This won't work on Windows)
|
54
|
+
|
55
|
+
git clone git://github.com/tablatom/hobo
|
56
|
+
export HOBODEV=`pwd`/hobo
|
57
|
+
cd wherever-you-want-to-generate-your-app
|
58
|
+
$HOBODEV/hobo/bin/hobo new foo
|
59
|
+
|
60
|
+
## Updating a Hobo 1.3 application
|
61
|
+
{.nomove}
|
62
|
+
|
63
|
+
Many of the changes required in upgrading a Hobo 1.3 application are necessitated by the switch from Rails 3.0 to 3.2. [Railscasts has a good guide to upgrading to Rails 3.1](railscasts.com/episodes/282-upgrading-to-rails-3-1).
|
64
|
+
|
65
|
+
There are several changes that need to be made to your application to
|
66
|
+
upgrade from Hobo 1.3 to Hobo 2.0. Most of these changes are
|
67
|
+
required by the addition of the asset pipeline which was introduced in
|
68
|
+
Rails 3.1.
|
69
|
+
|
70
|
+
Follow the asset pipeline upgrade steps outlined here:
|
71
|
+
http://guides.rubyonrails.org/asset_pipeline.html#upgrading-from-old-versions-of-rails
|
72
|
+
|
73
|
+
The easiest way to upgrade an existing Hobo 1.3 application is to
|
74
|
+
generate a new Hobo 2.0 application and copy differences from the new
|
75
|
+
app into your existing app.
|
76
|
+
|
77
|
+
### Gemfile
|
78
|
+
|
79
|
+
You'll need to add the gems required for the asset pipeline, add the
|
80
|
+
jquery-rails and jquery-ui-themes gem, and adjust the version numbers
|
81
|
+
for rails, hobo and perhaps others.
|
82
|
+
|
83
|
+
Hobo has also gained several additional gems, so you will have to add
|
84
|
+
dependencies for those. hobo_rapid is the Hobo tag library,
|
85
|
+
hobo_jquery is the javascript for hobo_rapid, and hobo_clean is the
|
86
|
+
default theme. Instead of or as well as hobo_clean you can use
|
87
|
+
hobo_clean_admin or hobo_clean_sidemenu or hobo_bootstrap.
|
88
|
+
|
89
|
+
You will also have to ensure that you are using Hobo's fork of will_paginate:
|
90
|
+
|
91
|
+
gem "will_paginate", :git => "git://github.com/Hobo/will_paginate.git"
|
92
|
+
|
93
|
+
### config/
|
94
|
+
|
95
|
+
Most the changes in config/ are due to the assets pipeline. See
|
96
|
+
http://guides.rubyonrails.org/asset_pipeline.html#upgrading-from-old-versions-of-rails
|
97
|
+
|
98
|
+
In addition, you will probably want to add:
|
99
|
+
|
100
|
+
config.hobo.dont_emit_deprecated_routes = true
|
101
|
+
|
102
|
+
to your config/application.rb. See the [named routes section in this document](#named_routes_names_changed_to_use_standard_rails_names) for more details.
|
103
|
+
|
104
|
+
You will also want to add
|
105
|
+
|
106
|
+
config.watchable_dirs[File.join(config.root, 'app/view')] = ['dryml']
|
107
|
+
|
108
|
+
to your config/environments/development.rb
|
109
|
+
|
110
|
+
### application.dryml or front_site.dryml
|
111
|
+
|
112
|
+
Replace
|
113
|
+
|
114
|
+
<set-theme name="clean"/>
|
115
|
+
{.dryml}
|
116
|
+
|
117
|
+
with
|
118
|
+
|
119
|
+
<include gem='hobo_rapid'/>
|
120
|
+
<include gem='hobo_jquery'/>
|
121
|
+
<include gem='hobo_jquery_ui'/>
|
122
|
+
<include gem='hobo_clean'/>
|
123
|
+
{.dryml}
|
124
|
+
|
125
|
+
Note that the default Hobo generation now always creates both a
|
126
|
+
front_site.dryml and an application.dryml, even if you don't create
|
127
|
+
any subsites.
|
128
|
+
|
129
|
+
Also be aware that application.dryml is no longer loaded automatically
|
130
|
+
if you have a front_site.dryml. Add
|
131
|
+
|
132
|
+
<include src="application" />
|
133
|
+
{.dryml}
|
134
|
+
|
135
|
+
to your front_site.dryml, your admin_site.dryml, et cetera.
|
136
|
+
|
137
|
+
### move public/ to app/assets/
|
138
|
+
{.todo}
|
139
|
+
|
140
|
+
In Rails 3.1, images, javascripts and stylesheets are loaded from
|
141
|
+
app/assets/ rather than from public/ so you'll have to move them.
|
142
|
+
Note that the following are Rails and/or Hobo assets that are now
|
143
|
+
included via the pipeline and can be deleted rather than moved:
|
144
|
+
|
145
|
+
images/rails.png
|
146
|
+
hobothemes/**
|
147
|
+
javascripts/controls.js,dryml-support.js,hobo-rapid.js,ie7-recalc.js,prototype.js,blank.gif,dragdrop.js,effects.js,IE7.js,lowpro.js,rails.js
|
148
|
+
stylesheets/reset.css,hobo-rapid.css
|
149
|
+
|
150
|
+
You can organize your app/assets directory however you like, but you
|
151
|
+
probably should arrange it the way Hobo does, the install_plugin
|
152
|
+
generator expects it.
|
153
|
+
|
154
|
+
If you generate a new Hobo 2.0 application with the front site named "front" and an additional admin subsite named admin, it will put these in app/assets/javascripts:
|
155
|
+
|
156
|
+
application.js
|
157
|
+
application/
|
158
|
+
front.js
|
159
|
+
front/
|
160
|
+
admin.js
|
161
|
+
admin/
|
162
|
+
|
163
|
+
Application.js loads any rails plugins and then everything in the
|
164
|
+
application/ directory. Front.js loads application.js, then any hobo
|
165
|
+
plugins you've installed and then everything in the front/ directory.
|
166
|
+
Admin.js behaves similarly. Hobo views in the front subsite load
|
167
|
+
front.js and Hobo views in the admin subsite load admin.js.
|
168
|
+
|
169
|
+
app/assets/stylesheets is organized in a similar manner.
|
170
|
+
|
171
|
+
# Changes from Hobo 1.3 & hobo-jquery 1.3
|
172
|
+
|
173
|
+
## Javascript framework changed to jQuery
|
174
|
+
{.nomove}
|
175
|
+
|
176
|
+
Hobo 1.3 and earlier versions used prototype.js for its Ajax support.
|
177
|
+
In Hobo 2.0 all of our javascript code has been rewritten to use
|
178
|
+
jQuery instead of prototype.js.
|
179
|
+
|
180
|
+
In the process of rewriting the code many tags have been updated to
|
181
|
+
add AJAX support, and tags that used non-standard AJAX mechanisms have
|
182
|
+
been updated to use standard Hobo form AJAX. The most visible of
|
183
|
+
these changes have been to the editors.
|
184
|
+
|
185
|
+
## The Asset Pipeline
|
186
|
+
{.todo}
|
187
|
+
|
188
|
+
we should create a (small) chapter on the Hobo asset pipeline layout. see above (move public/ to app/assets/)
|
189
|
+
{.hidden}
|
190
|
+
|
191
|
+
Hobo 2.0 uses the asset pipeline features introduced in Rails 3.1.
|
192
|
+
Hobo 2.0 does not work out of the box with the asset pipeline turned
|
193
|
+
off. It'd certainly be possible to copy all Hobo assets into public/,
|
194
|
+
but you would have to do so manually, there are no longer any rake
|
195
|
+
tasks to do this for you.
|
196
|
+
|
197
|
+
## application.dryml is no longer loaded automatically
|
198
|
+
{.todo}
|
199
|
+
|
200
|
+
Hobo 1.3 loaded application.dryml and then X_site.dryml, where X was
|
201
|
+
front or admin or the name of the current subsite. Hobo 2.0 only
|
202
|
+
loads X_site.dryml. If that fails, it loads application.dryml
|
203
|
+
instead.
|
204
|
+
|
205
|
+
A new application generated by Hobo 2.0 will have `<include
|
206
|
+
src="application"/>` in X_site.dryml so that application.dryml is
|
207
|
+
still loaded. When it is loaded is now controlled by the the author
|
208
|
+
rather than always loading first.
|
209
|
+
|
210
|
+
## :inverse_of recommended
|
211
|
+
{.todo}
|
212
|
+
|
213
|
+
For correct behaviour, please ensure that all accessible associations
|
214
|
+
have their :inverse_of option set in both directions.
|
215
|
+
|
216
|
+
## set-theme deprecated
|
217
|
+
{.nomove}
|
218
|
+
|
219
|
+
The old Hobo theme support has never worked well, and has been
|
220
|
+
replaced. Themes are now Hobo plugins and work like every other Hobo
|
221
|
+
2.0 plugin.
|
222
|
+
|
223
|
+
Replace:
|
224
|
+
|
225
|
+
<set-theme name="clean"/>
|
226
|
+
{.dryml}
|
227
|
+
|
228
|
+
with
|
229
|
+
|
230
|
+
<include gem="hobo_clean"/>
|
231
|
+
{.dryml}
|
232
|
+
|
233
|
+
and add
|
234
|
+
|
235
|
+
*= require hobo_clean
|
236
|
+
|
237
|
+
to your app/assets/stylesheets/front.css. Some themes may also
|
238
|
+
include javascript which would require them to be added to front.js as
|
239
|
+
well.
|
240
|
+
|
241
|
+
## default doctype changed
|
242
|
+
{.nomove}
|
243
|
+
|
244
|
+
The default doctype has been changed from `XHTML 1.0 TRANSITIONAL` to
|
245
|
+
`html`, also known as "standards mode" in Internet Explorer 8 and 9
|
246
|
+
and "html5" in other browsers.
|
247
|
+
|
248
|
+
## named routes' names changed to use standard Rails names
|
249
|
+
{.nomove}
|
250
|
+
|
251
|
+
The names of named routes generated by Hobo have changed to more
|
252
|
+
closely match the default names generated by the Rails REST route
|
253
|
+
generator. The standard 7 REST routes have not changed, but some
|
254
|
+
additional routes such as nested routes and lifecycle routes have been
|
255
|
+
renamed.
|
256
|
+
|
257
|
+
For the moment you can ask Hobo to emit both the new style and old
|
258
|
+
style routes by not defining
|
259
|
+
`config.hobo.dont_emit_deprecated_routes`.
|
260
|
+
|
261
|
+
Note that paths and method names have not changed, only the named
|
262
|
+
route has changed, so this change should not be visible to the user or
|
263
|
+
impact controller code.
|
264
|
+
|
265
|
+
The route name is leftmost column in `rake routes`.
|
266
|
+
|
267
|
+
Here are some example changes:
|
268
|
+
|
269
|
+
create_task_path => create_tasks_path # tasks#create
|
270
|
+
create_task_for_story_path => create_story_tasks_path # tasks#create_for_story
|
271
|
+
foo_transition_path => transition_foo_path # foos lifecycle transition
|
272
|
+
foo_show2_path => show2_foo_path # show_action :show2 in foos_controller
|
273
|
+
|
274
|
+
Note that in the second example, create_story_tasks_path, the
|
275
|
+
controller method name is `create_for_story`. This is the same method
|
276
|
+
name that Hobo 1.0 and 1.3 use; the default Rails method name would be
|
277
|
+
just plain `create`.
|
278
|
+
|
279
|
+
There are several named routes used in the user_mailer views generated
|
280
|
+
in a new application. These must be fixed up when upgrading an old
|
281
|
+
application. For instance, user_activate_url must be changed to
|
282
|
+
activate_user_url in activation.erb.
|
283
|
+
|
284
|
+
In exchange for the pain of updating some of your named routes, we
|
285
|
+
receive the following benefits:
|
286
|
+
|
287
|
+
- polymorphic_url works with nested routes and in more situations
|
288
|
+
|
289
|
+
- url_for will work in more situations
|
290
|
+
|
291
|
+
- the `<a>` tag and the many tags which use it now accept all the
|
292
|
+
`url_for` options, such as host and port.
|
293
|
+
|
294
|
+
- hobo_routes.rb is easier to read and understand
|
295
|
+
|
296
|
+
- code reduction in Hobo
|
297
|
+
|
298
|
+
## `remote-method-button` and `update-button` broken
|
299
|
+
{.nomove}
|
300
|
+
|
301
|
+
`remote-method-button`, `update-button` and similar buttons such as
|
302
|
+
`delete-button` were written early in the history of Hobo, before
|
303
|
+
standard form/part ajax was supported. These tags are easy to replace
|
304
|
+
with the much more flexible forms.
|
305
|
+
|
306
|
+
For backwards compatibility, most of these buttons have been updated
|
307
|
+
to 2.0. However, the little used `remote-method-button` and
|
308
|
+
`update-button` have not been converted to the 2.0 form.
|
309
|
+
|
310
|
+
## default field-list changed
|
311
|
+
{.nomove}
|
312
|
+
|
313
|
+
The default for `<field-list>` has changed to `<feckless-fieldset>`.
|
314
|
+
The old behaviour is still available in `<field-list-v1>`. Please
|
315
|
+
provide feedback: we are open to reversion before final release.
|
316
|
+
|
317
|
+
## Helper rearrangement
|
318
|
+
{.todo}
|
319
|
+
|
320
|
+
In previous versions of Hobo, all Hobo helpers were available in both
|
321
|
+
the controllers and the views. In this version, some helpers are
|
322
|
+
only available in the views. If there is a helper function that you
|
323
|
+
need to access in your controller, you can call in your controller:
|
324
|
+
|
325
|
+
HoboTypeHelper.add_to_controller(self)
|
326
|
+
|
327
|
+
Other Helper classes not included in the controller by default are
|
328
|
+
HoboDebugHelper, HoboDeprecatedHelper and HoboViewHintHelper.
|
329
|
+
|
330
|
+
Several helpers have been moved into
|
331
|
+
app/helpers/hobo_deprecated_helper.rb
|
332
|
+
|
333
|
+
If your application depends on any of these, you can set
|
334
|
+
config.hobo.include_deprecated_helper.
|
335
|
+
|
336
|
+
## Rails 3.2 required
|
337
|
+
|
338
|
+
Hobo 2.0 currently requires Rails 3.2 for operation.
|
339
|
+
|
340
|
+
## Enhancements
|
341
|
+
|
342
|
+
### Nested caching
|
343
|
+
{.todo}
|
344
|
+
|
345
|
+
See the docs for `<nested-cache>` and the blog post I'm going to
|
346
|
+
eventually write...
|
347
|
+
|
348
|
+
### push-state
|
349
|
+
{.todo}
|
350
|
+
|
351
|
+
AJAX now supports a new AJAX option 'push-state' if you have
|
352
|
+
History.js installed. It was inspired by [this
|
353
|
+
post](http://37signals.com/svn/posts/3112-how-basecamp-next-got-to-be-so-damn-fast-without-using-much-client-side-ui)
|
354
|
+
which uses push-state and fragment caching to create a very responsive
|
355
|
+
rails application. Hobo has always supported fragment caching
|
356
|
+
through Rails, but push-state support is new.
|
357
|
+
|
358
|
+
The easiest way to install History.js is to use the [jquery-historyjs](https://github.com/wweidendorf/jquery-historyjs)
|
359
|
+
gem. Follow the instructions in the [README at the
|
360
|
+
link](https://github.com/wweidendorf/jquery-historyjs).
|
361
|
+
|
362
|
+
push-state blurs the line between AJAX and non-AJAX techniques,
|
363
|
+
bringing the advantages of both to the table. It's considerably more
|
364
|
+
responsive than a page refresh, yet provides allows browser bookmarks
|
365
|
+
and history navigation to work correctly.
|
366
|
+
|
367
|
+
For example, if the foos and the bars pages have exactly the same
|
368
|
+
headers but different content, you can speed up links between the
|
369
|
+
pages by only refreshing the content:
|
370
|
+
|
371
|
+
<%# foos/index.dryml %>
|
372
|
+
<index-page>
|
373
|
+
<content:>
|
374
|
+
<do part="content">
|
375
|
+
<a href="&bars_page" ajax push-state new-title="Bars">Bars</a>
|
376
|
+
...
|
377
|
+
</do>
|
378
|
+
</content:>
|
379
|
+
<index-page>
|
380
|
+
|
381
|
+
Note to Hobo 1.3 users: We're using the new `ajax` attribute instead of
|
382
|
+
`update="content"` because the link is inside the part. Outside of the
|
383
|
+
part we'd use `update="content"` instead of `ajax`.
|
384
|
+
|
385
|
+
The `new-title` attribute may be used with push state to update the
|
386
|
+
title. If you want to update any other section in your headers, you
|
387
|
+
can put that into a part and list it in the update list as well.
|
388
|
+
However the new page cannot have new javascript or stylesheets.
|
389
|
+
Avoiding the refresh of these assets is one of the major reasons to
|
390
|
+
use push-state!
|
391
|
+
|
392
|
+
push-state is well suited for tasks that refreshed the current page
|
393
|
+
with new query parameters in Hobo 1.3, like `filter-menu`, pagination and
|
394
|
+
sorting on a `table-plus`. Thus these tags have been updated to
|
395
|
+
support all of the standard ajax attributes.
|
396
|
+
|
397
|
+
Of course, ajax requests that update only a small portion of the page
|
398
|
+
will update faster than those that update most of the page. However,
|
399
|
+
a small update may mean that a change to the URL is warranted, so you
|
400
|
+
may want to use standard Ajax rather than push-state in those cases.
|
401
|
+
Also, push-state generally should not be used for requests that modify
|
402
|
+
state
|
403
|
+
|
404
|
+
push-state works best in an HTML5 browser. It works in older browsers
|
405
|
+
such as IE8, IE9 or Firefox 3, but results in strange looking URL's. See
|
406
|
+
the README for History.js for more details on that behaviour.
|
407
|
+
|
408
|
+
### plugin generators
|
409
|
+
{.part}
|
410
|
+
|
411
|
+
Hobo has gained two new generators.
|
412
|
+
|
413
|
+
`hobo generate install_plugin` may be used from inside a Hobo
|
414
|
+
application to install a Hobo plugin. It modifies the Gemfile,
|
415
|
+
application.dryml or X_site.dryml and adds the plugin to
|
416
|
+
app/assets/javascripts and app/assets/stylesheets.
|
417
|
+
|
418
|
+
`hobo plugin` is used from outside of a Hobo application to create the
|
419
|
+
skeleton for a new plugin. See [the plugin manual page](FIXME) for
|
420
|
+
more details.
|
421
|
+
|
422
|
+
### multiple parts
|
423
|
+
{.todo}
|
424
|
+
|
425
|
+
I've updated DRYML so that it emits a different DOM ID if you
|
426
|
+
re-instantiate a part. (The first use of a part retains the DOM
|
427
|
+
ID=partname convention for backwards compatibility) "update=" requires
|
428
|
+
a DOM ID, so I've also added 2 new AJAX attributes that can be used
|
429
|
+
instead of "update=".
|
430
|
+
|
431
|
+
The first one is "updates=". Instead of a comma separated list of DOM
|
432
|
+
ID's, it takes a CSS selector.
|
433
|
+
|
434
|
+
The other one is "ajax". If used inside of a part, it indicates that
|
435
|
+
the containing part should be updated. If used outside of a part,
|
436
|
+
AJAX will be used but no parts will be updated.
|
437
|
+
|
438
|
+
These three Ajax attributes may be used simultaneously.
|
439
|
+
|
440
|
+
Example:
|
441
|
+
|
442
|
+
<collection:stories>
|
443
|
+
<div part="inner">
|
444
|
+
<form ajax>
|
445
|
+
<input:title/>
|
446
|
+
</form>
|
447
|
+
</div>
|
448
|
+
</collection>
|
449
|
+
|
450
|
+
### Bottom-loading Javascript
|
451
|
+
{.todo}
|
452
|
+
|
453
|
+
The `<page>` tag has a new attribute: `bottom-load-javascript`. If
|
454
|
+
set, Javascript is loaded via a deferred load at the bottom of the
|
455
|
+
body rather than being loaded conventionally in the head.
|
456
|
+
|
457
|
+
You probably want to enable this globally in your application by
|
458
|
+
adding this to your application.dryml:
|
459
|
+
|
460
|
+
<extend tag="page">
|
461
|
+
<old-page bottom-load-javascript merge/>
|
462
|
+
</extend>
|
463
|
+
|
464
|
+
Note that if this option is set, the custom-scripts parameter is no
|
465
|
+
longer available. There is a new parameter called custom-javascript
|
466
|
+
that can be used instead, though.
|
467
|
+
|
468
|
+
Replace:
|
469
|
+
|
470
|
+
<custom-scripts:>
|
471
|
+
<script type="text/javascript">
|
472
|
+
$(document).ready(function() {
|
473
|
+
alert('hi');
|
474
|
+
});
|
475
|
+
</script>
|
476
|
+
</custom-scripts:>
|
477
|
+
|
478
|
+
with:
|
479
|
+
|
480
|
+
<custom-javascript:>
|
481
|
+
alert('hi');
|
482
|
+
</custom-javascript:>
|
483
|
+
|
484
|
+
If you wish to be compatible with both top & bottom loading use:
|
485
|
+
|
486
|
+
<custom-javascript:>
|
487
|
+
$(document).read(function() {
|
488
|
+
alert('hi');
|
489
|
+
})
|
490
|
+
</custom-javascript:>
|
491
|
+
|
492
|
+
If you were previously loading files via custom-scripts, use the asset
|
493
|
+
pipeline instead.
|
494
|
+
|
495
|
+
Turning on bottom-load will prevent Rails from splitting front.js into
|
496
|
+
multiple files even if you enable config.assets.debug in your
|
497
|
+
environment.
|
498
|
+
|
499
|
+
### allowing errors in parts
|
500
|
+
{.todo}
|
501
|
+
|
502
|
+
Older versions of Hobo did not render a part update if the update did
|
503
|
+
not pass validation.
|
504
|
+
|
505
|
+
This behaviour may now be overridden by using the 'errors-ok'
|
506
|
+
attribute on your form. (or formlet or whatever other tag initiates
|
507
|
+
the Ajax call).
|
508
|
+
|
509
|
+
The 'errors-ok' attribute is processed in update_response. If you've
|
510
|
+
supplied a block to hobo_update you will be responsible for
|
511
|
+
implementing this functionality yourself.
|
512
|
+
|
513
|
+
### AJAX file uploads
|
514
|
+
{.todo}
|
515
|
+
|
516
|
+
If you have malsup's form plugin installed, Ajax file uploads should
|
517
|
+
"just work", as long as you don't have debug_rjs turned on in your
|
518
|
+
config/initializers/development.rb.
|
519
|
+
|
520
|
+
Make sure you're form uses multipart encoding:
|
521
|
+
|
522
|
+
<form multipart ajax/>
|
523
|
+
|
524
|
+
### AJAX events
|
525
|
+
{.todo}
|
526
|
+
|
527
|
+
The standard 'before', 'success', 'done' and 'error' callbacks may
|
528
|
+
still be used. Additionally, the AJAX code now triggers
|
529
|
+
'rapid:ajax:before', 'rapid:ajax:success', 'rapid:ajax:done' and
|
530
|
+
'rapid:ajax:error' events to enable you to code more unobtrusively.
|
531
|
+
|
532
|
+
If your form is inside of a part, it's quite likely that the form will
|
533
|
+
be replaced before the rapid:ajax:success and rapid:ajax:done events
|
534
|
+
fire. To prevent memory leaks, jQuery removes event handlers from all
|
535
|
+
removed elements, making it impossible to catch these events.
|
536
|
+
If this is the case, hobo-jquery triggers these events on the document
|
537
|
+
itself, and passes the element as an argument.
|
538
|
+
|
539
|
+
$(document).ready(function() {
|
540
|
+
jQuery(document).on("rapid:ajax:success", function(event, el) {
|
541
|
+
// `this` is the document and `el` is the form
|
542
|
+
alert('success');
|
543
|
+
});
|
544
|
+
});
|
545
|
+
|
546
|
+
### remove-class
|
547
|
+
|
548
|
+
`remove-class` is a new attribute that can be used if you're extending or parameterizing a part to remove a class or several classes from the element you're extending or parameterizing.
|
549
|
+
|
550
|
+
<new-page>
|
551
|
+
<form: remove-class="form-horizontal"/>
|
552
|
+
</new-page>
|
553
|
+
|
554
|
+
### before callback
|
555
|
+
{.todo}
|
556
|
+
|
557
|
+
A new callback has been added to the list of Ajax Callbacks: before.
|
558
|
+
This callback fires before any Ajax is done. If you return false
|
559
|
+
from this, the Ajax is cancelled. So you should probably ensure you
|
560
|
+
explicitly return true if you use it and don't want your ajax
|
561
|
+
cancelled.
|
562
|
+
|
563
|
+
### callbacks
|
564
|
+
{.todo}
|
565
|
+
|
566
|
+
Normally in HTML you can attach either a snippet of javascript or a
|
567
|
+
function to a callback.
|
568
|
+
|
569
|
+
<button onclick=fbar/>
|
570
|
+
|
571
|
+
This doesn't work in DRYML because the function is not defined in
|
572
|
+
Ruby, it's only defined in Javascript.
|
573
|
+
|
574
|
+
In Hobo 1.3 you would thus be forced to do this to get equivalent behaviour:
|
575
|
+
|
576
|
+
<form update="foo" success="return fbar.call(this);"/>
|
577
|
+
|
578
|
+
Now you can just return the function name:
|
579
|
+
|
580
|
+
<form ajax success="fbar"/>
|
581
|
+
|
582
|
+
### `hide` and `show` ajax options
|
583
|
+
{.todo}
|
584
|
+
|
585
|
+
There are two new ajax options: `hide` and `show`. These are passed
|
586
|
+
directly to the jQuery-UI `hide` and `show` functions. See
|
587
|
+
(here)[http://jqueryui.com/demos/show/] and
|
588
|
+
(here)[http://docs.jquery.com/UI/Effects] for more documentation on
|
589
|
+
these two functions. Due to ruby to javascript translation
|
590
|
+
difficulties, you may not drop optional middle parameters.
|
591
|
+
|
592
|
+
Examples:
|
593
|
+
|
594
|
+
<form ajax hide="puff,,slow" show="&['slide', {:direction => :up}, 'fast', 'myFunctionName']/>
|
595
|
+
|
596
|
+
<form ajax hide="drop" show="&['slide', nil, 1000, 'alert(done);']"/>
|
597
|
+
|
598
|
+
These two options have global defaults which are TBD. They may be overridden by passing options to the page-script parameter of `<page>`:
|
599
|
+
|
600
|
+
<extend tag="page">
|
601
|
+
<old-page merge>
|
602
|
+
<page-scripts: hide="&['slide',{:direction => :up}, 'fast']" show="&['slide',{:direction => :up},'fast']"/>
|
603
|
+
</old-page>
|
604
|
+
</extend>
|
605
|
+
|
606
|
+
To disable effects entirely: FIXME.
|
607
|
+
|
608
|
+
### spinner options
|
609
|
+
{.todo}
|
610
|
+
|
611
|
+
By default, the spinner is now displayed next to the element being
|
612
|
+
updated. Besides the old `spinner-next-to` option, there are a number
|
613
|
+
of new options that control how the spinner is displayed.
|
614
|
+
|
615
|
+
- spinner-next-to: DOM id of the element to place the spinner next to.
|
616
|
+
- spinner-at: CSS selector for the element to place the spinner next to.
|
617
|
+
- no-spinner: if set, the spinner is not displayed.
|
618
|
+
- spinner-options: passed to [jQuery-UI's position](http://jqueryui.com/demos/position/). Defaults are `{my: 'right bottom', at: 'left top'}`
|
619
|
+
- message: the message to display inside the spinner
|
620
|
+
|
621
|
+
The above attributes may be added to most tags that accept the standard ajax attributes.
|
622
|
+
|
623
|
+
These options may be overridden globally by adding them as attributes to the `page-scripts` parameter for the page.
|
624
|
+
|
625
|
+
<extend tag="page">
|
626
|
+
<old-page merge>
|
627
|
+
<page-scripts: spinner-at="#header" spinner-options="&{:my => 'left top', :at => 'left top'}" />
|
628
|
+
</old-page>
|
629
|
+
</extend>
|
630
|
+
|
631
|
+
### hjq-datepicker
|
632
|
+
{.done}
|
633
|
+
|
634
|
+
hjq-datepicker now automatically sets dateFormat to the value
|
635
|
+
specified in your translations: (I18n.t :"date.formats.default").
|
636
|
+
|
637
|
+
### sortable-collection
|
638
|
+
{.done}
|
639
|
+
|
640
|
+
sortable-collection now supports the standard Ajax callbacks
|
641
|
+
|
642
|
+
### delete-button
|
643
|
+
{.done}
|
644
|
+
|
645
|
+
The new `delete-button` behaviour is not as much different from the
|
646
|
+
old `delete-button` as a comparison of the documentation would have
|
647
|
+
you believe, however its Ajax triggering behaviour has changed slightly.
|
648
|
+
|
649
|
+
The `fade` attribute is no longer supported. Instead use the new
|
650
|
+
standard ajax attribute `hide`.
|
651
|
+
|
652
|
+
### autocomplete
|
653
|
+
{.done}
|
654
|
+
|
655
|
+
`hjq-autocomplete` has been renamed to `autocomplete`. It has gained
|
656
|
+
the attribute `nil-value` and the ability to work with the standard
|
657
|
+
Hobo autocomplete and hobo_completions controller actions.
|
658
|
+
|
659
|
+
`name-one` is now a simple backwards-compatibility wrapper around
|
660
|
+
`autocomplete`.
|
661
|
+
|
662
|
+
### input-many
|
663
|
+
{.done}
|
664
|
+
|
665
|
+
`hjq-input-many` and `input-many` have been merged into `input-many`.
|
666
|
+
The new standard ajax attributes `hide` and `show` are also now
|
667
|
+
supported.
|
668
|
+
|
669
|
+
Differences from old `input-many`:
|
670
|
+
|
671
|
+
- supports hobo-jquery delayed initialization.
|
672
|
+
- new attributes: add-hook, remove-hook, hide, show
|
673
|
+
|
674
|
+
Differences from `hjq-input-many`:
|
675
|
+
|
676
|
+
- name of the main parameter is `default` rather than `item`.
|
677
|
+
- rapid:add, rapid:change and rapid:remove events added.
|
678
|
+
- new attributes: hide, show
|
679
|
+
|
680
|
+
### filter-menu
|
681
|
+
{.done}
|
682
|
+
|
683
|
+
filter-menu now accepts AJAX attributes.
|
684
|
+
|
685
|
+
### a
|
686
|
+
{.done}
|
687
|
+
|
688
|
+
the a tag now accepts AJAX attributes. This is especially useful with
|
689
|
+
the new 'push-state' option.
|
690
|
+
|
691
|
+
### dialog-box
|
692
|
+
{.done}
|
693
|
+
|
694
|
+
`hjq-dialog` has been renamed to `dialog-box`. (`dialog` has already
|
695
|
+
been taken in HTML5).
|
696
|
+
|
697
|
+
The helper functions have been renamed. For instance,
|
698
|
+
`hjq.dialog.formletSubmit` has been renamed to
|
699
|
+
`hjq_dialog_box.submit`.
|
700
|
+
|
701
|
+
Dialog positioning has been updated and should work better now. See
|
702
|
+
the documentation for more details.
|
703
|
+
|
704
|
+
### search-filter
|
705
|
+
{.done}
|
706
|
+
|
707
|
+
The table-plus search filter has been extracted into its own tag for
|
708
|
+
use outside of table-plus. It has also gained a "clear" button.
|
709
|
+
|
710
|
+
### live-search
|
711
|
+
{.part}
|
712
|
+
|
713
|
+
`live-search` works in a substantially different fashion now, it has
|
714
|
+
almost completely lost its magic, instead using standard ajax forms
|
715
|
+
and parts. It should now be possible to customize using standard
|
716
|
+
Hobo techniques. See the documentation for `<live-search>` and
|
717
|
+
`<search-results>` for more details.
|
718
|
+
|
719
|
+
`live-search` has temporarily lost it's live-ness. Currently you have
|
720
|
+
to press 'return' to initiate the search. This should be easy to fix
|
721
|
+
in hjq-live-search.js -- the hard part will probably be in doing it in
|
722
|
+
a way that works in all possible browsers.
|
723
|
+
|
724
|
+
### hot-input
|
725
|
+
{.done}
|
726
|
+
|
727
|
+
see tag documentation
|
728
|
+
|
729
|
+
### page-nav
|
730
|
+
{.done}
|
731
|
+
|
732
|
+
The params attribute now defaults to
|
733
|
+
recognize_page_path.slice(:controller,:action,:id).
|
734
|
+
|
735
|
+
Standard form ajax attributes are now also supported, and behave
|
736
|
+
similar to `<a>`.
|
737
|
+
|
738
|
+
### query_params
|
739
|
+
{.todo}
|
740
|
+
|
741
|
+
The old query_params helper has been removed. You can use
|
742
|
+
Rails (request.query_parameters | request.request_parameters) instead
|
743
|
+
if you still need it.
|
744
|
+
|
745
|
+
There's a new helper function called query_parameters_filtered that
|
746
|
+
returns query parameters with the ajax parameters removed.
|
747
|
+
|
748
|
+
### parse_sort_param
|
749
|
+
|
750
|
+
The controller function parse_sort_param has been updated so that it
|
751
|
+
can take a hash instead of or as well as an argument list. The key of
|
752
|
+
the hash is the field name and the value is the column name.
|
753
|
+
Example:
|
754
|
+
|
755
|
+
Book.include(:authors).order(parse_sort_param(:title, :authors => "authors.last_name")
|
756
|
+
|
757
|
+
parse_sort_param now also pluralizes table names. For example, if the
|
758
|
+
field is named "project.title", parse_sort_param will sort on the
|
759
|
+
column "projects.title".
|
760
|
+
|
761
|
+
### controller actions
|
762
|
+
{.todo}
|
763
|
+
|
764
|
+
Hobo no longer attempts to perform its part-based AJAX actions when
|
765
|
+
sent an xhr request. Instead, Hobo performs part-based AJAX when
|
766
|
+
params[:render] is set.
|
767
|
+
|
768
|
+
The signature for the function update_response and friends has changed. This should make it useful for use in your application. It can be used like this:
|
769
|
+
|
770
|
+
def update
|
771
|
+
hobo_update do
|
772
|
+
if params[:foo]==17
|
773
|
+
render_my_way
|
774
|
+
else
|
775
|
+
update_response # let Hobo handle it all
|
776
|
+
end
|
777
|
+
end
|
778
|
+
end
|
779
|
+
|
780
|
+
### default controller actions now use respond_with
|
781
|
+
|
782
|
+
All Hobo model controller actions now use [respond_with](http://apidock.com/rails/ActionController/MimeResponds/respond_with) where appropriate. This means that you can create an API interface for a controller simply by adding:
|
783
|
+
|
784
|
+
respond_to :html, :json, :xml
|
785
|
+
|
786
|
+
See [respond_to](http://apidock.com/rails/ActionController/MimeResponds/ClassMethods/respond_to) and Google for "respond_with" for more information.
|
787
|
+
|
788
|
+
Note that the JSON and XML interfaces will only use coarse grained
|
789
|
+
model-level permission checking rather than fine grained attribute
|
790
|
+
level permission checking.
|
791
|
+
|
792
|
+
### before-unload
|
793
|
+
{.check}
|
794
|
+
|
795
|
+
`<form>` has gained a new option, before-unload, which adds an
|
796
|
+
onbeforeunload helper to the page.
|
797
|
+
|
798
|
+
## Editors
|
799
|
+
{.todo}
|
800
|
+
|
801
|
+
Editors are no longer special-cased, they now use the standard DRYML
|
802
|
+
part mechanism.
|
803
|
+
|
804
|
+
There are two types of editors: `<click-editor>` and `<live-editor>`.
|
805
|
+
click-editor is the click-to-edit type of control similar to what
|
806
|
+
Rapid currently uses for a string, and live-editor always renders the
|
807
|
+
input, and is similar to what Rapid currently uses for Boolean's and
|
808
|
+
enum-strings.
|
809
|
+
|
810
|
+
Please refer to the documentation for `click-editor` and `live-editor`
|
811
|
+
for more details.
|
812
|
+
|
813
|
+
`<editor>` is now a polymorphic input that uses either `<click-editor>` or
|
814
|
+
`<live-editor>`.
|
815
|
+
|
816
|
+
TBD: Right now live-editor and click-editor use `<formlet>`. The
|
817
|
+
major advantage of formlet is that it is safe to use inside of a form.
|
818
|
+
I can't think of any good use cases for that behaviour, but it does
|
819
|
+
seem like something people might do by accident.
|
820
|
+
|
821
|
+
The alternative is to use `<form>`. Since this implementation of
|
822
|
+
editor starts with an input and switches to a view via Javascript,
|
823
|
+
using a form would allow reasonable javascript-disabled behaviour.
|
824
|
+
|
825
|
+
## Changes behind the scenes
|
826
|
+
|
827
|
+
### reloading of part context
|
828
|
+
{.todo}
|
829
|
+
|
830
|
+
[This change](https://github.com/tablatom/hobo/commit/6048925) ensures that
|
831
|
+
DRYML does not reload the part context if it is already in `this`.
|
832
|
+
|
833
|
+
### i18n
|
834
|
+
{.todo}
|
835
|
+
|
836
|
+
These commits will require translation updates for languages other
|
837
|
+
than English. (Presumably this list will get larger because right now
|
838
|
+
the change is one I could do myself...)
|
839
|
+
|
840
|
+
- https://github.com/tablatom/hobo/commit/e9460d336ef85388af859e5082763bfae0ad01f5
|
841
|
+
|
842
|
+
### controller changes
|
843
|
+
{.todo}
|
844
|
+
|
845
|
+
Due to limitations on Ajax file uploads, multipart forms are not sent with the proper Ajax headers. If your controller action may receive multipart forms, rather than using:
|
846
|
+
|
847
|
+
respond_to do |wants|
|
848
|
+
wants.js { hobo_ajax_response }
|
849
|
+
wants.html {...}
|
850
|
+
end
|
851
|
+
|
852
|
+
use
|
853
|
+
|
854
|
+
if request.params[:render]
|
855
|
+
hobo_ajax_response
|
856
|
+
else
|
857
|
+
....
|
858
|
+
end
|
859
|
+
|
860
|
+
for more information see http://jquery.malsup.com/form/#file-upload
|
861
|
+
|
862
|
+
### hobo_ajax_response
|
863
|
+
{.todo}
|
864
|
+
|
865
|
+
the `hobo_ajax_response` function now has a different signature.
|
866
|
+
Standard usage doesn't supply any arguments to hobo_ajax_response.
|
867
|
+
This use case has not changed.
|
868
|
+
|
869
|
+
However, if you have code that supplied arguments to
|
870
|
+
hobo_ajax_response, that code likely will need to be updated for 2.0.
|
871
|
+
|
872
|
+
FIXME: pointer to AJAX background documentation.
|
873
|
+
|
874
|
+
### Dryml.render
|
875
|
+
{.todo}
|
876
|
+
|
877
|
+
Dryml.render now has an additional argument: imports. The template
|
878
|
+
environment no longer automatically imports ActionView::Helpers.
|
879
|
+
|
880
|
+
### View helpers imported
|
881
|
+
|
882
|
+
All application helpers are now available in the template
|
883
|
+
environment.
|
884
|
+
|
885
|
+
## Attribute Whitelist
|
886
|
+
{.todo}
|
887
|
+
|
888
|
+
Rails 3.2.3 and later changed the default for config.whitelist_attributes to true, so any newly generated Hobo apps will have this feature turned on. Hobo heavily depends on mass attribute assignation, so this may cause inconveniences.
|
889
|
+
|
890
|
+
Mass assignment protection is redundant in Hobo: your primary protection should come through the edit_permitted? function. If all of your models have properly defined edit_permitted? then it is safe to turn off config.whitelist_attributes.
|
891
|
+
|
892
|
+
If you choose not to turn off config.whitelist_attributes, any fields that are not in your attr_accessible declaration will not be available in forms. Hobo's generators will now assist in the creation of attr_accessible declarations.
|
893
|
+
|
894
|
+
# jQuery rewrite
|
895
|
+
|
896
|
+
FIXME: pull into separate document, along with interface specs
|
897
|
+
|
898
|
+
## Framework Agnosticism
|
899
|
+
{.dontmove}
|
900
|
+
|
901
|
+
jQuery support is being written in a manner that should make it easier to support other frameworks if we ever decide to do so. Basically all this means is that we're annotating our HTML and the javascript is picking up the information from the annotations rather than calling functions or setting variables.
|
902
|
+
|
903
|
+
## Unobtrusiveness
|
904
|
+
{.todo}
|
905
|
+
|
906
|
+
The agnosticism is a side benefit -- really the main reason its written this way is so that we're coding using "unobtrusive javascript" techniques.
|
907
|
+
|
908
|
+
Hobo currently many different mechanisms to pass data to javascript:
|
909
|
+
|
910
|
+
- classdata ex class="model::story:2"
|
911
|
+
- non-HTML5-compliant element attributes: ex hobo-blank-message="(click to edit)"
|
912
|
+
- variable assignment: ex hoboParts = ...;
|
913
|
+
- function calls: ex onclick="Hobo.ajaxRequest(url, {spinnerNextTo: 'foo'})"
|
914
|
+
|
915
|
+
hobo-jquery currently uses JSON inside of comments:
|
916
|
+
|
917
|
+
<!-- json_annotation ({"tag":"datepicker","options":{},"events":{}}); -->
|
918
|
+
|
919
|
+
We are switching all 5 of these mechanisms to use HTML5 data
|
920
|
+
attributes. HTML5 data attributes are technically illegal in HTML4
|
921
|
+
but work in all browsers future and past (even IE6). The illegality
|
922
|
+
of them is the reason that I didn't choose them in Hobo-jQuery, but
|
923
|
+
it's now 2011.
|
924
|
+
|
925
|
+
We mostly use a single attribute: `data-rapid`. This is a JSON hash
|
926
|
+
where the keys are the tag names and the values are options hashes.
|
927
|
+
DRYML has been modified to appropriately merge this tag in a fashion
|
928
|
+
similar to what it currently does for the `class` tag. For example,
|
929
|
+
live-search will have the attribute
|
930
|
+
`data-rapid='{"live-search":{"foo": 17}}'`. When hobo-jquery
|
931
|
+
initializes, it will then attempt to initialize a jQuery plugin named
|
932
|
+
`hjq_live_search`, which we provide in
|
933
|
+
public/javascripts/hobo-jquery/hjq-live-search.js. The plugin will
|
934
|
+
get passed the options hash {"foo": 17}.
|
935
|
+
|
936
|
+
`data-rapid-page-data` contains data required by the javascript
|
937
|
+
library, such as the part information.
|
938
|
+
|
939
|
+
One last attribute that may be set is `data-rapid-context`. This
|
940
|
+
contains a typed_id of the current context. This is used to assist
|
941
|
+
tags like `delete-button` with DOM manipulation.
|
942
|
+
|
943
|
+
## Compatibility
|
944
|
+
{.dontmove}
|
945
|
+
|
946
|
+
Obviously compatibility with hobo-rapid.js is not going to be
|
947
|
+
maintained, since that's written in prototype.
|
948
|
+
|
949
|
+
The internal structure of hobo-jquery has changed completely. We have
|
950
|
+
switched to using a more standard jQuery plugin style.
|
951
|
+
|
952
|
+
# Running the integration tests:
|
953
|
+
|
954
|
+
see https://github.com/tablatom/hobo/integration_tests/agility/README
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
2.0.0.
|
1
|
+
2.0.0.pre4
|
@@ -44,6 +44,9 @@ module Hobo
|
|
44
44
|
def add_routes
|
45
45
|
return unless options[:add_routes]
|
46
46
|
route "match 'search' => '#{file_path}#search', :as => 'site_search'"
|
47
|
+
route "match '#{options[:user_resource_name]}s/:id/activate_from_email/:key' => '#{options[:user_resource_name]}s#activate', :as => 'activate_from_email'"
|
48
|
+
route "match '#{options[:user_resource_name]}s/:id/accept_invitation_from_email/:key' => '#{options[:user_resource_name]}s#accept_invitation', :as => 'accept_invitation_from_email'"
|
49
|
+
route "match '#{options[:user_resource_name]}s/:id/reset_password_from_email/:key' => '#{options[:user_resource_name]}s#reset_password', :as => 'reset_password_from_email'"
|
47
50
|
if class_path.empty?
|
48
51
|
route "root :to => '#{file_path}#index'"
|
49
52
|
route "match ENV['RAILS_RELATIVE_URL_ROOT'] => 'front#index' if ENV['RAILS_RELATIVE_URL_ROOT']"
|
@@ -38,9 +38,9 @@
|
|
38
38
|
# These are the Hobo 1.3 style routes. They've been included for backwards
|
39
39
|
# compatibility reasons because the names of some named routes have been changed.
|
40
40
|
# Please update your views to use the new named route names and then disable this
|
41
|
-
# section by setting config.hobo.dont_emit_deprecated_routes = true.
|
42
|
-
|
41
|
+
# section by setting config.hobo.dont_emit_deprecated_routes = true. blah blah
|
43
42
|
|
43
|
+
<% puts "Warning: deprecated routes emitted into config/hobo_routes.rb. These will be removed in Hobo 2.1. Disable this warning by setting config.hobo.dont_emit_deprecated_routes = true." unless subsites.blank? %>
|
44
44
|
<% for subsite in subsites -%>
|
45
45
|
<%- if subsite -%>
|
46
46
|
|
@@ -156,6 +156,12 @@ EOI
|
|
156
156
|
end
|
157
157
|
end
|
158
158
|
|
159
|
+
def dont_emit_deprecated_routes
|
160
|
+
environment "#"
|
161
|
+
environment "config.hobo.dont_emit_deprecated_routes = true"
|
162
|
+
environment "# Hobo: Named routes have changed in Hobo 2.0. Set to false to emit both the 2.0 and 1.3 names."
|
163
|
+
end
|
164
|
+
|
159
165
|
def quiet_assets
|
160
166
|
say "Adding quiet_assets gem"
|
161
167
|
gem_with_comments('quiet_assets', :group => :development, :comments => "\n# Hobo has a lot of assets. Stop cluttering the log in development mode.")
|
@@ -3,7 +3,7 @@
|
|
3
3
|
If you have forgotten your password for <%%= @app_name %>, you can choose
|
4
4
|
a new one by clicking on this link:
|
5
5
|
|
6
|
-
<%%=
|
6
|
+
<%%= reset_password_from_email_url :id => @<%= name.underscore -%>, :key => @key %>
|
7
7
|
|
8
8
|
Thank you,
|
9
9
|
|
@@ -2,7 +2,7 @@
|
|
2
2
|
|
3
3
|
You have been invited to join <%%= @app_name %>. If you wish to accept, please click on the following link
|
4
4
|
|
5
|
-
<%%=
|
5
|
+
<%%= accept_invitation_from_email_url :id => @<%= name.underscore %>, :key => @key %>
|
6
6
|
|
7
7
|
Thank you,
|
8
8
|
|
@@ -409,7 +409,7 @@ module Hobo
|
|
409
409
|
end) ||
|
410
410
|
|
411
411
|
# Then try the record's show page
|
412
|
-
(!destroyed && object_url(@this)) ||
|
412
|
+
(!destroyed && !@this.new_record? && object_url(@this)) ||
|
413
413
|
|
414
414
|
# Then the show page of the 'owning' object if there is one
|
415
415
|
object_url(owning_object) ||
|
data/lib/hobo/controller.rb
CHANGED
@@ -89,7 +89,6 @@ module Hobo
|
|
89
89
|
if spec[:part_context]
|
90
90
|
part_content = renderer.refresh_part(spec[:part_context], session, dom_id)
|
91
91
|
part_content.gsub!('"', '&quot;') if options[:fix_quotes]
|
92
|
-
debugger
|
93
92
|
page << "#{function}(#{dom_id.to_json}, #{part_content.to_json})\n"
|
94
93
|
elsif spec[:result]
|
95
94
|
result = results[spec[:result].to_sym]
|
@@ -10,7 +10,7 @@ module Hobo
|
|
10
10
|
array = params_hash_to_array(array_or_hash)
|
11
11
|
array.map! do |record_hash_or_string|
|
12
12
|
finder = association.member_class
|
13
|
-
conditions = association.proxy_association.reflection.conditions
|
13
|
+
conditions = association.proxy_association.reflection.options[:conditions]
|
14
14
|
finder = finder.scoped :conditions => conditions unless conditions == [[]] || conditions == [[],[]]
|
15
15
|
find_or_create_and_update(owner, association_name, finder, record_hash_or_string) do |id|
|
16
16
|
# The block is required to either locate find an existing record in the collection, or build a new one
|
@@ -1,6 +1,7 @@
|
|
1
1
|
<% # routing's not available yet, so we just guess based on presence
|
2
2
|
# of methods
|
3
|
-
def linkable?(model, action)
|
3
|
+
def linkable?(model, action)
|
4
|
+
action = action.to_s if RUBY_VERSION < "1.9"
|
4
5
|
model.hobo_controller[subsite] && model.hobo_controller[subsite].public_instance_methods.include?(action)
|
5
6
|
end
|
6
7
|
|
@@ -1,6 +1,7 @@
|
|
1
1
|
<% # routing's not available yet, so we just guess based on presence
|
2
2
|
# of methods
|
3
3
|
def linkable?(model, action)
|
4
|
+
action = action.to_s if RUBY_VERSION < "1.9"
|
4
5
|
model.hobo_controller[subsite] && model.hobo_controller[subsite].public_instance_methods.include?(action)
|
5
6
|
end
|
6
7
|
|
@@ -1,6 +1,7 @@
|
|
1
1
|
<% # routing's not available yet, so we just guess based on presence
|
2
2
|
# of methods
|
3
3
|
def linkable?(model, action)
|
4
|
+
action = action.to_s if RUBY_VERSION < "1.9"
|
4
5
|
model.hobo_controller[subsite] && model.hobo_controller[subsite].public_instance_methods.include?(action)
|
5
6
|
end
|
6
7
|
|
data/lib/hobo.rb
CHANGED
@@ -1,8 +1,12 @@
|
|
1
1
|
require 'hobo_support'
|
2
2
|
require 'hobo_fields'
|
3
3
|
require 'dryml'
|
4
|
-
|
5
|
-
|
4
|
+
begin
|
5
|
+
gem 'will_paginate', "3.0.4.hobo"
|
6
|
+
rescue Gem::LoadError => e
|
7
|
+
puts "WARNING: unable to activate will_paginate 3.0.4.hobo. Please add gem \"will_paginate\", :git => \"git://github.com/Hobo/will_paginate.git\" to your Gemfile." if File.exist?("app/views/taglibs/application.dryml")
|
8
|
+
# don't print warning if setup not complete
|
9
|
+
end
|
6
10
|
require 'hobo/extensions/enumerable'
|
7
11
|
|
8
12
|
ActiveSupport::Dependencies.autoload_paths |= [File.dirname(__FILE__)]
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: hobo
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.0.0.
|
4
|
+
version: 2.0.0.pre4
|
5
5
|
prerelease: 6
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2012-
|
12
|
+
date: 2012-10-19 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: hobo_support
|
@@ -18,7 +18,7 @@ dependencies:
|
|
18
18
|
requirements:
|
19
19
|
- - '='
|
20
20
|
- !ruby/object:Gem::Version
|
21
|
-
version: 2.0.0.
|
21
|
+
version: 2.0.0.pre4
|
22
22
|
type: :runtime
|
23
23
|
prerelease: false
|
24
24
|
version_requirements: !ruby/object:Gem::Requirement
|
@@ -26,7 +26,7 @@ dependencies:
|
|
26
26
|
requirements:
|
27
27
|
- - '='
|
28
28
|
- !ruby/object:Gem::Version
|
29
|
-
version: 2.0.0.
|
29
|
+
version: 2.0.0.pre4
|
30
30
|
- !ruby/object:Gem::Dependency
|
31
31
|
name: hobo_fields
|
32
32
|
requirement: !ruby/object:Gem::Requirement
|
@@ -34,7 +34,7 @@ dependencies:
|
|
34
34
|
requirements:
|
35
35
|
- - '='
|
36
36
|
- !ruby/object:Gem::Version
|
37
|
-
version: 2.0.0.
|
37
|
+
version: 2.0.0.pre4
|
38
38
|
type: :runtime
|
39
39
|
prerelease: false
|
40
40
|
version_requirements: !ruby/object:Gem::Requirement
|
@@ -42,7 +42,7 @@ dependencies:
|
|
42
42
|
requirements:
|
43
43
|
- - '='
|
44
44
|
- !ruby/object:Gem::Version
|
45
|
-
version: 2.0.0.
|
45
|
+
version: 2.0.0.pre4
|
46
46
|
- !ruby/object:Gem::Dependency
|
47
47
|
name: dryml
|
48
48
|
requirement: !ruby/object:Gem::Requirement
|
@@ -50,7 +50,7 @@ dependencies:
|
|
50
50
|
requirements:
|
51
51
|
- - '='
|
52
52
|
- !ruby/object:Gem::Version
|
53
|
-
version: 2.0.0.
|
53
|
+
version: 2.0.0.pre4
|
54
54
|
type: :runtime
|
55
55
|
prerelease: false
|
56
56
|
version_requirements: !ruby/object:Gem::Requirement
|
@@ -58,7 +58,7 @@ dependencies:
|
|
58
58
|
requirements:
|
59
59
|
- - '='
|
60
60
|
- !ruby/object:Gem::Version
|
61
|
-
version: 2.0.0.
|
61
|
+
version: 2.0.0.pre4
|
62
62
|
- !ruby/object:Gem::Dependency
|
63
63
|
name: will_paginate
|
64
64
|
requirement: !ruby/object:Gem::Requirement
|
@@ -181,6 +181,7 @@ files:
|
|
181
181
|
- CHANGES-1.1.txt
|
182
182
|
- CHANGES-1.3.txt
|
183
183
|
- CHANGES-1.4.txt
|
184
|
+
- CHANGES-2.0.markdown
|
184
185
|
- Gemfile
|
185
186
|
- LICENSE.txt
|
186
187
|
- README
|