zena 1.0.0.rc2 → 1.0.0.rc3

Sign up to get free protection for your applications and to get access to all the features.
Files changed (274) hide show
  1. data/History.txt +23 -0
  2. data/README.rdoc +1 -1
  3. data/app/controllers/columns_controller.rb +3 -31
  4. data/app/controllers/comments_controller.rb +8 -3
  5. data/app/controllers/data_entries_controller.rb +1 -1
  6. data/app/controllers/documents_controller.rb +2 -2
  7. data/app/controllers/nodes_controller.rb +29 -12
  8. data/app/controllers/relations_controller.rb +2 -2
  9. data/app/controllers/sites_controller.rb +1 -1
  10. data/app/controllers/user_sessions_controller.rb +6 -3
  11. data/app/controllers/users_controller.rb +18 -16
  12. data/app/controllers/versions_controller.rb +20 -18
  13. data/app/controllers/virtual_classes_controller.rb +103 -17
  14. data/app/helpers/users_helper.rb +1 -1
  15. data/app/models/column.rb +19 -50
  16. data/app/models/comment.rb +2 -1
  17. data/app/models/node.rb +45 -22
  18. data/app/models/relation.rb +13 -0
  19. data/app/models/relation_proxy.rb +3 -2
  20. data/app/models/role.rb +213 -4
  21. data/app/models/site.rb +18 -11
  22. data/app/models/template.rb +37 -35
  23. data/app/models/version.rb +1 -1
  24. data/app/models/virtual_class.rb +154 -86
  25. data/app/views/columns/_li.html.erb +1 -1
  26. data/app/views/columns/index.html.erb +1 -9
  27. data/app/views/comments/index.rhtml +10 -8
  28. data/app/views/documents/_crop.rhtml +5 -6
  29. data/app/views/documents/crop_form.rjs +3 -2
  30. data/app/views/groups/index.rhtml +1 -1
  31. data/app/views/iformats/index.rhtml +1 -1
  32. data/app/views/nodes/_import_results.rhtml +1 -1
  33. data/app/views/nodes/_parent.rhtml +1 -2
  34. data/app/views/nodes/update.rjs +3 -4
  35. data/app/views/relations/index.erb +1 -1
  36. data/app/views/sites/index.erb +1 -1
  37. data/app/views/templates/drive_tabs/_drive.rhtml +0 -2
  38. data/app/views/templates/edit_tabs/_image.rhtml +1 -1
  39. data/app/views/templates/edit_tabs/_title.rhtml +0 -6
  40. data/app/views/users/index.rhtml +1 -1
  41. data/app/views/users/preferences.html.erb +2 -2
  42. data/app/views/versions/backup.rjs +1 -1
  43. data/app/views/versions/custom_tab.rhtml +9 -4
  44. data/app/views/versions/destroy.rjs +2 -2
  45. data/app/views/versions/update.rjs +2 -9
  46. data/app/views/virtual_classes/_form.erb +3 -2
  47. data/app/views/virtual_classes/import_prepare.html.erb +13 -0
  48. data/app/views/virtual_classes/index.erb +28 -8
  49. data/app/views/zafu/default/Node-+adminLayout.zafu +1 -13
  50. data/app/views/zafu/default/Node-+login.zafu +1 -0
  51. data/app/views/zafu/default/Node-+notFound.zafu +1 -1
  52. data/app/views/zafu/default/Node-+popupLayout.zafu +1 -2
  53. data/app/views/zafu/default/Node-+search.zafu +1 -1
  54. data/app/views/zafu/default/Node-admin.zafu +205 -0
  55. data/app/views/zafu/default/Node.zafu +11 -11
  56. data/bricks/captcha/lib/bricks/captcha.rb +3 -2
  57. data/bricks/mongrel/zena/init.rb +2 -1
  58. data/bricks/pdf/README +5 -5
  59. data/bricks/pdf/lib/bricks/pdf/engine/prince.rb +2 -2
  60. data/bricks/pdf/lib/bricks/pdf/engine/xhtml2pdf.rb +2 -2
  61. data/bricks/pdf/lib/bricks/pdf/install.rb +5 -5
  62. data/bricks/pdf/lib/bricks/pdf.rb +11 -11
  63. data/bricks/pdf/test/engines/test_prince.rb +4 -4
  64. data/bricks/pdf/test/engines/test_xhtml2pdf.rb +4 -4
  65. data/bricks/pdf/test/shoulda_macros/shoulda_pdf.rb +2 -2
  66. data/bricks/pdf/zena/init.rb +2 -2
  67. data/bricks/pdf/zena/tasks.rb +2 -2
  68. data/bricks/sphinx/lib/bricks/sphinx.rb +6 -2
  69. data/bricks/sphinx/zena/{sphinx.yml → sphinx.yml.erb} +2 -2
  70. data/bricks/sphinx/zena/tasks.rb +28 -2
  71. data/bricks/tags/lib/bricks/tags.rb +16 -1
  72. data/bricks/tags/zena/test/unit/tags_test.rb +15 -0
  73. data/bricks/tags/zena/test/zafu/tags.yml +5 -1
  74. data/bricks/worker/lib/bricks/worker.rb +39 -0
  75. data/bricks/worker/zena/deploy.rb +0 -2
  76. data/bricks/worker/zena/init.rb +1 -0
  77. data/bricks/worker/zena/test/sites/zena/delayed_jobs.yml +16 -0
  78. data/bricks/worker/zena/test/zafu/worker.yml +8 -0
  79. data/bricks/zena/zena/migrate/01_base.rb +36 -60
  80. data/bricks/zena/zena/migrate/02_zerox1_schema.rb +388 -0
  81. data/bricks/zena/zena/migrate/03_zerox1_data.rb +380 -0
  82. data/bricks/zena/zena/migrate/20110315161158_add_reverse_scope_to_roles.rb +9 -0
  83. data/config/database_example.yml +1 -1
  84. data/config/environment.rb +1 -1
  85. data/config/gems.yml +17 -14
  86. data/db/init/base/skins/default/Node-+index.zafu +8 -1
  87. data/db/init/base/skins/default/Node-+login.zafu +1 -0
  88. data/db/init/base/skins/default/Node-+popupLayout.zafu +1 -2
  89. data/db/init/base/skins/default/Node-+search.zafu +2 -2
  90. data/db/init/base/skins/default/Node.zafu +9 -9
  91. data/db/init/base/skins/default/{favicon.png → img/favicon.png} +0 -0
  92. data/db/init/base/skins/default/{style.css → img/style.css} +0 -0
  93. data/db/init/base/skins/default/img/translations.yml +11 -0
  94. data/db/init/base/skins/default/notes.zafu +7 -9
  95. data/doc/zafu_changes.yml +12 -0
  96. data/lib/bricks/loader.rb +38 -15
  97. data/lib/tasks/zena.rake +74 -24
  98. data/lib/zena/acts/enrollable.rb +4 -1
  99. data/lib/zena/acts/secure.rb +2 -48
  100. data/lib/zena/acts/serializable.rb +13 -1
  101. data/lib/zena/app.rb +9 -0
  102. data/lib/zena/code_syntax.rb +154 -151
  103. data/lib/zena/console.rb +141 -0
  104. data/lib/zena/controller/test_case.rb +1 -1
  105. data/lib/zena/db_helper/abstract_db.rb +17 -5
  106. data/lib/zena/db_helper/mysql.rb +14 -12
  107. data/lib/zena/db_helper/postgresql.rb +1 -2
  108. data/lib/zena/db_helper/sqlite3.rb +6 -6
  109. data/lib/zena/deploy/awstats.conf.rhtml +1 -1
  110. data/lib/zena/deploy/httpd.rhtml +6 -1
  111. data/lib/zena/deploy/vhost.rhtml +9 -1
  112. data/lib/zena/deploy.rb +12 -7
  113. data/lib/zena/foxy_parser.rb +3 -1
  114. data/lib/zena/info.rb +1 -1
  115. data/lib/zena/parser/zafu_tags.rb +1 -0
  116. data/lib/zena/parser/zazen_rules.rb +1 -1
  117. data/lib/zena/remote/node.rb +15 -3
  118. data/lib/zena/remote/serializable_array.rb +19 -0
  119. data/lib/zena/remote.rb +1 -0
  120. data/lib/zena/routes.rb +7 -2
  121. data/lib/zena/site_worker.rb +11 -1
  122. data/lib/zena/unit/test_case.rb +68 -0
  123. data/lib/zena/use/action.rb +6 -2
  124. data/lib/zena/use/ajax.rb +127 -53
  125. data/lib/zena/use/ancestry.rb +11 -8
  126. data/lib/zena/use/calendar.rb +265 -129
  127. data/lib/zena/use/conditional.rb +1 -1
  128. data/lib/zena/use/context.rb +5 -5
  129. data/lib/zena/use/dates.rb +172 -60
  130. data/lib/zena/use/display.rb +70 -39
  131. data/lib/zena/use/error_rendering.rb +1 -3
  132. data/lib/zena/use/field_index.rb +4 -1
  133. data/lib/zena/use/forms.rb +94 -72
  134. data/lib/zena/use/fulltext.rb +16 -24
  135. data/lib/zena/use/html_tags.rb +20 -12
  136. data/lib/zena/use/i18n.rb +37 -37
  137. data/lib/zena/use/image_builder.rb +8 -1
  138. data/lib/zena/use/ml_index.rb +16 -16
  139. data/lib/zena/use/prop_eval.rb +10 -5
  140. data/lib/zena/use/query_builder.rb +55 -23
  141. data/lib/zena/use/query_node.rb +51 -25
  142. data/lib/zena/use/refactor.rb +2 -28
  143. data/lib/zena/use/relations.rb +1 -1
  144. data/lib/zena/use/rendering.rb +29 -0
  145. data/lib/zena/use/scope_index.rb +75 -14
  146. data/lib/zena/use/search.rb +5 -10
  147. data/lib/zena/use/test_helper.rb +2 -2
  148. data/lib/zena/use/urls.rb +125 -104
  149. data/lib/zena/use/workflow.rb +2 -1
  150. data/lib/zena/use/zafu_attributes.rb +2 -2
  151. data/lib/zena/use/zafu_safe_definitions.rb +20 -0
  152. data/lib/zena/use/zafu_templates.rb +20 -6
  153. data/lib/zena/use/zazen.rb +31 -20
  154. data/lib/zena/view/test_case.rb +5 -0
  155. data/lib/zena/zafu_compiler.rb +24 -2
  156. data/lib/zena.rb +12 -6
  157. data/locale/de/LC_MESSAGES/zena.mo +0 -0
  158. data/locale/de/zena.po +1345 -1164
  159. data/locale/en/LC_MESSAGES/zena.mo +0 -0
  160. data/locale/en/zena.po +1275 -1129
  161. data/locale/fr/LC_MESSAGES/zena.mo +0 -0
  162. data/locale/fr/zena.mo +0 -0
  163. data/locale/fr/zena.po +1617 -1441
  164. data/locale/log.txt +9 -0
  165. data/locale/zena.pot +957 -748
  166. data/public/javascripts/prototype.js +1 -1
  167. data/public/javascripts/zena.js +99 -44
  168. data/public/stylesheets/admin.css +6 -4
  169. data/public/stylesheets/backend.css +71 -0
  170. data/public/stylesheets/calendar.css +24 -25
  171. data/public/stylesheets/code.css +11 -6
  172. data/public/stylesheets/comment.css +2 -1
  173. data/public/stylesheets/popup.css +7 -8
  174. data/test/custom_queries/complex.host.yml +15 -1
  175. data/test/fixtures/files/Node-test.zafu +29 -28
  176. data/test/fixtures/files/translations_de.yml +12 -1
  177. data/test/fixtures/files/translations_fr.yml +12 -1
  178. data/test/functional/comments_controller_test.rb +9 -0
  179. data/test/functional/iformats_controller_test.rb +1 -1
  180. data/test/functional/nodes_controller_test.rb +124 -35
  181. data/test/functional/users_controller_test.rb +132 -3
  182. data/test/functional/virtual_classes_controller_test.rb +75 -4
  183. data/test/integration/navigation_test.rb +51 -9
  184. data/test/integration/query_node/basic.yml +19 -7
  185. data/test/integration/query_node/complex.yml +1 -1
  186. data/test/integration/query_node/dates.yml +27 -1
  187. data/test/integration/query_node/filters.yml +1 -1
  188. data/test/integration/query_node/relations.yml +13 -4
  189. data/test/integration/query_node_test.rb +4 -0
  190. data/test/integration/xml_api_test.rb +6 -1
  191. data/test/integration/zafu_compiler/action.yml +3 -3
  192. data/test/integration/zafu_compiler/ajax.yml +103 -22
  193. data/test/integration/zafu_compiler/basic.yml +0 -52
  194. data/test/integration/zafu_compiler/calendar.yml +44 -20
  195. data/test/integration/zafu_compiler/comments.yml +53 -0
  196. data/test/integration/zafu_compiler/complex.yml +11 -11
  197. data/test/integration/zafu_compiler/complex_ok.yml +16 -3
  198. data/test/integration/zafu_compiler/conditional.yml +15 -5
  199. data/test/integration/zafu_compiler/context.yml +9 -0
  200. data/test/integration/zafu_compiler/dates.yml +43 -15
  201. data/test/integration/zafu_compiler/display.yml +60 -6
  202. data/test/integration/zafu_compiler/errors.yml +6 -2
  203. data/test/integration/zafu_compiler/forms.yml +45 -6
  204. data/test/integration/zafu_compiler/i18n.yml +8 -1
  205. data/test/integration/zafu_compiler/meta.yml +38 -0
  206. data/test/integration/zafu_compiler/query.yml +43 -4
  207. data/test/integration/zafu_compiler/relations.yml +26 -33
  208. data/test/integration/zafu_compiler/rubyless.yml +10 -0
  209. data/test/integration/zafu_compiler/safe_definitions.yml +21 -1
  210. data/test/integration/zafu_compiler/urls.yml +75 -5
  211. data/test/integration/zafu_compiler/version.yml +2 -2
  212. data/test/integration/zafu_compiler/zafu_attributes.yml +5 -1
  213. data/test/integration/zafu_compiler/zazen.yml +14 -6
  214. data/test/integration/zafu_compiler_test.rb +5 -1
  215. data/test/sites/complex/columns.yml +5 -0
  216. data/test/sites/complex/roles.yml +4 -0
  217. data/test/sites/zena/nodes.yml +13 -2
  218. data/test/sites/zena/roles.yml +13 -5
  219. data/test/sites/zena/versions.yml +27 -9
  220. data/test/unit/column_test.rb +51 -5
  221. data/test/unit/iformat_test.rb +2 -2
  222. data/test/unit/node_test.rb +29 -17
  223. data/test/unit/note_test.rb +1 -1
  224. data/test/unit/relation_proxy_test.rb +4 -5
  225. data/test/unit/relation_test.rb +16 -0
  226. data/test/unit/remote_test.rb +2 -2
  227. data/test/unit/role_test.rb +292 -4
  228. data/test/unit/site_test.rb +12 -0
  229. data/test/unit/template_test.rb +1 -1
  230. data/test/unit/text_document_test.rb +1 -1
  231. data/test/unit/virtual_class_test.rb +200 -83
  232. data/test/unit/zena/acts/enrollable_test.rb +26 -31
  233. data/test/unit/zena/use/calendar_test.rb +90 -37
  234. data/test/unit/zena/use/field_index_test.rb +28 -0
  235. data/test/unit/zena/use/html_tags_test.rb +7 -3
  236. data/test/unit/zena/use/ml_index_test.rb +2 -16
  237. data/test/unit/zena/use/nested_attributes_alias_view_test.rb +2 -2
  238. data/test/unit/zena/use/prop_eval_test.rb +50 -8
  239. data/test/unit/zena/use/query_node_test.rb +11 -0
  240. data/test/unit/zena/use/rendering_test.rb +72 -0
  241. data/test/unit/zena/use/scope_index_test.rb +37 -2
  242. data/test/unit/zena/use/urls_test.rb +10 -0
  243. data/test/unit/zena/use/zazen_test.rb +3 -3
  244. data/vendor/plugins/gettext_i18n_rails/Gemfile +11 -0
  245. data/vendor/plugins/gettext_i18n_rails/Gemfile.lock +92 -0
  246. data/vendor/plugins/gettext_i18n_rails/Rakefile +12 -17
  247. data/vendor/plugins/gettext_i18n_rails/Readme.md +215 -0
  248. data/vendor/plugins/gettext_i18n_rails/VERSION +1 -1
  249. data/vendor/plugins/gettext_i18n_rails/gettext_i18n_rails.gemspec +38 -34
  250. data/vendor/plugins/gettext_i18n_rails/lib/gettext_i18n_rails/active_record.rb +1 -1
  251. data/vendor/plugins/gettext_i18n_rails/lib/gettext_i18n_rails/backend.rb +30 -14
  252. data/vendor/plugins/gettext_i18n_rails/lib/gettext_i18n_rails/haml_parser.rb +1 -1
  253. data/vendor/plugins/gettext_i18n_rails/lib/gettext_i18n_rails/html_safe_translations.rb +29 -0
  254. data/vendor/plugins/gettext_i18n_rails/lib/gettext_i18n_rails/i18n_hacks.rb +29 -1
  255. data/vendor/plugins/gettext_i18n_rails/lib/gettext_i18n_rails/model_attributes_finder.rb +7 -1
  256. data/vendor/plugins/gettext_i18n_rails/lib/gettext_i18n_rails/railtie.rb +10 -0
  257. data/vendor/plugins/gettext_i18n_rails/lib/gettext_i18n_rails/ruby_gettext_extractor.rb +6 -2
  258. data/vendor/plugins/gettext_i18n_rails/lib/gettext_i18n_rails/string_interpolate_fix.rb +20 -0
  259. data/vendor/plugins/gettext_i18n_rails/lib/gettext_i18n_rails/tasks.rb +120 -0
  260. data/vendor/plugins/gettext_i18n_rails/lib/gettext_i18n_rails.rb +10 -3
  261. data/vendor/plugins/gettext_i18n_rails/lib/tasks/gettext_rails_i18n.rake +1 -74
  262. data/vendor/plugins/gettext_i18n_rails/spec/gettext_i18n_rails/active_record_spec.rb +51 -20
  263. data/vendor/plugins/gettext_i18n_rails/spec/gettext_i18n_rails/backend_spec.rb +12 -7
  264. data/vendor/plugins/gettext_i18n_rails/spec/gettext_i18n_rails/string_interpolate_fix_spec.rb +32 -0
  265. data/vendor/plugins/gettext_i18n_rails/spec/gettext_i18n_rails_spec.rb +38 -1
  266. data/vendor/plugins/gettext_i18n_rails/spec/rails2/Gemfile +11 -0
  267. data/vendor/plugins/gettext_i18n_rails/spec/spec_helper.rb +1 -8
  268. data/zena.gemspec +2241 -2217
  269. metadata +123 -83
  270. data/.gitignore +0 -36
  271. data/app/views/nodes/_dates.rhtml +0 -13
  272. data/db/init/base/skins/default/Node-+adminLayout.zafu +0 -46
  273. data/db/init/base/skins/default/Node-tree.zafu +0 -19
  274. data/vendor/plugins/gettext_i18n_rails/README.markdown +0 -143
@@ -2,7 +2,9 @@ require 'rubygems'
2
2
  require 'syntax/convertors/html'
3
3
  require 'syntax/lang/xml'
4
4
  require 'syntax/lang/ruby'
5
+ require 'syntax/lang/yaml'
5
6
  require 'syntax'
7
+ require 'redcloth'
6
8
 
7
9
  module Zena
8
10
  class CodeSyntax
@@ -128,172 +130,173 @@ module Syntax
128
130
  end
129
131
  end
130
132
  end # Convertors
131
- end # CodeSyntax
132
133
 
133
- class ZafuTokenizer < Syntax::Tokenizer
134
- def step
135
- if ztag = scan(/\A<\/?r:[^>]+>/)
136
- ztag =~ /<(\/?)r:([\w_]+)([^>]*?)(\/?)>/
137
- start_group :tag, "<#{$1}r:"
138
- start_group :ztag, $2
139
- trailing = $4
140
- params = parse_params($3)
141
- params.each do |k,v|
142
- append " "
143
- if v =~ /[^\\]'/
144
- v = "\"#{v}\""
145
- else
146
- v = "'#{v}'"
134
+ class ZafuTokenizer < Tokenizer
135
+ METHOD = "[\\w]+\\??"
136
+ def step
137
+ if ztag = scan(/\A<\/?r:[^>]+>/)
138
+ ztag =~ /<(\/?)r:(#{METHOD})([^>]*?)(\/?)>/
139
+ start_group :tag, "<#{$1}r:"
140
+ start_group :ztag, $2
141
+ trailing = $4
142
+ params = parse_params($3)
143
+ params.each do |k,v|
144
+ append " "
145
+ if v =~ /[^\\]'/
146
+ v = "\"#{v}\""
147
+ else
148
+ v = "'#{v}'"
149
+ end
150
+ start_group :param, k.to_s
151
+ append '='
152
+ start_group :value, v
147
153
  end
148
- start_group :param, k.to_s
149
- append '='
150
- start_group :value, v
151
- end
152
- start_group :tag, "#{trailing}>"
153
- elsif dotag = scan(/<(\w+)([^>]*?)do\s*=('|")([^\3]*?[^\\])\3([^>]*?)(\/?)>/)
154
- if dotag =~ /\A<(\w+)([^>]*?)do\s*=('|")([^\3]*?[^\\])\3([^>]*?)(\/?)>/
155
- start_group :tag, "<#{$1}#{$2}"
156
- start_group :tag, "do="
157
- start_group :ztag, "'#{$4}'"
158
- trailing = $6
159
- params = parse_params($5)
160
- params.each do |k,v|
161
- append " "
162
- if v =~ /[^\\]'/
163
- v = "\"#{v}\""
164
- else
165
- v = "'#{v}'"
166
- end
167
- if k == :do
168
- start_group :tag, k.to_s
169
- append '='
170
- start_group :ztag, v
171
- else
172
- start_group :param, k.to_s
173
- append '='
174
- start_group :value, v
154
+ start_group :tag, "#{trailing}>"
155
+ elsif dotag = scan(/<(\w+)([^>]*?)do\s*=('|")([^\3]*?[^\\])\3([^>]*?)(\/?)>/)
156
+ if dotag =~ /\A<(\w+)([^>]*?)do\s*=('|")([^\3]*?[^\\])\3([^>]*?)(\/?)>/
157
+ start_group :tag, "<#{$1}#{$2}"
158
+ start_group :tag, "do="
159
+ start_group :ztag, "'#{$4}'"
160
+ trailing = $6
161
+ params = parse_params($5)
162
+ params.each do |k,v|
163
+ append " "
164
+ if v =~ /[^\\]'/
165
+ v = "\"#{v}\""
166
+ else
167
+ v = "'#{v}'"
168
+ end
169
+ if k == :do
170
+ start_group :tag, k.to_s
171
+ append '='
172
+ start_group :ztag, v
173
+ else
174
+ start_group :param, k.to_s
175
+ append '='
176
+ start_group :value, v
177
+ end
175
178
  end
179
+ start_group :tag, "#{trailing}>"
180
+ else
181
+ start_group :normal, dotag
176
182
  end
177
- start_group :tag, "#{trailing}>"
178
- else
179
- start_group :normal, dotag
180
- end
181
- elsif html = scan(/\A<\/?[^>]+>/)
182
- html =~/<\/?([^>]+)>/
183
- start_group :tag, html
184
- else
185
- start_group :normal, scan(/./m)
183
+ elsif html = scan(/\A<\/?[^>]+>/)
184
+ html =~/<\/?([^>]+)>/
185
+ start_group :tag, html
186
+ else
187
+ start_group :normal, scan(/./m)
188
+ end
186
189
  end
187
- end
188
- end # ZafuTokenizer
189
- Syntax::SYNTAX['zafu'] = ZafuTokenizer
190
+ end # ZafuTokenizer
191
+ SYNTAX['zafu'] = ZafuTokenizer
190
192
 
191
- class ErbTokenizer < Syntax::Tokenizer
192
- def step
193
- if methods = scan(/<%[^>]+%>/m)
194
- methods =~ /<%(=?)([^>]+?)(-?)%>/m
195
- start_group :punct, "<%#{$1}"
196
- trailing = $3
197
- sub_lang :expr, "<code class='ruby'>#{Syntax::Convertors::HTML.for_syntax('ruby').convert($2, false)}</code>"
198
- start_group :punct, "#{trailing}%>"
199
- elsif html = scan(/<\/?[^>]+>/)
200
- html =~/<\/?([^>]+)>/
201
- start_group :tag, html
202
- else
203
- start_group :normal, scan(/./m)
193
+ class ErbTokenizer < Tokenizer
194
+ def step
195
+ if methods = scan(/<%[^>]+%>/m)
196
+ methods =~ /<%(=?)([^>]+?)(-?)%>/m
197
+ start_group :punct, "<%#{$1}"
198
+ trailing = $3
199
+ sub_lang :expr, "<code class='ruby'>#{Convertors::HTML.for_syntax('ruby').convert($2, false)}</code>"
200
+ start_group :punct, "#{trailing}%>"
201
+ elsif html = scan(/<\/?[^>]+>/)
202
+ html =~/<\/?([^>]+)>/
203
+ start_group :tag, html
204
+ else
205
+ start_group :normal, scan(/./m)
206
+ end
204
207
  end
205
- end
206
- end # ErbTokenizer
207
- Syntax::SYNTAX['erb'] = ErbTokenizer
208
+ end # ErbTokenizer
209
+ SYNTAX['erb'] = ErbTokenizer
208
210
 
209
- class CssTokenizer < Syntax::Tokenizer
210
- def step
211
- if comments = scan(/\s*\/\*.*?\*\/\s*/m)
212
- start_group :comment, comments
213
- elsif variables = scan(/[^\{]*?\{[^\}]*?\}/m)
214
- variables =~ /(\s*)([^\{]*?)\{([^\}]*?)\}/m
215
- start_group :normal, $1
216
- vars = $3
217
- selectors = $2.split(',').map { |s| s.strip }
218
- selectors.each_index do |i|
219
- selectors[i].gsub('.','|.').gsub('#','|#').split('|').each do |g|
220
- g = g.split(' ')
221
- g.each do |s|
222
- if s[0..0] == '#'
223
- start_group :id, s
224
- elsif s[0..0] == '.'
225
- start_group :class, s
226
- else
227
- start_group :tag, s
211
+ class CssTokenizer < Tokenizer
212
+ def step
213
+ if comments = scan(/\s*\/\*.*?\*\/\s*/m)
214
+ start_group :comment, comments
215
+ elsif variables = scan(/[^\{]*?\{[^\}]*?\}/m)
216
+ variables =~ /(\s*)([^\{]*?)\{([^\}]*?)\}/m
217
+ start_group :normal, $1
218
+ vars = $3
219
+ selectors = $2.split(',').map { |s| s.strip }
220
+ selectors.each_index do |i|
221
+ selectors[i].gsub('.','|.').gsub('#','|#').split('|').each do |g|
222
+ g = g.split(' ')
223
+ g.each do |s|
224
+ if s[0..0] == '#'
225
+ start_group :id, s
226
+ elsif s[0..0] == '.'
227
+ start_group :class, s
228
+ else
229
+ start_group :tag, s
230
+ end
231
+ start_group :normal, ' '
228
232
  end
229
- start_group :normal, ' '
233
+ end
234
+ unless i == selectors.size - 1
235
+ start_group :punct, ', '
230
236
  end
231
237
  end
232
- unless i == selectors.size - 1
233
- start_group :punct, ', '
234
- end
235
- end
236
- start_group :punct, '{ '
238
+ start_group :punct, '{ '
237
239
 
238
- rest = vars
239
- while rest != '' && rest =~ /([\w-]+)\s*:\s*(.*?)\s*;(.*)/m
240
- start_group :variable, $1
241
- start_group :punct, ':'
242
- start_group :normal, $2
243
- start_group :punct, '; '
244
- rest = $3
240
+ rest = vars
241
+ while rest != '' && rest =~ /([\w-]+)\s*:\s*(.*?)\s*;(.*)/m
242
+ start_group :variable, $1
243
+ start_group :punct, ':'
244
+ start_group :normal, $2
245
+ start_group :punct, '; '
246
+ rest = $3
247
+ end
248
+ start_group :punct, "#{rest}}"
249
+ else
250
+ start_group :normal, scan(/./m)
245
251
  end
246
- start_group :punct, "#{rest}}"
247
- else
248
- start_group :normal, scan(/./m)
249
252
  end
250
- end
251
- end # CssTokenizer
252
- Syntax::SYNTAX['css'] = CssTokenizer
253
+ end # CssTokenizer
254
+ SYNTAX['css'] = CssTokenizer
253
255
 
254
- class ShTokenizer < Syntax::Tokenizer
255
- def step
256
- if variables = scan(/\$\w+/)
257
- start_group :variable, variables
258
- elsif start = scan(/# \S+/)
259
- start_group :punct, '# '
260
- start_group :method, start[2..-1]
261
- elsif start = scan(/\$ \S+/)
262
- start_group :root, '$ '
263
- start_group :method, start[2..-1]
264
- else
265
- start_group :normal, scan(/./m)
256
+ class ShTokenizer < Tokenizer
257
+ def step
258
+ if variables = scan(/\$\w+/)
259
+ start_group :variable, variables
260
+ elsif start = scan(/# \S+/)
261
+ start_group :punct, '# '
262
+ start_group :method, start[2..-1]
263
+ elsif start = scan(/\$ \S+/)
264
+ start_group :root, '$ '
265
+ start_group :method, start[2..-1]
266
+ else
267
+ start_group :normal, scan(/./m)
268
+ end
266
269
  end
267
- end
268
- end # ShTokenizer
269
- Syntax::SYNTAX['sh'] = ShTokenizer
270
+ end # ShTokenizer
271
+ SYNTAX['sh'] = ShTokenizer
270
272
 
271
- class PseudoSqlTokenizer < Syntax::Tokenizer
272
- def step
273
- if @state.nil? and method = scan(/\w+/)
274
- start_group :method, method
275
- @state = :method
276
- elsif @state == :in and context = scan(/\w+/)
277
- start_group :context, context
278
- @state = :context
279
- elsif keyword = scan(/\bin\b/)
280
- start_group :context, keyword
281
- @state = :in
282
- elsif keyword = scan(/\bfrom\b/)
283
- start_group :sub, keyword
284
- @state = nil
285
- elsif keyword = scan(/\bwhere|group|order|limit|offset|paginate\b/)
286
- start_group :keyword, keyword
287
- elsif punct = scan(/\b>=|<=|<>|<|=|>|not\s+like|like|lt|le|eq|ne|ge|gt\b/)
288
- start_group :punct, punct
289
- elsif string = scan(/("|')[^'"]*\1/)
290
- string =~ /("|')([^'"]*)\1/
291
- start_group :punct, $1
292
- start_group :string, $2
293
- start_group :punct, $1
294
- else
295
- start_group :normal, scan(/./m)
273
+ class PseudoSqlTokenizer < Tokenizer
274
+ def step
275
+ if @state.nil? and method = scan(/\w+/)
276
+ start_group :method, method
277
+ @state = :method
278
+ elsif @state == :in and context = scan(/\w+/)
279
+ start_group :context, context
280
+ @state = :context
281
+ elsif keyword = scan(/\bin\b/)
282
+ start_group :context, keyword
283
+ @state = :in
284
+ elsif keyword = scan(/\bfrom\b/)
285
+ start_group :sub, keyword
286
+ @state = nil
287
+ elsif keyword = scan(/\bwhere|select|group\s+by|having|order|limit|offset|paginate\b/)
288
+ start_group :keyword, keyword
289
+ elsif punct = scan(/\b>=|<=|<>|<|=|>|not\s+like|like|lt|le|eq|ne|ge|gt\b/)
290
+ start_group :punct, punct
291
+ elsif string = scan(/("|')[^'"]*\1/)
292
+ string =~ /("|')([^'"]*)\1/
293
+ start_group :punct, $1
294
+ start_group :string, $2
295
+ start_group :punct, $1
296
+ else
297
+ start_group :normal, scan(/./m)
298
+ end
296
299
  end
297
- end
298
- end # PseudoSqlTokenizer
299
- Syntax::SYNTAX['pseudo_sql'] = PseudoSqlTokenizer
300
+ end # PseudoSqlTokenizer
301
+ SYNTAX['sqliss'] = PseudoSqlTokenizer
302
+ end # Syntax
@@ -0,0 +1,141 @@
1
+ module Zena
2
+ module Console
3
+ include Zena::Acts::Secure
4
+
5
+ def self.included(base)
6
+ if base == Object
7
+ raise %q{You should not include Zena::Console directly in Object. Use this instead: class << self; include Zena::Console; end
8
+ }
9
+ end
10
+ end
11
+
12
+ def err(obj)
13
+ obj.errors.each_error do |er,msg|
14
+ puts "[#{er}] #{msg}"
15
+ end
16
+ end
17
+
18
+ def rename_prop(list, old_key, new_key)
19
+ if list.first.kind_of?(Node)
20
+ list = list.map(&:visible_versions).flatten
21
+ end
22
+ list.each do |rec|
23
+ prop = rec.prop
24
+ if value = prop.delete(old_key)
25
+ prop[new_key] = value
26
+ Zena::Db.execute "UPDATE #{rec.class.table_name} SET properties=#{Zena::Db.quote(rec.class.encode_properties(prop))} WHERE id=#{rec[:id]}"
27
+ end
28
+ end
29
+ end
30
+
31
+ def field_to_prop(list, native_key, prop_key)
32
+ list.each do |rec|
33
+ next unless value = rec[native_key]
34
+ if rec.kind_of?(Node)
35
+ elems = rec.visible_versions
36
+ else
37
+ elems = [rec]
38
+ end
39
+ elems.each do |rec|
40
+ prop = rec.prop
41
+ prop[prop_key] = value
42
+ Zena::Db.execute "UPDATE #{rec.class.table_name} SET properties=#{Zena::Db.quote(rec.class.encode_properties(prop))} WHERE id=#{rec[:id]}"
43
+ end
44
+ end
45
+ end
46
+
47
+ def login(name, host = nil)
48
+ finder = {}
49
+ finder[:conditions] = cond = [[]]
50
+ if host
51
+ finder[:joins] = 'INNER JOIN sites ON sites.id = users.site_id'
52
+ cond.first << 'sites.host = ?'
53
+ cond << host.to_s
54
+ end
55
+
56
+ cond.first << 'users.login = ?'
57
+ cond << name.to_s
58
+ cond[0] = cond.first.join(' AND ')
59
+ if visitor = User.find(:first, finder)
60
+ Thread.current[:visitor] = visitor
61
+ puts "Logged #{visitor.login} in #{visitor.site.host}"
62
+ else
63
+ raise ActiveRecord::RecordNotFound
64
+ end
65
+ rescue ActiveRecord::RecordNotFound
66
+ puts "Could not login with user name: #{name}"
67
+ end
68
+
69
+ def nodes(zip_or_name)
70
+ if zip_or_name.kind_of?(Fixnum)
71
+ secure(Node) { Node.find_by_zip(zip_or_name) }
72
+ else
73
+ secure(Node) { Node.find_by_title(zip_or_name) }
74
+ end
75
+ end
76
+
77
+ def find(query)
78
+ default_scope = 'site'
79
+ query = {:qb => query} unless query.kind_of?(Hash)
80
+ nodes = secure(Node) { Node.search_records(query, :node => current_site.root_node, :default => {:scope => default_scope}) }
81
+ end
82
+
83
+ def count(pseudo_sql, opts = {})
84
+ node = opts.delete(:node) || current_site.root_node
85
+ options = {:errors => true, :rubyless_helper => self, :default => {:scope => 'site'}}
86
+
87
+ count = node.find(:count, pseudo_sql, options)
88
+
89
+ if count.kind_of?(::QueryBuilder::Error)
90
+ puts "Error parsing query #{pseudo_sql.inspect} (#{count.message})"
91
+ return nil
92
+ else
93
+ return count
94
+ end
95
+ end
96
+
97
+ def foreach(pseudo_sql, opts = {})
98
+ limit = 100
99
+
100
+ return nil unless block_given?
101
+ node = opts.delete(:node) || current_site.root_node
102
+ options = {:errors => true, :rubyless_helper => self, :default => {:scope => 'site'}}
103
+
104
+ count = node.find(:count, pseudo_sql, options)
105
+
106
+ if count.kind_of?(::QueryBuilder::Error)
107
+ puts "Error parsing query #{pseudo_sql.inspect} (#{count.message})"
108
+ return nil
109
+ end
110
+
111
+ begin
112
+ query = Node.build_query(:all, pseudo_sql,
113
+ :node_name => 'self',
114
+ :main_class => VirtualClass['Node'],
115
+ :rubyless_helper => self,
116
+ :default => options[:default]
117
+ )
118
+ rescue ::QueryBuilder::Error => err
119
+ puts "Error parsing query #{pseudo_sql.inspect} (#{err.message})"
120
+ return nil
121
+ end
122
+
123
+
124
+ query.limit = " LIMIT #{limit}"
125
+
126
+ page_count = (count.to_f / limit).ceil
127
+ puts "#{count} nodes, #{page_count} chunk(s) (100 items)"
128
+ curr_page = 1
129
+ for curr_page in (1..page_count)
130
+ query.offset = " OFFSET #{limit * (curr_page - 1)}"
131
+ if list = Node.do_find(:all, eval(query.to_s(:find)))
132
+ puts "Page #{curr_page}/#{page_count}"
133
+ list.each do |record|
134
+ yield(record)
135
+ end
136
+ end
137
+ end
138
+ nil
139
+ end
140
+ end # Console
141
+ end # Zena
@@ -24,7 +24,7 @@ module Zena
24
24
  %w{get post put delete}.each do |method|
25
25
  class_eval <<-END_TXT
26
26
  def #{method}_subject
27
- without_files('/test.host/zafu') do
27
+ without_files('test.host/zafu') do
28
28
  #{method} subject.delete(:action), subject
29
29
  if block_given?
30
30
  yield
@@ -11,7 +11,7 @@ module Zena
11
11
 
12
12
  # Set a single attribute directly in the database.
13
13
  def set_attribute(obj, key, value)
14
- obj.send("#{key}=", value)
14
+ obj.write_attribute(key, value)
15
15
  execute "UPDATE #{obj.class.table_name} SET #{key}=#{quote(value)} WHERE id=#{obj[:id]}"
16
16
  obj.send(:changed_attributes).delete(key.to_s)
17
17
  end
@@ -35,7 +35,7 @@ module Zena
35
35
  end
36
36
 
37
37
  def adapter
38
- self.class.to_s.downcase
38
+ @adapter ||= self.to_s.downcase.split('::').last
39
39
  end
40
40
 
41
41
  def execute(*args)
@@ -117,8 +117,20 @@ module Zena
117
117
  end
118
118
 
119
119
  # Return a string matching the SQLiss function.
120
- def sql_function(function, key)
121
- raise Exception.new("Database Adapter #{adapter.inspect} does not support function #{function.inspect}.")
120
+ def sql_function(function, arg)
121
+ return arg unless function
122
+ case function
123
+ when 'count'
124
+ "COUNT(#{arg})"
125
+ when 'min'
126
+ "MIN(#{arg})"
127
+ when 'max'
128
+ "MAX(#{arg})"
129
+ when 'sum'
130
+ "SUM(#{arg})"
131
+ else
132
+ super
133
+ end
122
134
  end
123
135
 
124
136
  # This is used by zafu and it's a mess.
@@ -171,7 +183,7 @@ module Zena
171
183
  end
172
184
 
173
185
  # Fixes #98
174
- def prepare_connection_for_timezone
186
+ def prepare_connection
175
187
  # do nothing by default ?
176
188
  end
177
189
 
@@ -37,7 +37,7 @@ module Zena
37
37
  end
38
38
 
39
39
  def table_options
40
- 'type=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_general_ci'
40
+ 'type=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci'
41
41
  end
42
42
 
43
43
  def update_value(name, opts)
@@ -78,17 +78,17 @@ module Zena
78
78
  end
79
79
 
80
80
  # Return a string matching the SQLiss function.
81
- def sql_function(function, key)
82
- return key unless function
81
+ def sql_function(function, arg)
82
+ return arg unless function
83
83
  case function
84
84
  when 'year'
85
- "year(#{key})"
85
+ "year(#{arg})"
86
86
  when 'month'
87
- "date_format(#{key},'%Y-%m')"
87
+ "date_format(#{arg},'%Y-%m')"
88
88
  when 'week'
89
- "date_format(#{key},'%Y-%v')"
89
+ "date_format(#{arg},'%Y-%v')"
90
90
  when 'day'
91
- "DATE(#{key})"
91
+ "DATE(#{arg})"
92
92
  when 'random'
93
93
  'RAND()'
94
94
  else
@@ -99,6 +99,7 @@ module Zena
99
99
  # This is used by zafu and it's a mess.
100
100
  # ref_date can be a string ('2005-05-03') or ruby ('Time.now'). It should not come uncleaned from evil web.
101
101
  def date_condition(date_cond, field, ref_date)
102
+ # raise "DEPRECATED"
102
103
  case date_cond
103
104
  when 'today', 'current', 'same'
104
105
  "DATE(#{field}) = DATE(#{ref_date})"
@@ -131,17 +132,18 @@ module Zena
131
132
  end
132
133
  end # date_condition
133
134
 
134
- def prepare_connection_for_timezone
135
+ def prepare_connection
135
136
  # Fixes timezone to "+0:0"
136
- raise "prepare_connection_for_timezone executed too late, connection already active." if Class.new(ActiveRecord::Base).connected?
137
+ raise "prepare_connection executed too late, connection already active." if Class.new(ActiveRecord::Base).connected?
137
138
 
138
139
  ActiveRecord::ConnectionAdapters::MysqlAdapter.class_eval do
139
- def configure_connection_with_timezone
140
- configure_connection_without_timezone
140
+ def configure_connection_with_zena
141
+ configure_connection_without_zena
141
142
  tz = ActiveRecord::Base.default_timezone == :utc ? "+0:0" : "SYSTEM"
142
143
  execute("SET time_zone = '#{tz}'")
144
+ execute("SET collation_connection = 'utf8_unicode_ci'")
143
145
  end
144
- alias_method_chain :configure_connection, :timezone
146
+ alias_method_chain :configure_connection, :zena
145
147
  end
146
148
  end
147
149
  end # class << self
@@ -54,8 +54,7 @@ module Zena
54
54
  end
55
55
 
56
56
  # Return a string matching the SQLiss function.
57
- def sql_function(function, key)
58
- return key unless function
57
+ def sql_function(function, arg)
59
58
  # TODO
60
59
  super
61
60
  end
@@ -73,19 +73,19 @@ module Zena
73
73
  end
74
74
 
75
75
  # Return a string matching the SQLiss function.
76
- def sql_function(function, key)
77
- return key unless function
76
+ def sql_function(function, arg)
77
+ return arg unless function
78
78
  case function
79
79
  when 'year'
80
80
  # we multiply by '1' to force a cast to INTEGER so that comparaison against
81
81
  # numbers works.
82
- "strftime('%Y', #{key})*1"
82
+ "strftime('%Y', #{arg})*1"
83
83
  when 'month'
84
- "strftime('%Y-%m', #{key})"
84
+ "strftime('%Y-%m', #{arg})"
85
85
  when 'week'
86
- "strftime('%Y-%W', #{key})"
86
+ "strftime('%Y-%W', #{arg})"
87
87
  when 'day'
88
- "DATE(#{key})"
88
+ "DATE(#{arg})"
89
89
  when 'random'
90
90
  'random()'
91
91
  else
@@ -777,7 +777,7 @@ DecodeUA=0
777
777
  # - Realplayer G2 plugin
778
778
  # - QuickTime plugin
779
779
  # - Mediaplayer plugin
780
- # - Acrobat PDF plugin
780
+ # - Acrobat Pdf plugin
781
781
  # To enable all this features, you must copy the awstats_misc_tracker.js file
782
782
  # into a /js/ directory stored in your web document root and add the following
783
783
  # HTML code at the end of your index page (but before </BODY>) :
@@ -23,4 +23,9 @@ PassengerDefaultUser www-data
23
23
  ExpiresByType image/png "access plus 1 year"
24
24
  ExpiresByType text/css "access plus 1 year"
25
25
  ExpiresByType application/javascript "access plus 1 year"
26
- </IfModule>
26
+ </IfModule>
27
+
28
+ <% if config[:ssl] %>
29
+ SSLProtocol all
30
+ SSLCipherSuite HIGH:MEDIUM
31
+ <% end %>