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.
- data/History.txt +23 -0
- data/README.rdoc +1 -1
- data/app/controllers/columns_controller.rb +3 -31
- data/app/controllers/comments_controller.rb +8 -3
- data/app/controllers/data_entries_controller.rb +1 -1
- data/app/controllers/documents_controller.rb +2 -2
- data/app/controllers/nodes_controller.rb +29 -12
- data/app/controllers/relations_controller.rb +2 -2
- data/app/controllers/sites_controller.rb +1 -1
- data/app/controllers/user_sessions_controller.rb +6 -3
- data/app/controllers/users_controller.rb +18 -16
- data/app/controllers/versions_controller.rb +20 -18
- data/app/controllers/virtual_classes_controller.rb +103 -17
- data/app/helpers/users_helper.rb +1 -1
- data/app/models/column.rb +19 -50
- data/app/models/comment.rb +2 -1
- data/app/models/node.rb +45 -22
- data/app/models/relation.rb +13 -0
- data/app/models/relation_proxy.rb +3 -2
- data/app/models/role.rb +213 -4
- data/app/models/site.rb +18 -11
- data/app/models/template.rb +37 -35
- data/app/models/version.rb +1 -1
- data/app/models/virtual_class.rb +154 -86
- data/app/views/columns/_li.html.erb +1 -1
- data/app/views/columns/index.html.erb +1 -9
- data/app/views/comments/index.rhtml +10 -8
- data/app/views/documents/_crop.rhtml +5 -6
- data/app/views/documents/crop_form.rjs +3 -2
- data/app/views/groups/index.rhtml +1 -1
- data/app/views/iformats/index.rhtml +1 -1
- data/app/views/nodes/_import_results.rhtml +1 -1
- data/app/views/nodes/_parent.rhtml +1 -2
- data/app/views/nodes/update.rjs +3 -4
- data/app/views/relations/index.erb +1 -1
- data/app/views/sites/index.erb +1 -1
- data/app/views/templates/drive_tabs/_drive.rhtml +0 -2
- data/app/views/templates/edit_tabs/_image.rhtml +1 -1
- data/app/views/templates/edit_tabs/_title.rhtml +0 -6
- data/app/views/users/index.rhtml +1 -1
- data/app/views/users/preferences.html.erb +2 -2
- data/app/views/versions/backup.rjs +1 -1
- data/app/views/versions/custom_tab.rhtml +9 -4
- data/app/views/versions/destroy.rjs +2 -2
- data/app/views/versions/update.rjs +2 -9
- data/app/views/virtual_classes/_form.erb +3 -2
- data/app/views/virtual_classes/import_prepare.html.erb +13 -0
- data/app/views/virtual_classes/index.erb +28 -8
- data/app/views/zafu/default/Node-+adminLayout.zafu +1 -13
- data/app/views/zafu/default/Node-+login.zafu +1 -0
- data/app/views/zafu/default/Node-+notFound.zafu +1 -1
- data/app/views/zafu/default/Node-+popupLayout.zafu +1 -2
- data/app/views/zafu/default/Node-+search.zafu +1 -1
- data/app/views/zafu/default/Node-admin.zafu +205 -0
- data/app/views/zafu/default/Node.zafu +11 -11
- data/bricks/captcha/lib/bricks/captcha.rb +3 -2
- data/bricks/mongrel/zena/init.rb +2 -1
- data/bricks/pdf/README +5 -5
- data/bricks/pdf/lib/bricks/pdf/engine/prince.rb +2 -2
- data/bricks/pdf/lib/bricks/pdf/engine/xhtml2pdf.rb +2 -2
- data/bricks/pdf/lib/bricks/pdf/install.rb +5 -5
- data/bricks/pdf/lib/bricks/pdf.rb +11 -11
- data/bricks/pdf/test/engines/test_prince.rb +4 -4
- data/bricks/pdf/test/engines/test_xhtml2pdf.rb +4 -4
- data/bricks/pdf/test/shoulda_macros/shoulda_pdf.rb +2 -2
- data/bricks/pdf/zena/init.rb +2 -2
- data/bricks/pdf/zena/tasks.rb +2 -2
- data/bricks/sphinx/lib/bricks/sphinx.rb +6 -2
- data/bricks/sphinx/zena/{sphinx.yml → sphinx.yml.erb} +2 -2
- data/bricks/sphinx/zena/tasks.rb +28 -2
- data/bricks/tags/lib/bricks/tags.rb +16 -1
- data/bricks/tags/zena/test/unit/tags_test.rb +15 -0
- data/bricks/tags/zena/test/zafu/tags.yml +5 -1
- data/bricks/worker/lib/bricks/worker.rb +39 -0
- data/bricks/worker/zena/deploy.rb +0 -2
- data/bricks/worker/zena/init.rb +1 -0
- data/bricks/worker/zena/test/sites/zena/delayed_jobs.yml +16 -0
- data/bricks/worker/zena/test/zafu/worker.yml +8 -0
- data/bricks/zena/zena/migrate/01_base.rb +36 -60
- data/bricks/zena/zena/migrate/02_zerox1_schema.rb +388 -0
- data/bricks/zena/zena/migrate/03_zerox1_data.rb +380 -0
- data/bricks/zena/zena/migrate/20110315161158_add_reverse_scope_to_roles.rb +9 -0
- data/config/database_example.yml +1 -1
- data/config/environment.rb +1 -1
- data/config/gems.yml +17 -14
- data/db/init/base/skins/default/Node-+index.zafu +8 -1
- data/db/init/base/skins/default/Node-+login.zafu +1 -0
- data/db/init/base/skins/default/Node-+popupLayout.zafu +1 -2
- data/db/init/base/skins/default/Node-+search.zafu +2 -2
- data/db/init/base/skins/default/Node.zafu +9 -9
- data/db/init/base/skins/default/{favicon.png → img/favicon.png} +0 -0
- data/db/init/base/skins/default/{style.css → img/style.css} +0 -0
- data/db/init/base/skins/default/img/translations.yml +11 -0
- data/db/init/base/skins/default/notes.zafu +7 -9
- data/doc/zafu_changes.yml +12 -0
- data/lib/bricks/loader.rb +38 -15
- data/lib/tasks/zena.rake +74 -24
- data/lib/zena/acts/enrollable.rb +4 -1
- data/lib/zena/acts/secure.rb +2 -48
- data/lib/zena/acts/serializable.rb +13 -1
- data/lib/zena/app.rb +9 -0
- data/lib/zena/code_syntax.rb +154 -151
- data/lib/zena/console.rb +141 -0
- data/lib/zena/controller/test_case.rb +1 -1
- data/lib/zena/db_helper/abstract_db.rb +17 -5
- data/lib/zena/db_helper/mysql.rb +14 -12
- data/lib/zena/db_helper/postgresql.rb +1 -2
- data/lib/zena/db_helper/sqlite3.rb +6 -6
- data/lib/zena/deploy/awstats.conf.rhtml +1 -1
- data/lib/zena/deploy/httpd.rhtml +6 -1
- data/lib/zena/deploy/vhost.rhtml +9 -1
- data/lib/zena/deploy.rb +12 -7
- data/lib/zena/foxy_parser.rb +3 -1
- data/lib/zena/info.rb +1 -1
- data/lib/zena/parser/zafu_tags.rb +1 -0
- data/lib/zena/parser/zazen_rules.rb +1 -1
- data/lib/zena/remote/node.rb +15 -3
- data/lib/zena/remote/serializable_array.rb +19 -0
- data/lib/zena/remote.rb +1 -0
- data/lib/zena/routes.rb +7 -2
- data/lib/zena/site_worker.rb +11 -1
- data/lib/zena/unit/test_case.rb +68 -0
- data/lib/zena/use/action.rb +6 -2
- data/lib/zena/use/ajax.rb +127 -53
- data/lib/zena/use/ancestry.rb +11 -8
- data/lib/zena/use/calendar.rb +265 -129
- data/lib/zena/use/conditional.rb +1 -1
- data/lib/zena/use/context.rb +5 -5
- data/lib/zena/use/dates.rb +172 -60
- data/lib/zena/use/display.rb +70 -39
- data/lib/zena/use/error_rendering.rb +1 -3
- data/lib/zena/use/field_index.rb +4 -1
- data/lib/zena/use/forms.rb +94 -72
- data/lib/zena/use/fulltext.rb +16 -24
- data/lib/zena/use/html_tags.rb +20 -12
- data/lib/zena/use/i18n.rb +37 -37
- data/lib/zena/use/image_builder.rb +8 -1
- data/lib/zena/use/ml_index.rb +16 -16
- data/lib/zena/use/prop_eval.rb +10 -5
- data/lib/zena/use/query_builder.rb +55 -23
- data/lib/zena/use/query_node.rb +51 -25
- data/lib/zena/use/refactor.rb +2 -28
- data/lib/zena/use/relations.rb +1 -1
- data/lib/zena/use/rendering.rb +29 -0
- data/lib/zena/use/scope_index.rb +75 -14
- data/lib/zena/use/search.rb +5 -10
- data/lib/zena/use/test_helper.rb +2 -2
- data/lib/zena/use/urls.rb +125 -104
- data/lib/zena/use/workflow.rb +2 -1
- data/lib/zena/use/zafu_attributes.rb +2 -2
- data/lib/zena/use/zafu_safe_definitions.rb +20 -0
- data/lib/zena/use/zafu_templates.rb +20 -6
- data/lib/zena/use/zazen.rb +31 -20
- data/lib/zena/view/test_case.rb +5 -0
- data/lib/zena/zafu_compiler.rb +24 -2
- data/lib/zena.rb +12 -6
- data/locale/de/LC_MESSAGES/zena.mo +0 -0
- data/locale/de/zena.po +1345 -1164
- data/locale/en/LC_MESSAGES/zena.mo +0 -0
- data/locale/en/zena.po +1275 -1129
- data/locale/fr/LC_MESSAGES/zena.mo +0 -0
- data/locale/fr/zena.mo +0 -0
- data/locale/fr/zena.po +1617 -1441
- data/locale/log.txt +9 -0
- data/locale/zena.pot +957 -748
- data/public/javascripts/prototype.js +1 -1
- data/public/javascripts/zena.js +99 -44
- data/public/stylesheets/admin.css +6 -4
- data/public/stylesheets/backend.css +71 -0
- data/public/stylesheets/calendar.css +24 -25
- data/public/stylesheets/code.css +11 -6
- data/public/stylesheets/comment.css +2 -1
- data/public/stylesheets/popup.css +7 -8
- data/test/custom_queries/complex.host.yml +15 -1
- data/test/fixtures/files/Node-test.zafu +29 -28
- data/test/fixtures/files/translations_de.yml +12 -1
- data/test/fixtures/files/translations_fr.yml +12 -1
- data/test/functional/comments_controller_test.rb +9 -0
- data/test/functional/iformats_controller_test.rb +1 -1
- data/test/functional/nodes_controller_test.rb +124 -35
- data/test/functional/users_controller_test.rb +132 -3
- data/test/functional/virtual_classes_controller_test.rb +75 -4
- data/test/integration/navigation_test.rb +51 -9
- data/test/integration/query_node/basic.yml +19 -7
- data/test/integration/query_node/complex.yml +1 -1
- data/test/integration/query_node/dates.yml +27 -1
- data/test/integration/query_node/filters.yml +1 -1
- data/test/integration/query_node/relations.yml +13 -4
- data/test/integration/query_node_test.rb +4 -0
- data/test/integration/xml_api_test.rb +6 -1
- data/test/integration/zafu_compiler/action.yml +3 -3
- data/test/integration/zafu_compiler/ajax.yml +103 -22
- data/test/integration/zafu_compiler/basic.yml +0 -52
- data/test/integration/zafu_compiler/calendar.yml +44 -20
- data/test/integration/zafu_compiler/comments.yml +53 -0
- data/test/integration/zafu_compiler/complex.yml +11 -11
- data/test/integration/zafu_compiler/complex_ok.yml +16 -3
- data/test/integration/zafu_compiler/conditional.yml +15 -5
- data/test/integration/zafu_compiler/context.yml +9 -0
- data/test/integration/zafu_compiler/dates.yml +43 -15
- data/test/integration/zafu_compiler/display.yml +60 -6
- data/test/integration/zafu_compiler/errors.yml +6 -2
- data/test/integration/zafu_compiler/forms.yml +45 -6
- data/test/integration/zafu_compiler/i18n.yml +8 -1
- data/test/integration/zafu_compiler/meta.yml +38 -0
- data/test/integration/zafu_compiler/query.yml +43 -4
- data/test/integration/zafu_compiler/relations.yml +26 -33
- data/test/integration/zafu_compiler/rubyless.yml +10 -0
- data/test/integration/zafu_compiler/safe_definitions.yml +21 -1
- data/test/integration/zafu_compiler/urls.yml +75 -5
- data/test/integration/zafu_compiler/version.yml +2 -2
- data/test/integration/zafu_compiler/zafu_attributes.yml +5 -1
- data/test/integration/zafu_compiler/zazen.yml +14 -6
- data/test/integration/zafu_compiler_test.rb +5 -1
- data/test/sites/complex/columns.yml +5 -0
- data/test/sites/complex/roles.yml +4 -0
- data/test/sites/zena/nodes.yml +13 -2
- data/test/sites/zena/roles.yml +13 -5
- data/test/sites/zena/versions.yml +27 -9
- data/test/unit/column_test.rb +51 -5
- data/test/unit/iformat_test.rb +2 -2
- data/test/unit/node_test.rb +29 -17
- data/test/unit/note_test.rb +1 -1
- data/test/unit/relation_proxy_test.rb +4 -5
- data/test/unit/relation_test.rb +16 -0
- data/test/unit/remote_test.rb +2 -2
- data/test/unit/role_test.rb +292 -4
- data/test/unit/site_test.rb +12 -0
- data/test/unit/template_test.rb +1 -1
- data/test/unit/text_document_test.rb +1 -1
- data/test/unit/virtual_class_test.rb +200 -83
- data/test/unit/zena/acts/enrollable_test.rb +26 -31
- data/test/unit/zena/use/calendar_test.rb +90 -37
- data/test/unit/zena/use/field_index_test.rb +28 -0
- data/test/unit/zena/use/html_tags_test.rb +7 -3
- data/test/unit/zena/use/ml_index_test.rb +2 -16
- data/test/unit/zena/use/nested_attributes_alias_view_test.rb +2 -2
- data/test/unit/zena/use/prop_eval_test.rb +50 -8
- data/test/unit/zena/use/query_node_test.rb +11 -0
- data/test/unit/zena/use/rendering_test.rb +72 -0
- data/test/unit/zena/use/scope_index_test.rb +37 -2
- data/test/unit/zena/use/urls_test.rb +10 -0
- data/test/unit/zena/use/zazen_test.rb +3 -3
- data/vendor/plugins/gettext_i18n_rails/Gemfile +11 -0
- data/vendor/plugins/gettext_i18n_rails/Gemfile.lock +92 -0
- data/vendor/plugins/gettext_i18n_rails/Rakefile +12 -17
- data/vendor/plugins/gettext_i18n_rails/Readme.md +215 -0
- data/vendor/plugins/gettext_i18n_rails/VERSION +1 -1
- data/vendor/plugins/gettext_i18n_rails/gettext_i18n_rails.gemspec +38 -34
- data/vendor/plugins/gettext_i18n_rails/lib/gettext_i18n_rails/active_record.rb +1 -1
- data/vendor/plugins/gettext_i18n_rails/lib/gettext_i18n_rails/backend.rb +30 -14
- data/vendor/plugins/gettext_i18n_rails/lib/gettext_i18n_rails/haml_parser.rb +1 -1
- data/vendor/plugins/gettext_i18n_rails/lib/gettext_i18n_rails/html_safe_translations.rb +29 -0
- data/vendor/plugins/gettext_i18n_rails/lib/gettext_i18n_rails/i18n_hacks.rb +29 -1
- data/vendor/plugins/gettext_i18n_rails/lib/gettext_i18n_rails/model_attributes_finder.rb +7 -1
- data/vendor/plugins/gettext_i18n_rails/lib/gettext_i18n_rails/railtie.rb +10 -0
- data/vendor/plugins/gettext_i18n_rails/lib/gettext_i18n_rails/ruby_gettext_extractor.rb +6 -2
- data/vendor/plugins/gettext_i18n_rails/lib/gettext_i18n_rails/string_interpolate_fix.rb +20 -0
- data/vendor/plugins/gettext_i18n_rails/lib/gettext_i18n_rails/tasks.rb +120 -0
- data/vendor/plugins/gettext_i18n_rails/lib/gettext_i18n_rails.rb +10 -3
- data/vendor/plugins/gettext_i18n_rails/lib/tasks/gettext_rails_i18n.rake +1 -74
- data/vendor/plugins/gettext_i18n_rails/spec/gettext_i18n_rails/active_record_spec.rb +51 -20
- data/vendor/plugins/gettext_i18n_rails/spec/gettext_i18n_rails/backend_spec.rb +12 -7
- data/vendor/plugins/gettext_i18n_rails/spec/gettext_i18n_rails/string_interpolate_fix_spec.rb +32 -0
- data/vendor/plugins/gettext_i18n_rails/spec/gettext_i18n_rails_spec.rb +38 -1
- data/vendor/plugins/gettext_i18n_rails/spec/rails2/Gemfile +11 -0
- data/vendor/plugins/gettext_i18n_rails/spec/spec_helper.rb +1 -8
- data/zena.gemspec +2241 -2217
- metadata +123 -83
- data/.gitignore +0 -36
- data/app/views/nodes/_dates.rhtml +0 -13
- data/db/init/base/skins/default/Node-+adminLayout.zafu +0 -46
- data/db/init/base/skins/default/Node-tree.zafu +0 -19
- data/vendor/plugins/gettext_i18n_rails/README.markdown +0 -143
data/lib/zena/code_syntax.rb
CHANGED
@@ -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 <
|
134
|
-
|
135
|
-
|
136
|
-
ztag
|
137
|
-
|
138
|
-
|
139
|
-
|
140
|
-
|
141
|
-
|
142
|
-
|
143
|
-
|
144
|
-
v
|
145
|
-
|
146
|
-
|
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 :
|
149
|
-
|
150
|
-
|
151
|
-
|
152
|
-
|
153
|
-
|
154
|
-
|
155
|
-
|
156
|
-
|
157
|
-
|
158
|
-
|
159
|
-
|
160
|
-
|
161
|
-
|
162
|
-
|
163
|
-
|
164
|
-
|
165
|
-
|
166
|
-
|
167
|
-
|
168
|
-
|
169
|
-
|
170
|
-
|
171
|
-
|
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
|
-
|
178
|
-
|
179
|
-
|
180
|
-
|
181
|
-
|
182
|
-
|
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
|
-
|
189
|
-
Syntax::SYNTAX['zafu'] = ZafuTokenizer
|
190
|
+
end # ZafuTokenizer
|
191
|
+
SYNTAX['zafu'] = ZafuTokenizer
|
190
192
|
|
191
|
-
class ErbTokenizer <
|
192
|
-
|
193
|
-
|
194
|
-
|
195
|
-
|
196
|
-
|
197
|
-
|
198
|
-
|
199
|
-
|
200
|
-
|
201
|
-
|
202
|
-
|
203
|
-
|
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
|
-
|
207
|
-
Syntax::SYNTAX['erb'] = ErbTokenizer
|
208
|
+
end # ErbTokenizer
|
209
|
+
SYNTAX['erb'] = ErbTokenizer
|
208
210
|
|
209
|
-
class CssTokenizer <
|
210
|
-
|
211
|
-
|
212
|
-
|
213
|
-
|
214
|
-
|
215
|
-
|
216
|
-
|
217
|
-
|
218
|
-
|
219
|
-
|
220
|
-
|
221
|
-
|
222
|
-
|
223
|
-
|
224
|
-
|
225
|
-
|
226
|
-
|
227
|
-
|
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
|
-
|
233
|
+
end
|
234
|
+
unless i == selectors.size - 1
|
235
|
+
start_group :punct, ', '
|
230
236
|
end
|
231
237
|
end
|
232
|
-
|
233
|
-
start_group :punct, ', '
|
234
|
-
end
|
235
|
-
end
|
236
|
-
start_group :punct, '{ '
|
238
|
+
start_group :punct, '{ '
|
237
239
|
|
238
|
-
|
239
|
-
|
240
|
-
|
241
|
-
|
242
|
-
|
243
|
-
|
244
|
-
|
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
|
-
|
252
|
-
Syntax::SYNTAX['css'] = CssTokenizer
|
253
|
+
end # CssTokenizer
|
254
|
+
SYNTAX['css'] = CssTokenizer
|
253
255
|
|
254
|
-
class ShTokenizer <
|
255
|
-
|
256
|
-
|
257
|
-
|
258
|
-
|
259
|
-
|
260
|
-
|
261
|
-
|
262
|
-
|
263
|
-
|
264
|
-
|
265
|
-
|
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
|
-
|
269
|
-
Syntax::SYNTAX['sh'] = ShTokenizer
|
270
|
+
end # ShTokenizer
|
271
|
+
SYNTAX['sh'] = ShTokenizer
|
270
272
|
|
271
|
-
class PseudoSqlTokenizer <
|
272
|
-
|
273
|
-
|
274
|
-
|
275
|
-
|
276
|
-
|
277
|
-
|
278
|
-
|
279
|
-
|
280
|
-
|
281
|
-
|
282
|
-
|
283
|
-
|
284
|
-
|
285
|
-
|
286
|
-
|
287
|
-
|
288
|
-
|
289
|
-
|
290
|
-
|
291
|
-
|
292
|
-
|
293
|
-
|
294
|
-
|
295
|
-
|
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
|
-
|
299
|
-
|
300
|
+
end # PseudoSqlTokenizer
|
301
|
+
SYNTAX['sqliss'] = PseudoSqlTokenizer
|
302
|
+
end # Syntax
|
data/lib/zena/console.rb
ADDED
@@ -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
|
@@ -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.
|
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.
|
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,
|
121
|
-
|
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
|
186
|
+
def prepare_connection
|
175
187
|
# do nothing by default ?
|
176
188
|
end
|
177
189
|
|
data/lib/zena/db_helper/mysql.rb
CHANGED
@@ -37,7 +37,7 @@ module Zena
|
|
37
37
|
end
|
38
38
|
|
39
39
|
def table_options
|
40
|
-
'type=InnoDB DEFAULT CHARSET=utf8 COLLATE=
|
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,
|
82
|
-
return
|
81
|
+
def sql_function(function, arg)
|
82
|
+
return arg unless function
|
83
83
|
case function
|
84
84
|
when 'year'
|
85
|
-
"year(#{
|
85
|
+
"year(#{arg})"
|
86
86
|
when 'month'
|
87
|
-
"date_format(#{
|
87
|
+
"date_format(#{arg},'%Y-%m')"
|
88
88
|
when 'week'
|
89
|
-
"date_format(#{
|
89
|
+
"date_format(#{arg},'%Y-%v')"
|
90
90
|
when 'day'
|
91
|
-
"DATE(#{
|
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
|
135
|
+
def prepare_connection
|
135
136
|
# Fixes timezone to "+0:0"
|
136
|
-
raise "
|
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
|
140
|
-
|
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, :
|
146
|
+
alias_method_chain :configure_connection, :zena
|
145
147
|
end
|
146
148
|
end
|
147
149
|
end # class << self
|
@@ -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,
|
77
|
-
return
|
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', #{
|
82
|
+
"strftime('%Y', #{arg})*1"
|
83
83
|
when 'month'
|
84
|
-
"strftime('%Y-%m', #{
|
84
|
+
"strftime('%Y-%m', #{arg})"
|
85
85
|
when 'week'
|
86
|
-
"strftime('%Y-%W', #{
|
86
|
+
"strftime('%Y-%W', #{arg})"
|
87
87
|
when 'day'
|
88
|
-
"DATE(#{
|
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
|
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>) :
|
data/lib/zena/deploy/httpd.rhtml
CHANGED
@@ -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 %>
|