zena 1.0.0 → 1.1.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (245) hide show
  1. data/History.txt +28 -0
  2. data/README.rdoc +6 -6
  3. data/Rakefile +3 -0
  4. data/app/controllers/users_controller.rb +4 -2
  5. data/app/models/acl.rb +6 -0
  6. data/app/models/cached_page.rb +2 -1
  7. data/app/models/document.rb +3 -4
  8. data/app/models/node.rb +8 -5
  9. data/app/models/site.rb +1 -1
  10. data/app/models/template.rb +2 -2
  11. data/app/models/user.rb +5 -3
  12. data/app/views/acls/_add.rhtml +2 -1
  13. data/app/views/acls/_form.rhtml +15 -7
  14. data/app/views/acls/_li.rhtml +2 -0
  15. data/app/views/acls/index.rhtml +3 -1
  16. data/app/views/acls/show.html.erb +1 -1
  17. data/app/views/links/destroy.rjs +16 -2
  18. data/app/views/versions/destroy.rjs +1 -1
  19. data/app/views/zafu/default/Node-admin.zafu +1 -1
  20. data/bin/zena +5 -3
  21. data/bricks/acls/lib/bricks/acls.rb +11 -4
  22. data/bricks/acls/zena/migrate/20110627193757_add_allowed_mode_and_format_to_acl.rb +11 -0
  23. data/bricks/acls/zena/test/integration/acl_integration_test.rb +42 -0
  24. data/bricks/acls/zena/test/sites/erebus/acls.yml +8 -0
  25. data/bricks/mongrel/zena/deploy.rb +19 -0
  26. data/bricks/single/lib/bricks/single.rb +15 -0
  27. data/bricks/single/zena/init.rb +1 -0
  28. data/bricks/sphinx/zena/tasks.rb +1 -1
  29. data/bricks/static/lib/bricks/static.rb +151 -0
  30. data/bricks/static/zena/init.rb +1 -0
  31. data/bricks/static/zena/migrate/20110702010330_add_static_to_idx_templates.rb +12 -0
  32. data/bricks/static/zena/skins/blog/Image-edit.zafu +6 -0
  33. data/bricks/static/zena/skins/blog/Image.zafu +19 -0
  34. data/bricks/static/zena/skins/blog/Node-+index.zafu +1 -0
  35. data/bricks/static/zena/skins/blog/Node-+notFound.zafu +7 -0
  36. data/bricks/static/zena/skins/blog/Node-+search.zafu +19 -0
  37. data/bricks/static/zena/skins/blog/Node.zafu +66 -0
  38. data/bricks/static/zena/skins/blog/Post.zafu +12 -0
  39. data/bricks/static/zena/skins/blog/Project--kml.zafu +30 -0
  40. data/bricks/static/zena/skins/blog/Project.zafu +45 -0
  41. data/bricks/static/zena/skins/blog/comments.zafu +30 -0
  42. data/bricks/static/zena/skins/blog/dict.yml +11 -0
  43. data/bricks/static/zena/skins/blog/img/dateBg.jpg +0 -0
  44. data/bricks/static/zena/skins/blog/img/header.png +0 -0
  45. data/bricks/static/zena/skins/blog/img/mapPin.png +0 -0
  46. data/bricks/static/zena/skins/blog/img/menu.gif +0 -0
  47. data/bricks/static/zena/skins/blog/img/menuover.gif +0 -0
  48. data/bricks/static/zena/skins/blog/img/style.css +110 -0
  49. data/bricks/static/zena/test/integration/static_integration_test.rb +30 -0
  50. data/bricks/static/zena/test/unit/static_test.rb +33 -0
  51. data/bricks/zena/zena/migrate/01_base.rb +1 -2
  52. data/bricks/zena/zena/migrate/20110623072048_fix_cached_path_index.rb +10 -0
  53. data/bricks/zena/zena/migrate/20110710113731_remove_icon_field.rb +18 -0
  54. data/config/bricks.yml +4 -0
  55. data/config/deploy.rb +17 -2
  56. data/config/gems.yml +9 -7
  57. data/config/selenium.yml +38 -0
  58. data/lib/bricks/requirements_validation.rb +8 -2
  59. data/lib/gettext_strings.rb +2 -1
  60. data/lib/tasks/zena.rake +5 -0
  61. data/lib/zena/app.rb +12 -0
  62. data/lib/zena/console.rb +9 -1
  63. data/lib/zena/core_ext/string.rb +7 -2
  64. data/lib/zena/deploy.rb +60 -6
  65. data/lib/zena/deploy/app_init.rhtml +56 -0
  66. data/lib/zena/deploy/haproxy.cnf.rhtml +34 -0
  67. data/lib/zena/deploy/httpd.rhtml +6 -0
  68. data/lib/zena/deploy/start_stop.rhtml +35 -0
  69. data/lib/zena/info.rb +1 -1
  70. data/lib/zena/remote/connection.rb +1 -1
  71. data/lib/zena/site_worker.rb +9 -5
  72. data/lib/zena/use.rb +1 -1
  73. data/lib/zena/use/action.rb +2 -2
  74. data/lib/zena/use/ajax.rb +22 -9
  75. data/lib/zena/use/conditional.rb +5 -0
  76. data/lib/zena/use/context.rb +6 -1
  77. data/lib/zena/use/dates.rb +17 -2
  78. data/lib/zena/use/display.rb +14 -3
  79. data/lib/zena/use/forms.rb +37 -47
  80. data/lib/zena/use/html_tags.rb +3 -0
  81. data/lib/zena/use/node_context.rb +17 -17
  82. data/lib/zena/use/rendering.rb +1 -1
  83. data/lib/zena/use/urls.rb +11 -2
  84. data/lib/zena/use/zafu_attributes.rb +1 -0
  85. data/lib/zena/use/zafu_safe_definitions.rb +16 -1
  86. data/lib/zena/use/zafu_templates.rb +39 -24
  87. data/lib/zena/use/zazen.rb +1 -0
  88. data/locale/de/LC_MESSAGES/zena.mo +0 -0
  89. data/locale/de/zena.po +105 -89
  90. data/locale/en/LC_MESSAGES/zena.mo +0 -0
  91. data/locale/en/zena.mo +0 -0
  92. data/locale/en/zena.po +188 -253
  93. data/locale/fr/LC_MESSAGES/zena.mo +0 -0
  94. data/locale/fr/zena.mo +0 -0
  95. data/locale/fr/zena.po +200 -257
  96. data/locale/zena.pot +95 -85
  97. data/public/javascripts/zena.js +2 -2
  98. data/test/fixtures/files/{Node-test.zafu → TestNode.zafu} +206 -4
  99. data/test/functional/nodes_controller_test.rb +2 -2
  100. data/test/integration/navigation_test.rb +9 -3
  101. data/test/integration/query_node/basic.yml +4 -4
  102. data/test/integration/query_node/filters.yml +2 -2
  103. data/test/integration/zafu_compiler/ajax.yml +6 -6
  104. data/test/integration/zafu_compiler/basic.yml +1 -1
  105. data/test/integration/zafu_compiler/calendar.yml +4 -3
  106. data/test/integration/zafu_compiler/conditional.yml +3 -10
  107. data/test/integration/zafu_compiler/context.yml +1 -1
  108. data/test/integration/zafu_compiler/dates.yml +9 -1
  109. data/test/integration/zafu_compiler/display.yml +7 -1
  110. data/test/integration/zafu_compiler/eval.yml +12 -46
  111. data/test/integration/zafu_compiler/forms.yml +1 -1
  112. data/test/integration/zafu_compiler/query.yml +2 -2
  113. data/test/integration/zafu_compiler/relations.yml +19 -9
  114. data/test/integration/zafu_compiler/roles.yml +12 -0
  115. data/test/integration/zafu_compiler/safe_definitions.yml +1 -1
  116. data/test/integration/zafu_compiler/urls.yml +13 -5
  117. data/test/integration/zafu_compiler/version.yml +6 -0
  118. data/test/integration/zafu_compiler/zafu_attributes.yml +4 -4
  119. data/test/integration/zafu_compiler_test.rb +1 -1
  120. data/test/selenium.readme +8 -0
  121. data/test/selenium/Add/0setup.rsel +12 -0
  122. data/test/selenium/Add/add1.rsel +22 -0
  123. data/test/selenium/Add/add2.rsel +22 -0
  124. data/test/selenium/Add/add3.rsel +22 -0
  125. data/test/selenium/Drop/0setup.rsel +12 -0
  126. data/test/selenium/Drop/drop1.rsel +25 -0
  127. data/test/selenium/Drop/drop2.rsel +25 -0
  128. data/test/selenium/Drop/drop3.rsel +51 -0
  129. data/test/selenium/Drop/drop4.rsel +44 -0
  130. data/test/selenium/Drop/drop5.rsel +16 -0
  131. data/test/selenium/Edit/0setup.rsel +12 -0
  132. data/test/selenium/Edit/edit1.rsel +31 -0
  133. data/test/selenium/Edit/edit2.rsel +39 -0
  134. data/test/selenium/Edit/edit3.rsel +40 -0
  135. data/test/selenium/Form/0setup.rsel +12 -0
  136. data/test/selenium/Form/form1.rsel +9 -0
  137. data/test/selenium/Form/form2.rsel +9 -0
  138. data/test/selenium/Paginate/0setup.rsel +12 -0
  139. data/test/selenium/Paginate/paginate1.rsel +24 -0
  140. data/test/selenium/Toggle/0setup.rsel +12 -0
  141. data/test/selenium/Toggle/toggle1.rsel +21 -0
  142. data/test/sites/zena/nodes.yml +4 -4
  143. data/test/sites/zena/roles.yml +3 -2
  144. data/test/sites/zena/versions.yml +12 -11
  145. data/test/unit/core_ext_test.rb +23 -5
  146. data/test/unit/document_test.rb +6 -2
  147. data/test/unit/node_test.rb +2 -2
  148. data/test/unit/remote_test.rb +1 -2
  149. data/test/unit/role_test.rb +2 -2
  150. data/test/unit/user_test.rb +48 -1
  151. data/test/unit/virtual_class_test.rb +7 -7
  152. data/test/unit/zena/acts/secure_test.rb +1 -1
  153. data/test/unit/zena/use/rendering_test.rb +1 -1
  154. data/test/unit/zena/use/urls_test.rb +3 -3
  155. data/zena.gemspec +65 -101
  156. metadata +67 -103
  157. data/vendor/TextMate/Ruby Shoulda.tmbundle/Commands/Run 2.tmCommand +0 -24
  158. data/vendor/TextMate/Ruby Shoulda.tmbundle/Commands/Run Context.tmCommand +0 -58
  159. data/vendor/TextMate/Ruby Shoulda.tmbundle/Commands/Run Focused Should.tmCommand +0 -88
  160. data/vendor/TextMate/Ruby Shoulda.tmbundle/Commands/Run.tmCommand +0 -27
  161. data/vendor/TextMate/Ruby Shoulda.tmbundle/Commands/YAML to Shoulda.tmCommand +0 -23
  162. data/vendor/TextMate/Ruby Shoulda.tmbundle/Preferences/Symbol List: Context.tmPreferences +0 -19
  163. data/vendor/TextMate/Ruby Shoulda.tmbundle/Preferences/Symbol List: Should.tmPreferences +0 -19
  164. data/vendor/TextMate/Ruby Shoulda.tmbundle/Snippets/Factory attributes for.tmSnippet +0 -16
  165. data/vendor/TextMate/Ruby Shoulda.tmbundle/Snippets/Factory build.tmSnippet +0 -16
  166. data/vendor/TextMate/Ruby Shoulda.tmbundle/Snippets/Factory.tmSnippet +0 -16
  167. data/vendor/TextMate/Ruby Shoulda.tmbundle/Snippets/Factory_define with class.tmSnippet +0 -18
  168. data/vendor/TextMate/Ruby Shoulda.tmbundle/Snippets/Factory_define.tmSnippet +0 -18
  169. data/vendor/TextMate/Ruby Shoulda.tmbundle/Snippets/Factory_next.tmSnippet +0 -16
  170. data/vendor/TextMate/Ruby Shoulda.tmbundle/Snippets/Factory_sequence.tmSnippet +0 -18
  171. data/vendor/TextMate/Ruby Shoulda.tmbundle/Snippets/assert_bad_value.tmSnippet +0 -16
  172. data/vendor/TextMate/Ruby Shoulda.tmbundle/Snippets/assert_contains.tmSnippet +0 -16
  173. data/vendor/TextMate/Ruby Shoulda.tmbundle/Snippets/assert_does_not_contain.tmSnippet +0 -16
  174. data/vendor/TextMate/Ruby Shoulda.tmbundle/Snippets/assert_good_value.tmSnippet +0 -16
  175. data/vendor/TextMate/Ruby Shoulda.tmbundle/Snippets/assert_same_elements.tmSnippet +0 -16
  176. data/vendor/TextMate/Ruby Shoulda.tmbundle/Snippets/assert_save.tmSnippet +0 -16
  177. data/vendor/TextMate/Ruby Shoulda.tmbundle/Snippets/assert_sent_email.tmSnippet +0 -18
  178. data/vendor/TextMate/Ruby Shoulda.tmbundle/Snippets/assert_valid.tmSnippet +0 -16
  179. data/vendor/TextMate/Ruby Shoulda.tmbundle/Snippets/association.tmSnippet +0 -17
  180. data/vendor/TextMate/Ruby Shoulda.tmbundle/Snippets/attribute.tmSnippet +0 -17
  181. data/vendor/TextMate/Ruby Shoulda.tmbundle/Snippets/before_should block.tmSnippet +0 -18
  182. data/vendor/TextMate/Ruby Shoulda.tmbundle/Snippets/context block get.tmSnippet +0 -22
  183. data/vendor/TextMate/Ruby Shoulda.tmbundle/Snippets/context block post.tmSnippet +0 -23
  184. data/vendor/TextMate/Ruby Shoulda.tmbundle/Snippets/context block with setup.tmSnippet +0 -25
  185. data/vendor/TextMate/Ruby Shoulda.tmbundle/Snippets/setup.tmSnippet +0 -18
  186. data/vendor/TextMate/Ruby Shoulda.tmbundle/Snippets/should block with before proc.tmSnippet +0 -18
  187. data/vendor/TextMate/Ruby Shoulda.tmbundle/Snippets/should block.tmSnippet +0 -18
  188. data/vendor/TextMate/Ruby Shoulda.tmbundle/Snippets/should_allow_values_for.tmSnippet +0 -16
  189. data/vendor/TextMate/Ruby Shoulda.tmbundle/Snippets/should_assign_to.tmSnippet +0 -16
  190. data/vendor/TextMate/Ruby Shoulda.tmbundle/Snippets/should_be_restful denied.tmSnippet +0 -20
  191. data/vendor/TextMate/Ruby Shoulda.tmbundle/Snippets/should_be_restful.tmSnippet +0 -20
  192. data/vendor/TextMate/Ruby Shoulda.tmbundle/Snippets/should_belong_to.tmSnippet +0 -16
  193. data/vendor/TextMate/Ruby Shoulda.tmbundle/Snippets/should_change by.tmSnippet +0 -16
  194. data/vendor/TextMate/Ruby Shoulda.tmbundle/Snippets/should_change from to.tmSnippet +0 -16
  195. data/vendor/TextMate/Ruby Shoulda.tmbundle/Snippets/should_ensure_length_at_least.tmSnippet +0 -16
  196. data/vendor/TextMate/Ruby Shoulda.tmbundle/Snippets/should_ensure_length_in_range.tmSnippet +0 -16
  197. data/vendor/TextMate/Ruby Shoulda.tmbundle/Snippets/should_ensure_length_is.tmSnippet +0 -16
  198. data/vendor/TextMate/Ruby Shoulda.tmbundle/Snippets/should_ensure_value_in_range.tmSnippet +0 -16
  199. data/vendor/TextMate/Ruby Shoulda.tmbundle/Snippets/should_eventually.tmSnippet +0 -18
  200. data/vendor/TextMate/Ruby Shoulda.tmbundle/Snippets/should_filter_params.tmSnippet +0 -16
  201. data/vendor/TextMate/Ruby Shoulda.tmbundle/Snippets/should_have_and_belong_to_many.tmSnippet +0 -16
  202. data/vendor/TextMate/Ruby Shoulda.tmbundle/Snippets/should_have_class_methods.tmSnippet +0 -16
  203. data/vendor/TextMate/Ruby Shoulda.tmbundle/Snippets/should_have_db_column.tmSnippet +0 -16
  204. data/vendor/TextMate/Ruby Shoulda.tmbundle/Snippets/should_have_db_columns.tmSnippet +0 -16
  205. data/vendor/TextMate/Ruby Shoulda.tmbundle/Snippets/should_have_index.tmSnippet +0 -16
  206. data/vendor/TextMate/Ruby Shoulda.tmbundle/Snippets/should_have_indices.tmSnippet +0 -16
  207. data/vendor/TextMate/Ruby Shoulda.tmbundle/Snippets/should_have_instance_methods.tmSnippet +0 -16
  208. data/vendor/TextMate/Ruby Shoulda.tmbundle/Snippets/should_have_many.tmSnippet +0 -16
  209. data/vendor/TextMate/Ruby Shoulda.tmbundle/Snippets/should_have_named_scope.tmSnippet +0 -16
  210. data/vendor/TextMate/Ruby Shoulda.tmbundle/Snippets/should_have_one.tmSnippet +0 -16
  211. data/vendor/TextMate/Ruby Shoulda.tmbundle/Snippets/should_have_readonly_attributes.tmSnippet +0 -16
  212. data/vendor/TextMate/Ruby Shoulda.tmbundle/Snippets/should_not_allow_mass_assignment_of.tmSnippet +0 -16
  213. data/vendor/TextMate/Ruby Shoulda.tmbundle/Snippets/should_not_allow_values_for.tmSnippet +0 -16
  214. data/vendor/TextMate/Ruby Shoulda.tmbundle/Snippets/should_not_assign_to.tmSnippet +0 -16
  215. data/vendor/TextMate/Ruby Shoulda.tmbundle/Snippets/should_not_change.tmSnippet +0 -16
  216. data/vendor/TextMate/Ruby Shoulda.tmbundle/Snippets/should_not_set_the_flash.tmSnippet +0 -16
  217. data/vendor/TextMate/Ruby Shoulda.tmbundle/Snippets/should_redirect_to.tmSnippet +0 -16
  218. data/vendor/TextMate/Ruby Shoulda.tmbundle/Snippets/should_render_a_form.tmSnippet +0 -16
  219. data/vendor/TextMate/Ruby Shoulda.tmbundle/Snippets/should_render_template.tmSnippet +0 -16
  220. data/vendor/TextMate/Ruby Shoulda.tmbundle/Snippets/should_render_with_layout.tmSnippet +0 -16
  221. data/vendor/TextMate/Ruby Shoulda.tmbundle/Snippets/should_render_without_layout.tmSnippet +0 -16
  222. data/vendor/TextMate/Ruby Shoulda.tmbundle/Snippets/should_respond_with.tmSnippet +0 -16
  223. data/vendor/TextMate/Ruby Shoulda.tmbundle/Snippets/should_respond_with_content_type.tmSnippet +0 -16
  224. data/vendor/TextMate/Ruby Shoulda.tmbundle/Snippets/should_return_from_session.tmSnippet +0 -16
  225. data/vendor/TextMate/Ruby Shoulda.tmbundle/Snippets/should_route.tmSnippet +0 -16
  226. data/vendor/TextMate/Ruby Shoulda.tmbundle/Snippets/should_set_the_flash_to.tmSnippet +0 -16
  227. data/vendor/TextMate/Ruby Shoulda.tmbundle/Snippets/should_validate_acceptance_of.tmSnippet +0 -16
  228. data/vendor/TextMate/Ruby Shoulda.tmbundle/Snippets/should_validate_numericality_of.tmSnippet +0 -16
  229. data/vendor/TextMate/Ruby Shoulda.tmbundle/Snippets/should_validate_presence_of.tmSnippet +0 -16
  230. data/vendor/TextMate/Ruby Shoulda.tmbundle/Snippets/should_validate_uniqueness_of with scope.tmSnippet +0 -16
  231. data/vendor/TextMate/Ruby Shoulda.tmbundle/Snippets/should_validate_uniqueness_of.tmSnippet +0 -16
  232. data/vendor/TextMate/Ruby Shoulda.tmbundle/Support/RubyMate/catch_exception.rb +0 -39
  233. data/vendor/TextMate/Ruby Shoulda.tmbundle/Support/RubyMate/run_script.rb +0 -104
  234. data/vendor/TextMate/Ruby Shoulda.tmbundle/Support/RubyMate/stdin_dialog.rb +0 -14
  235. data/vendor/TextMate/Ruby Shoulda.tmbundle/Support/RubyMate/test.rb +0 -17
  236. data/vendor/TextMate/Ruby Shoulda.tmbundle/Support/RubyMate/todo.txt +0 -13
  237. data/vendor/TextMate/Ruby Shoulda.tmbundle/Support/bin/yaml_to_shoulda.rb +0 -25
  238. data/vendor/TextMate/Ruby Shoulda.tmbundle/Syntaxes/Ruby on Rails (Shoulda).tmLanguage +0 -166
  239. data/vendor/TextMate/Ruby Shoulda.tmbundle/info.plist +0 -304
  240. data/vendor/TextMate/Zena.tmbundle/Commands/Run all yaml tests.tmCommand +0 -37
  241. data/vendor/TextMate/Zena.tmbundle/Commands/Run focused yaml test.tmCommand +0 -52
  242. data/vendor/TextMate/Zena.tmbundle/Support/RubyMate/catch_exception.rb +0 -39
  243. data/vendor/TextMate/Zena.tmbundle/Support/RubyMate/run_script.rb +0 -118
  244. data/vendor/TextMate/Zena.tmbundle/Support/RubyMate/stdin_dialog.rb +0 -14
  245. data/vendor/TextMate/Zena.tmbundle/info.plist +0 -17
data/lib/zena/use.rb CHANGED
@@ -2,7 +2,7 @@ module Zena
2
2
  # This module is used to declare and manage the list of features used by Zena.
3
3
  module Use
4
4
  SUFFIX_NAME = 'Methods'
5
- MODULE_NAMES = %w{Controller View Zafu User}
5
+ MODULE_NAMES = %w{Controller View Zafu User Site Skin}
6
6
  # "Controller" => "ControllerMethods"
7
7
  MODULE_NAME = Hash[*MODULE_NAMES.map {|n| [n, "#{n}#{SUFFIX_NAME}"]}.flatten]
8
8
 
@@ -151,7 +151,7 @@ module Zena
151
151
 
152
152
  def login_path
153
153
  if params[:controller] == 'nodes'
154
- url_for params.merge(:prefix => AUTHENTICATED_PREFIX)
154
+ zen_path(@node, :prefix => AUTHENTICATED_PREFIX)
155
155
  else
156
156
  super
157
157
  end
@@ -159,7 +159,7 @@ module Zena
159
159
 
160
160
  def logout_path
161
161
  if params[:controller] == 'nodes' && @node.public?
162
- super :redirect => url_for(params.merge(:prefix => visitor.lang))
162
+ super :redirect => zen_path(@node, :prefix => visitor.lang)
163
163
  else
164
164
  super
165
165
  end
data/lib/zena/use/ajax.rb CHANGED
@@ -7,11 +7,13 @@ module Zena
7
7
 
8
8
  # Return the DOM id for a node. We had to name this method 'ndom_id' because we want
9
9
  # to avoid the clash with Rails' dom_id method.
10
- def ndom_id(node)
10
+ def ndom_id(node = @node, append_form = true)
11
11
  if node.kind_of?(Node) && !node.new_record?
12
12
  if params[:action] == 'create' && !params[:udom_id]
13
13
  return "#{params[:dom_id]}_#{node.zip}"
14
14
  end
15
+ elsif append_form && node.kind_of?(Node) && params[:zadd]
16
+ return "#{params[:dom_id]}_form"
15
17
  end
16
18
 
17
19
  @dom_id || params[:udom_id] || params[:dom_id]
@@ -42,12 +44,12 @@ module Zena
42
44
 
43
45
  if obj.new_record?
44
46
  # A. could not create object: show form with errors
45
- page.replace "#{params[:dom_id]}_form", :file => template_path_from_template_url + "_form.erb"
47
+ page.replace ndom_id, :file => template_path_from_template_url + "_form.erb"
46
48
  elsif @errors || !obj.errors.empty?
47
49
  # B. could not update/delete: show errors
48
50
  form_file = template_path_from_template_url + "_form.erb"
49
51
  if File.exist?(form_file)
50
- page.replace "#{params[:dom_id]}_form", :file => form_file
52
+ page.replace ndom_id, :file => form_file
51
53
  else
52
54
  page.insert_html :top, params[:dom_id], :inline => render_errors
53
55
  end
@@ -71,7 +73,7 @@ module Zena
71
73
  @dom_id = params[:dom_id]
72
74
  page.replace params[:dom_id], :file => template_path_from_template_url + ".erb"
73
75
  end
74
- if params[:done] && params[:action] == 'create'
76
+ if params[:done] && params[:zadd]
75
77
  page.toggle "#{params[:dom_id]}_form", "#{params[:dom_id]}_add"
76
78
  page << params[:done]
77
79
  elsif params[:done]
@@ -98,18 +100,29 @@ module Zena
98
100
  else
99
101
  instance_variable_set("@#{base_class.to_s.underscore}", obj.clone)
100
102
  end
101
- page.replace "#{params[:dom_id]}_form", :file => template_path_from_template_url + "_form.erb"
103
+ page.replace ndom_id, :file => template_path_from_template_url + "_form.erb"
102
104
  if params[:done]
103
105
  page << params[:done]
104
- else
106
+ elsif params[:zadd]
105
107
  page.toggle "#{params[:dom_id]}_form", "#{params[:dom_id]}_add"
106
108
  end
107
109
  when 'update'
108
- page.replace params[:dom_id], :file => template_path_from_template_url + ".erb"
110
+ page.replace ndom_id, :file => template_path_from_template_url + ".erb"
109
111
  page << params[:done] if params[:done]
110
112
  when 'destroy'
111
- page.visual_effect :highlight, params[:dom_id], :duration => 0.3
112
- page.visual_effect :fade, params[:dom_id], :duration => 0.3
113
+ page << %Q{
114
+ new Effect.Highlight('#{ndom_id}', {
115
+ duration: 0.3,
116
+ afterFinish: function() {
117
+ new Effect.Fade('#{ndom_id}', {
118
+ duration: 0.5,
119
+ afterFinish: function() {
120
+ $('#{ndom_id}').remove();
121
+ }
122
+ });
123
+ }
124
+ });
125
+ }
113
126
  when 'drop'
114
127
  case params[:done]
115
128
  when 'remove'
@@ -1,6 +1,11 @@
1
1
  module Zena::Use::Conditional
2
2
  module ZafuMethods
3
3
 
4
+ def r_selenium
5
+ return parser_error("missing 'id'.") if @name.blank?
6
+ out expand_if("params[:test]==#{@name.inspect} || params[:test]=='all'")
7
+ end
8
+
4
9
  def rubyless_class_scope(class_name)
5
10
  return parser_error("Cannot scope class in list (use each before filtering).") if node.list_context?
6
11
  # capital letter ==> class conditional
@@ -191,7 +191,12 @@ module Zena
191
191
  typed_string = ::RubyLess.translate(self, code)
192
192
  name = get_var_name('set_var', var)
193
193
  out "<% #{name} = #{typed_string} %>"
194
- set_context_var('set_var', var, RubyLess::TypedString.new(name, typed_string.opts))
194
+ var_setting = {}
195
+ set_context_var('set_var', var, RubyLess::TypedString.new(name, typed_string.opts), var_setting)
196
+ # Leak into following siblings
197
+ self.pass(var_setting)
198
+ # Set inside
199
+ @context.merge!(var_setting)
195
200
  rescue RubyLess::NoMethodError => err
196
201
  parser_error(err.message, code)
197
202
  end
@@ -306,8 +306,8 @@ module Zena
306
306
  safe_method :date => :get_date
307
307
  safe_method [:date, TZInfo::Timezone] => :get_date
308
308
  safe_method :tz => :get_tz
309
- safe_method [:parse_date, String] => {:class => Time, :nil => true, :accept_nil => true}
310
- safe_method [:parse_date, String, String] => {:class => Time, :nil => true, :accept_nil => true}
309
+ safe_method [:parse_date, String] => :get_parse_date
310
+ safe_method [:parse_date, String, String] => :get_parse_date
311
311
  safe_method [:parse_date, String, String, TZInfo::Timezone] => {:class => Time, :nil => true, :accept_nil => true}
312
312
 
313
313
  def get_date(signature)
@@ -326,6 +326,21 @@ module Zena
326
326
  end
327
327
  end
328
328
 
329
+ def get_parse_date(signature)
330
+ tz_var = get_context_var('set_var', 'tz')
331
+ if signature == ['parse_date', String]
332
+ append = [
333
+ RubyLess::TypedString.new(_(DATETIME).inspect, :class => String),
334
+ tz_var || RubyLess::TypedString.new('visitor.tz', :class => TZInfo::Timezone),
335
+ ]
336
+ elsif signature = ['parse_date', String, String]
337
+ append = tz_var || RubyLess::TypedString.new('visitor.tz', :class => TZInfo::Timezone)
338
+ else
339
+ append = nil
340
+ end
341
+ {:method => 'parse_date', :class => Time, :nil => true, :accept_nil => true, :append_args => append}
342
+ end
343
+
329
344
  def r_default
330
345
  if tz_name = @params.delete(:tz)
331
346
  set_tz_code, tz_var = set_tz_var(tz_name)
@@ -492,6 +492,9 @@ module Zena
492
492
  "<label>#{attribute}</label> <span>#{res}</span>"
493
493
  when 't'
494
494
  "<label>#{trans(attribute)}</label> <span>#{res}</span>"
495
+ when '','false'
496
+ # no label
497
+ res
495
498
  else
496
499
  if @params[:tlabel]
497
500
  code = ::RubyLess.translate(self, "t(%Q{#{label}})")
@@ -599,13 +602,21 @@ module Zena
599
602
 
600
603
  # Find icon through a relation named 'icon' or use first image child
601
604
  def r_icon
602
- finder = build_finder(:first, icon_finder)
603
- expand_with_finder(finder)
605
+ if node.will_be?(Node)
606
+ finder = build_finder(:first, icon_finder)
607
+ expand_with_finder(finder)
608
+ else
609
+ rubyless_eval
610
+ end
604
611
  end
605
612
 
606
613
  # Display an image
607
614
  def r_img
608
- return unless node.will_be?(Node)
615
+ if node.will_be?(VirtualClass)
616
+ return "<img src='<%= #{node}.prop['icon'] %>'/>"
617
+ elsif !node.will_be?(Node)
618
+ return
619
+ end
609
620
 
610
621
  if src = @params[:src]
611
622
  finder = ::RubyLess.translate(self, @params[:src]) #build_finder(:first, @params[:src])
@@ -86,14 +86,14 @@ module Zena
86
86
  return parser_error("invalid 'klass' parameter (not a Node)") unless klass <= Node
87
87
 
88
88
  res = []
89
- keys = {:klass => 'klass'}
89
+ keys = {:klass => 'this.klass', :parent_id => "#{node(Node)}.zip"}
90
90
  @params.each do |key, value|
91
91
  next if key == :klass
92
92
  # TODO: maybe it would be safer to check with [:"key="] and change safe_property to
93
93
  # authorize both ?
94
94
  next unless type = klass.safe_method_type([key.to_s])
95
95
  # Store how to access current value to show hidden field in form.
96
- keys[key] = type[:method]
96
+ keys[key] = "this.#{type[:method]}"
97
97
  code = RubyLess.translate(self, value)
98
98
  if code.klass == type[:class]
99
99
  res << ":#{key} => #{code}"
@@ -112,7 +112,6 @@ module Zena
112
112
  :method => method,
113
113
  :class => klass,
114
114
  :nil => true,
115
- :new_record => true,
116
115
  :new_keys => keys
117
116
  )
118
117
  end
@@ -206,10 +205,20 @@ module Zena
206
205
  opts[:form_cancel] = "#{cancel_pre}<a href='#' onclick='[\"#{dom_name}_add\", \"#{dom_name}_form\"].each(Element.toggle);return false;'>#{cancel_text}</a>#{cancel_post}\n"
207
206
  else
208
207
  # Saved form
209
- opts[:id] = "<%= ndom_id(#{node}) %>_form"
208
+ if @markup.tag == 'table'
209
+ # the normal id goes to the form wrapping the table
210
+ opts[:id] = "#{node.dom_prefix}_tbl"
211
+ str_form_id = "\#{ndom_id(#{node})}"
212
+ else
213
+ opts[:id] = "<%= ndom_id(#{node}) %>"
214
+ str_form_id = "\#{ndom_id(#{node})}_form_t"
215
+ end
216
+
217
+ form_id ||= "#{node.dom_prefix}_form_t"
218
+ opts[:id] = "<%= ndom_id(#{node}) %>"
210
219
 
211
220
  opts[:form_tag] = %Q{
212
- <% remote_form_for(:#{node.form_name}, #{node}, :url => #{node}.new_record? ? #{node.form_name.pluralize}_path : #{node.form_name}_path(#{node}.zip), :html => {:method => #{node}.new_record? ? :post : :put, :id => \"\#{ndom_id(#{node})}_form_t\"}) do |f| %>
221
+ <% remote_form_for(:#{node.form_name}, #{node}, :url => #{node}.new_record? ? #{node.form_name.pluralize}_path : #{node.form_name}_path(#{node}.zip), :html => {:method => #{node}.new_record? ? :post : :put, :id => \"#{str_form_id}\"}) do |f| %>
213
222
  }
214
223
 
215
224
  opts[:form_cancel] = %Q{
@@ -246,16 +255,15 @@ module Zena
246
255
  set_fields << "#{node.form_name}[#{tag.params[:name]}]"
247
256
  end
248
257
 
258
+ if (descendants('input') || []).detect {|elem| elem.params[:type] == 'submit'}
259
+ # has submit
260
+ else
261
+ # Hidden submit for Firefox compatibility
262
+ hidden_fields['submit'] = ["<input type='submit'/>"]
263
+ end
264
+
249
265
  if template_url = @context[:template_url]
250
266
  # Ajax
251
-
252
- if (descendants('input') || []).detect {|elem| elem.params[:type] == 'submit'}
253
- # has submit
254
- else
255
- # Hidden submit for Firefox compatibility
256
- hidden_fields['submit'] = ["<input type='submit'/>"]
257
- end
258
-
259
267
  hidden_fields['link_id'] = "<%= #{node}.link_id %>" if @context[:has_link_id] && node.will_be?(Node)
260
268
 
261
269
  if upd = @params[:update]
@@ -273,26 +281,11 @@ module Zena
273
281
 
274
282
  hidden_fields['t_url'] = template_url
275
283
  # This is a hack to fix wrong dom_prefix in drop+add.
276
- erb_dom_id = @context[:saved_template] ? "<%= ndom_id(#{node}) %>" : (@context[:dom_prefix] || node.dom_prefix)
284
+ erb_dom_id = @context[:saved_template] ? "<%= ndom_id(#{node}, false) %>" : (@context[:dom_prefix] || node.dom_prefix)
277
285
 
278
286
  hidden_fields['dom_id'] = erb_dom_id
279
287
 
280
- if node.will_be?(Node)
281
- # Nested contexts:
282
- # 1. @node
283
- # 2. var1 = @node.children
284
- # 3. var1_new = Node.new
285
- if node.opts[:new_record] #|| @context[:saved_template]
286
- if @context[:saved_template] || !@context[:in_add]
287
- # TODO: we should not add parent_id on every saved_template. Why is this needed ?
288
- parent_id = "#{node}.parent_zip"
289
- else
290
- parent_id = "#{node.up.up}.zip"
291
- end
292
-
293
- hidden_fields['node[parent_id]'] = "<%= #{parent_id} %>"
294
- end
295
- elsif node.will_be?(Comment)
288
+ if node.will_be?(Comment)
296
289
  # FIXME: the "... || '@node'" is a hack and I don't understand why it's needed...
297
290
  hidden_fields['node_id'] = "<%= #{node.get(Node) || '@node'}.zip %>"
298
291
  elsif node.will_be?(DataEntry)
@@ -302,6 +295,7 @@ module Zena
302
295
 
303
296
  if add_block = @context[:add]
304
297
  params = add_block.params
298
+ hidden_fields['zadd'] = 'true'
305
299
  [:after, :before, :top, :bottom].each do |sym|
306
300
  if value = params[sym]
307
301
  hidden_fields['position'] = sym.to_s
@@ -332,16 +326,6 @@ module Zena
332
326
  end
333
327
  else
334
328
  # no ajax
335
-
336
- if node.will_be?(Node)
337
- # Nested contexts:
338
- # 1. @node
339
- # 2. var1 = @node.children
340
- # 3. var1_new = Node.new
341
- if node.opts[:new_record]
342
- hidden_fields['node[parent_id]'] = "<%= #{node.up}.zip %>"
343
- end
344
- end
345
329
  cancel = "" # link to normal node ?
346
330
  end
347
331
 
@@ -356,6 +340,7 @@ module Zena
356
340
  hidden_fields['node[v_status]'] = Zena::Status::Pub.to_s if add_params[:publish] || auto_publish_param || @context[:publish_after_save]
357
341
 
358
342
  # All default values set in the <r:new> field should at least appear as hidden fields
343
+
359
344
  if new_keys = node.opts[:new_keys]
360
345
  input_keys = (
361
346
  (descendants('input') || []).map {|e| e.params[:name]} +
@@ -369,22 +354,26 @@ module Zena
369
354
  ).compact.uniq
370
355
 
371
356
  new_keys.each do |key, value|
372
- next if input_keys.include?(key)
373
- hidden_fields["node[#{key}]"] = "<%= #{node}.#{value} %>"
357
+ # Security: make sure value does not come from user input !
358
+ # TINT !
359
+ next if input_keys.include?(key) || value.nil?
360
+ hidden_fields["node[#{key}]"] = "<%= #{value.sub(/^this\./, "#{node}.")} %>"
374
361
  end
375
362
  end
376
363
 
377
364
  # Read @params
378
- @params.each do |key, value|
365
+ add_params.merge(@params).each do |key, value|
366
+ # r_add params
367
+ next if [:after, :before, :top, :bottom, :focus, :publish,
379
368
  # r_form params
380
- next if [:klass, :done, :on, :update].include?(key)
369
+ :klass, :done, :on, :update,
381
370
  # r_each params (make_form)
382
- next if [:join].include?(key)
371
+ :join].include?(key)
383
372
  code = ::RubyLess.translate(self, value)
384
373
  if code.literal.kind_of?(String) || code.literal.kind_of?(Number)
385
- hidden_fields[key] = "#{code.literal}"
374
+ hidden_fields[key.to_s] = "#{code.literal}"
386
375
  else
387
- hidden_fields[key] = "<%= #{code} %>"
376
+ hidden_fields[key.to_s] = "<%= #{code} %>"
388
377
  end
389
378
  end
390
379
 
@@ -514,6 +503,7 @@ module Zena
514
503
  return parser_error("select id without name") unless attribute
515
504
  name = "#{attribute}_id" unless attribute[-3..-1] == '_id'
516
505
  input_id = @context[:erb_dom_id] ? ", :input_id =>\"#{erb_dom_id}_#{attribute}\"" : ''
506
+ # FIXME: pass object
517
507
  "<%= select_id('#{node.form_name}', #{attribute.inspect}#{input_id}) %>"
518
508
  when 'time_zone'
519
509
  out parser_error("please use [select] here")
@@ -40,6 +40,9 @@ module Zena
40
40
  else
41
41
  id = nil
42
42
  end
43
+ if !node || node.new_record?
44
+ node = current_site.root_node
45
+ end
43
46
  end
44
47
 
45
48
  if !id.blank?
@@ -32,23 +32,23 @@ module Zena
32
32
  end
33
33
 
34
34
  # Get an uppers NodeContext that is of the given class kind.
35
- def get(klass)
36
- if real_single_class <= klass
37
- return self unless list_context?
38
-
39
- res_class = self.klass
40
- method = self.name
41
- while res_class.kind_of?(Array)
42
- method = "#{method}.first"
43
- res_class = res_class.first
44
- end
45
- move_to(method, res_class)
46
- elsif @up
47
- @up.get(klass)
48
- else
49
- nil
50
- end
51
- end
35
+ # def get(klass)
36
+ # if real_single_class <= klass
37
+ # return self unless list_context?
38
+ #
39
+ # res_class = self.klass
40
+ # method = self.name
41
+ # while res_class.kind_of?(Array)
42
+ # method = "#{method}.first"
43
+ # res_class = res_class.first
44
+ # end
45
+ # move_to(method, res_class)
46
+ # elsif @up
47
+ # @up.get(klass)
48
+ # else
49
+ # nil
50
+ # end
51
+ # end
52
52
 
53
53
  # Return the 'real' class name or the superclass name if the current class is an anonymous class.
54
54
  def class_name
@@ -28,7 +28,7 @@ module Zena
28
28
  end
29
29
 
30
30
  def help(key)
31
- %Q{<div class='help'><p>#{_(key)}</p></div>}
31
+ %Q{<div class='help'><p>#{key}</p></div>}
32
32
  end
33
33
  end
34
34
 
data/lib/zena/use/urls.rb CHANGED
@@ -65,7 +65,6 @@ module Zena
65
65
  # Path for a node. Options can be :format, :host and :mode.
66
66
  # ex '/en/document34_print.html'
67
67
  def zen_path(node, options={})
68
-
69
68
  return '#' unless node
70
69
 
71
70
  if anchor = options.delete(:anchor)
@@ -151,6 +150,7 @@ module Zena
151
150
  path
152
151
  else
153
152
  cachestamp = opts.delete(:cachestamp)
153
+ tz = opts.delete(:tz)
154
154
  list = opts.keys.map do |k|
155
155
  # FIXME: DOC
156
156
  if k.to_s == 'encode_params'
@@ -166,7 +166,7 @@ module Zena
166
166
  end
167
167
  elsif value = opts[k]
168
168
  if value.respond_to?(:strftime_tz)
169
- "#{k}=#{CGI.escape(value.strftime_tz(_(Zena::Use::Dates::DATETIME)))}"
169
+ "#{k}=#{CGI.escape(value.strftime_tz(_(Zena::Use::Dates::DATETIME), tz))}"
170
170
  elsif value.kind_of?(Hash)
171
171
  "#{k}=#{value.to_query}"
172
172
  elsif value.kind_of?(Node)
@@ -348,6 +348,15 @@ module Zena
348
348
  # <r:link update='dom_id'/>
349
349
  # <r:link page='next'/> <r:link page='previous'/> <r:link page='list'/>
350
350
  def r_link
351
+ # If we have a contextual timezone set, pass it to @params
352
+ if tz_name = @params[:tz]
353
+ tz_result, tz_var = set_tz_var(tz_name)
354
+ return tz_result unless tz_var
355
+ @params[:tz] = 'tz'
356
+ elsif tz_var = get_context_var('set_var', 'tz')
357
+ @params[:tz] = 'tz'
358
+ end
359
+
351
360
  if @params[:page] && @params[:page] != '[page_page]' # lets users use 'page' as pagination key
352
361
  pagination_links
353
362
  else