zena 1.0.0 → 1.1.0

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 (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
@@ -0,0 +1,38 @@
1
+ # Please read as our directions have changed:
2
+ # Move this file to your rails apps config directory and rename it to selenium.yml in order to configure the plugin
3
+
4
+ #
5
+ # General settings
6
+ #
7
+
8
+ environments:
9
+ - test
10
+ # - development # Uncomment this line to enable in development environment. N.B. your development database will likely be altered/destroyed/abducted
11
+
12
+ #selenium_path: 'c:\selenium' #path to selenium installation. only needed if you for some reason don't want to use the bundled version of selenium core
13
+
14
+ #
15
+ # rake test:acceptance settings
16
+ #
17
+
18
+ browsers:
19
+ # Windows
20
+ #firefox: 'c:\Program Files\Mozilla Firefox\firefox.exe'
21
+ #ie: 'c:\Program Files\Internet Explorer\iexplore.exe'
22
+
23
+ # Mac OS X
24
+ firefox: '/Applications/Firefox.app/Contents/MacOS/firefox-bin'
25
+ safari: '/Applications/Safari.app/Contents/MacOS/Safari'
26
+ chrome: '/Applications/Google Chrome.app/Contents/MacOS/Google Chrome'
27
+
28
+ host: 'test.host'
29
+ #port_start: 3000
30
+ #port_end: 3005
31
+ #base_url_path: '/'
32
+ #max_browser_duration: 120
33
+ #multi_window: false
34
+
35
+ #result_dir: 'c:\result' # the directory where the results will be stored after a test:acceptance run
36
+
37
+ #fixtures_path: <%= "#{RAILS_ROOT}/spec/fixtures" %>
38
+ #selenium_tests_path: <%= "#{RAILS_ROOT}/spec/selenium" %>
@@ -23,8 +23,14 @@ module Bricks
23
23
  end
24
24
  end
25
25
  when 'adapter'
26
- config = YAML.load_file(File.join(RAILS_ROOT, 'config', 'database.yml'))
27
- adapter = config[RAILS_ENV]['adapter']
26
+ db_config = File.join(RAILS_ROOT, 'config', 'database.yml')
27
+ if File.exist?(db_config)
28
+ config = YAML.load_file(db_config)
29
+ adapter = config[RAILS_ENV]['adapter']
30
+ else
31
+ puts "No config/database.yml file, using 'mysql' as adapter to validate bricks"
32
+ adapter = 'mysql'
33
+ end
28
34
  unless v.split(',').map(&:strip).include?(adapter)
29
35
  errors << "'#{adapter}' not supported"
30
36
  end
@@ -115,7 +115,8 @@ module Zena
115
115
  N_('Sunday')
116
116
 
117
117
  N_('datetime') # Same as %Y-%m-%d %H:%M
118
- N_('%Y-%m-%d %H:%M')
118
+ N_(Zena::Use::Dates::DATETIME)
119
+ N_('%Y-%m-%d %H:%M') # marked as not needed if we use the above constant...
119
120
  N_('news_date') # calendar day (event list view)
120
121
 
121
122
  N_('Mon')
data/lib/tasks/zena.rake CHANGED
@@ -441,6 +441,11 @@ namespace :zena do
441
441
  end
442
442
  Rake::Task['zena:test'].comment = "Run the tests in test/helpers and test/unit"
443
443
 
444
+ desc 'Start server for Selenium testing'
445
+ task :test_server => ["zena:test:prepare", "zena:build_fixtures"] do
446
+ exec('script/server -e test')
447
+ end
448
+
444
449
  desc 'Analyse code coverage by tests (needs rcov)'
445
450
  task :coverage do
446
451
  cmd = "rcov -I 'lib:test' --rails --exclude 'var/*,gems/*,/Library/*'"
data/lib/zena/app.rb CHANGED
@@ -61,6 +61,18 @@ module Zena
61
61
  include mod
62
62
  end
63
63
  end
64
+
65
+ ::Site.class_eval do
66
+ Zena::Use.each_module_for('Site') do |mod|
67
+ include mod
68
+ end
69
+ end
70
+
71
+ ::Skin.class_eval do
72
+ Zena::Use.each_module_for('Skin') do |mod|
73
+ include mod
74
+ end
75
+ end
64
76
  end
65
77
  end
66
78
  end
data/lib/zena/console.rb CHANGED
@@ -15,7 +15,13 @@ module Zena
15
15
  end
16
16
  end
17
17
 
18
+ # FIXME: DOCUMENT
19
+ def create(attrs)
20
+ secure(Node) { Node.create_node(Node.transform_attributes(attrs)) }
21
+ end
22
+
18
23
  def rename_prop(list, old_key, new_key)
24
+ list = find(list) if list.kind_of?(String)
19
25
  if list.first.kind_of?(Node)
20
26
  list = list.map(&:visible_versions).flatten
21
27
  end
@@ -32,6 +38,7 @@ module Zena
32
38
  end
33
39
 
34
40
  def field_to_prop(list, native_key, prop_key)
41
+ list = find(list) if list.kind_of?(String)
35
42
  list.each do |rec|
36
43
  next unless value = rec[native_key]
37
44
  if rec.kind_of?(Node)
@@ -48,6 +55,7 @@ module Zena
48
55
  end
49
56
 
50
57
  def set_prop(list, key, value)
58
+ list = find(list) if list.kind_of?(String)
51
59
  list.each do |rec|
52
60
  if rec.kind_of?(Node)
53
61
  elems = rec.visible_versions
@@ -100,7 +108,7 @@ module Zena
100
108
  if count_or_query.kind_of?(Hash)
101
109
  query = count_or_query
102
110
  elsif count_or_query.kind_of?(Fixnum)
103
- query = {:qb => "node in site where id = #{count_or_query}", :_find => :first}
111
+ query = {:qb => "node where id = #{count_or_query} in site", :_find => :first}
104
112
  elsif pseudo_sql.nil?
105
113
  query = {:qb => count_or_query}
106
114
  else
@@ -16,9 +16,9 @@ class String
16
16
  ALLOWED_CHARS_IN_URL = " a-zA-Z0-9\\."
17
17
  # in filename, allow '-' and '_' because it does not represent a space and we do
18
18
  # not have the mode confusion thing.
19
- ALLOWED_CHARS_IN_FILENAME = "#{ALLOWED_CHARS_IN_URL}_\\-"
19
+ ALLOWED_CHARS_IN_FILENAME = "#{ALLOWED_CHARS_IN_URL}_\\-\\+$"
20
20
  # Everything apart from a-zA-Z0-9_.-/$ are not allowed in template paths
21
- ALLOWED_CHARS_IN_FILEPATH = "#{ALLOWED_CHARS_IN_FILENAME}+/$"
21
+ ALLOWED_CHARS_IN_FILEPATH = "#{ALLOWED_CHARS_IN_FILENAME}/"
22
22
  TO_FILENAME_REGEXP = %r{([^ #{ALLOWED_CHARS_IN_FILENAME}]+)}n
23
23
  TO_URL_NAME_REGEXP = %r{([^ #{ALLOWED_CHARS_IN_URL}])}
24
24
 
@@ -29,6 +29,11 @@ class String
29
29
  end.tr(' ', '-')
30
30
  end
31
31
 
32
+ # Change a string into something that can be inserted in an url.
33
+ def urlencode
34
+ URI.escape(self)
35
+ end
36
+
32
37
  # Retrieve original title from an url_name
33
38
  def self.from_url_name(str)
34
39
  CGI.unescape(str.tr('-', ' '))
data/lib/zena/deploy.rb CHANGED
@@ -27,7 +27,6 @@ require 'erb'
27
27
  require File.join(File.dirname(__FILE__), 'info')
28
28
  require File.join(File.dirname(__FILE__), '..', 'bricks')
29
29
 
30
-
31
30
  Capistrano::Configuration.instance(:must_exist).load do
32
31
 
33
32
  set :templates, File.join(File.dirname(__FILE__), 'deploy')
@@ -196,6 +195,10 @@ Capistrano::Configuration.instance(:must_exist).load do
196
195
  vhost = render("#{templates}/vhost.rhtml", :config => self)
197
196
  put(vhost, "#{vhost_root}/#{self[:host]}")
198
197
 
198
+ # directory setup for log
199
+ run "test -e #{sites_root}/#{self[:host]}/log || mkdir #{sites_root}/#{self[:host]}/log"
200
+ run "chown www-data:www-data #{sites_root}/#{self[:host]}/log"
201
+
199
202
  run "test -e /etc/apache2/sites-enabled/#{self[:host]} || a2ensite #{self[:host]}" if debian_host
200
203
 
201
204
  unless self[:host] =~ /^www/
@@ -297,10 +300,6 @@ Capistrano::Configuration.instance(:must_exist).load do
297
300
 
298
301
  desc "Apache2 initial setup"
299
302
  task :apache2_setup, :roles => :web do
300
- # TODO: can we move this into the mongrel brick?
301
- if self[:mongrel_port]
302
- self[:ports] = (mongrel_port.to_i...(mongrel_port.to_i + mongrel_count.to_i)).to_a
303
- end
304
303
  httpd_conf = render("#{templates}/httpd.rhtml", :config => self)
305
304
  log_rotate = render("#{templates}/logrotate_app.rhtml", :config => self)
306
305
  if debian_host
@@ -384,6 +383,61 @@ Capistrano::Configuration.instance(:must_exist).load do
384
383
  end
385
384
  end # db
386
385
 
386
+ #========================== INIT (start/stop init scripts) ===============================#
387
+
388
+ namespace :debian do
389
+
390
+ desc "create Start/stop scripts and installs rc.d defaults"
391
+ task :setup, :roles => :app do
392
+ unless debian_host
393
+ puts "skipping 'logrotate' (debian specific)"
394
+ else
395
+ # Create /usr/local/bin/zena_[app] script
396
+ app_init = render("#{templates}/app_init.rhtml", :config => self)
397
+ put(app_init, "/usr/local/bin/zena_#{db_name}")
398
+ run "chmod 700 /usr/local/bin/zena_#{db_name}"
399
+ if db_name == 'zena'
400
+ init_name = 'zapp'
401
+ else
402
+ init_name = db_name
403
+ end
404
+ run "cd /usr/local/bin && test -e /usr/local/bin/#{init_name} || ln -sf /usr/local/bin/zena_#{db_name} /usr/local/bin/#{init_name}"
405
+
406
+ if self[:rvm_ruby_string]
407
+ run "rvm wrapper #{self[:rvm_ruby_string]} init zena_#{db_name}"
408
+ init_script = "/usr/local/rvm/bin/init_zena_#{db_name}"
409
+ else
410
+ init_script = "/usr/local/bin/zena_#{db_name}"
411
+ end
412
+
413
+ start_stop = render("#{templates}/start_stop.rhtml", :config => self, :init_script => init_script)
414
+ put(start_stop, "/etc/init.d/zena_#{db_name}")
415
+ run "chmod 755 /etc/init.d/zena_#{db_name}"
416
+ # Install defaults
417
+ run "cd /etc/init.d && update-rc.d zena_#{db_name} defaults"
418
+ end
419
+ end
420
+
421
+ # FIXME: We now have the on_stop, on_start callbacks that do not handle haproxy and the
422
+ # init script which is some sort of hack but useful on the server... A better solution
423
+ # would be to use a directory config/start and config/stop with scripts that are run on
424
+ # start/stop/restart.... Then each service just writes what it needs there and that's it.
425
+ desc "Use init script to start all services"
426
+ task :restart, :roles => :app do
427
+ run "/usr/local/bin/zena_#{db_name} start"
428
+ end
429
+
430
+ desc "Use init script to stop all services"
431
+ task :stop, :roles => :app do
432
+ run "/usr/local/bin/zena_#{db_name} stop"
433
+ end
434
+
435
+ desc "Use init script to restart all services"
436
+ task :start, :roles => :app do
437
+ run "/usr/local/bin/zena_#{db_name} restart"
438
+ end
439
+ end # debian
440
+
387
441
  # Would need to be fixed before being used
388
442
  #
389
443
  # desc "Get backup file back"
@@ -457,5 +511,5 @@ Capistrano::Configuration.instance(:must_exist).load do
457
511
  app.stop
458
512
  end
459
513
 
460
- end # mongrel/deploy
514
+ end # deploy
461
515
  end
@@ -0,0 +1,56 @@
1
+ #!/usr/bin/env ruby
2
+ #
3
+ # Zena Startup script (automatically generated by 'cap debian:app_setup')
4
+ #
5
+ # chkconfig: - 85 15
6
+ # description: zena_<%= config[:db_name] %> starts and stop services for <%= config[:db_name] %> Zena application.
7
+ #
8
+ ROOT = "<%= config[:deploy_to] %>"
9
+ APP_ROOT = "#{ROOT}/current"
10
+
11
+ cmd = ARGV.first
12
+
13
+ def run(cmd)
14
+ puts cmd
15
+ system(cmd)
16
+ end
17
+
18
+ operations = [
19
+ 'ruby lib/upload_progress_server.rb ',
20
+ 'rake worker:',
21
+ <% if config[:app_type] == :mongrel %>
22
+ 'mongrel_rails cluster::',
23
+ <% end %>
24
+ ]
25
+
26
+ if %w{stop restart}.include?(cmd)
27
+ puts "Stopping #{APP_ROOT}..."
28
+ operations.each do |op|
29
+ run "cd #{APP_ROOT} && #{op}stop"
30
+ end
31
+
32
+ <% if config[:haproxy_port] %>
33
+ # Stop haproxy
34
+ pid_file = "#{ROOT}/shared/pids/haproxy.pid"
35
+ if File.exist?(pid_file) && pid = File.read("#{ROOT}/shared/pids/haproxy.pid")
36
+ run "kill #{pid}"
37
+ end
38
+ <% end %>
39
+ end
40
+
41
+ if %w{start restart}.include?(cmd)
42
+ puts "Starting #{APP_ROOT}..."
43
+ operations.each do |op|
44
+ run "cd #{APP_ROOT} && #{op}start"
45
+ end
46
+
47
+ <% if config[:haproxy_port] %>
48
+ # Start haproxy
49
+ run "cd #{APP_ROOT} && haproxy -D -f config/haproxy.cnf"
50
+ <% end %>
51
+ end
52
+
53
+ unless %w{start stop restart}.include?(cmd)
54
+ puts "Usage: zena_<%= config[:db_name] %> {start|stop|restart}"
55
+ exit
56
+ end
@@ -0,0 +1,34 @@
1
+ # Start haproxy with
2
+ # > haproxy -d -f config/haproxy.cnf
3
+
4
+ global
5
+ maxconn 1024
6
+ pidfile <%= config[:deploy_to] %>/shared/pids/haproxy.pid
7
+ log 127.0.0.1 local0 info
8
+
9
+ defaults
10
+ balance roundrobin
11
+ mode http
12
+ retries 3
13
+ option redispatch
14
+ contimeout 300000
15
+ clitimeout 300000
16
+ srvtimeout 300000
17
+
18
+ # [<%= config[:balancer] %>]
19
+ listen <%= config[:balancer] %>_haproxy 127.0.0.1:<%= config[:haproxy_port] %>
20
+ option httplog
21
+ log global
22
+ <% if config[:haproxy_password] %>
23
+ stats enable
24
+ stats uri /_haproxy
25
+ stats auth admin:<%= config[:haproxy_password] %>
26
+ <% end %>
27
+ <% config[:ports].each do |port| %>
28
+ server worker_<%= port %> localhost:<%= port %> check inter 20000 maxconn 1<% end %>
29
+ # [/<%= config[:balancer] %>]
30
+
31
+ # Beware of /etc/apache2/conf.d/<%= config[:balancer] %>
32
+ # <Proxy balancer://<%= config[:balancer] %>>
33
+ # BalancerMember http://127.0.0.1:<%= config[:haproxy_port] %>
34
+ # </Proxy>
@@ -10,10 +10,16 @@ PassengerDefaultUser www-data
10
10
  Order allow,deny
11
11
  Allow from all
12
12
  </Proxy>
13
+ <% if config[:haproxy_port] %>
14
+ <Proxy balancer://<%= config[:balancer] %>>
15
+ BalancerMember http://127.0.0.1:<%= config[:haproxy_port] %>
16
+ </Proxy>
17
+ <% else %>
13
18
  <Proxy balancer://<%= config[:balancer] %>><% config[:ports].each do |port| %>
14
19
  BalancerMember http://127.0.0.1:<%= port %><% end %>
15
20
  </Proxy>
16
21
  <% end %>
22
+ <% end %>
17
23
 
18
24
  <IfModule mod_expires.c>
19
25
  ExpiresActive on
@@ -0,0 +1,35 @@
1
+ #! /bin/sh
2
+ ### BEGIN INIT INFO
3
+ # Provides: zena
4
+ # Required-Start: $remote_fs
5
+ # Required-Stop: $remote_fs
6
+ # Default-Start: 2 3 4 5
7
+ # Default-Stop: 0 1 6
8
+ # Short-Description: launch <%= init_script %>
9
+ ### END INIT INFO
10
+
11
+ # Author: Gaspard Bucher <gaspard@teti.ch>
12
+ #
13
+
14
+ # PATH should only include /usr/* if it runs after the mountnfs.sh script
15
+ PATH=/sbin:/usr/sbin:/bin:/usr/bin:/usr/local/bin
16
+ DESC="Zena server"
17
+
18
+ case "$1" in
19
+ start)
20
+ # launch all services for <%= config[:db_name] %>
21
+ <%= init_script %> start
22
+ ;;
23
+ stop)
24
+ # stop all services for <%= config[:db_name] %>
25
+ <%= init_script %> stop
26
+ ;;
27
+ restart)
28
+ # restart all services for <%= config[:db_name] %>
29
+ <%= init_script %> restart
30
+ ;;
31
+ *)
32
+ echo "Usage: $SCRIPTNAME {start|stop|restart}" >&2
33
+ exit 3
34
+ ;;
35
+ esac
data/lib/zena/info.rb CHANGED
@@ -1,4 +1,4 @@
1
1
  module Zena
2
- VERSION = '1.0.0'
2
+ VERSION = '1.1.0'
3
3
  ROOT = File.expand_path(File.join(File.dirname(__FILE__), '..', '..'))
4
4
  end
@@ -1,4 +1,4 @@
1
- require 'HTTParty'
1
+ require 'httparty'
2
2
 
3
3
  module Zena
4
4
  module Remote
@@ -22,12 +22,16 @@ module Zena
22
22
  Thread.current[:visitor] = site.any_admin
23
23
  end
24
24
 
25
- if nodes = get_nodes
26
- # Register next one (if we are lucky and have many workers, we can parallelize work)
27
- Zena::SiteWorker.perform(site, action, page + 1)
25
+ if page.nil?
26
+ site.send(action)
27
+ else
28
+ if nodes = get_nodes
29
+ # Register next one (if we are lucky and have many workers, we can parallelize work)
30
+ Zena::SiteWorker.perform(site, action, page + 1)
28
31
 
29
- # do action on nodes
30
- site.send(action, nodes, page, page_count)
32
+ # do action on nodes
33
+ site.send(action, nodes, page, page_count)
34
+ end
31
35
  end
32
36
  end
33
37