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/bricks/loader.rb
CHANGED
@@ -1,5 +1,7 @@
|
|
1
1
|
module Bricks
|
2
2
|
module Loader
|
3
|
+
@@no_init = false
|
4
|
+
|
3
5
|
def bricks
|
4
6
|
@@bricks ||= bricks_folders.map do |bricks_folder|
|
5
7
|
if File.exist?(bricks_folder)
|
@@ -21,12 +23,12 @@ module Bricks
|
|
21
23
|
!File.exist?(f)
|
22
24
|
end
|
23
25
|
end
|
24
|
-
|
26
|
+
|
25
27
|
# Find all paths matching 'sub_path' in the active bricks.
|
26
28
|
def paths_for(sub_path)
|
27
29
|
bricks.map {|f| Dir["#{f}/#{sub_path}"] }.flatten
|
28
30
|
end
|
29
|
-
|
31
|
+
|
30
32
|
def models_paths
|
31
33
|
paths_for('models')
|
32
34
|
end
|
@@ -36,11 +38,20 @@ module Bricks
|
|
36
38
|
end
|
37
39
|
|
38
40
|
def migrations_for(brick)
|
39
|
-
File.join(
|
41
|
+
File.join(brick_path(brick), 'zena', 'migrate')
|
40
42
|
end
|
41
43
|
|
42
44
|
def fixtures_path_for(brick)
|
43
|
-
File.join(
|
45
|
+
File.join(brick_path(brick), 'zena', 'test', 'sites')
|
46
|
+
end
|
47
|
+
|
48
|
+
def brick_path(brick)
|
49
|
+
p = nil
|
50
|
+
bricks_folders.each do |f|
|
51
|
+
p = File.join(f, brick)
|
52
|
+
return p if File.exist?(p)
|
53
|
+
end
|
54
|
+
return p
|
44
55
|
end
|
45
56
|
|
46
57
|
def zafu_tests
|
@@ -77,17 +88,15 @@ module Bricks
|
|
77
88
|
end
|
78
89
|
end
|
79
90
|
|
80
|
-
# FIXME: remove
|
91
|
+
# FIXME: remove when we can use
|
92
|
+
# Zena::Use.modules_for('Zafu')
|
81
93
|
def load_zafu(mod)
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
next if rules_name =~ /\A\./
|
88
|
-
load File.join(zafu_path, rules_name)
|
94
|
+
Bricks::CONFIG.keys.each do |brick_name|
|
95
|
+
begin
|
96
|
+
mod.send(:include, eval("Bricks::#{brick_name.capitalize}::ZafuMethods"))
|
97
|
+
rescue NameError
|
98
|
+
# ignore
|
89
99
|
end
|
90
|
-
mod.send(:include, eval("Bricks::#{brick_name.capitalize}::ZafuMethods"))
|
91
100
|
end
|
92
101
|
end
|
93
102
|
|
@@ -97,14 +106,28 @@ module Bricks
|
|
97
106
|
end
|
98
107
|
end
|
99
108
|
|
109
|
+
def no_init=(v)
|
110
|
+
@@no_init = v
|
111
|
+
end
|
112
|
+
|
113
|
+
# Returns true if the Bricks code should not be executed (such
|
114
|
+
# as during the initial migrations, legacy cleanup, etc).
|
115
|
+
def no_init
|
116
|
+
!Zena::Db.migrated_once? || @@no_init
|
117
|
+
end
|
118
|
+
|
100
119
|
def load_bricks
|
101
120
|
bricks.each do |path|
|
102
121
|
path = File.join(path, 'lib')
|
103
|
-
ActiveSupport::Dependencies.
|
104
|
-
ActiveSupport::Dependencies.
|
122
|
+
ActiveSupport::Dependencies.autoload_paths << path
|
123
|
+
ActiveSupport::Dependencies.autoload_once_paths << path
|
105
124
|
$LOAD_PATH << path
|
106
125
|
end
|
107
126
|
|
127
|
+
if @@no_init
|
128
|
+
puts "=> Not executing bricks init code."
|
129
|
+
return
|
130
|
+
end
|
108
131
|
# load 'init'
|
109
132
|
init_paths.each do |init_path|
|
110
133
|
require init_path
|
data/lib/tasks/zena.rake
CHANGED
@@ -112,7 +112,7 @@ namespace :zena do
|
|
112
112
|
end
|
113
113
|
end
|
114
114
|
|
115
|
-
desc "Create a new site, parameters are PASSWORD, HOST,
|
115
|
+
desc "Create a new site, parameters are PASSWORD, HOST, HOST_LANG"
|
116
116
|
task :mksite => :environment do
|
117
117
|
# 0. set host name
|
118
118
|
unless host = ENV['HOST']
|
@@ -121,18 +121,18 @@ namespace :zena do
|
|
121
121
|
unless pass = ENV['PASSWORD']
|
122
122
|
puts "Please set PASSWORD to the admin password for the new site. Aborting."
|
123
123
|
else
|
124
|
-
ENV['
|
124
|
+
ENV['HOST_LANG'] ||= 'en'
|
125
125
|
host_path = "#{SITES_ROOT}/#{host}"
|
126
126
|
if Site.find_by_host(host)
|
127
127
|
puts "Host already exists in the database. Aborting."
|
128
128
|
else
|
129
|
-
site = Site.create_for_host(host, pass, :default_lang => ENV['
|
129
|
+
site = Site.create_for_host(host, pass, :default_lang => ENV['HOST_LANG'])
|
130
130
|
if site.new_record?
|
131
131
|
puts "Could not create site ! Errors:"
|
132
132
|
site.errors.each do |k,v|
|
133
133
|
puts "[#{k}] #{v}"
|
134
134
|
end
|
135
|
-
|
135
|
+
raise "Aborting."
|
136
136
|
else
|
137
137
|
# 1. create directories and symlinks
|
138
138
|
`rake zena:mksymlinks HOST=#{host.inspect}`
|
@@ -155,8 +155,12 @@ namespace :zena do
|
|
155
155
|
next if File.exist?("#{host_path}/#{dir}")
|
156
156
|
FileUtils.mkpath("#{host_path}/#{dir}")
|
157
157
|
end
|
158
|
-
|
159
|
-
|
158
|
+
if RAILS_ROOT =~ /releases\/\d+/
|
159
|
+
root = (Pathname(RAILS_ROOT) + '../../current').to_s
|
160
|
+
else
|
161
|
+
root = RAILS_ROOT
|
162
|
+
end
|
163
|
+
symlink_assets(root, host_path)
|
160
164
|
end
|
161
165
|
end
|
162
166
|
|
@@ -245,8 +249,14 @@ namespace :zena do
|
|
245
249
|
puts `#{cmd}`
|
246
250
|
end
|
247
251
|
|
252
|
+
desc "Load environment without running brick init code."
|
253
|
+
task :environment_without_bricks do
|
254
|
+
Bricks.no_init = true
|
255
|
+
Rake::Task["environment"].invoke
|
256
|
+
end
|
257
|
+
|
248
258
|
desc "Migrate the database through scripts in db/migrate. Target specific brick and version with BRICK=x and VERSION=x"
|
249
|
-
task :migrate => :
|
259
|
+
task :migrate => :environment_without_bricks do
|
250
260
|
if ENV['VERSION'] || ENV['BRICK']
|
251
261
|
ENV['BRICK'] ||= 'zena'
|
252
262
|
# migrate specific bricks only
|
@@ -285,6 +295,8 @@ namespace :zena do
|
|
285
295
|
if RAILS_ENV == 'production'
|
286
296
|
puts "You cannot reset database in production !"
|
287
297
|
else
|
298
|
+
ENV['WORKER'] = 'false'
|
299
|
+
# FIXME: it seems the ENV is not propagated to the tasks below...
|
288
300
|
%w{db:drop db:create zena:migrate zena:build_fixtures db:test:clone}.each do |task|
|
289
301
|
puts "******************************* #{task}"
|
290
302
|
Rake::Task[task].invoke
|
@@ -336,34 +348,67 @@ namespace :zena do
|
|
336
348
|
|
337
349
|
index_tables = Node.connection.tables.select {|t| t =~ /^idx_/ }
|
338
350
|
Zena::FoxyParser.dump_fixtures(index_tables)
|
351
|
+
# Currently, inline indexes are not serialized in the fixtures and need to be
|
352
|
+
# explicitely set along with the property value.
|
339
353
|
end
|
340
354
|
end
|
341
355
|
|
342
|
-
desc 'Rebuild index for all sites
|
356
|
+
desc 'Rebuild index for all sites or site defined by HOST param.'
|
343
357
|
task :rebuild_index => :environment do
|
344
358
|
include Zena::Acts::Secure
|
345
|
-
|
346
|
-
|
347
|
-
|
348
|
-
|
349
|
-
|
350
|
-
|
351
|
-
|
352
|
-
|
359
|
+
if ENV['HOST']
|
360
|
+
sites = [Site.find_by_host(ENV['HOST'])]
|
361
|
+
else
|
362
|
+
sites = Site.all
|
363
|
+
end
|
364
|
+
sites.each do |site|
|
365
|
+
if ENV['WORKER'] == 'false' || RAILS_ENV == 'test'
|
366
|
+
# We avoid SiteWorker by passing nodes.
|
367
|
+
Thread.current[:visitor] = site.any_admin
|
368
|
+
nodes = Node.find(:all,
|
369
|
+
:conditions => ['site_id = ?', site.id]
|
370
|
+
)
|
371
|
+
site.rebuild_index(secure_result(nodes))
|
372
|
+
else
|
373
|
+
# We try to use the site worker.
|
374
|
+
Thread.current[:visitor] = site.any_admin
|
375
|
+
site.rebuild_index
|
376
|
+
end
|
353
377
|
end
|
354
378
|
end
|
355
379
|
|
356
|
-
desc 'Rebuild fullpath for all sites
|
380
|
+
desc 'Rebuild fullpath for all sites or site defined by HOST param.'
|
357
381
|
task :rebuild_fullpath => :environment do
|
358
382
|
include Zena::Acts::Secure
|
359
|
-
|
360
|
-
|
361
|
-
|
362
|
-
|
383
|
+
if ENV['HOST']
|
384
|
+
sites = [Site.find_by_host(ENV['HOST'])]
|
385
|
+
else
|
386
|
+
sites = Site.all
|
387
|
+
end
|
388
|
+
sites.each do |site|
|
389
|
+
# Does not use SiteWorker.
|
363
390
|
site.rebuild_fullpath
|
364
391
|
end
|
365
392
|
end
|
366
393
|
|
394
|
+
desc 'Rebuild vhash for all sites or site defined by HOST param.'
|
395
|
+
task :rebuild_vhash => :environment do
|
396
|
+
include Zena::Acts::Secure
|
397
|
+
if ENV['HOST']
|
398
|
+
sites = [Site.find_by_host(ENV['HOST'])]
|
399
|
+
else
|
400
|
+
sites = Site.all
|
401
|
+
end
|
402
|
+
sites.each do |site|
|
403
|
+
# We avoid SiteWorker by passing nodes.
|
404
|
+
Thread.current[:visitor] = site.any_admin
|
405
|
+
nodes = Node.find(:all,
|
406
|
+
:conditions => ['site_id = ?', site.id]
|
407
|
+
)
|
408
|
+
site.rebuild_vhash(secure_result(nodes))
|
409
|
+
end
|
410
|
+
end
|
411
|
+
|
367
412
|
Rake::RDocTask.new do |rdoc|
|
368
413
|
files = ['README', 'doc/README_FOR_APP', 'CREDITS', 'MIT-LICENSE', 'app/**/*.rb',
|
369
414
|
'lib/**/*.rb']
|
@@ -476,15 +521,15 @@ namespace :zena do
|
|
476
521
|
# FIXME: how to run sub-task
|
477
522
|
ENV['RAILS_ENV'] = RAILS_ENV || 'production'
|
478
523
|
ENV['HOST'] ||= 'localhost'
|
479
|
-
ENV['
|
480
|
-
ENV['
|
524
|
+
ENV['HOST_LANG'] = ENV['HOST_LANG'].to_s
|
525
|
+
ENV['HOST_LANG'] = 'en' if ENV['HOST_LANG'].empty?
|
481
526
|
ENV['PASSWORD'] ||= 'admin'
|
482
527
|
|
483
528
|
Rake::Task["db:create"].invoke
|
484
529
|
Rake::Task["zena:migrate"].invoke
|
485
530
|
|
486
531
|
# We cannot use 'invoke' here because the User class needs to be reloaded
|
487
|
-
env = %w{RAILS_ENV HOST
|
532
|
+
env = %w{RAILS_ENV HOST HOST_LANG PASSWORD}.map{|e| "#{e}=#{ENV[e]}"}.join(' ')
|
488
533
|
cmd = "rake zena:mksite #{env}"
|
489
534
|
puts cmd
|
490
535
|
system(cmd)
|
@@ -504,5 +549,10 @@ namespace :zena do
|
|
504
549
|
exec cmd
|
505
550
|
end
|
506
551
|
end
|
552
|
+
end # zena
|
507
553
|
|
554
|
+
namespace :gettext do
|
555
|
+
def files_to_translate
|
556
|
+
Dir.glob("{app,lib,bricks,config,locale}/**/*.{rb,erb,rjs,rhtml}")
|
557
|
+
end
|
508
558
|
end
|
data/lib/zena/acts/enrollable.rb
CHANGED
@@ -191,8 +191,11 @@ module Zena
|
|
191
191
|
|
192
192
|
module Common
|
193
193
|
extend self
|
194
|
+
# Resolve class for @post ==> Post, etc. Used in Zena::Use::Context.
|
194
195
|
def get_class(class_name)
|
195
|
-
VirtualClass.
|
196
|
+
VirtualClass[class_name] || Module.const_get(class_name)
|
197
|
+
rescue NameError => err
|
198
|
+
nil
|
196
199
|
end
|
197
200
|
end # Common
|
198
201
|
|
data/lib/zena/acts/secure.rb
CHANGED
@@ -316,54 +316,8 @@ def visitor
|
|
316
316
|
end
|
317
317
|
|
318
318
|
if defined?(IRB)
|
319
|
-
puts "IRB console: including Zena::
|
319
|
+
puts "IRB console: including Zena::Console in main"
|
320
320
|
class << self
|
321
|
-
include Zena::
|
322
|
-
|
323
|
-
def err(obj)
|
324
|
-
obj.errors.each_error do |er,msg|
|
325
|
-
puts "[#{er}] #{msg}"
|
326
|
-
end
|
327
|
-
end
|
328
|
-
|
329
|
-
def rename_prop(list, old_key, new_key)
|
330
|
-
list.each do |rec|
|
331
|
-
prop = rec.prop
|
332
|
-
if value = prop.delete(old_key)
|
333
|
-
prop[new_key] = value
|
334
|
-
Zena::Db.execute "UPDATE #{rec.class.table_name} SET properties=#{Zena::Db.quote(rec.class.encode_properties(prop))} WHERE id=#{rec[:id]}"
|
335
|
-
end
|
336
|
-
end
|
337
|
-
end
|
338
|
-
|
339
|
-
def login(name, host = nil)
|
340
|
-
finder = {}
|
341
|
-
finder[:conditions] = cond = [[]]
|
342
|
-
if host
|
343
|
-
finder[:joins] = 'INNER JOIN sites ON sites.id = users.site_id'
|
344
|
-
cond.first << 'sites.host = ?'
|
345
|
-
cond << host.to_s
|
346
|
-
end
|
347
|
-
|
348
|
-
cond.first << 'users.login = ?'
|
349
|
-
cond << name.to_s
|
350
|
-
cond[0] = cond.first.join(' AND ')
|
351
|
-
if visitor = User.find(:first, finder)
|
352
|
-
Thread.current[:visitor] = visitor
|
353
|
-
puts "Logged #{visitor.login} in #{visitor.site.host}"
|
354
|
-
else
|
355
|
-
raise ActiveRecord::RecordNotFound
|
356
|
-
end
|
357
|
-
rescue ActiveRecord::RecordNotFound
|
358
|
-
puts "Could not login with user name: #{name}"
|
359
|
-
end
|
360
|
-
|
361
|
-
def nodes(zip_or_name)
|
362
|
-
if zip_or_name.kind_of?(Fixnum)
|
363
|
-
secure(Node) { Node.find_by_zip(zip_or_name) }
|
364
|
-
else
|
365
|
-
secure(Node) { Node.find_by_title(zip_or_name) }
|
366
|
-
end
|
367
|
-
end
|
321
|
+
include Zena::Console
|
368
322
|
end
|
369
323
|
end
|
@@ -12,7 +12,6 @@ module Zena
|
|
12
12
|
end
|
13
13
|
|
14
14
|
protected
|
15
|
-
|
16
15
|
def raw_value
|
17
16
|
@raw_value ||= @record.prop[name]
|
18
17
|
end
|
@@ -76,6 +75,17 @@ module Zena
|
|
76
75
|
end
|
77
76
|
|
78
77
|
module ModelMethods
|
78
|
+
def self.included(base)
|
79
|
+
class << base
|
80
|
+
cattr_accessor :export_procs
|
81
|
+
|
82
|
+
def export_xml(proc)
|
83
|
+
self.export_procs << proc
|
84
|
+
end
|
85
|
+
end
|
86
|
+
base.export_procs = []
|
87
|
+
end
|
88
|
+
|
79
89
|
def to_xml(options = {}, &block)
|
80
90
|
options = default_serialization_options.merge(options)
|
81
91
|
serializer = XmlNodeSerializer.new(self, options)
|
@@ -85,6 +95,8 @@ module Zena
|
|
85
95
|
def default_serialization_options
|
86
96
|
{ :only => %w{created_at updated_at log_at event_at kpath ref_lang fullpath position},
|
87
97
|
:methods => %w{v_status klass},
|
98
|
+
:procs => self.class.export_procs,
|
99
|
+
:record => self, # needed by procs
|
88
100
|
:properties => export_properties,
|
89
101
|
:ids => export_ids,
|
90
102
|
:dasherize => false,
|
data/lib/zena/app.rb
CHANGED
@@ -30,7 +30,16 @@ module Zena
|
|
30
30
|
def self.included(base)
|
31
31
|
base.prepend_view_path SITES_ROOT
|
32
32
|
base.class_eval do
|
33
|
+
bricks = []
|
33
34
|
Zena::Use.each_module_for('Controller') do |mod|
|
35
|
+
if mod.to_s =~ /^Bricks::/
|
36
|
+
bricks << mod
|
37
|
+
else
|
38
|
+
include mod
|
39
|
+
end
|
40
|
+
end
|
41
|
+
|
42
|
+
bricks.each do |mod|
|
34
43
|
include mod
|
35
44
|
end
|
36
45
|
|