hobo 0.7.0 → 0.7.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (48) hide show
  1. data/hobo_files/plugin/CHANGES.txt +220 -23
  2. data/hobo_files/plugin/generators/hobo_front_controller/templates/index.dryml +18 -25
  3. data/hobo_files/plugin/generators/hobo_migration/hobo_migration_generator.rb +20 -15
  4. data/hobo_files/plugin/generators/hobo_model/templates/model.rb +3 -3
  5. data/hobo_files/plugin/generators/hobo_rapid/hobo_rapid_generator.rb +3 -3
  6. data/hobo_files/plugin/generators/hobo_rapid/templates/hobo-rapid.css +1 -2
  7. data/hobo_files/plugin/generators/hobo_rapid/templates/hobo-rapid.js +21 -4
  8. data/hobo_files/plugin/generators/hobo_rapid/templates/themes/clean/public/images/fieldbg.gif +0 -0
  9. data/hobo_files/plugin/generators/hobo_rapid/templates/themes/clean/public/images/spinner.gif +0 -0
  10. data/hobo_files/plugin/generators/hobo_rapid/templates/themes/clean/public/stylesheets/application.css +154 -26
  11. data/hobo_files/plugin/generators/hobo_rapid/templates/themes/clean/public/stylesheets/rapid-ui.css +144 -0
  12. data/hobo_files/plugin/generators/hobo_rapid/templates/themes/default/views/application.dryml +1 -1
  13. data/hobo_files/plugin/generators/hobo_user_controller/templates/controller.rb +1 -1
  14. data/hobo_files/plugin/generators/hobo_user_model/templates/model.rb +8 -11
  15. data/hobo_files/plugin/init.rb +0 -2
  16. data/hobo_files/plugin/lib/active_record/has_many_association.rb +0 -9
  17. data/hobo_files/plugin/lib/active_record/has_many_through_association.rb +0 -10
  18. data/hobo_files/plugin/lib/hobo.rb +57 -44
  19. data/hobo_files/plugin/lib/hobo/bundle.rb +222 -0
  20. data/hobo_files/plugin/lib/hobo/controller.rb +2 -5
  21. data/hobo_files/plugin/lib/hobo/dryml.rb +8 -7
  22. data/hobo_files/plugin/lib/hobo/dryml/dryml_builder.rb +10 -21
  23. data/hobo_files/plugin/lib/hobo/dryml/taglib.rb +107 -80
  24. data/hobo_files/plugin/lib/hobo/dryml/template.rb +27 -20
  25. data/hobo_files/plugin/lib/hobo/enum_string.rb +1 -1
  26. data/hobo_files/plugin/lib/hobo/field_declaration_dsl.rb +7 -0
  27. data/hobo_files/plugin/lib/hobo/guest.rb +4 -0
  28. data/hobo_files/plugin/lib/hobo/hobo_helper.rb +37 -9
  29. data/hobo_files/plugin/lib/hobo/model.rb +79 -17
  30. data/hobo_files/plugin/lib/hobo/model_controller.rb +59 -60
  31. data/hobo_files/plugin/lib/hobo/model_router.rb +16 -4
  32. data/hobo_files/plugin/lib/hobo/rapid_helper.rb +2 -1
  33. data/hobo_files/plugin/lib/hobo/user.rb +10 -7
  34. data/hobo_files/plugin/lib/hobo/user_controller.rb +6 -6
  35. data/hobo_files/plugin/{tags → taglibs}/core.dryml +5 -4
  36. data/hobo_files/plugin/{tags → taglibs}/rapid.dryml +54 -7
  37. data/hobo_files/plugin/{tags → taglibs}/rapid_document_tags.dryml +0 -0
  38. data/hobo_files/plugin/{tags → taglibs}/rapid_editing.dryml +4 -2
  39. data/hobo_files/plugin/{tags → taglibs}/rapid_forms.dryml +1 -4
  40. data/hobo_files/plugin/{tags → taglibs}/rapid_navigation.dryml +1 -2
  41. data/hobo_files/plugin/taglibs/rapid_pages.dryml +411 -0
  42. data/hobo_files/plugin/{tags → taglibs}/rapid_plus.dryml +0 -0
  43. data/hobo_files/plugin/{tags → taglibs}/rapid_support.dryml +9 -6
  44. data/hobo_files/plugin/tasks/fix_dryml.rake +0 -1
  45. metadata +16 -14
  46. data/hobo_files/plugin/generators/hobo_rapid/templates/themes/clean/public/stylesheets/rapid_ui.css +0 -167
  47. data/hobo_files/plugin/lib/hobo/plugins.rb +0 -75
  48. data/hobo_files/plugin/tags/rapid_pages.dryml +0 -341
@@ -1,3 +1,217 @@
1
+ === Release 0.7.1 ===
2
+
3
+ Hobo 0.7 is tested against Rails 2.0.1
4
+
5
+ Adding docs to the repo in /doc, including the beginings of a Hobo
6
+ tutorial
7
+
8
+ Front controller generator -- improvements to index page (app home
9
+ page)
10
+
11
+ Migration generator -- fix for situations where a table is being
12
+ renamed and modified in the same migration.
13
+
14
+ Hobo user controller generator -- no index page for users by default.
15
+
16
+
17
+ Hobo models
18
+
19
+ New style for declarting extra metadata on fields /
20
+ associations. Now part of the field / assoication declaration
21
+ instead of requiring an additional declaration:
22
+
23
+ set_creator_attr :foo
24
+ is now:
25
+ belongs_to :foo, :creator => true
26
+
27
+ Note that :creator => true can now be set on either a belongs_to
28
+ or a string field. In the latter case the string is set to the
29
+ login name of the current user.
30
+
31
+ set_login_attr :username
32
+ is now:
33
+ username :string, :login => true
34
+ (within the "fields do" block)
35
+
36
+ Can also write
37
+ username :string, :login => true, :validate => false
38
+ to disable the automatic login validations (see hobo/lib/hobo/user.rb)
39
+
40
+ Plus two new ones for fields: :name => true and :description => true.
41
+
42
+ All hobo models have a "recent" scope by default.
43
+
44
+ Added reflection helpers to find which collections are dependent.
45
+
46
+ The permission system can now be used to check for edit permission
47
+ on the object (rather than individual field) level. If the model
48
+ defined #can_edit?, that will be used, otherwise #can_update? is
49
+ called with a nil 'new object'.
50
+
51
+ #same_fields? and #only_changed_fields? now return true without
52
+ testing anything if the record passed is nil. This is more
53
+ compatible with the new ability to test for general edit
54
+ permission on an object.
55
+
56
+ #to_s now uses the declated name field (:name => true) if there is
57
+ one
58
+
59
+
60
+
61
+
62
+ Hobo user model
63
+
64
+ New class-level declaration set_admin_on_forst_user. Does what it
65
+ says on the tin. Only use it if your user model defines a boolean
66
+ field 'administrator'
67
+
68
+
69
+ Active Record extensions -- removed dubious #include? optimisation
70
+ from has_many associations.
71
+
72
+
73
+ New plugin feature -- Bundles
74
+
75
+ Bundles are Hobo's equivalent to "appable plugins" or "engines". A
76
+ plugin provides a bundle, and the app *instantiates* the bundle,
77
+ possibly more than once in file app/assemble.rb. This is the wrong
78
+ place to start documenting them but there are some examples in
79
+ /plugins
80
+
81
+
82
+ Hobo controllers
83
+
84
+ Options given to the include_plugin declaration have changed. They
85
+ are now exactly the same as the attributes taken by DRYML's
86
+ <include>
87
+
88
+
89
+ Hobo model controllers
90
+
91
+ Removed cruft left over from view-layer permissions experiment.
92
+
93
+ Simplified template lookup mechanism and removed inheritence aware
94
+ search for partials.
95
+
96
+ Added a cache for file-system tests to locate the correct
97
+ template. This avoids the need to stat files in production mode.
98
+
99
+ Better smarts for where to redirect to after a model is created.
100
+
101
+ Better support for model controllers that handle more than one
102
+ model. (this is a bit of a strange thing to do but a need for it
103
+ cropped up in an app than has a single place for users of different
104
+ types to log in)
105
+
106
+
107
+ Hobo user controller
108
+
109
+ "Account not available" is now a separate page
110
+ (<account-disabled-page>) instead of just a flash message.
111
+
112
+ Fixed occasional missing template bug
113
+
114
+
115
+
116
+ DRYML
117
+
118
+ DRYML now supports bundle class renaming when defining polymorphic
119
+ tags
120
+
121
+ Changes to <include> for plugins:
122
+
123
+ <include src="plugin/foo/taglibs/baa"/>
124
+ becomes
125
+ <include src="baa" plugin="foo"/>
126
+
127
+ You can also say <include src="foo" bundle="abc"/> which includes a
128
+ taglib from the bundle's plugin, as well as handling class renames
129
+ for polymorphic definitions.
130
+
131
+ Fix to allow calling tags with upper-case letters in their names.
132
+
133
+
134
+ DRYML core tags
135
+
136
+ <call-tag> now dasherises the tag name passed
137
+
138
+ <partial> is now just a trivial wrapper around render :partial
139
+
140
+
141
+
142
+
143
+ Hobo helpers
144
+
145
+ can_edit? can now be given nil as the field parameter to test for
146
+ general ability to edit this record (e.g. to decide wether to render
147
+ an "Edit" link). Also, parameters now default to #this and nil.
148
+
149
+ Renamed create_model to new_for_current_user. Pass a class or
150
+ association, defaults to #this.
151
+
152
+ New helper #font_models. Returns a list of models that are
153
+ candidates to appear on the default front page and main nav.
154
+
155
+ Changes to linkable? Subsite is now a named option (:subsite =>
156
+ "admin"), the target of the links defaults to #this and the action
157
+ defaults to :index for model targets and :show for records.
158
+
159
+
160
+ Hobo routing
161
+
162
+ Now automatically updates routes without restarting the server in
163
+ dev mode (yay!)
164
+
165
+
166
+ Site search -- don't search for records that are not linkable
167
+
168
+
169
+ Hobo Rapid
170
+
171
+ Clean theme is now the default theme
172
+
173
+ CSS -- small tweaks
174
+
175
+ JavaScript -- Ajax spinner now appears for a minimum time, and has a
176
+ fade effect.
177
+
178
+ Clean theme -- many improvements
179
+
180
+ Added an ajax option -- :spinner_next_to. Pass the dom id of a node
181
+ and the spinner will appear near that node.
182
+
183
+
184
+ Rapid tag library
185
+
186
+ <field-list> now defaults to <view> not <edit> as the tag for the
187
+ fields. Also, if the tag is <input>, non-editable fields are skipped
188
+ (used keep them in but to drop back to views).
189
+
190
+ <card> displays nothing if the object is not viewable. Default card
191
+ has various improvements.
192
+
193
+ New attribute <type-name dasherize/>
194
+
195
+ Fix: merge-attrs was missing on the belongs_to view
196
+
197
+ <boolean-checkbox-editor> now supports a custom ajax message and
198
+ configures the ajax spinner to appear near the checkbox.
199
+
200
+ Fix: incorrect use of <ul> in <error-messages>
201
+
202
+ <magic-nav> -- removed serach item, extended to maximum of 6 models
203
+
204
+ Many, many improvements to the default pages
205
+
206
+ <with-fields associations="has_many"> iterates of all has_many
207
+ relationships
208
+
209
+ Removed require of ruby-debug from fixdryml.task
210
+
211
+ New plugins featuring bundles: rapid_blog, rapid_comments,
212
+ rapid_images and rapid_tagging. All are work-in-progress.
213
+
214
+
1
215
  === Release 0.7 ===
2
216
 
3
217
  Hobo 0.7 is tested against Rails 1.99.1 (aka Rais 2.0 RC2)
@@ -40,13 +254,13 @@ DRYML
40
254
  A rake task hobo:fixdryml has been added which does a pretty good
41
255
  job of converting Hobo 0.6 DRYML source-code to the new style. It
42
256
  will change every file in app/views/**/*.dryml, and keeps a backup
43
- copy of app/views in app_views_before_fixdryml. If you pass it CSS=y
257
+ copy of app/views in app_views_before_fixdryml. If you pass it CLASS=y
44
258
  and ID=y it will 'dasherize' css classes and IDs too, which is the
45
- new Hobo concention. You can also pass DIR=... if you want to point
259
+ new Hobo convention. You can also pass DIR=... if you want to point
46
260
  it somewhere other than app/views. It won't fix anything in erb
47
261
  scriptlets, e.g. use of the tagbody local variable. Expect to do
48
262
  some manual fixes after running the task (good job you've got that
49
- thourough test suite eh?)
263
+ thorough test suite eh?)
50
264
 
51
265
  The add_classes helper now automatically dasherizes all class names.
52
266
 
@@ -57,13 +271,13 @@ DRYML
57
271
  Migration generator
58
272
 
59
273
  Better support for STI. It no longer wants to generate tables for
60
- the subclasses. Stil needed: a way of integrating fields declared in
274
+ the subclasses. Still needed: a way of integrating fields declared in
61
275
  the subclasses -- they are currently ignored by the generator.
62
276
 
63
277
 
64
278
  Hobo Rapid
65
279
 
66
- In place editiing (and Ajax in general) will now provide the form
280
+ In place editing (and Ajax in general) will now provide the form
67
281
  authentication token (CSRF protection) if available. No need to
68
282
  disable protect_from_forgery any more.
69
283
 
@@ -141,7 +355,7 @@ User model
141
355
  Newly generated user models (hobo_user_model generator) now give
142
356
  create permission to all by default (to enable signup).
143
357
 
144
- logins_count renamed to login_count (Hobo manages this feild for you
358
+ logins_count renamed to login_count (Hobo manages this field for you
145
359
  if it exists).
146
360
 
147
361
 
@@ -151,23 +365,6 @@ Core extensions
151
365
  gone. (It's not needed now that camel-case tags have gone).
152
366
 
153
367
 
154
-
155
-
156
-
157
-
158
-
159
-
160
-
161
-
162
-
163
-
164
-
165
-
166
-
167
-
168
-
169
-
170
-
171
368
  === Release 0.6.4 ===
172
369
 
173
370
  Fix: In-place-editors were not working with the new version of
@@ -1,38 +1,31 @@
1
- <page title="<%= app_name %>">
1
+ <page>
2
+
3
+ <body: class="front-page"/>
2
4
 
3
5
  <content-header:>
4
- <h1 class="front-page-title"><%= app_name %></h1>
5
- <panel>
6
- <div>
7
- <h3>Congratulations! Your Hobo Rails App is up and running</h3>
8
- <ul>
9
- <li>To customise this page: edit app/views/<%= file_name %>/index.dryml </li>
10
- </ul>
11
- </div>
12
- </panel>
6
+ <h1 class="front-page-title">Welcome to <app-name/></h1>
7
+ <section class="welcome-message">
8
+ <h3>Congratulations! Your Hobo Rails App is up and running</h3>
9
+ <ul>
10
+ <li>To customise this page: edit app/views/<%= file_name %>/index.dryml</li>
11
+ </ul>
12
+ </section>
13
13
  </content-header>
14
14
 
15
-
16
15
  <content-body:>
17
- <repeat with="&Hobo.models">
18
- <panel>
19
- <header><h2><%%= this.name.titlecase.pluralize %></h2></header>
16
+ <ul with="&front_models">
17
+ <li:>
18
+ <header><h2><a/></h2></header>
20
19
  <section>
21
- <if test="&this.count == 0">
22
- <p>There are no <%%= this.name.titleize.pluralize %></p>
23
- <if test="&can_create?">
24
- <p>Create a <a to="&this" action="new"/>.</p>
25
- </if>
26
- </if>
20
+ <p if="&this.count == 0">There are no <type-name plural/></p>
27
21
  <else>
28
- <repeat with="&this.find(:all, :limit => 3)">
29
- <card if="&can_view?"/>
30
- </repeat>
22
+ <card repeat="&select_viewable(this.recent.all)"/>
31
23
  <p><a>More</a> (<count/>)</p>
32
24
  </else>
25
+ <p if="&can_create? && linkable?(:new)">Create a <a to="&this" action="new"/>.</p>
33
26
  </section>
34
- </panel>
35
- </repeat>
27
+ </li:>
28
+ </ul>
36
29
  </content-body>
37
30
 
38
31
  </page>
@@ -34,7 +34,7 @@ class HoboMigrationGenerator < Rails::Generator::Base
34
34
 
35
35
  to_create = model_table_names - db_tables
36
36
  to_drop = db_tables - model_table_names - ['schema_info']
37
- to_change = db_tables & model_table_names
37
+ to_change = model_table_names
38
38
 
39
39
  to_rename = rename_or_drop!(to_create, to_drop, "table")
40
40
 
@@ -62,13 +62,17 @@ class HoboMigrationGenerator < Rails::Generator::Base
62
62
  changes = []
63
63
  undo_changes = []
64
64
  to_change.each do |t|
65
- change, undo = change_table(models_by_table_name[t])
66
- changes << change
67
- undo_changes << undo
65
+ model = models_by_table_name[t]
66
+ table = to_rename.index(t) || model.table_name
67
+ if table.in?(db_tables)
68
+ change, undo = change_table(model, table)
69
+ changes << change
70
+ undo_changes << undo
71
+ end
68
72
  end
69
73
 
70
74
  up = [renames, drops, creates, changes].flatten.select{|s|!s.blank?} * "\n\n"
71
- down = [undo_renames, undo_drops, undo_creates, undo_changes].flatten.select{|s|!s.blank?} * "\n\n"
75
+ down = [undo_changes, undo_renames, undo_drops, undo_creates].flatten.select{|s|!s.blank?} * "\n\n"
72
76
 
73
77
  if up.blank?
74
78
  puts "Database and models match -- nothing to change"
@@ -78,7 +82,7 @@ class HoboMigrationGenerator < Rails::Generator::Base
78
82
  puts "\n---------- Up Migration ----------", up, "----------------------------------"
79
83
  puts "\n---------- Down Migration --------", down, "----------------------------------"
80
84
 
81
- action = input("What now: [g]enerate migrations, generate and [m]igrate now or [c]ancel?", %w(g m c))
85
+ action = input("What now: [g]enerate migration, generate and [m]igrate now or [c]ancel?", %w(g m c))
82
86
 
83
87
  if action == 'c'
84
88
  # record nothing to keep the generator happy
@@ -147,40 +151,41 @@ class HoboMigrationGenerator < Rails::Generator::Base
147
151
  " t.%-*s %s" % [field_name_width, field_spec.sql_type, args.join(', ')]
148
152
  end
149
153
 
150
- def change_table(model)
151
- table_name = model.table_name
152
- db_columns = model.connection.columns(model.table_name).index_by{|c|c.name} - [model.primary_key]
154
+ def change_table(model, current_table_name)
155
+ new_table_name = model.table_name
156
+
157
+ db_columns = model.connection.columns(current_table_name).index_by{|c|c.name} - [model.primary_key]
153
158
  model_column_names = model.field_specs.keys.every(:to_s)
154
159
  db_column_names = db_columns.keys.every(:to_s)
155
160
 
156
161
  to_add = model_column_names - db_column_names
157
162
  to_remove = db_column_names - model_column_names - [model.primary_key.to_sym]
158
163
 
159
- to_rename = rename_or_drop!(to_add, to_remove, "column", "#{table_name}.")
164
+ to_rename = rename_or_drop!(to_add, to_remove, "column", "#{new_table_name}.")
160
165
 
161
166
  db_column_names -= to_rename.keys
162
167
  db_column_names |= to_rename.values
163
168
  to_change = db_column_names & model_column_names
164
169
 
165
170
  renames = to_rename.map do |old_name, new_name|
166
- "rename_column :#{table_name}, :#{old_name}, :#{new_name}"
171
+ "rename_column :#{new_table_name}, :#{old_name}, :#{new_name}"
167
172
  end
168
173
  undo_renames = to_rename.map do |old_name, new_name|
169
- "rename_column :#{table_name}, :#{new_name}, :#{old_name}"
174
+ "rename_column :#{new_table_name}, :#{new_name}, :#{old_name}"
170
175
  end
171
176
 
172
177
  to_add = to_add.sort_by{|c| model.field_specs[c].position }
173
178
  adds = to_add.map do |c|
174
179
  spec = model.field_specs[c]
175
180
  args = [":#{spec.sql_type}"] + format_options(spec.options, spec.sql_type)
176
- "add_column :#{table_name}, :#{c}, #{args * ', '}"
181
+ "add_column :#{new_table_name}, :#{c}, #{args * ', '}"
177
182
  end
178
183
  undo_adds = to_add.map do |c|
179
- "remove_column :#{table_name}, :#{c}"
184
+ "remove_column :#{new_table_name}, :#{c}"
180
185
  end
181
186
 
182
187
  removes = to_remove.map do |c|
183
- "remove_column :#{table_name}, :#{c}"
188
+ "remove_column :#{new_table_name}, :#{c}"
184
189
  end
185
190
  undo_removes = to_remove.map do |c|
186
191
  revert_column(table_name, c)
@@ -13,15 +13,15 @@ class <%= class_name %> < ActiveRecord::Base
13
13
  # --- Hobo Permissions --- #
14
14
 
15
15
  def creatable_by?(user)
16
- false
16
+ user.administrator?
17
17
  end
18
18
 
19
19
  def updatable_by?(user, new)
20
- false
20
+ user.administrator?
21
21
  end
22
22
 
23
23
  def deletable_by?(user)
24
- false
24
+ user.administrator?
25
25
  end
26
26
 
27
27
  def viewable_by?(user, field)
@@ -14,15 +14,15 @@ class HoboRapidGenerator < Hobo::Generator
14
14
  m.file "lowpro.js", "public/javascripts/lowpro.js"
15
15
  m.file "reset.css", "public/stylesheets/reset.css"
16
16
  m.file "hobo-rapid.css", "public/stylesheets/hobo-rapid.css"
17
- create_all(m, "themes/default/public", "public/hobothemes/default")
18
- create_all(m, "themes/default/views", "app/views/taglibs/themes/default")
17
+ create_all(m, "themes/clean/public", "public/hobothemes/clean")
18
+ create_all(m, "themes/clean/views", "app/views/taglibs/themes/clean")
19
19
  end
20
20
  end
21
21
 
22
22
  def import_tags
23
23
  path = File.join(RAILS_ROOT, "app/views/taglibs/application.dryml")
24
24
 
25
- tag = "<include src=\"plugins/hobo/tags/rapid\"/>\n\n<set-theme name=\"default\"/>\n"
25
+ tag = "<include src=\"rapid\" plugin=\"hobo\"/>\n\n<set-theme name=\"clean\"/>\n"
26
26
 
27
27
  src = File.read(path)
28
28
  return if src.include?(tag)