hobo 1.0.3 → 1.1.0.pre0

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.
Files changed (64) hide show
  1. data/CHANGES.txt +0 -66
  2. data/README +3 -0
  3. data/Rakefile +7 -7
  4. data/doctest/model.rdoctest +0 -2
  5. data/doctest/multi_model_forms.rdoctest +0 -2
  6. data/doctest/scopes.rdoctest +13 -21
  7. data/lib/active_record/association_collection.rb +7 -16
  8. data/lib/hobo.rb +10 -65
  9. data/lib/hobo/accessible_associations.rb +1 -5
  10. data/lib/hobo/authentication_support.rb +1 -1
  11. data/lib/hobo/controller.rb +5 -5
  12. data/lib/hobo/hobo_helper.rb +0 -84
  13. data/lib/hobo/lifecycles/lifecycle.rb +37 -31
  14. data/lib/hobo/lifecycles/transition.rb +1 -2
  15. data/lib/hobo/model.rb +13 -21
  16. data/lib/hobo/model_controller.rb +8 -8
  17. data/lib/hobo/rapid_helper.rb +12 -1
  18. data/lib/hobo/scopes/automatic_scopes.rb +26 -13
  19. data/lib/hobo/scopes/named_scope_extensions.rb +16 -28
  20. data/lib/hobo/user_controller.rb +1 -0
  21. data/lib/hobo/view_hints.rb +1 -5
  22. data/rails_generators/hobo/templates/initializer.rb +1 -1
  23. data/rails_generators/hobo_front_controller/templates/summary.dryml +4 -2
  24. data/rails_generators/hobo_model/hobo_model_generator.rb +12 -0
  25. data/rails_generators/hobo_model/templates/model.rb +9 -2
  26. data/rails_generators/hobo_rapid/templates/hobo-rapid.js +98 -23
  27. data/rails_generators/hobo_rapid/templates/themes/clean/public/stylesheets/clean.css +1 -1
  28. data/rails_generators/hobo_rapid/templates/themes/clean/public/stylesheets/rapid-ui.css +3 -1
  29. data/{dryml_generators → rapid_generators}/rapid/cards.dryml.erb +0 -0
  30. data/{dryml_generators → rapid_generators}/rapid/forms.dryml.erb +0 -0
  31. data/{dryml_generators → rapid_generators}/rapid/pages.dryml.erb +1 -1
  32. data/taglibs/rapid.dryml +2 -0
  33. data/taglibs/rapid_core.dryml +10 -9
  34. data/taglibs/rapid_forms.dryml +70 -35
  35. data/taglibs/rapid_lifecycles.dryml +17 -4
  36. data/taglibs/rapid_plus.dryml +3 -3
  37. data/taglibs/rapid_summary.dryml +11 -0
  38. data/taglibs/rapid_user_pages.dryml +39 -28
  39. data/tasks/hobo_tasks.rake +1 -1
  40. metadata +45 -61
  41. data/hobo.gemspec +0 -226
  42. data/lib/hobo/dryml.rb +0 -188
  43. data/lib/hobo/dryml/dryml_builder.rb +0 -140
  44. data/lib/hobo/dryml/dryml_doc.rb +0 -159
  45. data/lib/hobo/dryml/dryml_generator.rb +0 -263
  46. data/lib/hobo/dryml/dryml_support_controller.rb +0 -13
  47. data/lib/hobo/dryml/parser.rb +0 -3
  48. data/lib/hobo/dryml/parser/attribute.rb +0 -41
  49. data/lib/hobo/dryml/parser/base_parser.rb +0 -254
  50. data/lib/hobo/dryml/parser/document.rb +0 -57
  51. data/lib/hobo/dryml/parser/element.rb +0 -27
  52. data/lib/hobo/dryml/parser/elements.rb +0 -45
  53. data/lib/hobo/dryml/parser/source.rb +0 -58
  54. data/lib/hobo/dryml/parser/text.rb +0 -13
  55. data/lib/hobo/dryml/parser/tree_parser.rb +0 -67
  56. data/lib/hobo/dryml/part_context.rb +0 -137
  57. data/lib/hobo/dryml/scoped_variables.rb +0 -42
  58. data/lib/hobo/dryml/tag_parameters.rb +0 -36
  59. data/lib/hobo/dryml/taglib.rb +0 -123
  60. data/lib/hobo/dryml/template.rb +0 -1019
  61. data/lib/hobo/dryml/template_environment.rb +0 -613
  62. data/lib/hobo/dryml/template_handler.rb +0 -187
  63. data/lib/hobo/static_tags +0 -98
  64. data/taglibs/core.dryml +0 -104
@@ -1,187 +0,0 @@
1
- module Hobo::Dryml
2
-
3
- class TemplateHandler < ActionView::TemplateHandler
4
-
5
- def compile(*args)
6
- # Ignore - we handle compilation ourselves
7
- end
8
-
9
- # Pre Rails 2.2
10
- def render(template)
11
- renderer = Hobo::Dryml.page_renderer_for_template(@view, template.locals.keys, template)
12
- this = @view.instance_variable_set("@this", @view.controller.send(:dryml_context) || template.locals[:this])
13
- s = renderer.render_page(this, template.locals)
14
- # Important to strip whitespace, or the browser hangs around for ages (FF2)
15
- s.strip
16
- end
17
-
18
- def render_for_rails22(template, view, local_assigns)
19
- renderer = Hobo::Dryml.page_renderer_for_template(view, local_assigns.keys, template)
20
- this = view.controller.send(:dryml_context) || local_assigns[:this]
21
- @view._?.instance_variable_set("@this", this)
22
- s = renderer.render_page(this, local_assigns)
23
-
24
- # Important to strip whitespace, or the browser hangs around for ages (FF2)
25
- s.strip
26
- end
27
-
28
- end
29
-
30
- end
31
-
32
- module ActionController
33
-
34
- class Base
35
-
36
- def dryml_context
37
- @this
38
- end
39
-
40
- def dryml_fallback_tag(tag_name)
41
- @dryml_fallback_tag = tag_name
42
- end
43
-
44
-
45
- def call_dryml_tag(tag, options={})
46
- @template.send(:_evaluate_assigns_and_ivars)
47
-
48
- # TODO: Figure out what this bit is all about :-)
49
- if options[:with]
50
- @this = options[:with] unless options[:field]
51
- else
52
- options[:with] = dryml_context
53
- end
54
-
55
- Hobo::Dryml.render_tag(@template, tag, options)
56
- end
57
-
58
-
59
- # TODO: This is namespace polution, should be called render_dryml_tag
60
- def render_tag(tag, attributes={}, options={})
61
- text = call_dryml_tag(tag, attributes)
62
- text && render({:text => text, :layout => false }.merge(options))
63
- end
64
-
65
- # DRYML fallback tags -- monkey patch this method to attempt to render a tag if there's no template
66
- def render_for_file_with_dryml(template, status = nil, layout = nil, locals = {})
67
- # in rails 2.2, "template" is actually "template_path"
68
-
69
- # if we're passed a MissingTemplateWrapper, see if there's a
70
- # dryml tag that will render the page
71
- if template.respond_to? :original_template_path
72
- # this is the Rails 2.3 path
73
- tag_name = @dryml_fallback_tag || "#{File.basename(template.original_template_path).dasherize}-page"
74
-
75
- text = call_dryml_tag(tag_name)
76
- if text
77
- return render_for_text(text, status)
78
- else
79
- template.raise_wrapped_exception
80
- end
81
- else
82
- begin
83
- result = render_for_file_without_dryml(template, status, layout, locals)
84
- rescue ActionView::MissingTemplate => ex
85
- # this is the Rails 2.2 path
86
- tag_name = @dryml_fallback_tag || "#{File.basename(template).dasherize}-page"
87
-
88
- text = call_dryml_tag(tag_name)
89
- if text
90
- return render_for_text(text, status)
91
- else
92
- raise ex
93
- end
94
- end
95
- end
96
- end
97
- alias_method_chain :render_for_file, :dryml
98
-
99
- end
100
- end
101
-
102
- class ActionView::Template
103
-
104
- def render_with_dryml(view, local_assigns = {})
105
- if handler == Hobo::Dryml::TemplateHandler
106
- render_dryml(view, local_assigns)
107
- else
108
- render_without_dryml(view, local_assigns)
109
- end
110
- end
111
- alias_method_chain :render, :dryml
112
-
113
- # We've had to copy a bunch of logic from Renderable#render, because we need to prevent Rails
114
- # from trying to compile our template. DRYML templates are each compiled as a class, not just a method,
115
- # so the support for compiling templates that Rails provides is innadequate.
116
- def render_dryml(view, local_assigns = {})
117
- if view.instance_variable_defined?(:@_render_stack)
118
- # Rails 2.2
119
- stack = view.instance_variable_get(:@_render_stack)
120
- stack.push(self)
121
-
122
- # This is only used for TestResponse to set rendered_template
123
- unless is_a?(ActionView::InlineTemplate) || view.instance_variable_get(:@_first_render)
124
- view.instance_variable_set(:@_first_render, self)
125
- end
126
-
127
- view.send(:_evaluate_assigns_and_ivars)
128
- view.send(:_set_controller_content_type, mime_type) if respond_to?(:mime_type)
129
-
130
- result = Hobo::Dryml::TemplateHandler.new.render_for_rails22(self, view, local_assigns)
131
-
132
- stack.pop
133
- result
134
- else
135
- # Rails 2.3
136
- compile(local_assigns)
137
-
138
- view.with_template self do
139
- view.send(:_evaluate_assigns_and_ivars)
140
- view.send(:_set_controller_content_type, mime_type) if respond_to?(:mime_type)
141
-
142
- Hobo::Dryml::TemplateHandler.new.render_for_rails22(self, view, local_assigns)
143
- end
144
- end
145
- end
146
-
147
- end
148
-
149
- # this is only used in Rails 2.3
150
- class MissingTemplateWrapper
151
- attr_reader :original_template_path
152
-
153
- def initialize(exception, path)
154
- @exception = exception
155
- @original_template_path = path
156
- end
157
-
158
- def method_missing(*args)
159
- raise @exception
160
- end
161
-
162
- def render
163
- raise @exception
164
- end
165
- end
166
-
167
-
168
- module ActionView
169
- class PathSet < Array
170
- # this is only used by Rails 2.3
171
- def find_template_with_dryml(original_template_path, format = nil, html_fallback = true)
172
- begin
173
- find_template_without_dryml(original_template_path, format, html_fallback)
174
- rescue ActionView::MissingTemplate => ex
175
- # instead of throwing the exception right away, hand back a
176
- # time bomb instead. It'll blow if mishandled...
177
- return MissingTemplateWrapper.new(ex, original_template_path)
178
- end
179
- end
180
-
181
- if method_defined? "find_template"
182
- # only rails 2.3 has this function
183
- alias_method_chain :find_template, :dryml
184
- end
185
- end
186
- end
187
-
@@ -1,98 +0,0 @@
1
- abbr
2
- acronym
3
- address
4
- applet
5
- article
6
- audio
7
- b
8
- basefont
9
- bdo
10
- big
11
- blockquote
12
- body
13
- button
14
- canvas
15
- caption
16
- center
17
- cite
18
- code
19
- colgroup
20
- command
21
- datagrid
22
- datalist
23
- dd
24
- del
25
- details
26
- dfn
27
- dialog
28
- dir
29
- div
30
- dl
31
- dt
32
- em
33
- embed
34
- fieldset
35
- figure
36
- font
37
- frameset
38
- h1
39
- h2
40
- h3
41
- h4
42
- h5
43
- h6
44
- head
45
- hgroup
46
- i
47
- iframe
48
- ins
49
- isindex
50
- kbd
51
- label
52
- legend
53
- li
54
- map
55
- mark
56
- menu
57
- meter
58
- nav
59
- noframes
60
- noscript
61
- object
62
- ol
63
- optgroup
64
- option
65
- output
66
- p
67
- pre
68
- progress
69
- q
70
- rp
71
- rt
72
- ruby
73
- s
74
- samp
75
- script
76
- select
77
- small
78
- source
79
- span
80
- strike
81
- strong
82
- style
83
- sub
84
- sup
85
- tbody
86
- td
87
- textarea
88
- tfoot
89
- th
90
- thead
91
- time
92
- title
93
- tr
94
- tt
95
- u
96
- ul
97
- var
98
- video
@@ -1,104 +0,0 @@
1
- <!-- Core DRYML tags. These are included implicitly and are always available. Contains mainly control-flow tags. -->
2
-
3
- <!-- Call the tag given by the `tag` attribute. This lets you call tags dynamically based on some runtime value.
4
- It's the DRYML equivalent of Ruby's `send` method.
5
- -->
6
- <def tag="call-tag" attrs="tag">
7
- <%= send(tag.gsub('-', '_'), attributes, parameters) %>
8
- </def>
9
-
10
-
11
- <!-- Wrap the body in the tag specified by the `tag` attribute, iff `when` is true.
12
-
13
- Using regular DRYML conditional logic it is rather akward to conditionally wrap some tag in another tag. This tag makes it easy to do that.
14
-
15
- ### Usage
16
-
17
- For example, you might want to wrap an `<img>` tag in an `<a>` tag but only under certain conditions. Say the current context has an `href` attribute that may or may not be nil. We want to wrap the img in `<a>` if `href` is not nil:
18
-
19
- <wrap when="&this.href.present?" tag="a" href="&this.href"><img src="&this.img_filename"/></wrap>
20
- {: .dryml}
21
- -->
22
- <def tag="wrap" attrs="tag, when, parameter">
23
- <% parameter ||= :default %>
24
- <%= when_ ? send(tag, attributes, { parameter.to_sym => parameters[:default] }) : parameters.default %>
25
- </def>
26
-
27
-
28
- <!-- DRYML version of `render(:partial => 'my_partial')`
29
-
30
- ### Usage
31
-
32
- <partial name="my-partial" locals="&{:x => 10, :y => 20}"/>
33
- -->
34
- <def tag="partial" attrs="name, locals"><%=
35
- locals ||= {}
36
- render(:partial => name, :locals => locals.merge(:this => this))
37
- %></def>
38
-
39
-
40
- <!-- Repeat a section of mark-up. The context should be a collection (anything that responds to `each`). The content of the call to `<repeat>` will be repeated for each item in the collection, and the context will be set to each item in turn.
41
-
42
- ### Attributes
43
-
44
- - join: The value of this attribute, if given, will be inserted between each of the items (e.g. `join=", "` is very common).
45
- -->
46
- <def tag="repeat" attrs="join"><if><%=
47
- raise ArgumentError, "Cannot <repeat> on #{this.inspect}" unless this.respond_to? :each
48
- context_map do
49
- parameters.default
50
- end.join(join)
51
- %></if></def>
52
-
53
-
54
- <!-- The 'do nothing' tag. Used to add parameters or change context without adding any markup -->
55
- <def tag="do"><%= parameters.default %></def>
56
-
57
- <!-- Alias of `do` -->
58
- <def tag="with" alias-of="do"/>
59
-
60
- <!-- DRYML's 'if' test
61
-
62
- ### Usage
63
-
64
- <if test="&current_user.administrtator?">Logged in as administrator</if>
65
- <else>Logged in as normal user</else>
66
-
67
- **IMPORTANT NOTE**: `<if>` tests for non-blank vs. blank (as defined by ActiveSuport), not true vs. false.
68
-
69
- If you do not give the `test` attribute, uses the current context instead. This allows a nice trick like this:
70
-
71
- <if:comments>...</if>
72
-
73
- This has the double effect of changing the context to the `this.comments`, and only evaluating the body if there are comments (because an empty
74
- collection is considered blank)
75
- -->
76
- <def tag="if" attrs="test"><%=
77
- test = all_attributes.fetch(:test, this)
78
- res = (cond = !test.blank?) ? parameters.default : ""
79
- Hobo::Dryml.last_if = cond
80
- res
81
- %></def>
82
-
83
- <!-- General purpose `else` clause.
84
-
85
- `<else>` works with various tags such as `<if>` and `<repeat>` (the else clause will be output if the collection was empty). It simply outputs its content if `Hobo::Dryml.last_if` is false. This is pretty much a crazy hack which violates many good principles of language design, but it's very useful : )
86
- -->
87
- <def tag="else"><%= parameters.default unless Hobo::Dryml.last_if %></def>
88
-
89
-
90
- <!-- Same behaviour as `<if>`, except the test is negated. -->
91
- <def tag="unless" attrs="test"><%=
92
- test = all_attributes.fetch(:test, this)
93
- res = (cond = test.blank?) ? parameters.default : ""
94
- Hobo::Dryml.last_if = cond
95
- res
96
- %></def>
97
-
98
-
99
- <!-- nodoc. -->
100
- <def tag="fake-field-context" attrs="fake-field, context"><%=
101
- res = ""
102
- new_field_context(fake_field, context) { res << parameters.default }
103
- res
104
- %></def>