Hobo 2.0 Changes
{: .document-title}
Documents the changes made in Hobo 2.0 and the changes required to
migrate applications to Hobo 2.0
Contents
{: .contents-heading}
- contents
{:toc}
# Installation
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.
{.hidden}
## Creating a new application
{.part}
Final hobo 2.0 gems have not yet been released, so the standard instructions
of "gem install hobo; hobo new foo" do not yet work.
If you're on Linux you'll have to install a javascript runtime.
On Ubuntu 11.10 you can get one by typing `apt-get install
nodejs-dev`. Other Linuxes should be similar. Windows & OS X users
should already have a javascript scripting host installed. The list
of compatible javascript runtimes is
[here](https://github.com/sstephenson/execjs).
To install prerelease versions of Hobo, you have three options: gems
from rubygems, gems from source or pointing your Gemfile at hobo
source.
### Via gems from rubygems.org
gem install hobo --pre
hobo new foo
### Via gems from source
git clone git://github.com/tablatom/hobo
cd hobo
rake gems[install]
cd wherever-you-want-to-generate-your-app
hobo new foo
Once you've generated an app, you may wish to go in and replace the
version strings for the hobo_* gems with `:git => "git://github.com/tablatom/hobo"`
### Via source path
(This won't work on Windows)
git clone git://github.com/tablatom/hobo
export HOBODEV=`pwd`/hobo
cd wherever-you-want-to-generate-your-app
$HOBODEV/hobo/bin/hobo new foo
## Updating a Hobo 1.3 application
{.nomove}
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).
There are several changes that need to be made to your application to
upgrade from Hobo 1.3 to Hobo 2.0. Most of these changes are
required by the addition of the asset pipeline which was introduced in
Rails 3.1.
Follow the asset pipeline upgrade steps outlined here:
http://guides.rubyonrails.org/asset_pipeline.html#upgrading-from-old-versions-of-rails
The easiest way to upgrade an existing Hobo 1.3 application is to
generate a new Hobo 2.0 application and copy differences from the new
app into your existing app.
### Gemfile
You'll need to add the gems required for the asset pipeline, add the
jquery-rails and jquery-ui-themes gem, and adjust the version numbers
for rails, hobo and perhaps others.
Hobo has also gained several additional gems, so you will have to add
dependencies for those. hobo_rapid is the Hobo tag library,
hobo_jquery is the javascript for hobo_rapid, and hobo_clean is the
default theme. Instead of or as well as hobo_clean you can use
hobo_clean_admin or hobo_clean_sidemenu or hobo_bootstrap.
You will also have to ensure that you are using Hobo's fork of will_paginate:
gem "will_paginate", :git => "git://github.com/Hobo/will_paginate.git"
### config/
Most the changes in config/ are due to the assets pipeline. See
http://guides.rubyonrails.org/asset_pipeline.html#upgrading-from-old-versions-of-rails
In addition, you will probably want to add:
config.hobo.dont_emit_deprecated_routes = true
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.
You will also want to add
config.watchable_dirs[File.join(config.root, 'app/view')] = ['dryml']
to your config/environments/development.rb
### application.dryml or front_site.dryml
Replace
{.dryml}
with
{.dryml}
Note that the default Hobo generation now always creates both a
front_site.dryml and an application.dryml, even if you don't create
any subsites.
Also be aware that application.dryml is no longer loaded automatically
if you have a front_site.dryml. Add
{.dryml}
to your front_site.dryml, your admin_site.dryml, et cetera.
### move public/ to app/assets/
{.todo}
In Rails 3.1, images, javascripts and stylesheets are loaded from
app/assets/ rather than from public/ so you'll have to move them.
Note that the following are Rails and/or Hobo assets that are now
included via the pipeline and can be deleted rather than moved:
images/rails.png
hobothemes/**
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
stylesheets/reset.css,hobo-rapid.css
You can organize your app/assets directory however you like, but you
probably should arrange it the way Hobo does, the install_plugin
generator expects it.
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:
application.js
application/
front.js
front/
admin.js
admin/
Application.js loads any rails plugins and then everything in the
application/ directory. Front.js loads application.js, then any hobo
plugins you've installed and then everything in the front/ directory.
Admin.js behaves similarly. Hobo views in the front subsite load
front.js and Hobo views in the admin subsite load admin.js.
app/assets/stylesheets is organized in a similar manner.
# Changes from Hobo 1.3 & hobo-jquery 1.3
## Javascript framework changed to jQuery
{.nomove}
Hobo 1.3 and earlier versions used prototype.js for its Ajax support.
In Hobo 2.0 all of our javascript code has been rewritten to use
jQuery instead of prototype.js.
In the process of rewriting the code many tags have been updated to
add AJAX support, and tags that used non-standard AJAX mechanisms have
been updated to use standard Hobo form AJAX. The most visible of
these changes have been to the editors.
## The Asset Pipeline
{.todo}
we should create a (small) chapter on the Hobo asset pipeline layout. see above (move public/ to app/assets/)
{.hidden}
Hobo 2.0 uses the asset pipeline features introduced in Rails 3.1.
Hobo 2.0 does not work out of the box with the asset pipeline turned
off. It'd certainly be possible to copy all Hobo assets into public/,
but you would have to do so manually, there are no longer any rake
tasks to do this for you.
## application.dryml is no longer loaded automatically
{.todo}
Hobo 1.3 loaded application.dryml and then X_site.dryml, where X was
front or admin or the name of the current subsite. Hobo 2.0 only
loads X_site.dryml. If that fails, it loads application.dryml
instead.
A new application generated by Hobo 2.0 will have `` in X_site.dryml so that application.dryml is
still loaded. When it is loaded is now controlled by the the author
rather than always loading first.
## :inverse_of recommended
{.todo}
For correct behaviour, please ensure that all accessible associations
have their :inverse_of option set in both directions.
## set-theme deprecated
{.nomove}
The old Hobo theme support has never worked well, and has been
replaced. Themes are now Hobo plugins and work like every other Hobo
2.0 plugin.
Replace:
{.dryml}
with
{.dryml}
and add
*= require hobo_clean
to your app/assets/stylesheets/front.css. Some themes may also
include javascript which would require them to be added to front.js as
well.
## default doctype changed
{.nomove}
The default doctype has been changed from `XHTML 1.0 TRANSITIONAL` to
`html`, also known as "standards mode" in Internet Explorer 8 and 9
and "html5" in other browsers.
## named routes' names changed to use standard Rails names
{.nomove}
The names of named routes generated by Hobo have changed to more
closely match the default names generated by the Rails REST route
generator. The standard 7 REST routes have not changed, but some
additional routes such as nested routes and lifecycle routes have been
renamed.
For the moment you can ask Hobo to emit both the new style and old
style routes by not defining
`config.hobo.dont_emit_deprecated_routes`.
Note that paths and method names have not changed, only the named
route has changed, so this change should not be visible to the user or
impact controller code.
The route name is leftmost column in `rake routes`.
Here are some example changes:
create_task_path => create_tasks_path # tasks#create
create_task_for_story_path => create_story_tasks_path # tasks#create_for_story
foo_transition_path => transition_foo_path # foos lifecycle transition
foo_show2_path => show2_foo_path # show_action :show2 in foos_controller
Note that in the second example, create_story_tasks_path, the
controller method name is `create_for_story`. This is the same method
name that Hobo 1.0 and 1.3 use; the default Rails method name would be
just plain `create`.
There are several named routes used in the user_mailer views generated
in a new application. These must be fixed up when upgrading an old
application. For instance, user_activate_url must be changed to
activate_user_url in activation.erb.
In exchange for the pain of updating some of your named routes, we
receive the following benefits:
- polymorphic_url works with nested routes and in more situations
- url_for will work in more situations
- the `` tag and the many tags which use it now accept all the
`url_for` options, such as host and port.
- hobo_routes.rb is easier to read and understand
- code reduction in Hobo
## `remote-method-button` and `update-button` AJAX functionality removed
{.nomove}
`remote-method-button`, `update-button` and similar buttons such as
`delete-button` were written early in the history of Hobo, before
standard form/part ajax was supported. These tags are easy to replace
with the much more flexible forms.
For backwards compatibility, most of these buttons have been updated
to 2.0. However, the little used `remote-method-button` and
`update-button` have not been converted to support Hobo 2.0 AJAX.
## default field-list changed
{.nomove}
The default for `` has changed to ``.
The old behaviour is still available in ``.
## Chronic patches removed.
HoboSupport's patches to Chronic have been removed because they are not
supported in Ruby 2.0.0.
## rapid_summary tags removed
The rapid\_summary tags have been moved out of core Hobo into their own plugin, https://github.com/Hobo/hobo_summary, which is not yet in a working state
## Helper rearrangement
{.todo}
In previous versions of Hobo, all Hobo helpers were available in both
the controllers and the views. In this version, some helpers are
only available in the views. If there is a helper function that you
need to access in your controller, you can call in your controller:
HoboTypeHelper.add_to_controller(self)
Other Helper classes not included in the controller by default are
HoboDebugHelper, HoboDeprecatedHelper and HoboViewHintHelper.
Several helpers have been moved into
app/helpers/hobo_deprecated_helper.rb
If your application depends on any of these, you can set
config.hobo.include_deprecated_helper.
## Rails 3.2 required
Hobo 2.0 currently requires Rails 3.2 for operation.
## Editors
{.todo}
Editors are no longer special-cased, they now use the standard DRYML
part mechanism.
There are two types of editors: `` and ``.
click-editor is the click-to-edit type of control similar to what
Rapid currently uses for a string, and live-editor always renders the
input, and is similar to what Rapid currently uses for Boolean's and
enum-strings.
Please refer to the documentation for `click-editor` and `live-editor`
for more details.
`` is now a polymorphic input that uses either `` or
``.
TBD: Right now live-editor and click-editor use ``. The
major advantage of formlet is that it is safe to use inside of a form.
I can't think of any good use cases for that behaviour, but it does
seem like something people might do by accident.
The alternative is to use `