hobo 0.7.5 → 0.8

Sign up to get free protection for your applications and to get access to all the features.
Files changed (212) hide show
  1. data/{hobo_files/plugin/CHANGES.txt → CHANGES.txt} +391 -0
  2. data/Manifest +146 -0
  3. data/{hobo_files/plugin/README → README} +0 -0
  4. data/bin/hobo +13 -26
  5. data/dryml_generators/rapid/cards.dryml.erb +55 -0
  6. data/dryml_generators/rapid/forms.dryml.erb +43 -0
  7. data/dryml_generators/rapid/pages.dryml.erb +284 -0
  8. data/hobo.gemspec +168 -0
  9. data/init.rb +9 -0
  10. data/lib/action_view_extensions/helpers/tag_helper.rb +7 -0
  11. data/lib/active_record/association_collection.rb +54 -0
  12. data/{hobo_files/plugin/lib → lib}/active_record/association_proxy.rb +12 -4
  13. data/{hobo_files/plugin/lib → lib}/active_record/association_reflection.rb +7 -1
  14. data/{hobo_files/plugin/lib → lib}/extensions/test_case.rb +17 -17
  15. data/{hobo_files/plugin/lib → lib}/hobo.rb +193 -100
  16. data/{hobo_files/plugin/lib → lib}/hobo/authentication_support.rb +8 -8
  17. data/{hobo_files/plugin/lib → lib}/hobo/bundle.rb +90 -89
  18. data/{hobo_files/plugin/lib → lib}/hobo/composite_model.rb +21 -21
  19. data/{hobo_files/plugin/lib → lib}/hobo/controller.rb +38 -25
  20. data/{hobo_files/plugin/lib → lib}/hobo/dev_controller.rb +10 -6
  21. data/lib/hobo/dryml.rb +167 -0
  22. data/{hobo_files/plugin/lib → lib}/hobo/dryml/dryml_builder.rb +28 -25
  23. data/lib/hobo/dryml/dryml_generator.rb +210 -0
  24. data/{hobo_files/plugin/lib → lib}/hobo/dryml/dryml_support_controller.rb +1 -1
  25. data/lib/hobo/dryml/parser.rb +3 -0
  26. data/{hobo_files/plugin/lib → lib}/hobo/dryml/parser/attribute.rb +6 -6
  27. data/{hobo_files/plugin/lib → lib}/hobo/dryml/parser/base_parser.rb +16 -16
  28. data/lib/hobo/dryml/parser/document.rb +57 -0
  29. data/{hobo_files/plugin/lib → lib}/hobo/dryml/parser/element.rb +7 -7
  30. data/{hobo_files/plugin/lib → lib}/hobo/dryml/parser/elements.rb +9 -9
  31. data/{hobo_files/plugin/lib → lib}/hobo/dryml/parser/source.rb +3 -3
  32. data/{hobo_files/plugin/lib → lib}/hobo/dryml/parser/text.rb +3 -3
  33. data/{hobo_files/plugin/lib → lib}/hobo/dryml/parser/tree_parser.rb +3 -3
  34. data/{hobo_files/plugin/lib → lib}/hobo/dryml/part_context.rb +26 -26
  35. data/{hobo_files/plugin/lib → lib}/hobo/dryml/scoped_variables.rb +15 -15
  36. data/{hobo_files/plugin/lib → lib}/hobo/dryml/tag_parameters.rb +10 -10
  37. data/{hobo_files/plugin/lib → lib}/hobo/dryml/taglib.rb +43 -37
  38. data/{hobo_files/plugin/lib → lib}/hobo/dryml/template.rb +290 -208
  39. data/{hobo_files/plugin/lib → lib}/hobo/dryml/template_environment.rb +173 -115
  40. data/{hobo_files/plugin/lib → lib}/hobo/dryml/template_handler.rb +19 -24
  41. data/lib/hobo/find_for.rb +95 -0
  42. data/{hobo_files/plugin/lib → lib}/hobo/generator.rb +2 -1
  43. data/{hobo_files/plugin/lib → lib}/hobo/guest.rb +12 -4
  44. data/{hobo_files/plugin/lib → lib}/hobo/hobo_helper.rb +146 -117
  45. data/lib/hobo/include_in_save.rb +43 -0
  46. data/lib/hobo/lifecycles.rb +94 -0
  47. data/lib/hobo/lifecycles/actions.rb +73 -0
  48. data/lib/hobo/lifecycles/creator.rb +76 -0
  49. data/lib/hobo/lifecycles/lifecycle.rb +205 -0
  50. data/lib/hobo/lifecycles/state.rb +23 -0
  51. data/lib/hobo/lifecycles/transition.rb +66 -0
  52. data/{hobo_files/plugin/lib → lib}/hobo/model.rb +306 -217
  53. data/{hobo_files/plugin/lib → lib}/hobo/model_controller.rb +342 -213
  54. data/{hobo_files/plugin/lib → lib}/hobo/model_router.rb +151 -120
  55. data/{hobo_files/plugin/lib → lib}/hobo/model_support.rb +9 -9
  56. data/{hobo_files/plugin/lib → lib}/hobo/rapid_helper.rb +30 -23
  57. data/{hobo_files/plugin/lib → lib}/hobo/scopes.rb +22 -68
  58. data/{hobo_files/plugin/lib → lib}/hobo/scopes/apply_scopes.rb +5 -5
  59. data/lib/hobo/scopes/association_proxy_extensions.rb +47 -0
  60. data/{hobo_files/plugin/lib → lib}/hobo/scopes/automatic_scopes.rb +104 -79
  61. data/lib/hobo/scopes/named_scope_extensions.rb +27 -0
  62. data/{hobo_files/plugin/lib → lib}/hobo/static_tags +1 -11
  63. data/{hobo_files/plugin/lib → lib}/hobo/undefined.rb +1 -1
  64. data/{hobo_files/plugin/lib → lib}/hobo/undefined_access_error.rb +0 -0
  65. data/{hobo_files/plugin/lib → lib}/hobo/user.rb +27 -25
  66. data/{hobo_files/plugin/lib → lib}/hobo/user_controller.rb +80 -34
  67. data/{hobo_files/plugin/generators → rails_generators}/hobo/hobo_generator.rb +7 -7
  68. data/rails_generators/hobo/templates/application.css +0 -0
  69. data/{hobo_files/plugin/generators → rails_generators}/hobo/templates/application.dryml +0 -2
  70. data/{hobo_files/plugin/generators → rails_generators}/hobo/templates/dryml-support.js +0 -0
  71. data/{hobo_files/plugin/generators → rails_generators}/hobo/templates/guest.rb +0 -0
  72. data/rails_generators/hobo/templates/initializer.rb +9 -0
  73. data/{hobo_files/plugin/generators → rails_generators}/hobo_front_controller/USAGE +0 -0
  74. data/{hobo_files/plugin/generators → rails_generators}/hobo_front_controller/hobo_front_controller_generator.rb +1 -3
  75. data/{hobo_files/plugin/generators → rails_generators}/hobo_front_controller/templates/controller.rb +1 -1
  76. data/{hobo_files/plugin/generators → rails_generators}/hobo_front_controller/templates/functional_test.rb +0 -0
  77. data/{hobo_files/plugin/generators → rails_generators}/hobo_front_controller/templates/helper.rb +0 -0
  78. data/rails_generators/hobo_front_controller/templates/index.dryml +25 -0
  79. data/{hobo_files/plugin/generators → rails_generators}/hobo_model/USAGE +0 -0
  80. data/{hobo_files/plugin/generators → rails_generators}/hobo_model/hobo_model_generator.rb +0 -0
  81. data/{hobo_files/plugin/generators → rails_generators}/hobo_model/templates/fixtures.yml +0 -0
  82. data/{hobo_files/plugin/generators → rails_generators}/hobo_model/templates/model.rb +0 -0
  83. data/{hobo_files/plugin/generators → rails_generators}/hobo_model/templates/unit_test.rb +0 -0
  84. data/{hobo_files/plugin/generators → rails_generators}/hobo_model_controller/USAGE +0 -0
  85. data/{hobo_files/plugin/generators → rails_generators}/hobo_model_controller/hobo_model_controller_generator.rb +0 -7
  86. data/{hobo_files/plugin/generators → rails_generators}/hobo_model_controller/templates/controller.rb +0 -0
  87. data/{hobo_files/plugin/generators → rails_generators}/hobo_model_controller/templates/functional_test.rb +0 -0
  88. data/{hobo_files/plugin/generators → rails_generators}/hobo_model_controller/templates/helper.rb +0 -0
  89. data/{hobo_files/plugin/generators → rails_generators}/hobo_model_resource/hobo_model_resource_generator.rb +0 -0
  90. data/{hobo_files/plugin/generators → rails_generators}/hobo_model_resource/templates/controller.rb +0 -0
  91. data/{hobo_files/plugin/generators → rails_generators}/hobo_model_resource/templates/functional_test.rb +0 -0
  92. data/{hobo_files/plugin/generators → rails_generators}/hobo_model_resource/templates/helper.rb +0 -0
  93. data/{hobo_files/plugin/generators → rails_generators}/hobo_rapid/hobo_rapid_generator.rb +21 -11
  94. data/{hobo_files/plugin/generators → rails_generators}/hobo_rapid/templates/IE7.js +1 -1
  95. data/rails_generators/hobo_rapid/templates/blank.gif +0 -0
  96. data/{hobo_files/plugin/generators → rails_generators}/hobo_rapid/templates/hobo-rapid.css +0 -0
  97. data/{hobo_files/plugin/generators → rails_generators}/hobo_rapid/templates/hobo-rapid.js +175 -104
  98. data/{hobo_files/plugin/generators → rails_generators}/hobo_rapid/templates/lowpro.js +0 -0
  99. data/rails_generators/hobo_rapid/templates/nicEditorIcons.gif +0 -0
  100. data/rails_generators/hobo_rapid/templates/nicedit.js +91 -0
  101. data/{hobo_files/plugin/generators → rails_generators}/hobo_rapid/templates/reset.css +0 -0
  102. data/{hobo_files/plugin/generators → rails_generators}/hobo_rapid/templates/themes/clean/public/images/fieldbg.gif +0 -0
  103. data/{hobo_files/plugin/generators → rails_generators}/hobo_rapid/templates/themes/clean/public/images/pencil.png +0 -0
  104. data/{hobo_files/plugin/generators → rails_generators}/hobo_rapid/templates/themes/clean/public/images/small_close.png +0 -0
  105. data/{hobo_files/plugin/generators → rails_generators}/hobo_rapid/templates/themes/clean/public/images/spinner.gif +0 -0
  106. data/{hobo_files/plugin/generators → rails_generators}/hobo_rapid/templates/themes/clean/public/stylesheets/clean.css +80 -71
  107. data/{hobo_files/plugin/generators → rails_generators}/hobo_rapid/templates/themes/clean/public/stylesheets/rapid-ui.css +6 -1
  108. data/{hobo_files/plugin/generators → rails_generators}/hobo_rapid/templates/themes/clean/views/clean.dryml +4 -4
  109. data/rails_generators/hobo_subsite/hobo_subsite_generator.rb +73 -0
  110. data/rails_generators/hobo_subsite/templates/application.dryml +1 -0
  111. data/rails_generators/hobo_subsite/templates/controller.rb +5 -0
  112. data/rails_generators/hobo_subsite/templates/site_taglib.dryml +13 -0
  113. data/{hobo_files/plugin/generators → rails_generators}/hobo_user_controller/USAGE +0 -0
  114. data/{hobo_files/plugin/generators → rails_generators}/hobo_user_controller/hobo_user_controller_generator.rb +0 -0
  115. data/{hobo_files/plugin/generators → rails_generators}/hobo_user_controller/templates/controller.rb +0 -0
  116. data/{hobo_files/plugin/generators → rails_generators}/hobo_user_controller/templates/functional_test.rb +0 -0
  117. data/{hobo_files/plugin/generators → rails_generators}/hobo_user_controller/templates/helper.rb +0 -0
  118. data/{hobo_files/plugin/generators → rails_generators}/hobo_user_model/USAGE +0 -0
  119. data/rails_generators/hobo_user_model/hobo_user_model_generator.rb +30 -0
  120. data/{hobo_files/plugin/generators → rails_generators}/hobo_user_model/templates/fixtures.yml +0 -0
  121. data/rails_generators/hobo_user_model/templates/forgot_password.erb +10 -0
  122. data/rails_generators/hobo_user_model/templates/mailer.rb +14 -0
  123. data/rails_generators/hobo_user_model/templates/model.rb +55 -0
  124. data/{hobo_files/plugin/generators → rails_generators}/hobo_user_model/templates/unit_test.rb +0 -0
  125. data/script/destroy +14 -0
  126. data/script/generate +14 -0
  127. data/{hobo_files/plugin/taglibs → taglibs}/core.dryml +6 -7
  128. data/{hobo_files/plugin/taglibs → taglibs}/rapid.dryml +36 -67
  129. data/{hobo_files/plugin/taglibs → taglibs}/rapid_document_tags.dryml +7 -24
  130. data/{hobo_files/plugin/taglibs → taglibs}/rapid_editing.dryml +51 -50
  131. data/{hobo_files/plugin/taglibs → taglibs}/rapid_forms.dryml +62 -56
  132. data/taglibs/rapid_generics.dryml +33 -0
  133. data/taglibs/rapid_lifecycles.dryml +43 -0
  134. data/{hobo_files/plugin/taglibs → taglibs}/rapid_navigation.dryml +23 -23
  135. data/taglibs/rapid_pages.dryml +183 -0
  136. data/{hobo_files/plugin/taglibs → taglibs}/rapid_plus.dryml +30 -5
  137. data/{hobo_files/plugin/taglibs → taglibs}/rapid_support.dryml +3 -4
  138. data/taglibs/rapid_user_pages.dryml +179 -0
  139. data/{hobo_files/plugin/tasks → tasks}/environments.rake +0 -0
  140. data/{hobo_files/plugin/tasks → tasks}/fix_dryml.rake +0 -0
  141. data/{hobo_files/plugin/tasks → tasks}/generate_tag_reference.rb +21 -22
  142. data/tasks/hobo_tasks.rake +32 -0
  143. data/test/test_generator_helper.rb +29 -0
  144. data/test/test_helper.rb +1 -0
  145. data/test/test_hobo_model_controller_generator.rb +56 -0
  146. data/{hobo_files/plugin/uninstall.rb → uninstall.rb} +0 -0
  147. metadata +240 -225
  148. data/README.txt +0 -18
  149. data/hobo_files/plugin/LICENSE.txt +0 -22
  150. data/hobo_files/plugin/Rakefile +0 -96
  151. data/hobo_files/plugin/generators/hobo_front_controller/templates/index.dryml +0 -24
  152. data/hobo_files/plugin/generators/hobo_front_controller/templates/search.dryml +0 -19
  153. data/hobo_files/plugin/generators/hobo_rapid/templates/themes/default/public/images/banner.gif +0 -0
  154. data/hobo_files/plugin/generators/hobo_rapid/templates/themes/default/public/images/bkg-bodytop.gif +0 -0
  155. data/hobo_files/plugin/generators/hobo_rapid/templates/themes/default/public/images/bkg-corner-01.gif +0 -0
  156. data/hobo_files/plugin/generators/hobo_rapid/templates/themes/default/public/images/bkg-corner-02.gif +0 -0
  157. data/hobo_files/plugin/generators/hobo_rapid/templates/themes/default/public/images/bkg-corner-03.gif +0 -0
  158. data/hobo_files/plugin/generators/hobo_rapid/templates/themes/default/public/images/bkg-corner-04.gif +0 -0
  159. data/hobo_files/plugin/generators/hobo_rapid/templates/themes/default/public/images/bkg-shadow-bottom.gif +0 -0
  160. data/hobo_files/plugin/generators/hobo_rapid/templates/themes/default/public/images/bkg-shadow-left.gif +0 -0
  161. data/hobo_files/plugin/generators/hobo_rapid/templates/themes/default/public/images/bkg-shadow-right.gif +0 -0
  162. data/hobo_files/plugin/generators/hobo_rapid/templates/themes/default/public/images/bkg-shadow-top.gif +0 -0
  163. data/hobo_files/plugin/generators/hobo_rapid/templates/themes/default/public/images/header-blue.gif +0 -0
  164. data/hobo_files/plugin/generators/hobo_rapid/templates/themes/default/public/images/header-dblue.gif +0 -0
  165. data/hobo_files/plugin/generators/hobo_rapid/templates/themes/default/public/images/header-green.gif +0 -0
  166. data/hobo_files/plugin/generators/hobo_rapid/templates/themes/default/public/images/header-purple.gif +0 -0
  167. data/hobo_files/plugin/generators/hobo_rapid/templates/themes/default/public/images/header-red.gif +0 -0
  168. data/hobo_files/plugin/generators/hobo_rapid/templates/themes/default/public/images/logo.gif +0 -0
  169. data/hobo_files/plugin/generators/hobo_rapid/templates/themes/default/public/images/plus.png +0 -0
  170. data/hobo_files/plugin/generators/hobo_rapid/templates/themes/default/public/images/spinner.gif +0 -0
  171. data/hobo_files/plugin/generators/hobo_rapid/templates/themes/default/public/images/txt-list-img-dblue.gif +0 -0
  172. data/hobo_files/plugin/generators/hobo_rapid/templates/themes/default/public/images/txt-list-img-green.gif +0 -0
  173. data/hobo_files/plugin/generators/hobo_rapid/templates/themes/default/public/images/txt-list-img-purple.gif +0 -0
  174. data/hobo_files/plugin/generators/hobo_rapid/templates/themes/default/public/images/txt-list-img-red.gif +0 -0
  175. data/hobo_files/plugin/generators/hobo_rapid/templates/themes/default/public/images/window-corner-01.gif +0 -0
  176. data/hobo_files/plugin/generators/hobo_rapid/templates/themes/default/public/images/window-corner-02.gif +0 -0
  177. data/hobo_files/plugin/generators/hobo_rapid/templates/themes/default/public/images/window-corner-03.gif +0 -0
  178. data/hobo_files/plugin/generators/hobo_rapid/templates/themes/default/public/images/window-corner-04.gif +0 -0
  179. data/hobo_files/plugin/generators/hobo_rapid/templates/themes/default/public/images/window-shadow-bottom.gif +0 -0
  180. data/hobo_files/plugin/generators/hobo_rapid/templates/themes/default/public/images/window-shadow-left.gif +0 -0
  181. data/hobo_files/plugin/generators/hobo_rapid/templates/themes/default/public/images/window-shadow-right.gif +0 -0
  182. data/hobo_files/plugin/generators/hobo_rapid/templates/themes/default/public/images/window-shadow-top.gif +0 -0
  183. data/hobo_files/plugin/generators/hobo_rapid/templates/themes/default/public/stylesheets/application.css +0 -400
  184. data/hobo_files/plugin/generators/hobo_rapid/templates/themes/default/views/application.dryml +0 -96
  185. data/hobo_files/plugin/generators/hobo_user_model/hobo_user_model_generator.rb +0 -25
  186. data/hobo_files/plugin/generators/hobo_user_model/templates/model.rb +0 -56
  187. data/hobo_files/plugin/init.rb +0 -101
  188. data/hobo_files/plugin/lib/action_view_extensions/base.rb +0 -15
  189. data/hobo_files/plugin/lib/active_record/has_many_association.rb +0 -55
  190. data/hobo_files/plugin/lib/active_record/has_many_through_association.rb +0 -20
  191. data/hobo_files/plugin/lib/hobo/dryml.rb +0 -165
  192. data/hobo_files/plugin/lib/hobo/dryml/parser/document.rb +0 -53
  193. data/hobo_files/plugin/lib/hobo/scopes/association_proxy_extensions.rb +0 -33
  194. data/hobo_files/plugin/lib/hobo/scopes/defined_scope_proxy_extender.rb +0 -90
  195. data/hobo_files/plugin/lib/hobo/scopes/scope_reflection.rb +0 -18
  196. data/hobo_files/plugin/lib/hobo/scopes/scoped_proxy.rb +0 -55
  197. data/hobo_files/plugin/taglib-docs/core.markdown +0 -165
  198. data/hobo_files/plugin/taglib-docs/rapid.markdown +0 -677
  199. data/hobo_files/plugin/taglib-docs/rapid_document_tags.markdown +0 -240
  200. data/hobo_files/plugin/taglib-docs/rapid_editing.markdown +0 -418
  201. data/hobo_files/plugin/taglib-docs/rapid_forms.markdown +0 -562
  202. data/hobo_files/plugin/taglib-docs/rapid_generics.markdown +0 -187
  203. data/hobo_files/plugin/taglib-docs/rapid_navigation.markdown +0 -214
  204. data/hobo_files/plugin/taglib-docs/rapid_pages.markdown +0 -530
  205. data/hobo_files/plugin/taglib-docs/rapid_plus.markdown +0 -65
  206. data/hobo_files/plugin/taglib-docs/rapid_support.markdown +0 -50
  207. data/hobo_files/plugin/taglib-docs/rapid_user_pages.markdown +0 -129
  208. data/hobo_files/plugin/taglibs/rapid_generics.dryml +0 -117
  209. data/hobo_files/plugin/taglibs/rapid_pages.dryml +0 -359
  210. data/hobo_files/plugin/taglibs/rapid_user_pages.dryml +0 -104
  211. data/hobo_files/plugin/tasks/dump_fixtures.rake +0 -70
  212. data/hobo_files/plugin/tasks/hobo_tasks.rake +0 -17
@@ -3,15 +3,15 @@ module Hobo
3
3
  module Controller
4
4
 
5
5
  include AuthenticationSupport
6
-
6
+
7
7
  class << self
8
-
8
+
9
9
  def included(base)
10
10
  if base.is_a?(Class)
11
11
  included_in_class(base)
12
12
  end
13
13
  end
14
-
14
+
15
15
  def included_in_class(klass)
16
16
  klass.extend(ClassMethods)
17
17
  klass.class_eval do
@@ -20,11 +20,13 @@ module Hobo
20
20
  end
21
21
  Hobo::HoboHelper.add_to_controller(klass)
22
22
  end
23
-
23
+
24
+ attr_accessor :request_host, :app_name
25
+
24
26
  def controller_and_view_for(page_path)
25
27
  page_path.match(/(.*)\/([^\/]+)/)[1..2]
26
28
  end
27
-
29
+
28
30
  end
29
31
 
30
32
  module ClassMethods
@@ -34,12 +36,12 @@ module Hobo
34
36
  def include_taglib(src, options={})
35
37
  @included_taglibs << options.merge(:src => src)
36
38
  end
37
-
39
+
38
40
  end
39
41
 
40
-
42
+
41
43
  protected
42
-
44
+
43
45
  def redirect_to_with_object_url(destination, *args)
44
46
  if destination.is_a?(String, Hash, Symbol)
45
47
  redirect_to_without_object_url(destination)
@@ -48,7 +50,7 @@ module Hobo
48
50
  end
49
51
  end
50
52
 
51
-
53
+
52
54
  def hobo_ajax_response(*args)
53
55
  results = args.extract_options!
54
56
  this = args.first || @this
@@ -72,7 +74,7 @@ module Hobo
72
74
  for spec in render_specs
73
75
  function = spec[:function] || "_update"
74
76
  dom_id = spec[:id]
75
-
77
+
76
78
  if spec[:part_context]
77
79
  part_name, part_this, locals = Dryml::PartContext.unmarshal(spec[:part_context], this, session)
78
80
  part_content = renderer.call_part(dom_id, part_name, part_this, *locals)
@@ -87,8 +89,8 @@ module Hobo
87
89
  page << renderer.part_contexts_storage if renderer
88
90
  end
89
91
  end
90
-
91
-
92
+
93
+
92
94
  def dryml_context
93
95
  @this
94
96
  end
@@ -96,17 +98,28 @@ module Hobo
96
98
 
97
99
  def render_tags(objects, tag, options={})
98
100
  for_type = options.delete(:for_type)
99
- add_variables_to_assigns
100
- dryml_renderer = Hobo::Dryml.empty_page_renderer(@template)
101
-
102
- results = objects.map do |o|
103
- tag = dryml_renderer.find_polymorphic_tag(tag, o.class) if for_type
104
- dryml_renderer.send(tag, options.merge(:with => o))
101
+
102
+ results = objects.map do |o|
103
+ tag = tag_renderer.find_polymorphic_tag(tag, o.class) if for_type
104
+ tag_renderer.send(tag, options.merge(:with => o))
105
105
  end.join
106
-
107
- render :text => results + dryml_renderer.part_contexts_storage
108
- end
109
106
 
107
+ render :text => results + tag_renderer.part_contexts_storage
108
+ end
109
+
110
+
111
+ def tag_renderer
112
+ @tag_renderer ||= begin
113
+ add_variables_to_assigns
114
+ Hobo::Dryml.empty_page_renderer(@template)
115
+ end
116
+ end
117
+
118
+
119
+ def call_tag(name, options={})
120
+ tag_renderer.send(name, options)
121
+ end
122
+
110
123
 
111
124
  def site_search(query)
112
125
  results = Hobo.find_by_search(query).select{|r| Hobo.can_view?(current_user, r, nil)}
@@ -129,9 +142,9 @@ module Hobo
129
142
  def request_no_cache?
130
143
  request.env['HTTP_CACHE_CONTROL'] =~ /max-age=\s*0/
131
144
  end
132
-
145
+
133
146
  def not_found
134
-
147
+
135
148
  end
136
149
 
137
150
  end
@@ -139,9 +152,9 @@ end
139
152
 
140
153
 
141
154
  class ActionController::Base
142
-
155
+
143
156
  def home_page
144
157
  ""
145
158
  end
146
-
159
+
147
160
  end
@@ -1,21 +1,25 @@
1
1
  class Hobo::DevController < ActionController::Base
2
-
2
+
3
3
  hobo_controller
4
-
4
+
5
5
  before_filter :developer_modes_only
6
6
 
7
7
  def set_current_user
8
8
  model = params[:model] || Hobo::User.default_user_model
9
- self.current_user = params[:name] ? model[params[:name]] : model.find(params[:id])
9
+ self.current_user = if params[:login]
10
+ model.find(:first, :conditions => {model.login_attribute => params[:login]})
11
+ else
12
+ model.find(params[:id])
13
+ end
10
14
  redirect_to(request.env["HTTP_REFERER"] ? :back : home_page)
11
15
  end
12
-
16
+
13
17
  private
14
-
18
+
15
19
  def developer_modes_only
16
20
  # Belt and braces. In addition to this check, the routes only get
17
21
  # defined when developer_features? is true
18
22
  render :text => "Permission Denied", :status => 403 unless Hobo.developer_features?
19
23
  end
20
-
24
+
21
25
  end
@@ -0,0 +1,167 @@
1
+ module Hobo
2
+
3
+ module Dryml
4
+
5
+ class DrymlSyntaxError < RuntimeError; end
6
+
7
+ class DrymlException < Exception
8
+ def initialize(message, path=nil, line_num=nil)
9
+ if path && line_num
10
+ super(message + " -- at #{path}:#{line_num}")
11
+ else
12
+ super(message)
13
+ end
14
+ end
15
+ end
16
+
17
+ TagDef = Struct.new "TagDef", :name, :attrs, :proc
18
+
19
+ RESERVED_WORDS = %w{if for while do class else elsif unless case when module in}
20
+
21
+ EMPTY_PAGE = "[tag-page]"
22
+
23
+ APPLICATION_TAGLIB = { :src => "taglibs/application" }
24
+ CORE_TAGLIB = { :src => "core", :plugin => "hobo" }
25
+
26
+ DEFAULT_IMPORTS = (if defined?(ApplicationHelper)
27
+ [Hobo::HoboHelper, ApplicationHelper]
28
+ else
29
+ [Hobo::HoboHelper]
30
+ end)
31
+
32
+ @renderer_classes = {}
33
+ @tag_page_renderer_classes = {}
34
+
35
+ extend self
36
+
37
+ attr_accessor :last_if
38
+
39
+ def enable
40
+ ActionView::Template.register_template_handler("dryml", Hobo::Dryml::TemplateHandler)
41
+ end
42
+
43
+
44
+ def clear_cache
45
+ @renderer_classes = {}
46
+ @tag_page_renderer_classes = {}
47
+ end
48
+
49
+ def render_tag(view, tag, options={})
50
+ renderer = empty_page_renderer(view)
51
+ renderer.render_tag(tag, options)
52
+ end
53
+
54
+
55
+ def empty_page_renderer(view)
56
+ controller_name = view.controller.class.name.underscore.sub(/_controller$/, "")
57
+ page_renderer(view, [], "#{controller_name}/#{EMPTY_PAGE}")
58
+ end
59
+
60
+
61
+ def page_renderer_for_template(view, template)
62
+ page_renderer(view, template.locals.keys, template.path_without_extension)
63
+ end
64
+
65
+
66
+ def page_renderer(view, local_names=[], page=nil)
67
+ if RAILS_ENV == "development"
68
+ clear_cache
69
+ Taglib.clear_cache
70
+ end
71
+
72
+ prepare_view!(view)
73
+ included_taglibs = ([subsite_taglib(page)] + controller_taglibs(view.controller.class)).compact
74
+
75
+ if page.ends_with?(EMPTY_PAGE)
76
+ # DELETE ME: controller_class = controller_class_for(page)
77
+ controller_class = view.controller.class
78
+ @tag_page_renderer_classes[controller_class.name] ||=
79
+ make_renderer_class("", page, local_names, DEFAULT_IMPORTS, included_taglibs)
80
+ @tag_page_renderer_classes[controller_class.name].new(page, view)
81
+ else
82
+ template_path = "app/views/" + page + ".dryml"
83
+ src_file = File.join(RAILS_ROOT, template_path)
84
+ mtime = File.mtime(src_file)
85
+ renderer_class = @renderer_classes[page]
86
+
87
+ # do we need to recompile?
88
+ if (!renderer_class or # nothing cached?
89
+ (local_names - renderer_class.compiled_local_names).any? or # any new local names?
90
+ renderer_class.load_time < mtime) # cache out of date?
91
+ renderer_class = make_renderer_class(File.read(src_file), template_path, local_names,
92
+ DEFAULT_IMPORTS, included_taglibs)
93
+ renderer_class.load_time = mtime
94
+ @renderer_classes[page] = renderer_class
95
+ end
96
+ renderer_class.new(page, view)
97
+ end
98
+ end
99
+
100
+
101
+ # TODO: Delete this - not needed (use view.controller.class)
102
+ def controller_class_for(page)
103
+ controller, view = Controller.controller_and_view_for(page)
104
+ "#{controller.camelize}Controller".constantize
105
+ end
106
+
107
+
108
+ def controller_taglibs(controller_class)
109
+ (controller_class.respond_to?(:included_taglibs) && controller_class.included_taglibs) || []
110
+ end
111
+
112
+
113
+ def subsite_taglib(page)
114
+ parts = page.split("/")
115
+ subsite = parts.length >= 3 ? parts[0..-3].join('_') : "front"
116
+ src = "taglibs/#{subsite}_site"
117
+ { :src => src } if File.exists?("#{RAILS_ROOT}/app/views/#{src}.dryml")
118
+ end
119
+
120
+
121
+ def prepare_view!(view)
122
+ # Not sure why this isn't done for me...
123
+ # There's probably a button to press round here somewhere
124
+ for var in %w(@flash @cookies @action_name @_session @_request @request_origin
125
+ @template @request @ignore_missing_templates @_headers @variables_added
126
+ @_flash @response @template_class
127
+ @_cookies @before_filter_chain_aborted @url
128
+ @_response @template_root @headers @_params @params @session)
129
+ unless @view.instance_variables.include?(var)
130
+ view.instance_variable_set(var, view.controller.instance_variable_get(var))
131
+ end
132
+ end
133
+ end
134
+
135
+
136
+ def make_renderer_class(template_src, template_path, locals, imports, included_taglibs=[])
137
+ renderer_class = Class.new(TemplateEnvironment)
138
+ compile_renderer_class(renderer_class, template_src, template_path, locals, imports, included_taglibs)
139
+ renderer_class
140
+ end
141
+
142
+
143
+ def compile_renderer_class(renderer_class, template_src, template_path, locals, imports, included_taglibs=[])
144
+ template = Dryml::Template.new(template_src, renderer_class, template_path)
145
+ imports.each {|m| template.import_module(m)}
146
+
147
+ taglibs = [CORE_TAGLIB, APPLICATION_TAGLIB] + included_taglibs
148
+
149
+ # the sum of all the names we've seen so far - eventually we'll be ready for all of 'em
150
+ all_local_names = renderer_class.compiled_local_names | locals
151
+
152
+ template.compile(all_local_names, taglibs)
153
+ end
154
+
155
+
156
+ def unreserve(word)
157
+ word = word.to_s
158
+ if RESERVED_WORDS.include?(word)
159
+ word + "_"
160
+ else
161
+ word
162
+ end
163
+ end
164
+
165
+ end
166
+
167
+ end
@@ -1,15 +1,15 @@
1
1
  module Hobo::Dryml
2
-
2
+
3
3
  class DRYMLBuilder
4
4
 
5
5
  def initialize(template)
6
6
  @template = template
7
- @build_instructions = Array.new
7
+ @build_instructions = nil # set to [] on the first add_build_instruction
8
8
  @part_names = []
9
9
  end
10
-
10
+
11
11
  attr_reader :template
12
-
12
+
13
13
  def template_path
14
14
  template.template_path
15
15
  end
@@ -20,22 +20,22 @@ module Hobo::Dryml
20
20
  end
21
21
 
22
22
 
23
- def ready?(mtime)
24
- !@build_instructions.empty? && @last_build_mtime && @last_build_mtime >= mtime
23
+ def ready?(mtime, d=false)
24
+ @build_instructions && @last_build_mtime && @last_build_mtime >= mtime
25
25
  end
26
26
 
27
27
 
28
- def clear_instructions
28
+ def start
29
29
  @part_names.clear
30
- @build_instructions.clear
30
+ @build_instructions = []
31
31
  end
32
32
 
33
33
 
34
34
  def add_build_instruction(type, params)
35
35
  @build_instructions << params.merge(:type => type)
36
36
  end
37
-
38
-
37
+
38
+
39
39
  def add_part(name, src, line_num)
40
40
  raise DrymlException.new("duplicate part: #{name}", template_path, line_num) if name.in?(@part_names)
41
41
  add_build_instruction(:def, :src => src, :line_num => line_num)
@@ -56,8 +56,8 @@ module Hobo::Dryml
56
56
  src +
57
57
  "; _erbout; end; end")
58
58
  end
59
-
60
-
59
+
60
+
61
61
  def erb_process(erb_src)
62
62
  # Strip off "_erbout = ''" from the beginning and "; _erbout"
63
63
  # from the end, because we do things differently around
@@ -69,39 +69,42 @@ module Hobo::Dryml
69
69
  def build(local_names, auto_taglibs, src_mtime)
70
70
 
71
71
  auto_taglibs.each { |t| import_taglib(t) }
72
-
73
- @build_instructions.each do |instruction|
72
+
73
+ @build_instructions._?.each do |instruction|
74
74
  name = instruction[:name]
75
75
  case instruction[:type]
76
+ when :eval
77
+ @environment.class_eval(instruction[:src], template_path, instruction[:line_num])
78
+
76
79
  when :def
77
80
  src = erb_process(instruction[:src])
78
81
  @environment.class_eval(src, template_path, instruction[:line_num])
79
-
82
+
80
83
  when :render_page
81
84
  method_src = render_page_source(erb_process(instruction[:src]), local_names)
82
85
  @environment.compiled_local_names = local_names
83
86
  @environment.class_eval(method_src, template_path, instruction[:line_num])
84
-
87
+
85
88
  when :include
86
89
  import_taglib(instruction)
87
-
90
+
88
91
  when :module
89
92
  import_module(name.constantize, instruction[:as])
90
-
93
+
91
94
  when :set_theme
92
95
  set_theme(name)
93
-
96
+
94
97
  when :alias_method
95
98
  @environment.send(:alias_method, instruction[:new], instruction[:old])
96
-
99
+
97
100
  else
98
- raise RuntimeError.new("DRYML: Unknown build instruction :#{instruction[:type]}, " +
101
+ raise RuntimeError.new("DRYML: Unknown build instruction :#{instruction[:type]}, " +
99
102
  "building #{template_path}")
100
103
  end
101
104
  end
102
105
  @last_build_mtime = src_mtime
103
106
  end
104
-
107
+
105
108
 
106
109
  def import_taglib(options)
107
110
  if options[:module]
@@ -109,10 +112,10 @@ module Hobo::Dryml
109
112
  else
110
113
  template_dir = File.dirname(template_path)
111
114
  options = options.merge(:template_dir => template_dir)
112
-
115
+
113
116
  # Pass on the current bundle, if there is one, to the sub-taglib
114
117
  options[:bundle] = template.bundle.name unless template.bundle.nil? || options[:bundle] || options[:plugin]
115
-
118
+
116
119
  taglib = Taglib.get(options)
117
120
  taglib.import_into(@environment, options[:as])
118
121
  end
@@ -123,7 +126,7 @@ module Hobo::Dryml
123
126
  raise NotImplementedError if as
124
127
  @environment.send(:include, mod)
125
128
  end
126
-
129
+
127
130
 
128
131
  def set_theme(name)
129
132
  if Hobo.current_theme.nil? or Hobo.current_theme == name