hobo 0.5.3 → 0.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/bin/hobo +18 -4
- data/hobo_files/plugin/CHANGES.txt +511 -0
- data/hobo_files/plugin/README +8 -3
- data/hobo_files/plugin/Rakefile +81 -0
- data/hobo_files/plugin/generators/hobo/hobo_generator.rb +4 -4
- data/hobo_files/plugin/generators/hobo/templates/guest.rb +1 -1
- data/hobo_files/plugin/generators/hobo_front_controller/hobo_front_controller_generator.rb +1 -1
- data/hobo_files/plugin/generators/hobo_front_controller/templates/index.dryml +16 -22
- data/hobo_files/plugin/generators/hobo_front_controller/templates/login.dryml +4 -6
- data/hobo_files/plugin/generators/hobo_front_controller/templates/search.dryml +6 -5
- data/hobo_files/plugin/generators/hobo_front_controller/templates/signup.dryml +4 -6
- data/hobo_files/plugin/generators/hobo_migration/hobo_migration_generator.rb +237 -0
- data/hobo_files/plugin/generators/hobo_migration/templates/migration.rb +9 -0
- data/hobo_files/plugin/generators/hobo_model/USAGE +2 -3
- data/hobo_files/plugin/generators/hobo_model/hobo_model_generator.rb +1 -14
- data/hobo_files/plugin/generators/hobo_model/templates/fixtures.yml +1 -6
- data/hobo_files/plugin/generators/hobo_model/templates/model.rb +10 -4
- data/hobo_files/plugin/generators/hobo_rapid/hobo_rapid_generator.rb +7 -6
- data/hobo_files/plugin/generators/hobo_rapid/templates/hobo_base.css +68 -0
- data/hobo_files/plugin/generators/hobo_rapid/templates/hobo_rapid.css +93 -0
- data/hobo_files/plugin/generators/hobo_rapid/templates/hobo_rapid.js +11 -6
- data/hobo_files/plugin/generators/hobo_rapid/templates/themes/default/public/images/plus.png +0 -0
- data/hobo_files/plugin/generators/hobo_rapid/templates/themes/default/public/stylesheets/application.css +24 -14
- data/hobo_files/plugin/generators/hobo_rapid/templates/themes/default/views/application.dryml +28 -44
- data/hobo_files/plugin/generators/hobo_user_model/USAGE +2 -12
- data/hobo_files/plugin/generators/hobo_user_model/hobo_user_model_generator.rb +1 -14
- data/hobo_files/plugin/generators/hobo_user_model/templates/fixtures.yml +0 -6
- data/hobo_files/plugin/generators/hobo_user_model/templates/model.rb +8 -1
- data/hobo_files/plugin/init.rb +6 -2
- data/hobo_files/plugin/lib/active_record/has_many_association.rb +23 -12
- data/hobo_files/plugin/lib/extensions.rb +134 -40
- data/hobo_files/plugin/lib/extensions/test_case.rb +0 -1
- data/hobo_files/plugin/lib/hobo.rb +77 -46
- data/hobo_files/plugin/lib/hobo/authenticated_user.rb +24 -2
- data/hobo_files/plugin/lib/hobo/authentication_support.rb +2 -1
- data/hobo_files/plugin/lib/hobo/controller.rb +35 -12
- data/hobo_files/plugin/lib/hobo/define_tags.rb +4 -4
- data/hobo_files/plugin/lib/hobo/dryml.rb +33 -51
- data/hobo_files/plugin/lib/hobo/dryml/dryml_builder.rb +47 -34
- data/hobo_files/plugin/lib/hobo/dryml/scoped_variables.rb +37 -0
- data/hobo_files/plugin/lib/hobo/dryml/taglib.rb +27 -5
- data/hobo_files/plugin/lib/hobo/dryml/template.rb +545 -302
- data/hobo_files/plugin/lib/hobo/dryml/template_environment.rb +305 -135
- data/hobo_files/plugin/lib/hobo/email_address.rb +5 -0
- data/hobo_files/plugin/lib/hobo/field_spec.rb +66 -0
- data/hobo_files/plugin/lib/hobo/hobo_helper.rb +325 -0
- data/hobo_files/plugin/lib/hobo/html_string.rb +2 -0
- data/hobo_files/plugin/lib/hobo/lazy_hash.rb +13 -1
- data/hobo_files/plugin/lib/hobo/markdown_string.rb +3 -1
- data/hobo_files/plugin/lib/hobo/model.rb +185 -66
- data/hobo_files/plugin/lib/hobo/model_controller.rb +56 -49
- data/hobo_files/plugin/lib/hobo/password_string.rb +2 -0
- data/hobo_files/plugin/lib/hobo/plugins.rb +75 -0
- data/hobo_files/plugin/lib/hobo/rapid_helper.rb +98 -0
- data/hobo_files/plugin/lib/hobo/static_tags +0 -3
- data/hobo_files/plugin/lib/hobo/textile_string.rb +11 -1
- data/hobo_files/plugin/lib/hobo/undefined.rb +1 -1
- data/hobo_files/plugin/lib/rexml.rb +166 -75
- data/hobo_files/plugin/spec/fixtures/users.yml +9 -0
- data/hobo_files/plugin/spec/spec.opts +6 -0
- data/hobo_files/plugin/spec/spec_helper.rb +28 -0
- data/hobo_files/plugin/spec/unit/hobo/dryml/template_spec.rb +650 -0
- data/hobo_files/plugin/tags/core.dryml +58 -4
- data/hobo_files/plugin/tags/rapid.dryml +289 -135
- data/hobo_files/plugin/tags/rapid_document_tags.dryml +49 -0
- data/hobo_files/plugin/tags/rapid_editing.dryml +92 -69
- data/hobo_files/plugin/tags/rapid_forms.dryml +242 -0
- data/hobo_files/plugin/tags/rapid_navigation.dryml +65 -65
- data/hobo_files/plugin/tags/rapid_pages.dryml +197 -124
- data/hobo_files/plugin/tags/rapid_support.dryml +23 -0
- metadata +29 -22
- data/hobo_files/plugin/generators/hobo_model/templates/migration.rb +0 -13
- data/hobo_files/plugin/generators/hobo_rapid/templates/themes/default/default_mapping.rb +0 -11
- data/hobo_files/plugin/generators/hobo_user_model/templates/migration.rb +0 -15
- data/hobo_files/plugin/lib/hobo/HtmlString +0 -3
- data/hobo_files/plugin/lib/hobo/controller_helpers.rb +0 -135
- data/hobo_files/plugin/lib/hobo/core.rb +0 -475
- data/hobo_files/plugin/lib/hobo/rapid.rb +0 -447
- data/hobo_files/plugin/test/hobo_dryml_template_test.rb +0 -7
- data/hobo_files/plugin/test/hobo_test.rb +0 -7
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
<def tag="with_fields" attrs="fields, skip, skip_associations, include_timestamps"><%
|
|
2
|
+
field_names = if fields.nil?
|
|
3
|
+
columns = this.class.content_columns.every(:name)
|
|
4
|
+
columns -= %w{created_at updated_at created_on updated_on} unless include_timestamps
|
|
5
|
+
|
|
6
|
+
if skip_associations == "has_many"
|
|
7
|
+
assocs = this.class.reflections.values.reject {|r| r.macro == :has_many }.every(:name)
|
|
8
|
+
columns - assocs
|
|
9
|
+
elsif skip_associations
|
|
10
|
+
columns
|
|
11
|
+
else
|
|
12
|
+
assocs = this.class.reflections.values.every(:name)
|
|
13
|
+
columns + assocs
|
|
14
|
+
end
|
|
15
|
+
else
|
|
16
|
+
comma_split(fields)
|
|
17
|
+
end
|
|
18
|
+
|
|
19
|
+
field_names -= comma_split(skip) if skip
|
|
20
|
+
field_names = field_names.select {|f| can_view?(this, f)}
|
|
21
|
+
field_names.each do |field| %><with field="&field"><tagbody/></with><% end
|
|
22
|
+
%></def>
|
|
23
|
+
|
metadata
CHANGED
|
@@ -3,8 +3,8 @@ rubygems_version: 0.9.0
|
|
|
3
3
|
specification_version: 1
|
|
4
4
|
name: hobo
|
|
5
5
|
version: !ruby/object:Gem::Version
|
|
6
|
-
version: 0.
|
|
7
|
-
date: 2007-
|
|
6
|
+
version: "0.6"
|
|
7
|
+
date: 2007-08-22 00:00:00 +01:00
|
|
8
8
|
summary: The web app builder for Rails
|
|
9
9
|
require_paths:
|
|
10
10
|
- lib
|
|
@@ -37,12 +37,13 @@ files:
|
|
|
37
37
|
- hobo_files/plugin/LICENSE.txt
|
|
38
38
|
- hobo_files/plugin/Rakefile
|
|
39
39
|
- hobo_files/plugin/README
|
|
40
|
+
- hobo_files/plugin/spec
|
|
40
41
|
- hobo_files/plugin/tags
|
|
41
42
|
- hobo_files/plugin/tasks
|
|
42
|
-
- hobo_files/plugin/test
|
|
43
43
|
- hobo_files/plugin/uninstall.rb
|
|
44
44
|
- hobo_files/plugin/generators/hobo
|
|
45
45
|
- hobo_files/plugin/generators/hobo_front_controller
|
|
46
|
+
- hobo_files/plugin/generators/hobo_migration
|
|
46
47
|
- hobo_files/plugin/generators/hobo_model
|
|
47
48
|
- hobo_files/plugin/generators/hobo_model_controller
|
|
48
49
|
- hobo_files/plugin/generators/hobo_rapid
|
|
@@ -61,11 +62,13 @@ files:
|
|
|
61
62
|
- hobo_files/plugin/generators/hobo_front_controller/templates/login.dryml
|
|
62
63
|
- hobo_files/plugin/generators/hobo_front_controller/templates/search.dryml
|
|
63
64
|
- hobo_files/plugin/generators/hobo_front_controller/templates/signup.dryml
|
|
65
|
+
- hobo_files/plugin/generators/hobo_migration/hobo_migration_generator.rb
|
|
66
|
+
- hobo_files/plugin/generators/hobo_migration/templates
|
|
67
|
+
- hobo_files/plugin/generators/hobo_migration/templates/migration.rb
|
|
64
68
|
- hobo_files/plugin/generators/hobo_model/hobo_model_generator.rb
|
|
65
69
|
- hobo_files/plugin/generators/hobo_model/templates
|
|
66
70
|
- hobo_files/plugin/generators/hobo_model/USAGE
|
|
67
71
|
- hobo_files/plugin/generators/hobo_model/templates/fixtures.yml
|
|
68
|
-
- hobo_files/plugin/generators/hobo_model/templates/migration.rb
|
|
69
72
|
- hobo_files/plugin/generators/hobo_model/templates/model.rb
|
|
70
73
|
- hobo_files/plugin/generators/hobo_model/templates/unit_test.rb
|
|
71
74
|
- hobo_files/plugin/generators/hobo_model_controller/hobo_model_controller_generator.rb
|
|
@@ -77,10 +80,11 @@ files:
|
|
|
77
80
|
- hobo_files/plugin/generators/hobo_model_controller/templates/view.rhtml
|
|
78
81
|
- hobo_files/plugin/generators/hobo_rapid/hobo_rapid_generator.rb
|
|
79
82
|
- hobo_files/plugin/generators/hobo_rapid/templates
|
|
83
|
+
- hobo_files/plugin/generators/hobo_rapid/templates/hobo_base.css
|
|
84
|
+
- hobo_files/plugin/generators/hobo_rapid/templates/hobo_rapid.css
|
|
80
85
|
- hobo_files/plugin/generators/hobo_rapid/templates/hobo_rapid.js
|
|
81
86
|
- hobo_files/plugin/generators/hobo_rapid/templates/themes
|
|
82
87
|
- hobo_files/plugin/generators/hobo_rapid/templates/themes/default
|
|
83
|
-
- hobo_files/plugin/generators/hobo_rapid/templates/themes/default/default_mapping.rb
|
|
84
88
|
- hobo_files/plugin/generators/hobo_rapid/templates/themes/default/public
|
|
85
89
|
- hobo_files/plugin/generators/hobo_rapid/templates/themes/default/views
|
|
86
90
|
- hobo_files/plugin/generators/hobo_rapid/templates/themes/default/public/images
|
|
@@ -101,6 +105,7 @@ files:
|
|
|
101
105
|
- hobo_files/plugin/generators/hobo_rapid/templates/themes/default/public/images/header_purple.gif
|
|
102
106
|
- hobo_files/plugin/generators/hobo_rapid/templates/themes/default/public/images/header_red.gif
|
|
103
107
|
- hobo_files/plugin/generators/hobo_rapid/templates/themes/default/public/images/logo.gif
|
|
108
|
+
- hobo_files/plugin/generators/hobo_rapid/templates/themes/default/public/images/plus.png
|
|
104
109
|
- hobo_files/plugin/generators/hobo_rapid/templates/themes/default/public/images/spinner.gif
|
|
105
110
|
- hobo_files/plugin/generators/hobo_rapid/templates/themes/default/public/images/txt_list_img_dblue.gif
|
|
106
111
|
- hobo_files/plugin/generators/hobo_rapid/templates/themes/default/public/images/txt_list_img_green.gif
|
|
@@ -120,7 +125,6 @@ files:
|
|
|
120
125
|
- hobo_files/plugin/generators/hobo_user_model/templates
|
|
121
126
|
- hobo_files/plugin/generators/hobo_user_model/USAGE
|
|
122
127
|
- hobo_files/plugin/generators/hobo_user_model/templates/fixtures.yml
|
|
123
|
-
- hobo_files/plugin/generators/hobo_user_model/templates/migration.rb
|
|
124
128
|
- hobo_files/plugin/generators/hobo_user_model/templates/model.rb
|
|
125
129
|
- hobo_files/plugin/generators/hobo_user_model/templates/unit_test.rb
|
|
126
130
|
- hobo_files/plugin/lib/action_view_extensions
|
|
@@ -139,14 +143,14 @@ files:
|
|
|
139
143
|
- hobo_files/plugin/lib/hobo/authentication_support.rb
|
|
140
144
|
- hobo_files/plugin/lib/hobo/composite_model.rb
|
|
141
145
|
- hobo_files/plugin/lib/hobo/controller.rb
|
|
142
|
-
- hobo_files/plugin/lib/hobo/controller_helpers.rb
|
|
143
|
-
- hobo_files/plugin/lib/hobo/core.rb
|
|
144
146
|
- hobo_files/plugin/lib/hobo/define_tags.rb
|
|
145
147
|
- hobo_files/plugin/lib/hobo/dryml
|
|
146
148
|
- hobo_files/plugin/lib/hobo/dryml.rb
|
|
149
|
+
- hobo_files/plugin/lib/hobo/email_address.rb
|
|
150
|
+
- hobo_files/plugin/lib/hobo/field_spec.rb
|
|
147
151
|
- hobo_files/plugin/lib/hobo/generator.rb
|
|
152
|
+
- hobo_files/plugin/lib/hobo/hobo_helper.rb
|
|
148
153
|
- hobo_files/plugin/lib/hobo/html_string.rb
|
|
149
|
-
- hobo_files/plugin/lib/hobo/HtmlString
|
|
150
154
|
- hobo_files/plugin/lib/hobo/lazy_hash.rb
|
|
151
155
|
- hobo_files/plugin/lib/hobo/mapping_tags.rb
|
|
152
156
|
- hobo_files/plugin/lib/hobo/markdown_string.rb
|
|
@@ -155,9 +159,10 @@ files:
|
|
|
155
159
|
- hobo_files/plugin/lib/hobo/model_queries.rb
|
|
156
160
|
- hobo_files/plugin/lib/hobo/model_support.rb
|
|
157
161
|
- hobo_files/plugin/lib/hobo/password_string.rb
|
|
162
|
+
- hobo_files/plugin/lib/hobo/plugins.rb
|
|
158
163
|
- hobo_files/plugin/lib/hobo/predicate_dispatch.rb
|
|
159
164
|
- hobo_files/plugin/lib/hobo/proc_binding.rb
|
|
160
|
-
- hobo_files/plugin/lib/hobo/
|
|
165
|
+
- hobo_files/plugin/lib/hobo/rapid_helper.rb
|
|
161
166
|
- hobo_files/plugin/lib/hobo/static_tags
|
|
162
167
|
- hobo_files/plugin/lib/hobo/text.rb
|
|
163
168
|
- hobo_files/plugin/lib/hobo/textile_string.rb
|
|
@@ -165,20 +170,30 @@ files:
|
|
|
165
170
|
- hobo_files/plugin/lib/hobo/undefined_access_error.rb
|
|
166
171
|
- hobo_files/plugin/lib/hobo/where_fragment.rb
|
|
167
172
|
- hobo_files/plugin/lib/hobo/dryml/dryml_builder.rb
|
|
173
|
+
- hobo_files/plugin/lib/hobo/dryml/scoped_variables.rb
|
|
168
174
|
- hobo_files/plugin/lib/hobo/dryml/tag_module.rb
|
|
169
175
|
- hobo_files/plugin/lib/hobo/dryml/taglib.rb
|
|
170
176
|
- hobo_files/plugin/lib/hobo/dryml/template.rb
|
|
171
177
|
- hobo_files/plugin/lib/hobo/dryml/template_environment.rb
|
|
172
178
|
- hobo_files/plugin/lib/hobo/dryml/template_handler.rb
|
|
179
|
+
- hobo_files/plugin/spec/fixtures
|
|
180
|
+
- hobo_files/plugin/spec/spec.opts
|
|
181
|
+
- hobo_files/plugin/spec/spec_helper.rb
|
|
182
|
+
- hobo_files/plugin/spec/unit
|
|
183
|
+
- hobo_files/plugin/spec/fixtures/users.yml
|
|
184
|
+
- hobo_files/plugin/spec/unit/hobo
|
|
185
|
+
- hobo_files/plugin/spec/unit/hobo/dryml
|
|
186
|
+
- hobo_files/plugin/spec/unit/hobo/dryml/template_spec.rb
|
|
173
187
|
- hobo_files/plugin/tags/core.dryml
|
|
174
188
|
- hobo_files/plugin/tags/rapid.dryml
|
|
189
|
+
- hobo_files/plugin/tags/rapid_document_tags.dryml
|
|
175
190
|
- hobo_files/plugin/tags/rapid_editing.dryml
|
|
191
|
+
- hobo_files/plugin/tags/rapid_forms.dryml
|
|
176
192
|
- hobo_files/plugin/tags/rapid_navigation.dryml
|
|
177
193
|
- hobo_files/plugin/tags/rapid_pages.dryml
|
|
194
|
+
- hobo_files/plugin/tags/rapid_support.dryml
|
|
178
195
|
- hobo_files/plugin/tasks/environments.rake
|
|
179
196
|
- hobo_files/plugin/tasks/hobo_tasks.rake
|
|
180
|
-
- hobo_files/plugin/test/hobo_dryml_template_test.rb
|
|
181
|
-
- hobo_files/plugin/test/hobo_test.rb
|
|
182
197
|
- bin/hobo
|
|
183
198
|
- LICENSE.txt
|
|
184
199
|
- README.txt
|
|
@@ -194,13 +209,5 @@ extensions: []
|
|
|
194
209
|
|
|
195
210
|
requirements: []
|
|
196
211
|
|
|
197
|
-
dependencies:
|
|
198
|
-
|
|
199
|
-
name: rails
|
|
200
|
-
version_requirement:
|
|
201
|
-
version_requirements: !ruby/object:Gem::Version::Requirement
|
|
202
|
-
requirements:
|
|
203
|
-
- - ">="
|
|
204
|
-
- !ruby/object:Gem::Version
|
|
205
|
-
version: 1.2.1
|
|
206
|
-
version:
|
|
212
|
+
dependencies: []
|
|
213
|
+
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
class <%= migration_name %> < ActiveRecord::Migration
|
|
2
|
-
def self.up
|
|
3
|
-
create_table :<%= table_name %> do |t|
|
|
4
|
-
<% for attribute in attributes -%>
|
|
5
|
-
t.column :<%= attribute.name %>, :<%= attribute.type %>
|
|
6
|
-
<% end -%>
|
|
7
|
-
end
|
|
8
|
-
end
|
|
9
|
-
|
|
10
|
-
def self.down
|
|
11
|
-
drop_table :<%= table_name %>
|
|
12
|
-
end
|
|
13
|
-
end
|
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
class <%= migration_name %> < ActiveRecord::Migration
|
|
2
|
-
def self.up
|
|
3
|
-
create_table :<%= table_name %> do |t|
|
|
4
|
-
t.string :username
|
|
5
|
-
t.string :crypted_password, :salt, :limit => 40
|
|
6
|
-
t.string :remember_token
|
|
7
|
-
t.datetime :remember_token_expires_at
|
|
8
|
-
t.auto_dates
|
|
9
|
-
end
|
|
10
|
-
end
|
|
11
|
-
|
|
12
|
-
def self.down
|
|
13
|
-
drop_table :<%= table_name %>
|
|
14
|
-
end
|
|
15
|
-
end
|
|
@@ -1,135 +0,0 @@
|
|
|
1
|
-
module Hobo::ControllerHelpers
|
|
2
|
-
|
|
3
|
-
protected
|
|
4
|
-
|
|
5
|
-
def current_user
|
|
6
|
-
# simple one-hit-per-request cache
|
|
7
|
-
@current_user or
|
|
8
|
-
@current_user = if Hobo.user_model and session and id = session[:user]
|
|
9
|
-
Hobo.user_model.find(id)
|
|
10
|
-
else
|
|
11
|
-
Guest.new
|
|
12
|
-
end
|
|
13
|
-
end
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
def logged_in?
|
|
17
|
-
not current_user.guest?
|
|
18
|
-
end
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
def urlb
|
|
22
|
-
request.relative_url_root
|
|
23
|
-
end
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
def controller_for(obj)
|
|
27
|
-
if obj.is_a? Class
|
|
28
|
-
obj.name.underscore.pluralize
|
|
29
|
-
else
|
|
30
|
-
obj.class.name.underscore.pluralize
|
|
31
|
-
end
|
|
32
|
-
end
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
def object_url(obj, action=nil, *param_hashes)
|
|
36
|
-
action &&= action.to_s
|
|
37
|
-
|
|
38
|
-
controller_name = controller_for(obj)
|
|
39
|
-
|
|
40
|
-
parts = if obj.is_a? Class
|
|
41
|
-
[urlb, controller_name]
|
|
42
|
-
|
|
43
|
-
elsif obj.is_a? Hobo::CompositeModel
|
|
44
|
-
[urlb, controller_name, obj.id]
|
|
45
|
-
|
|
46
|
-
elsif obj.is_a? ActiveRecord::Base
|
|
47
|
-
if obj.new_record?
|
|
48
|
-
[urlb, controller_name]
|
|
49
|
-
else
|
|
50
|
-
raise HoboError.new("invalid object url: new for existing object") if action == "new"
|
|
51
|
-
|
|
52
|
-
klass = obj.class
|
|
53
|
-
id = if klass.id_name?
|
|
54
|
-
obj.id_name(true)
|
|
55
|
-
else
|
|
56
|
-
obj.id
|
|
57
|
-
end
|
|
58
|
-
|
|
59
|
-
[urlb, controller_name, id]
|
|
60
|
-
end
|
|
61
|
-
|
|
62
|
-
elsif obj.is_a? Array # warning - this breaks if we use `case/when Array`
|
|
63
|
-
owner = obj.proxy_owner
|
|
64
|
-
new_model = obj.proxy_reflection.klass
|
|
65
|
-
[object_url(owner), obj.proxy_reflection.name]
|
|
66
|
-
|
|
67
|
-
else
|
|
68
|
-
raise HoboError.new("cannot create url for #{obj.inspect} (#{obj.class})")
|
|
69
|
-
end
|
|
70
|
-
basic = parts.join("/")
|
|
71
|
-
|
|
72
|
-
controller = (controller_name.camelize + "Controller").constantize rescue nil
|
|
73
|
-
url = if action && controller && action.to_sym.in?(controller.web_methods)
|
|
74
|
-
basic + "/#{action}"
|
|
75
|
-
else
|
|
76
|
-
case action
|
|
77
|
-
when "new"
|
|
78
|
-
basic + "/new"
|
|
79
|
-
when "destroy"
|
|
80
|
-
basic + "?_method=DELETE"
|
|
81
|
-
when "update"
|
|
82
|
-
basic + "?_method=PUT"
|
|
83
|
-
when nil
|
|
84
|
-
basic
|
|
85
|
-
else
|
|
86
|
-
basic + ";" + action
|
|
87
|
-
end
|
|
88
|
-
end
|
|
89
|
-
params = make_params(*param_hashes)
|
|
90
|
-
params.blank? ? url : url + "?" + params
|
|
91
|
-
end
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
def _as_params(name, obj)
|
|
95
|
-
if obj.is_a? Array
|
|
96
|
-
obj.map {|x| _as_params("#{name}[]", x)}.join("&")
|
|
97
|
-
elsif obj.is_a? Hash
|
|
98
|
-
obj.map {|k,v| _as_params("#{name}[#{k}]", v)}.join("&")
|
|
99
|
-
elsif obj.is_a? Hobo::RawJs
|
|
100
|
-
"#{name}=' + #{obj} + '"
|
|
101
|
-
else
|
|
102
|
-
v = if obj.is_a?(ActiveRecord::Base) or obj.is_a?(Array)
|
|
103
|
-
"@" + dom_id(obj)
|
|
104
|
-
else
|
|
105
|
-
obj.to_s.gsub("'"){"\\'"}
|
|
106
|
-
end
|
|
107
|
-
"#{name}=#{v}"
|
|
108
|
-
end
|
|
109
|
-
end
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
def make_params(*hashes)
|
|
113
|
-
hash = {}
|
|
114
|
-
hashes.each {|h| hash.update(h) if h}
|
|
115
|
-
hash.map {|k,v| _as_params(k, v)}.join("&")
|
|
116
|
-
end
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
def dom_id(x, attr=nil)
|
|
120
|
-
Hobo.dom_id(x, attr)
|
|
121
|
-
end
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
# debugging support
|
|
125
|
-
|
|
126
|
-
def debug(*args)
|
|
127
|
-
logger.debug(args.map{|arg| PP.pp(arg, "")}.join("\n"))
|
|
128
|
-
return args.first
|
|
129
|
-
end
|
|
130
|
-
|
|
131
|
-
def abort_with(*args)
|
|
132
|
-
raise args.map{|arg| PP.pp(arg, "")}.join("\n")
|
|
133
|
-
end
|
|
134
|
-
|
|
135
|
-
end
|
|
@@ -1,475 +0,0 @@
|
|
|
1
|
-
module Hobo
|
|
2
|
-
|
|
3
|
-
module Core
|
|
4
|
-
|
|
5
|
-
include Hobo::DefineTags
|
|
6
|
-
|
|
7
|
-
include Hobo::ControllerHelpers
|
|
8
|
-
|
|
9
|
-
def debug(*args)
|
|
10
|
-
logger.debug("\n### DRYML Debug ###")
|
|
11
|
-
logger.debug(args.map {|a| PP.pp(a, "")}.join("-------\n"))
|
|
12
|
-
logger.debug("DRYML THIS = " + Hobo.dom_id(this).to_s)
|
|
13
|
-
logger.debug("###################\n")
|
|
14
|
-
args.first unless args.empty?
|
|
15
|
-
end
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
def add_classes!(options, *classes)
|
|
19
|
-
options[:class] = ([options[:class]] + classes).select{|x|x}.join(' ')
|
|
20
|
-
options
|
|
21
|
-
end
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
def add_classes(options, *classes)
|
|
25
|
-
add_classes!({}.update(options), classes)
|
|
26
|
-
end
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
def map_this
|
|
30
|
-
res = []
|
|
31
|
-
this.each_index {|i| new_field_context(i) { res << yield } }
|
|
32
|
-
res
|
|
33
|
-
end
|
|
34
|
-
alias_method :collect_this, :map_this
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
def comma_split(x)
|
|
38
|
-
case x
|
|
39
|
-
when nil
|
|
40
|
-
[]
|
|
41
|
-
when Symbol
|
|
42
|
-
x.to_s
|
|
43
|
-
when String
|
|
44
|
-
x.split(/\s*,\s*/)
|
|
45
|
-
else
|
|
46
|
-
x.map{|e| comma_split(e)}.flatten
|
|
47
|
-
end
|
|
48
|
-
end
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
def can_create?(object)
|
|
52
|
-
Hobo.can_create?(current_user, object)
|
|
53
|
-
end
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
def can_update?(object, new)
|
|
57
|
-
Hobo.can_update?(current_user, object, new)
|
|
58
|
-
end
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
def can_edit?(object, field)
|
|
62
|
-
if !field and object.respond_to?(:proxy_reflection)
|
|
63
|
-
Hobo.can_edit?(current_user, object.proxy_owner, object.proxy_reflection.name)
|
|
64
|
-
else
|
|
65
|
-
Hobo.can_edit?(current_user, object, field)
|
|
66
|
-
end
|
|
67
|
-
end
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
def can_edit_this?
|
|
71
|
-
this_parent && this_field && can_edit?(this_parent, this_field)
|
|
72
|
-
end
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
def can_delete?(object)
|
|
76
|
-
Hobo.can_delete?(current_user, object)
|
|
77
|
-
end
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
def can_view?(object, field=nil)
|
|
81
|
-
if !field and object.respond_to?(:proxy_reflection)
|
|
82
|
-
Hobo.can_view?(current_user, object.proxy_owner, object.proxy_reflection.name)
|
|
83
|
-
else
|
|
84
|
-
Hobo.can_view?(current_user, object, field)
|
|
85
|
-
end
|
|
86
|
-
end
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
def can_view_this?
|
|
90
|
-
if this_parent && this_field
|
|
91
|
-
can_view?(this_parent, this_field)
|
|
92
|
-
else
|
|
93
|
-
can_view?(this)
|
|
94
|
-
end
|
|
95
|
-
end
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
def viewable(collection)
|
|
99
|
-
collection.select {|x| can_view?(x)}
|
|
100
|
-
end
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
def theme_asset(path)
|
|
104
|
-
"#{urlb}/hobothemes/#{Hobo.current_theme}/#{path}"
|
|
105
|
-
end
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
def_tag :dynamic_tag, :name do
|
|
109
|
-
send(name, options)
|
|
110
|
-
end
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
def_tag :display_name do
|
|
114
|
-
name_tag = "display_name_for_#{this.class.name.underscore}"
|
|
115
|
-
if respond_to?(name_tag)
|
|
116
|
-
send(name_tag)
|
|
117
|
-
elsif this.is_a?(Array) && this.respond_to?(:proxy_reflection)
|
|
118
|
-
"(#{count})"
|
|
119
|
-
elsif this.is_a? Class and this < ActiveRecord::Base
|
|
120
|
-
this.name.pluralize.titleize
|
|
121
|
-
else
|
|
122
|
-
res = [:display_name, :name, :title].search do |m|
|
|
123
|
-
show(options.merge(:attr => m)) if this.respond_to?(m) and can_view?(this, m)
|
|
124
|
-
end
|
|
125
|
-
res || "#{this.class.name.humanize} #{this.id}"
|
|
126
|
-
end
|
|
127
|
-
end
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
def_tag :object_link, :view, :to, :params do
|
|
131
|
-
target = to || this
|
|
132
|
-
if target.nil?
|
|
133
|
-
"(Not Available)"
|
|
134
|
-
elsif to ? can_view?(to) : can_view_this?
|
|
135
|
-
content = tagbody ? tagbody.call : call_replaceable_tag(:display_name, options, options.delete(:name))
|
|
136
|
-
link_class = "#{target.class.name.underscore}_link"
|
|
137
|
-
link_to content, object_url(target, view, params), add_classes(options, link_class)
|
|
138
|
-
end
|
|
139
|
-
end
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
def_tag :new_object_link, :for do
|
|
143
|
-
f = for_ || this
|
|
144
|
-
new = f.new
|
|
145
|
-
new.created_by(current_user)
|
|
146
|
-
if can_create?(new)
|
|
147
|
-
default = "New " + (f.is_a?(Array) ? f.proxy_reflection.klass.name : f.name).titleize
|
|
148
|
-
content = tagbody ? tagbody.call : default
|
|
149
|
-
link_class = "new_#{new.class.name.underscore}_link"
|
|
150
|
-
link_to content, object_url(f, "new"), add_classes(options, link_class)
|
|
151
|
-
end
|
|
152
|
-
end
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
def_tag :tag_for_object, :name do
|
|
156
|
-
opts = {}.update(options)
|
|
157
|
-
opts.delete(:name)
|
|
158
|
-
|
|
159
|
-
if this_type and m = "#{name}_for_#{this_type.name.underscore}" and respond_to?(m)
|
|
160
|
-
send(m, opts)
|
|
161
|
-
else
|
|
162
|
-
send(name, opts)
|
|
163
|
-
end
|
|
164
|
-
end
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
def_tag :show, :no_span, :truncate_tail do
|
|
168
|
-
# We can't do this as a declared attribute as it will hide the truncate helper
|
|
169
|
-
trunc = options.delete(:truncate)
|
|
170
|
-
|
|
171
|
-
raise HoboError, "show of non-viewable field '#{this_field}' of #{this_parent.typed_id rescue this_parent}" unless
|
|
172
|
-
can_view_this?
|
|
173
|
-
|
|
174
|
-
res = if this_type.respond_to?(:macro)
|
|
175
|
-
if this_type.macro == :belongs_to
|
|
176
|
-
show_belongs_to
|
|
177
|
-
elsif this_type.macro == :has_many
|
|
178
|
-
show_has_many
|
|
179
|
-
end
|
|
180
|
-
|
|
181
|
-
else
|
|
182
|
-
res2 = case this
|
|
183
|
-
when nil
|
|
184
|
-
this_type <= String ? "" : "(Not Available)"
|
|
185
|
-
|
|
186
|
-
when Date
|
|
187
|
-
if respond_to?(:show_date)
|
|
188
|
-
show_date
|
|
189
|
-
else
|
|
190
|
-
this.to_s(:long)
|
|
191
|
-
end
|
|
192
|
-
|
|
193
|
-
when Time
|
|
194
|
-
if respond_to?(:show_datetime)
|
|
195
|
-
show_datetime
|
|
196
|
-
else
|
|
197
|
-
this.to_s(:long)
|
|
198
|
-
end
|
|
199
|
-
|
|
200
|
-
when Numeric
|
|
201
|
-
format = options[:format]
|
|
202
|
-
format ? format % this : this.to_s
|
|
203
|
-
|
|
204
|
-
when Hobo::HtmlString
|
|
205
|
-
this
|
|
206
|
-
|
|
207
|
-
when Hobo::MarkdownString
|
|
208
|
-
markdown(this)
|
|
209
|
-
|
|
210
|
-
when Hobo::TextileString
|
|
211
|
-
textilize(this)
|
|
212
|
-
|
|
213
|
-
when Hobo::PasswordString
|
|
214
|
-
"[password withheld]"
|
|
215
|
-
|
|
216
|
-
when String
|
|
217
|
-
h(this).gsub("\n", "<br/>")
|
|
218
|
-
|
|
219
|
-
when TrueClass
|
|
220
|
-
"Yes"
|
|
221
|
-
|
|
222
|
-
when FalseClass
|
|
223
|
-
"No"
|
|
224
|
-
|
|
225
|
-
else
|
|
226
|
-
raise HoboError, "Cannot show: #{this.inspect} (field is #{this_field}, type is #{this.class})"
|
|
227
|
-
end
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
if !no_span && this_parent.respond_to?(:typed_id)
|
|
232
|
-
"<span hobo_model_id='#{this_field_dom_id}'>#{res2}</span>"
|
|
233
|
-
else
|
|
234
|
-
res2
|
|
235
|
-
end
|
|
236
|
-
end
|
|
237
|
-
trunc ? truncate(res2, trunc.to_i, truncate_tail || "...") : res
|
|
238
|
-
end
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
def_tag :show_belongs_to do
|
|
242
|
-
object_link
|
|
243
|
-
end
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
def_tag :show_has_many do
|
|
247
|
-
if this.empty?
|
|
248
|
-
"(none)"
|
|
249
|
-
else
|
|
250
|
-
map_this { object_link }.join(", ")
|
|
251
|
-
end
|
|
252
|
-
end
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
def js_str(s)
|
|
256
|
-
if s.is_a? Hobo::RawJs
|
|
257
|
-
s.to_s
|
|
258
|
-
else
|
|
259
|
-
"'" + s.gsub("'"){"\\'"} + "'"
|
|
260
|
-
end
|
|
261
|
-
end
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
def make_params_js(*args)
|
|
265
|
-
("'" + make_params(*args) + "'").sub(/ \+ ''$/,'')
|
|
266
|
-
end
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
def render_params(*args)
|
|
270
|
-
parts = args.map{|x| x.split(/, */) if x}.compact.flatten
|
|
271
|
-
{ :part_page => view_name,
|
|
272
|
-
:render => parts.map do |part_id|
|
|
273
|
-
{ :object => Hobo::RawJs.new("hoboParts.#{part_id}"),
|
|
274
|
-
:part => part_id }
|
|
275
|
-
end
|
|
276
|
-
}
|
|
277
|
-
end
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
def nl_to_br(s)
|
|
281
|
-
s.to_s.gsub("\n", "<br/>") if s
|
|
282
|
-
end
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
def xattrs(options, klass=nil)
|
|
286
|
-
options ||= {}
|
|
287
|
-
if klass
|
|
288
|
-
options = add_classes(options.symbolize_keys, [klass])
|
|
289
|
-
end
|
|
290
|
-
options.map do |n,v|
|
|
291
|
-
v = v.to_s
|
|
292
|
-
val = v.include?("'") ? '"' + v + '"' : "'" + v + "'"
|
|
293
|
-
"#{n}=#{val}"
|
|
294
|
-
end.join(' ')
|
|
295
|
-
end
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
def param_name_for(object, field_path)
|
|
299
|
-
field_path = field_path.to_s.split(".") if field_path.is_a?(String, Symbol)
|
|
300
|
-
attrs = field_path.map{|part| "[#{part}]"}.join
|
|
301
|
-
"#{object.class.name.underscore}#{attrs}"
|
|
302
|
-
end
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
def param_name_for_this(association_foreign_key=false)
|
|
306
|
-
return "" unless form_this
|
|
307
|
-
name = if association_foreign_key and this_type.respond_to?(:macro) and this_type.macro == :belongs_to
|
|
308
|
-
param_name_for(form_this, form_field_path[0..-2] + [this_type.primary_key_name])
|
|
309
|
-
else
|
|
310
|
-
param_name_for(form_this, form_field_path)
|
|
311
|
-
end
|
|
312
|
-
register_form_field(name)
|
|
313
|
-
name
|
|
314
|
-
end
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
def selector_type
|
|
318
|
-
if this.is_a? ActiveRecord::Base
|
|
319
|
-
this.class
|
|
320
|
-
elsif this.respond_to? :member_class
|
|
321
|
-
this.member_class
|
|
322
|
-
elsif this == @this
|
|
323
|
-
@model
|
|
324
|
-
end
|
|
325
|
-
end
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
def_tag :human_type, :style do
|
|
329
|
-
if can_view_this?
|
|
330
|
-
res = if this.respond_to? :proxy_reflection
|
|
331
|
-
this.proxy_reflection.klass.name.pluralize
|
|
332
|
-
elsif this.is_a? Class
|
|
333
|
-
this.name
|
|
334
|
-
else
|
|
335
|
-
this.class.name
|
|
336
|
-
end
|
|
337
|
-
res.underscore.humanize.send(style || :titleize)
|
|
338
|
-
end
|
|
339
|
-
end
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
def_tag :partial, :as do
|
|
343
|
-
render(:partial => find_partial(this, as), :locals => { :this => this })
|
|
344
|
-
end
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
def_tag :repeat, :even_odd, :else do
|
|
348
|
-
if this.empty?
|
|
349
|
-
else_
|
|
350
|
-
else
|
|
351
|
-
if even_odd
|
|
352
|
-
map_this do
|
|
353
|
-
klass = [options[:class], cycle("even", "odd")].compact.join(' ')
|
|
354
|
-
content_tag(even_odd, tagbody.call, options.merge(:class => klass, :hobo_model_id => dom_id(this)))
|
|
355
|
-
end
|
|
356
|
-
else
|
|
357
|
-
map_this { tagbody.call }
|
|
358
|
-
end
|
|
359
|
-
end
|
|
360
|
-
end
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
def_tag :transpose_and_repeat, :with_field do
|
|
364
|
-
matrix = this.map {|obj| obj.send(with_field) }
|
|
365
|
-
max_length = matrix.omap{ length }.max
|
|
366
|
-
matrix = matrix.map do |a|
|
|
367
|
-
a + [nil] * (max_length - a.length)
|
|
368
|
-
end
|
|
369
|
-
repeat(:obj => matrix.transpose) { tagbody.call }
|
|
370
|
-
end
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
def_tag :count, :label, :prefix do
|
|
374
|
-
raise Exception.new("asked for count of a string") if this.is_a?(String)
|
|
375
|
-
|
|
376
|
-
l = label
|
|
377
|
-
if this.is_a?(Class) and this < ActiveRecord::Base
|
|
378
|
-
c = this.count
|
|
379
|
-
l ||= this.name.titleize
|
|
380
|
-
else
|
|
381
|
-
unless label
|
|
382
|
-
assoc_name = this.proxy_reflection.name.to_s
|
|
383
|
-
l = assoc_name.singularize.titleize
|
|
384
|
-
end
|
|
385
|
-
c = this.size
|
|
386
|
-
end
|
|
387
|
-
|
|
388
|
-
main = l.blank? ? c : pluralize(c, l)
|
|
389
|
-
|
|
390
|
-
if prefix == "are"
|
|
391
|
-
p = c == 1 ? "is" : "are"
|
|
392
|
-
p + ' ' + main
|
|
393
|
-
else
|
|
394
|
-
main
|
|
395
|
-
end
|
|
396
|
-
end
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
def_tag :with do
|
|
400
|
-
tagbody.call
|
|
401
|
-
end
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
def_tag :join, :with do
|
|
405
|
-
map_this { tagbody.call }.join(with)
|
|
406
|
-
end
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
def_tag :link_tag, :href, :controller, :action, :id do
|
|
410
|
-
link_to(tagbody.call, href ? href : { :controller => controller, :action => action, :id => id })
|
|
411
|
-
end
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
def_tag :if, :q do
|
|
415
|
-
res = q ? tagbody.call : ""
|
|
416
|
-
Dryml.last_if = q
|
|
417
|
-
res
|
|
418
|
-
end
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
def_tag :else do
|
|
422
|
-
tagbody.call unless Dryml.last_if
|
|
423
|
-
end
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
def_tag :unless, :q do
|
|
427
|
-
if_(:q => !q) { tagbody.call }
|
|
428
|
-
end
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
def_tag :if_blank do
|
|
432
|
-
if_(:q => this.blank?) { tagbody.call }
|
|
433
|
-
end
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
def_tag :unless_blank do
|
|
437
|
-
if_(:q => !this.blank?) { tagbody.call }
|
|
438
|
-
end
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
def_tag :if_empty do
|
|
442
|
-
if_(:q => this.empty?) { tagbody.call }
|
|
443
|
-
end
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
def_tag :unless_empty do
|
|
447
|
-
if_(:q => !this.empty?) { tagbody.call }
|
|
448
|
-
end
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
def_tag :if_this do
|
|
452
|
-
if_(:q => this) { tagbody.call }
|
|
453
|
-
end
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
def_tag :if_can_delete do
|
|
457
|
-
if_(:q => can_delete?(this)) { tagbody.call }
|
|
458
|
-
end
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
def_tag :if_can_create do
|
|
462
|
-
if_(:q => can_create?(this)) { tagbody.call }
|
|
463
|
-
end
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
def_tag :if_can_view do
|
|
467
|
-
if_(:q => can_view?(this)) { tagbody.call }
|
|
468
|
-
end
|
|
469
|
-
|
|
470
|
-
def_tag :if_can_edit do
|
|
471
|
-
if_(:q => can_edit_this?) { tagbody.call }
|
|
472
|
-
end
|
|
473
|
-
|
|
474
|
-
end
|
|
475
|
-
end
|