hobo 1.3.3 → 1.4.0.pre2
Sign up to get free protection for your applications and to get access to all the features.
- data/{CHANGES.txt → CHANGES-1.3.txt} +0 -0
- data/CHANGES-1.4.txt +678 -0
- data/Rakefile +13 -3
- data/TODO-1.4.txt +69 -0
- data/VERSION +1 -1
- data/app/helpers/hobo_debug_helper.rb +16 -0
- data/app/helpers/hobo_deprecated_helper.rb +45 -0
- data/app/helpers/hobo_helper_base.rb +8 -0
- data/app/helpers/hobo_permissions_helper.rb +136 -0
- data/app/helpers/hobo_route_helper.rb +196 -0
- data/{lib/hobo/helper/translations.rb → app/helpers/hobo_translations_helper.rb} +4 -7
- data/{lib/hobo/helper/translations/normalizer.rb → app/helpers/hobo_translations_normalizer_helper.rb} +3 -10
- data/app/helpers/hobo_type_helper.rb +24 -0
- data/app/helpers/hobo_view_hint_helper.rb +13 -0
- data/hobo.gemspec +3 -3
- data/lib/generators/hobo/admin_subsite/admin_subsite_generator.rb +0 -9
- data/lib/generators/hobo/admin_subsite/templates/application.dryml +2 -0
- data/lib/generators/hobo/admin_subsite/templates/gitkeep +0 -0
- data/lib/generators/hobo/admin_subsite/templates/site.css.erb +9 -0
- data/lib/generators/hobo/admin_subsite/templates/site.js.erb +10 -0
- data/lib/generators/hobo/assets/assets_generator.rb +16 -2
- data/lib/generators/hobo/assets/templates/application.css +9 -0
- data/lib/generators/hobo/assets/templates/application.dryml.erb +0 -5
- data/lib/generators/hobo/assets/templates/application.js +11 -0
- data/lib/generators/hobo/assets/templates/front.css +10 -0
- data/lib/generators/hobo/assets/templates/front.js +11 -0
- data/lib/generators/hobo/assets/templates/front_site.dryml.erb +6 -0
- data/lib/generators/hobo/assets/templates/gitkeep +0 -0
- data/lib/generators/hobo/dev_tweaks/dev_tweaks_generator.rb +31 -0
- data/lib/generators/hobo/i18n/templates/hobo.en.yml +1 -1
- data/lib/generators/hobo/install_plugin/USAGE +3 -0
- data/lib/generators/hobo/install_plugin/install_plugin_generator.rb +36 -0
- data/lib/generators/hobo/plugin.rb +112 -0
- data/lib/generators/hobo/setup_wizard/setup_wizard_generator.rb +31 -14
- data/lib/generators/hobo/subsite.rb +16 -2
- data/lib/generators/hobo/subsite/templates/gitkeep +0 -0
- data/lib/generators/hobo/subsite/templates/site.css.erb +9 -0
- data/lib/generators/hobo/subsite/templates/site.js.erb +10 -0
- data/lib/generators/hobo/subsite_taglib/templates/taglib.dryml.erb +0 -17
- data/lib/generators/hobo/test_framework/test_framework_generator.rb +1 -1
- data/lib/hobo.rb +3 -2
- data/lib/hobo/controller.rb +43 -24
- data/lib/hobo/controller/model.rb +63 -42
- data/lib/hobo/controller/user_base.rb +1 -3
- data/lib/hobo/engine.rb +1 -1
- data/lib/hobo/extensions/active_record/associations/association.rb +36 -0
- data/lib/hobo/extensions/active_record/associations/collection.rb +10 -19
- data/lib/hobo/extensions/active_record/associations/proxy.rb +3 -15
- data/lib/hobo/extensions/active_record/associations/scope.rb +2 -2
- data/lib/hobo/extensions/active_record/permissions.rb +32 -38
- data/lib/hobo/extensions/active_record/relation_with_origin.rb +5 -5
- data/lib/hobo/model.rb +12 -7
- data/lib/hobo/model/accessible_associations.rb +8 -15
- data/lib/hobo/model/lifecycles/creator.rb +1 -1
- data/lib/hobo/model/lifecycles/transition.rb +1 -1
- data/lib/hobo/model/permissions.rb +4 -4
- data/lib/hobo/model/scopes.rb +4 -17
- data/lib/hobo/model/scopes/automatic_scopes.rb +5 -13
- data/lib/hobo/rapid/helper.rb +1 -161
- data/lib/hobo/rapid/taglibs/rapid.dryml +3 -17
- data/test/doctest/hobo/hobo_helper.rdoctest +8 -44
- data/{doctests → test/doctest}/hobo/lifecycles.rdoctest +0 -0
- data/{doctests → test/doctest}/hobo/model.rdoctest +2 -4
- data/{doctests → test/doctest}/hobo/multi_model_forms.rdoctest +3 -24
- data/{doctests → test/doctest}/hobo/scopes.rdoctest +3 -53
- data/test/doctest/prepare_testapp.rb +11 -0
- data/test/irt/generators/admin_subsite.irt +1 -19
- data/test/irt/generators/assets.irt +4 -9
- data/test/irt/generators/controller.irt +0 -3
- data/test/irt/generators/front_controller.irt +0 -5
- data/test/irt/generators/{helper.rb → irt_helper.rb} +2 -2
- data/test/irt/generators/model.irt +1 -12
- data/test/irt/generators/partials/_account_user_model_tests.rb +0 -8
- data/test/irt/generators/partials/_accounts_users_controller_tests.rb +0 -2
- data/test/irt/generators/partials/_default_user_model_tests.rb +0 -8
- data/test/irt/generators/partials/_default_users_controller_tests.rb +0 -2
- data/test/irt/generators/partials/_house_controller_tests.rb +0 -2
- data/test/irt/generators/partials/_house_model_tests.rb +1 -9
- data/test/irt/generators/partials/_subsite_taglib_admin.rb +5 -2
- data/test/irt/generators/partials/_subsite_taglib_admin_invite_only.rb +1 -1
- data/test/irt/generators/partials/_subsite_taglib_noopt.rb +2 -2
- data/test/irt/generators/partials/_subsite_taglib_variables.rb +0 -15
- data/test/irt/generators/partials/_user_mailer_tests.rb +1 -3
- data/test/irt/generators/resource.irt +0 -3
- data/test/irt/generators/subsite.irt +6 -22
- data/test/irt/generators/subsite_taglib.irt +0 -18
- data/test/irt/generators/test_framework.irt +2 -5
- data/test/irt/generators/user_controller.irt +0 -3
- data/test/irt/generators/user_mailer.irt +0 -3
- data/test/irt/generators/user_model.irt +0 -3
- data/test/irt/generators/user_resource.irt +0 -3
- data/test/irt/readme.txt +6 -3
- metadata +116 -159
- data/app/controllers/dev_controller.rb +0 -25
- data/app/views/dev/summary.dryml +0 -102
- data/doctests/prepare_testapp.rb +0 -8
- data/lib/generators/hobo/admin_subsite/templates/admin.css +0 -20
- data/lib/generators/hobo/rapid/USAGE +0 -3
- data/lib/generators/hobo/rapid/rapid_generator.rb +0 -24
- data/lib/generators/hobo/rapid/templates/IE7.js +0 -2
- data/lib/generators/hobo/rapid/templates/blank.gif +0 -0
- data/lib/generators/hobo/rapid/templates/hobo-rapid.css +0 -94
- data/lib/generators/hobo/rapid/templates/hobo-rapid.js +0 -1015
- data/lib/generators/hobo/rapid/templates/ie7-recalc.js +0 -166
- data/lib/generators/hobo/rapid/templates/lowpro.js +0 -339
- data/lib/generators/hobo/rapid/templates/reset.css +0 -95
- data/lib/generators/hobo/rapid/templates/themes/clean/public/images/101-3B5F87-ACD3E6.png +0 -0
- data/lib/generators/hobo/rapid/templates/themes/clean/public/images/30-3E547A-242E42.png +0 -0
- data/lib/generators/hobo/rapid/templates/themes/clean/public/images/30-DBE1E5-FCFEF5.png +0 -0
- data/lib/generators/hobo/rapid/templates/themes/clean/public/images/300-ACD3E6-fff.png +0 -0
- data/lib/generators/hobo/rapid/templates/themes/clean/public/images/50-ACD3E6-fff.png +0 -0
- data/lib/generators/hobo/rapid/templates/themes/clean/public/images/fieldbg.gif +0 -0
- data/lib/generators/hobo/rapid/templates/themes/clean/public/images/pencil.png +0 -0
- data/lib/generators/hobo/rapid/templates/themes/clean/public/images/small_close.png +0 -0
- data/lib/generators/hobo/rapid/templates/themes/clean/public/images/spinner.gif +0 -0
- data/lib/generators/hobo/rapid/templates/themes/clean/public/stylesheets/clean.css +0 -327
- data/lib/generators/hobo/rapid/templates/themes/clean/public/stylesheets/rapid-ui.css +0 -102
- data/lib/generators/hobo/rapid/templates/themes/clean/views/clean.dryml +0 -10
- data/lib/hobo/helper.rb +0 -460
- data/lib/hobo/rapid/taglibs/rapid_core.dryml +0 -808
- data/lib/hobo/rapid/taglibs/rapid_document_tags.dryml +0 -56
- data/lib/hobo/rapid/taglibs/rapid_editing.dryml +0 -287
- data/lib/hobo/rapid/taglibs/rapid_forms.dryml +0 -1156
- data/lib/hobo/rapid/taglibs/rapid_generics.dryml +0 -48
- data/lib/hobo/rapid/taglibs/rapid_i18n.dryml +0 -173
- data/lib/hobo/rapid/taglibs/rapid_lifecycles.dryml +0 -96
- data/lib/hobo/rapid/taglibs/rapid_navigation.dryml +0 -108
- data/lib/hobo/rapid/taglibs/rapid_pages.dryml +0 -259
- data/lib/hobo/rapid/taglibs/rapid_plus.dryml +0 -247
- data/lib/hobo/rapid/taglibs/rapid_summary.dryml +0 -283
- data/lib/hobo/rapid/taglibs/rapid_support.dryml +0 -102
- data/lib/hobo/rapid/taglibs/rapid_user_pages.dryml +0 -182
- data/test/irt/generators/rapid.irt +0 -29
File without changes
|
data/CHANGES-1.4.txt
ADDED
@@ -0,0 +1,678 @@
|
|
1
|
+
Hobo 1.4 Changes
|
2
|
+
{: .document-title}
|
3
|
+
|
4
|
+
Documents the changes made in Hobo 1.4 and the changes required to
|
5
|
+
migrate applications to Hobo 1.4
|
6
|
+
|
7
|
+
Contents
|
8
|
+
{: .contents-heading}
|
9
|
+
|
10
|
+
- contents
|
11
|
+
{:toc}
|
12
|
+
|
13
|
+
# Installation
|
14
|
+
|
15
|
+
## Creating a new application
|
16
|
+
|
17
|
+
Hobo 1.4 gems have not yet been released, so the standard instructions
|
18
|
+
of "gem install hobo; hobo new foo" do not yet work.
|
19
|
+
|
20
|
+
If you're on Linux you'll have to install a javascript runtime.
|
21
|
+
On Ubuntu 11.10 you can get one by typing `apt-get install
|
22
|
+
nodejs-dev`. Other Linuxes should be similar. Windows & OS X users
|
23
|
+
should already have a javascript scripting host installed. The list
|
24
|
+
of compatible javascript runtimes is [here](https://github.com/sstephenson/execjs).
|
25
|
+
|
26
|
+
Next you'll need to download the hobo source
|
27
|
+
|
28
|
+
git clone git://github.com/tablatom/hobo
|
29
|
+
|
30
|
+
Now you have two options: create gems, or use the source.
|
31
|
+
|
32
|
+
### Via gems
|
33
|
+
|
34
|
+
cd hobo
|
35
|
+
rake gems[install]
|
36
|
+
cd wherever-you-want-to-generate-your-app
|
37
|
+
hobo new foo
|
38
|
+
|
39
|
+
Once you've generated an app, you may wish to go in and replace the
|
40
|
+
version strings for the hobo_* gems with `:git => "git://github.com/tablatom/hobo"
|
41
|
+
|
42
|
+
### Via source
|
43
|
+
|
44
|
+
(This won't work on Windows)
|
45
|
+
|
46
|
+
export HOBODEV=`pwd`/hobo
|
47
|
+
$HOBODEV/hobo/bin/hobo new foo
|
48
|
+
|
49
|
+
## Updating an existing installation
|
50
|
+
|
51
|
+
There are several changes that need to be made to your application to
|
52
|
+
upgrade from Hobo 1.3 to Hobo 1.4. Most of these changes are
|
53
|
+
required by the addition of the asset pipeline which was introduced in
|
54
|
+
Rails 3.1.
|
55
|
+
|
56
|
+
Follow the asset pipeline upgrade steps outlined here:
|
57
|
+
http://guides.rubyonrails.org/asset_pipeline.html#upgrading-from-old-versions-of-rails
|
58
|
+
|
59
|
+
The easiest way to upgrade an existing Hobo 1.3 application is to
|
60
|
+
generate a new Hobo 1.4 application and copy differences from the new
|
61
|
+
app into your existing app.
|
62
|
+
|
63
|
+
### Gemfile
|
64
|
+
|
65
|
+
You'll need to add the gems required for the asset pipeline, add the
|
66
|
+
jquery-rails and jquery-ui-themes gem, and adjust the version numbers
|
67
|
+
for rails, hobo and perhaps others.
|
68
|
+
|
69
|
+
Hobo has also gained several additional gems, so you will have to add
|
70
|
+
dependencies for those. hobo_rapid is the Hobo tag library,
|
71
|
+
hobo_jquery is the javascript for hobo_rapid, and hobo_clean is the
|
72
|
+
default theme. Instead of or as well as hobo_clean you can use
|
73
|
+
hobo_clean_admin or hobo_clean_sidemenu. Hopefully there will be
|
74
|
+
additional themes available soon.
|
75
|
+
|
76
|
+
### config/
|
77
|
+
|
78
|
+
All of the changes in config/ are due to the assets pipeline. See
|
79
|
+
http://guides.rubyonrails.org/asset_pipeline.html#upgrading-from-old-versions-of-rails
|
80
|
+
|
81
|
+
Additionally, the Hobo 1.4 generator installs the
|
82
|
+
[rails-dev-tweaks](https://github.com/wavii/rails-dev-tweaks) gem. We
|
83
|
+
adjust the configuration so that rails-dev-tweaks applies only to
|
84
|
+
assets, not to XHR.
|
85
|
+
|
86
|
+
### application.dryml or front_site.dryml
|
87
|
+
|
88
|
+
Replace
|
89
|
+
|
90
|
+
<set-theme name="clean"/>
|
91
|
+
|
92
|
+
with
|
93
|
+
|
94
|
+
<include gem='hobo_rapid'/>
|
95
|
+
<include gem='hobo_jquery'/>
|
96
|
+
<include gem='hobo_clean'/>
|
97
|
+
|
98
|
+
Note that the default Hobo generation now always creates both a
|
99
|
+
front_site.dryml and an application.dryml, even if you don't create
|
100
|
+
any subsites.
|
101
|
+
|
102
|
+
### move public/ to app/assets/
|
103
|
+
|
104
|
+
In Rails 3.1, images, javascripts and stylesheets are loaded from
|
105
|
+
app/assets/ rather than from public/ so you'll have to move them.
|
106
|
+
Note that the following are Rails and/or Hobo assets that are now
|
107
|
+
included via the pipeline and can be deleted rather than moved:
|
108
|
+
|
109
|
+
images/rails.png
|
110
|
+
hobothemes/**
|
111
|
+
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
|
112
|
+
stylesheets/reset.css,hobo-rapid.css
|
113
|
+
|
114
|
+
Note how Hobo organizes the app/assets directory. There will be a
|
115
|
+
directory called app/assets/javascripts/application/ and a directory
|
116
|
+
called app/assets/javascripts/front/. If you have added a subsite
|
117
|
+
called admin there will also be a directory called
|
118
|
+
app/assets/javascripts/admin/. Any files in application/ will always
|
119
|
+
be included, and the files in front/ or admin/ will be included only
|
120
|
+
on the corresponding subsite.
|
121
|
+
|
122
|
+
# Changes from Hobo 1.3 & hobo-jquery 1.3
|
123
|
+
|
124
|
+
## Javascript framework changed to jQuery
|
125
|
+
|
126
|
+
Hobo 1.3 and earlier versions used prototype.js for its Ajax support.
|
127
|
+
In Hobo 1.4 all of our javascript code has been rewritten to use
|
128
|
+
jQuery instead of prototype.js.
|
129
|
+
|
130
|
+
In the process of rewriting the code many tags have been updated to
|
131
|
+
add AJAX support, and tags that used non-standard AJAX mechanisms have
|
132
|
+
been updated to use standard Hobo form AJAX. The most visible of
|
133
|
+
these changes have been to the editors.
|
134
|
+
|
135
|
+
## The Asset Pipeline
|
136
|
+
|
137
|
+
Hobo 1.4 uses the asset pipeline features introduced in Rails 3.1.
|
138
|
+
Hobo 1.4 does not work out of the box with the asset pipeline turned
|
139
|
+
off. It'd certainly be possible to copy all Hobo assets into public/,
|
140
|
+
but you would have to do that manually.
|
141
|
+
|
142
|
+
## :inverse_of recommended
|
143
|
+
|
144
|
+
For correct behaviour, please ensure that all accessible associations
|
145
|
+
have their :inverse_of option set in both directions.
|
146
|
+
|
147
|
+
## set-theme deprecated
|
148
|
+
|
149
|
+
The old Hobo theme support has never worked well, and has been
|
150
|
+
replaced. Themes are now Hobo plugins and work like every other Hobo
|
151
|
+
1.4 plugin.
|
152
|
+
|
153
|
+
Replace:
|
154
|
+
|
155
|
+
<set-theme name="clean"/>
|
156
|
+
|
157
|
+
with
|
158
|
+
|
159
|
+
<include gem="hobo_clean"/>
|
160
|
+
|
161
|
+
and add
|
162
|
+
|
163
|
+
*= require hobo_clean
|
164
|
+
|
165
|
+
to your app/assets/stylesheets/front.css. Some themes may also
|
166
|
+
include javascript which would require them to be added to front.js as
|
167
|
+
well.
|
168
|
+
|
169
|
+
## default doctype changed
|
170
|
+
|
171
|
+
The default doctype has been changed from `XHTML 1.0 TRANSITIONAL` to
|
172
|
+
`html`, also known as "standards mode" in Internet Explorer 8 and 9
|
173
|
+
and "html5" in other browsers.
|
174
|
+
|
175
|
+
## default field-list changed
|
176
|
+
|
177
|
+
The default for `<field-list>` has changed to `<feckless-fieldset>`.
|
178
|
+
The old behaviour is still available in `<field-list-v1>`. Please
|
179
|
+
provide feedback: we are open to reversion before final release.
|
180
|
+
|
181
|
+
## Helper rearrangement
|
182
|
+
|
183
|
+
In previous versions of Hobo, all Hobo helpers were available in both
|
184
|
+
the controllers and the views. In this version, some helpers are
|
185
|
+
only available in the views. If there is a helper function that you
|
186
|
+
need to access in your controller, you can call in your controller:
|
187
|
+
|
188
|
+
HoboTypeHelper.add_to_controller(self)
|
189
|
+
|
190
|
+
Other Helper classes not included in the controller by default are
|
191
|
+
HoboDebugHelper, HoboDeprecatedHelper and HoboViewHintHelper.
|
192
|
+
|
193
|
+
Several helpers have been moved into
|
194
|
+
app/helpers/hobo_deprecated_helper.rb
|
195
|
+
|
196
|
+
If your application depends on any of these, you can set
|
197
|
+
config.hobo.include_deprecated_helper.
|
198
|
+
|
199
|
+
## Rails 3.1 required
|
200
|
+
|
201
|
+
Hobo 1.4 currently requires Rails 3.1 for operation. We expect to be
|
202
|
+
on Rails 3.2 before final release.
|
203
|
+
|
204
|
+
## Enhancements
|
205
|
+
|
206
|
+
### Nested caching
|
207
|
+
|
208
|
+
See the docs for `<nested-cache>` and the blog post I'm going to
|
209
|
+
eventually write...
|
210
|
+
|
211
|
+
### push-state
|
212
|
+
|
213
|
+
AJAX now supports a new AJAX option 'push-state' if you have
|
214
|
+
History.js installed. It was inspired by [this
|
215
|
+
post](http://37signals.com/svn/posts/3112-how-basecamp-next-got-to-be-so-damn-fast-without-using-much-client-side-ui)
|
216
|
+
which uses push-state and fragment caching to create a very responsive
|
217
|
+
rails application. Hobo has always supported fragment caching
|
218
|
+
through Rails, but push-state support is new.
|
219
|
+
|
220
|
+
The easiest way to install History.js is to use the [jquery-historyjs](https://github.com/wweidendorf/jquery-historyjs)
|
221
|
+
gem. Follow the instructions in the [README at the
|
222
|
+
link](https://github.com/wweidendorf/jquery-historyjs).
|
223
|
+
|
224
|
+
push-state blurs the line between AJAX and non-AJAX techniques,
|
225
|
+
bringing the advantages of both to the table. It's considerably more
|
226
|
+
responsive than a page refresh, yet provides allows browser bookmarks
|
227
|
+
and history navigation to work correctly.
|
228
|
+
|
229
|
+
For example, if the foos and the bars pages have exactly the same
|
230
|
+
headers but different content, you can speed up links between the
|
231
|
+
pages by only refreshing the content:
|
232
|
+
|
233
|
+
<%# foos/index.dryml %>
|
234
|
+
<index-page>
|
235
|
+
<content:>
|
236
|
+
<do part="content">
|
237
|
+
<a href="&bars_page" ajax push-state new-title="Bars">Bars</a>
|
238
|
+
...
|
239
|
+
</do>
|
240
|
+
</content:>
|
241
|
+
<index-page>
|
242
|
+
|
243
|
+
Note to Hobo 1.3 users: We're using the new `ajax` attribute instead of
|
244
|
+
`update="content"` because the link is inside the part. Outside of the
|
245
|
+
part we'd use `update="content"` instead of `ajax`.
|
246
|
+
|
247
|
+
The `new-title` attribute may be used with push state to update the
|
248
|
+
title. If you want to update any other section in your headers, you
|
249
|
+
can put that into a part and list it in the update list as well.
|
250
|
+
However the new page cannot have new javascript or stylesheets.
|
251
|
+
Avoiding the refresh of these assets is one of the major reasons to
|
252
|
+
use push-state!
|
253
|
+
|
254
|
+
push-state is well suited for tasks that refreshed the current page
|
255
|
+
with new query parameters in Hobo 1.3, like `filter-menu`, pagination and
|
256
|
+
sorting on a `table-plus`. Thus these tags have been updated to
|
257
|
+
support all of the standard ajax attributes.
|
258
|
+
|
259
|
+
Of course, ajax requests that update only a small portion of the page
|
260
|
+
will update faster than those that update most of the page. However,
|
261
|
+
a small update may mean that a change to the URL is warranted, so you
|
262
|
+
may want to use standard Ajax rather than push-state in those cases.
|
263
|
+
Also, push-state generally should not be used for requests that modify
|
264
|
+
state
|
265
|
+
|
266
|
+
push-state works best in an HTML5 browser. It works in older browsers
|
267
|
+
such as IE8, IE9 or Firefox 3, but results in strange looking URL's. See
|
268
|
+
the README for History.js for more details on that behaviour.
|
269
|
+
|
270
|
+
### plugin generators
|
271
|
+
|
272
|
+
Hobo has gained two new generators.
|
273
|
+
|
274
|
+
`hobo generate install_plugin` may be used from inside a Hobo
|
275
|
+
application to install a Hobo plugin. It modifies the Gemfile,
|
276
|
+
application.dryml or X_site.dryml and adds the plugin to
|
277
|
+
app/assets/javascripts and app/assets/stylesheets.
|
278
|
+
|
279
|
+
`hobo plugin` is used from outside of a Hobo application to create the
|
280
|
+
skeleton for a new plugin. See [the plugin manual page](FIXME) for
|
281
|
+
more details.
|
282
|
+
|
283
|
+
### multiple parts
|
284
|
+
|
285
|
+
I've updated DRYML so that it emits a different DOM ID if you
|
286
|
+
re-instantiate a part. (The first use of a part retains the DOM
|
287
|
+
ID=partname convention for backwards compatibility) "update=" requires
|
288
|
+
a DOM ID, so I've also added 2 new AJAX attributes that can be used
|
289
|
+
instead of "update=".
|
290
|
+
|
291
|
+
The first one is "updates=". Instead of a comma separated list of DOM
|
292
|
+
ID's, it takes a CSS selector.
|
293
|
+
|
294
|
+
The other one is "ajax". If used inside of a part, it indicates that
|
295
|
+
the containing part should be updated. If used outside of a part,
|
296
|
+
AJAX will be used but no parts will be updated.
|
297
|
+
|
298
|
+
These three Ajax attributes may be used simultaneously.
|
299
|
+
|
300
|
+
Example:
|
301
|
+
|
302
|
+
<collection:stories>
|
303
|
+
<div part="inner">
|
304
|
+
<form ajax>
|
305
|
+
<input:title/>
|
306
|
+
</form>
|
307
|
+
</div>
|
308
|
+
</collection>
|
309
|
+
|
310
|
+
### allowing errors in parts
|
311
|
+
|
312
|
+
Older versions of Hobo did not render a part update if the update did
|
313
|
+
not pass validation.
|
314
|
+
|
315
|
+
This behaviour may now be overridden by using the 'errors-ok'
|
316
|
+
attribute on your form. (or formlet or whatever other tag initiates
|
317
|
+
the Ajax call).
|
318
|
+
|
319
|
+
The 'errors-ok' attribute is processed in update_response. If you've
|
320
|
+
supplied a block to hobo_update you will be responsible for
|
321
|
+
implementing this functionality yourself.
|
322
|
+
|
323
|
+
### AJAX file uploads
|
324
|
+
|
325
|
+
If you have malsup's form plugin installed, Ajax file uploads should
|
326
|
+
"just work", as long as you don't have debug_rjs turned on in your
|
327
|
+
config/initializers/development.rb.
|
328
|
+
|
329
|
+
### AJAX events
|
330
|
+
|
331
|
+
The standard 'before', 'success', 'done' and 'error' callbacks may
|
332
|
+
still be used. Additionally, the AJAX code now triggers
|
333
|
+
'rapid:ajax:before', 'rapid:ajax:success', 'rapid:ajax:done' and
|
334
|
+
'rapid:ajax:error' events to enable you to code more unobtrusively.
|
335
|
+
|
336
|
+
If your form is inside of a part, it's quite likely that the form will
|
337
|
+
be replaced before the rapid:ajax:success and rapid:ajax:done events
|
338
|
+
fire. To prevent memory leaks, jQuery removes event handlers from all
|
339
|
+
removed elements, making it impossible to catch these events.
|
340
|
+
If this is the case, hobo-jquery triggers these events on the document
|
341
|
+
itself, and passes the element as an argument.
|
342
|
+
|
343
|
+
$(document).ready(function() {
|
344
|
+
jQuery(document).on("rapid:ajax:success", function(event, el) {
|
345
|
+
// `this` is the document and `el` is the form
|
346
|
+
alert('success');
|
347
|
+
});
|
348
|
+
});
|
349
|
+
|
350
|
+
### before callback
|
351
|
+
|
352
|
+
A new callback has been added to the list of Ajax Callbacks: before.
|
353
|
+
This callback fires before any Ajax is done. If you return false
|
354
|
+
from this, the Ajax is cancelled. So you should probably ensure you
|
355
|
+
explicitly return true if you use it and don't want your ajax
|
356
|
+
cancelled.
|
357
|
+
|
358
|
+
### callbacks
|
359
|
+
|
360
|
+
Normally in HTML you can attach either a snippet of javascript or a
|
361
|
+
function to a callback.
|
362
|
+
|
363
|
+
<button onclick=fbar/>
|
364
|
+
|
365
|
+
This doesn't work in DRYML because the function is not defined in
|
366
|
+
Ruby, it's only defined in Javascript.
|
367
|
+
|
368
|
+
In Hobo 1.3 you would thus be forced to do this to get equivalent behaviour:
|
369
|
+
|
370
|
+
<form update="foo" success="return fbar.call(this);"/>
|
371
|
+
|
372
|
+
Now you can just return the function name:
|
373
|
+
|
374
|
+
<form ajax success="fbar"/>
|
375
|
+
|
376
|
+
### `hide` and `show` ajax options
|
377
|
+
|
378
|
+
There are two new ajax options: `hide` and `show`. These are passed
|
379
|
+
directly to the jQuery-UI `hide` and `show` functions. See
|
380
|
+
(here)[http://jqueryui.com/demos/show/] and
|
381
|
+
(here)[http://docs.jquery.com/UI/Effects] for more documentation on
|
382
|
+
these two functions. Due to ruby to javascript translation
|
383
|
+
difficulties, you may not drop optional middle parameters.
|
384
|
+
|
385
|
+
Examples:
|
386
|
+
|
387
|
+
<form ajax hide="puff,,slow" show="&['slide', {:direction => :up}, 'fast', 'myFunctionName']/>
|
388
|
+
|
389
|
+
<form ajax hide="drop" show="&['slide', nil, 1000, 'alert(done);']"/>
|
390
|
+
|
391
|
+
These two options have global defaults which are TBD. They may be overridden by passing options to the page-script parameter of `<page>`:
|
392
|
+
|
393
|
+
<extend tag="page">
|
394
|
+
<old-page merge>
|
395
|
+
<page-scripts: hide="&['slide',{:direction => :up}, 'fast']" show="&['slide',{:direction => :up},'fast']"/>
|
396
|
+
</old-page>
|
397
|
+
</extend>
|
398
|
+
|
399
|
+
To disable effects entirely: FIXME.
|
400
|
+
|
401
|
+
### spinner options
|
402
|
+
|
403
|
+
By default, the spinner is now displayed next to the element being
|
404
|
+
updated. Besides the old `spinner-next-to` option, there are a number
|
405
|
+
of new options that control how the spinner is displayed.
|
406
|
+
|
407
|
+
- spinner-next-to: DOM id of the element to place the spinner next to.
|
408
|
+
- spinner-at: CSS selector for the element to place the spinner next to.
|
409
|
+
- no-spinner: if set, the spinner is not displayed.
|
410
|
+
- spinner-options: passed to [jQuery-UI's position](http://jqueryui.com/demos/position/). Defaults are `{my: 'right bottom', at: 'left top'}`
|
411
|
+
- message: the message to display inside the spinner
|
412
|
+
|
413
|
+
These options may be overridden globally by adding them as attributes to the `page-scripts` parameter for the page.
|
414
|
+
|
415
|
+
<extend tag="page">
|
416
|
+
<old-page merge>
|
417
|
+
<page-scripts: spinner-at="#header" spinner-options="&{:my => 'left top', :at => 'left top'}" />
|
418
|
+
</old-page>
|
419
|
+
</extend>
|
420
|
+
|
421
|
+
### hjq-datepicker
|
422
|
+
|
423
|
+
hjq-datepicker now automatically sets dateFormat to the value
|
424
|
+
specified in your translations: (I18n.t :"date.formats.default").
|
425
|
+
|
426
|
+
### sortable-collection
|
427
|
+
|
428
|
+
sortable-collection now supports the standard Ajax callbacks
|
429
|
+
|
430
|
+
### delete-button
|
431
|
+
|
432
|
+
The new `delete-button` behaviour is not as much different from the
|
433
|
+
old `delete-button` as a comparison of the documentation would have
|
434
|
+
you believe, however its Ajax triggering behaviour has changed slightly.
|
435
|
+
|
436
|
+
The `fade` attribute is no longer supported. Instead use the new
|
437
|
+
standard ajax attribute `hide`.
|
438
|
+
|
439
|
+
### autocomplete
|
440
|
+
|
441
|
+
`hjq-autocomplete` has been renamed to `autocomplete`. It has gained
|
442
|
+
the attribute `nil-value` and the ability to work with the standard
|
443
|
+
Hobo autocomplete and hobo_completions controller actions.
|
444
|
+
|
445
|
+
`name-one` is now a simple backwards-compatibility wrapper around
|
446
|
+
`autocomplete`.
|
447
|
+
|
448
|
+
### input-many
|
449
|
+
|
450
|
+
`hjq-input-many` and `input-many` have been merged into `input-many`.
|
451
|
+
The new standard ajax attributes `hide` and `show` are also now
|
452
|
+
supported.
|
453
|
+
|
454
|
+
Differences from old `input-many`:
|
455
|
+
|
456
|
+
- supports hobo-jquery delayed initialization.
|
457
|
+
- new attributes: add-hook, remove-hook, hide, show
|
458
|
+
|
459
|
+
Differences from `hjq-input-many`:
|
460
|
+
|
461
|
+
- name of the main parameter is `default` rather than `item`.
|
462
|
+
- rapid:add, rapid:change and rapid:remove events added.
|
463
|
+
- new attributes: hide, show
|
464
|
+
|
465
|
+
### filter-menu
|
466
|
+
|
467
|
+
filter-menu now accepts AJAX attributes.
|
468
|
+
|
469
|
+
### a
|
470
|
+
|
471
|
+
the a tag now accepts AJAX attributes. This is especially useful with
|
472
|
+
the new 'push-state' option.
|
473
|
+
|
474
|
+
### dialog-box
|
475
|
+
|
476
|
+
`hjq-dialog` has been renamed to `dialog-box`. (`dialog` has already
|
477
|
+
been taken in HTML5).
|
478
|
+
|
479
|
+
The helper functions have been renamed. For instance,
|
480
|
+
`hjq.dialog.formletSubmit` has been renamed to
|
481
|
+
`hjq_dialog_box.submit`.
|
482
|
+
|
483
|
+
Dialog positioning has been updated and should work better now. See
|
484
|
+
the documentation for more details.
|
485
|
+
|
486
|
+
### live-search
|
487
|
+
|
488
|
+
`live-search` works in a substantially different fashion now, it has
|
489
|
+
almost completely lost its magic, instead using standard ajax forms
|
490
|
+
and parts. It should now be possible to customize using standard
|
491
|
+
Hobo techniques. See the documentation for `<live-search>` and
|
492
|
+
`<search-results>` for more details.
|
493
|
+
|
494
|
+
`live-search` has temporarily lost it's live-ness. Currently you have
|
495
|
+
to press 'return' to initiate the search. This should be easy to fix
|
496
|
+
in hjq-live-search.js -- the hard part will probably be in doing it in
|
497
|
+
a way that works in all possible browsers.
|
498
|
+
|
499
|
+
### hot-input
|
500
|
+
|
501
|
+
see tag documentation
|
502
|
+
|
503
|
+
### page-nav
|
504
|
+
|
505
|
+
The params attribute now defaults to
|
506
|
+
recognize_page_path.slice(:controller,:action,:id).
|
507
|
+
|
508
|
+
Standard form ajax attributes are now also supported, and behave
|
509
|
+
similar to `<a>`.
|
510
|
+
|
511
|
+
### query_params
|
512
|
+
|
513
|
+
The old query_params helper has been removed. You can use
|
514
|
+
Rails (request.query_parameters | request.request_parameters) instead
|
515
|
+
if you still need it.
|
516
|
+
|
517
|
+
There's a new helper function called query_parameters_filtered that
|
518
|
+
returns query parameters with the ajax parameters removed.
|
519
|
+
|
520
|
+
## Editors
|
521
|
+
|
522
|
+
Editors are no longer special-cased, they now use the standard DRYML
|
523
|
+
part mechanism.
|
524
|
+
|
525
|
+
There are two types of editors: `<click-editor>` and `<live-editor>`.
|
526
|
+
click-editor is the click-to-edit type of control similar to what
|
527
|
+
Rapid currently uses for a string, and live-editor always renders the
|
528
|
+
input, and is similar to what Rapid currently uses for Boolean's and
|
529
|
+
enum-strings.
|
530
|
+
|
531
|
+
Please refer to the documentation for `click-editor` and `live-editor`
|
532
|
+
for more details.
|
533
|
+
|
534
|
+
`<editor>` is now a polymorphic input that uses either `<click-editor>` or
|
535
|
+
`<live-editor>`.
|
536
|
+
|
537
|
+
TBD: Right now live-editor and click-editor use `<formlet>`. The
|
538
|
+
major advantage of formlet is that it is safe to use inside of a form.
|
539
|
+
I can't think of any good use cases for that behaviour, but it does
|
540
|
+
seem like something people might do by accident.
|
541
|
+
|
542
|
+
The alternative is to use `<form>`. Since this implementation of
|
543
|
+
editor starts with an input and switches to a view via Javascript,
|
544
|
+
using a form would allow reasonable javascript-disabled behaviour.
|
545
|
+
|
546
|
+
## Changes behind the scenes
|
547
|
+
|
548
|
+
### reloading of part context
|
549
|
+
|
550
|
+
[This change](https://github.com/tablatom/hobo/commit/6048925) ensures that
|
551
|
+
DRYML does not reload the part context if it is already in `this`.
|
552
|
+
|
553
|
+
### i18n
|
554
|
+
|
555
|
+
These commits will require translation updates for languages other
|
556
|
+
than English. (Presumably this list will get larger because right now
|
557
|
+
the change is one I could do myself...)
|
558
|
+
|
559
|
+
- https://github.com/tablatom/hobo/commit/e9460d336ef85388af859e5082763bfae0ad01f5
|
560
|
+
|
561
|
+
### controller changes
|
562
|
+
|
563
|
+
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:
|
564
|
+
|
565
|
+
respond_to do |wants|
|
566
|
+
wants.js { hobo_ajax_response }
|
567
|
+
wants.html {...}
|
568
|
+
end
|
569
|
+
|
570
|
+
use
|
571
|
+
|
572
|
+
if request.params[:render]
|
573
|
+
hobo_ajax_response
|
574
|
+
else
|
575
|
+
....
|
576
|
+
end
|
577
|
+
|
578
|
+
for more information see http://jquery.malsup.com/form/#file-upload
|
579
|
+
|
580
|
+
### hobo_ajax_response
|
581
|
+
|
582
|
+
the `hobo_ajax_response` function now has a different signature.
|
583
|
+
Standard usage doesn't supply any arguments to hobo_ajax_response.
|
584
|
+
This use case has not changed.
|
585
|
+
|
586
|
+
However, if you have code that supplied arguments to
|
587
|
+
hobo_ajax_response, that code likely will need to be updated for 1.4.
|
588
|
+
|
589
|
+
FIXME: pointer to AJAX background documentation.
|
590
|
+
|
591
|
+
### Dryml.render
|
592
|
+
|
593
|
+
Dryml.render now has an additional argument: imports. The template
|
594
|
+
environment no longer automatically imports ActionView::Helpers.
|
595
|
+
|
596
|
+
### View helpers imported
|
597
|
+
|
598
|
+
All application helpers are now available in the template
|
599
|
+
environment.
|
600
|
+
|
601
|
+
# jQuery rewrite
|
602
|
+
|
603
|
+
FIXME: pull into separate document, along with interface specs
|
604
|
+
|
605
|
+
## Framework Agnosticism
|
606
|
+
|
607
|
+
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.
|
608
|
+
|
609
|
+
## Unobtrusiveness
|
610
|
+
|
611
|
+
The agnosticism is a side benefit -- really the main reason its written this way is so that we're coding using "unobtrusive javascript" techniques.
|
612
|
+
|
613
|
+
Hobo currently many different mechanisms to pass data to javascript:
|
614
|
+
|
615
|
+
- classdata ex class="model::story:2"
|
616
|
+
- non-HTML5-compliant element attributes: ex hobo-blank-message="(click to edit)"
|
617
|
+
- variable assignment: ex hoboParts = ...;
|
618
|
+
- function calls: ex onclick="Hobo.ajaxRequest(url, {spinnerNextTo: 'foo'})"
|
619
|
+
|
620
|
+
hobo-jquery currently uses JSON inside of comments:
|
621
|
+
|
622
|
+
<!-- json_annotation ({"tag":"datepicker","options":{},"events":{}}); -->
|
623
|
+
|
624
|
+
We are switching all 5 of these mechanisms to use HTML5 data
|
625
|
+
attributes. HTML5 data attributes are technically illegal in HTML4
|
626
|
+
but work in all browsers future and past (even IE6). The illegality
|
627
|
+
of them is the reason that I didn't choose them in Hobo-jQuery, but
|
628
|
+
it's now 2011.
|
629
|
+
|
630
|
+
We mostly use a single attribute: `data-rapid`. This is a JSON hash
|
631
|
+
where the keys are the tag names and the values are options hashes.
|
632
|
+
DRYML has been modified to appropriately merge this tag in a fashion
|
633
|
+
similar to what it currently does for the `class` tag. For example,
|
634
|
+
live-search will have the attribute
|
635
|
+
`data-rapid='{"live-search":{"foo": 17}}'`. When hobo-jquery
|
636
|
+
initializes, it will then attempt to initialize a jQuery plugin named
|
637
|
+
`hjq_live_search`, which we provide in
|
638
|
+
public/javascripts/hobo-jquery/hjq-live-search.js. The plugin will
|
639
|
+
get passed the options hash {"foo": 17}.
|
640
|
+
|
641
|
+
`data-rapid-page-data` contains data required by the javascript
|
642
|
+
library, such as the part information.
|
643
|
+
|
644
|
+
One last attribute that may be set is `data-rapid-context`. This
|
645
|
+
contains a typed_id of the current context. This is used to assist
|
646
|
+
tags like `delete-button` with DOM manipulation.
|
647
|
+
|
648
|
+
## Compatibility
|
649
|
+
|
650
|
+
Obviously compatibility with hobo-rapid.js is not going to be
|
651
|
+
maintained, since that's written in prototype.
|
652
|
+
|
653
|
+
The internal structure of hobo-jquery has changed completely. We have
|
654
|
+
switched to using a more standard jQuery plugin style.
|
655
|
+
|
656
|
+
# Running the integration tests:
|
657
|
+
|
658
|
+
hobo-jquery is being tested using capybara & qunit.js.
|
659
|
+
|
660
|
+
Unfortunately, 2 of the integration tests fails on firefox, which
|
661
|
+
works out of the box, so we also have to install capybara-webkit and
|
662
|
+
selenium-chrome.
|
663
|
+
|
664
|
+
$ git clone -b jquery git://github.com/Hobo/agility-gitorial.git
|
665
|
+
$ cd agility-gitorial
|
666
|
+
|
667
|
+
Make sure you have the prerequisites for capybara-webkit:
|
668
|
+
https://github.com/thoughtbot/capybara-webkit/wiki/Installing-QT
|
669
|
+
|
670
|
+
$ bundle install
|
671
|
+
$ rake db:migrate
|
672
|
+
|
673
|
+
Download the selenium-chrome server and place in your path:
|
674
|
+
http://code.google.com/p/chromium/downloads/list
|
675
|
+
|
676
|
+
$ rake test:integration
|
677
|
+
|
678
|
+
Email the list and/or bryan@larsen.st if you get any failures.
|