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
@@ -0,0 +1,380 @@
|
|
1
|
+
require 'fileutils'
|
2
|
+
# ============================================ contact_contents
|
3
|
+
# migrate content to properties
|
4
|
+
class ContactContent < ActiveRecord::Base
|
5
|
+
TRANSLATE_KEYS = {
|
6
|
+
'name' => 'last_name',
|
7
|
+
'zip' => 'postal_code',
|
8
|
+
'city' => 'locality',
|
9
|
+
}
|
10
|
+
def migrate(version)
|
11
|
+
%w{first_name name address zip city telephone mobile email birthday country}.each do |key|
|
12
|
+
value = self[key]
|
13
|
+
next if value.blank?
|
14
|
+
version.prop[TRANSLATE_KEYS[key] || key] = value
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
18
|
+
|
19
|
+
# ============================================ document_contents
|
20
|
+
# migrate page ref to attachments
|
21
|
+
class AttachmentMig < Versions::SharedAttachment
|
22
|
+
set_table_name :attachments
|
23
|
+
|
24
|
+
def filepath(format=nil)
|
25
|
+
"#{SITES_ROOT}#{$site.data_path}/full/#{super()}"
|
26
|
+
end
|
27
|
+
end
|
28
|
+
|
29
|
+
class VClassMig < ActiveRecord::Base
|
30
|
+
set_table_name :roles
|
31
|
+
end
|
32
|
+
|
33
|
+
class UploadedFile < File
|
34
|
+
attr_accessor :original_filename
|
35
|
+
end
|
36
|
+
|
37
|
+
# migrate content to properties
|
38
|
+
class DocumentContent < ActiveRecord::Base
|
39
|
+
TRANSLATE_KEYS = {
|
40
|
+
'exif_json' => 'exif'
|
41
|
+
}
|
42
|
+
|
43
|
+
# Disable type column
|
44
|
+
def self.inheritance_column
|
45
|
+
nil
|
46
|
+
end
|
47
|
+
|
48
|
+
def migrate_attachment(version)
|
49
|
+
if !self.attachment_id
|
50
|
+
# old path
|
51
|
+
digest = Digest::SHA1.hexdigest(self[:id].to_s)
|
52
|
+
# make sure name is not corrupted
|
53
|
+
fname = name.gsub(/[^a-zA-Z\-_0-9]/,'')
|
54
|
+
|
55
|
+
if File.exist?("#{SITES_ROOT}#{$site.data_path}/full") && !File.exist?("#{SITES_ROOT}#{$site.data_path}/full_old")
|
56
|
+
FileUtils.mv("#{SITES_ROOT}#{$site.data_path}/full","#{SITES_ROOT}#{$site.data_path}/full_old")
|
57
|
+
end
|
58
|
+
old_path = "#{SITES_ROOT}#{$site.data_path}/full_old/#{digest[0..0]}/#{digest[1..1]}/#{digest[2..2]}/#{fname}"
|
59
|
+
|
60
|
+
atta = AttachmentMig.new
|
61
|
+
atta['user_id'] = version.user_id
|
62
|
+
atta['site_id'] = version.site_id
|
63
|
+
if type != 'TextDocumentContent'
|
64
|
+
if File.exist?(old_path)
|
65
|
+
file = UploadedFile.new(old_path)
|
66
|
+
file.original_filename = fname
|
67
|
+
atta.file = file
|
68
|
+
atta.save
|
69
|
+
self.attachment_id = atta.id
|
70
|
+
else
|
71
|
+
puts "Missing attachment file for node_id #{version.node_id} (#{version.idx_text_high}): changed to Node"
|
72
|
+
NodeMig.connection.execute "UPDATE nodes SET kpath = 'N', type = 'Node' WHERE id = #{version.node_id}"
|
73
|
+
end
|
74
|
+
end
|
75
|
+
self.save
|
76
|
+
end
|
77
|
+
version.attachment_id = self.attachment_id
|
78
|
+
end
|
79
|
+
|
80
|
+
def migrate(version)
|
81
|
+
exif = self['exif_json']
|
82
|
+
if !exif.blank?
|
83
|
+
version.prop['exif'] = ExifData.json_create('data' => exif)
|
84
|
+
end
|
85
|
+
%w{size content_type ext width height}.each do |key|
|
86
|
+
value = self[key]
|
87
|
+
next if value.blank?
|
88
|
+
version.prop[TRANSLATE_KEYS[key] || key] = value
|
89
|
+
end
|
90
|
+
migrate_attachment(version)
|
91
|
+
end
|
92
|
+
end
|
93
|
+
|
94
|
+
# ============================================ dyn_attributes
|
95
|
+
class DynAttribute < ActiveRecord::Base
|
96
|
+
set_table_name :dyn_attributes
|
97
|
+
|
98
|
+
def migrate(version)
|
99
|
+
version.prop[key] = value
|
100
|
+
end
|
101
|
+
end
|
102
|
+
|
103
|
+
# ============================================ site_attributes
|
104
|
+
class SiteAttribute < ActiveRecord::Base
|
105
|
+
set_table_name :site_attributes
|
106
|
+
|
107
|
+
def migrate(site)
|
108
|
+
site.prop[key] = value
|
109
|
+
end
|
110
|
+
end
|
111
|
+
|
112
|
+
# ============================================ template_contents
|
113
|
+
# migrate content to properties
|
114
|
+
# rebuild index ==> should recreate idx_templates content
|
115
|
+
class TemplateContent < ActiveRecord::Base
|
116
|
+
TRANSLATE_KEYS = {
|
117
|
+
'klass' => 'target_klass'
|
118
|
+
}
|
119
|
+
def migrate(version)
|
120
|
+
version['skin_id'] = version.node[:section_id]
|
121
|
+
|
122
|
+
%w{format tkpath mode klass}.each do |key|
|
123
|
+
value = self[key]
|
124
|
+
next if value.blank?
|
125
|
+
version.prop[TRANSLATE_KEYS[key] || key] = value
|
126
|
+
end
|
127
|
+
end
|
128
|
+
end
|
129
|
+
|
130
|
+
# ============================================ versions
|
131
|
+
class VersionMig < ActiveRecord::Base
|
132
|
+
set_table_name :versions
|
133
|
+
belongs_to :node, :class_name => 'NodeMig', :foreign_key => 'node_id'
|
134
|
+
has_one :template_content, :foreign_key => 'node_id', :primary_key => 'node_id'
|
135
|
+
|
136
|
+
include Property
|
137
|
+
# Should be the same serialization as in Version and Site
|
138
|
+
include Property::Serialization::JSON
|
139
|
+
|
140
|
+
def contact_content
|
141
|
+
@contact_content ||= ContactContent.find(:first,
|
142
|
+
:conditions => ['version_id = ?', content_id || id]
|
143
|
+
)
|
144
|
+
end
|
145
|
+
|
146
|
+
def document_content
|
147
|
+
@document_content ||= DocumentContent.find(:first,
|
148
|
+
:conditions => ['version_id = ?', content_id || id]
|
149
|
+
)
|
150
|
+
end
|
151
|
+
|
152
|
+
def migrate!
|
153
|
+
migrate_base
|
154
|
+
migrate_contact
|
155
|
+
migrate_document
|
156
|
+
migrate_template
|
157
|
+
migrate_dyn_attributes
|
158
|
+
# Allow any property
|
159
|
+
class << self.prop
|
160
|
+
def validate
|
161
|
+
# do nothing
|
162
|
+
true
|
163
|
+
end
|
164
|
+
end
|
165
|
+
|
166
|
+
if !save
|
167
|
+
puts "Could not save version #{id} (#{idx_text_high}):"
|
168
|
+
errors.each_error do |er,msg|
|
169
|
+
puts " [#{er}] #{msg}"
|
170
|
+
end
|
171
|
+
end
|
172
|
+
end
|
173
|
+
|
174
|
+
def migrate_base
|
175
|
+
# migrate content to version properties
|
176
|
+
prop['custom_a'] = node.custom_a unless node.custom_a.nil?
|
177
|
+
prop['custom_b'] = node.custom_b unless node.custom_b.nil?
|
178
|
+
prop['title'] = idx_text_high
|
179
|
+
prop['summary'] = idx_text_medium
|
180
|
+
prop['text'] = idx_text_low
|
181
|
+
prop['ext'] = 'zafu' if node.kpath =~ /\ANDTT/
|
182
|
+
end
|
183
|
+
|
184
|
+
def migrate_contact
|
185
|
+
if contact_content
|
186
|
+
contact_content.migrate(self)
|
187
|
+
end
|
188
|
+
end
|
189
|
+
|
190
|
+
def migrate_document
|
191
|
+
if document_content
|
192
|
+
document_content.migrate(self)
|
193
|
+
end
|
194
|
+
end
|
195
|
+
|
196
|
+
def migrate_template
|
197
|
+
if template_content
|
198
|
+
template_content.migrate(self)
|
199
|
+
end
|
200
|
+
end
|
201
|
+
|
202
|
+
def migrate_dyn_attributes
|
203
|
+
DynAttribute.find(:all, :conditions => ["owner_id = ?", self.id]).each do |dyn|
|
204
|
+
dyn.migrate(self)
|
205
|
+
end
|
206
|
+
end
|
207
|
+
end
|
208
|
+
|
209
|
+
class NodeMig < ActiveRecord::Base
|
210
|
+
set_table_name :nodes
|
211
|
+
has_many :versions, :class_name => 'VersionMig', :foreign_key => 'node_id'
|
212
|
+
|
213
|
+
# Disable type column
|
214
|
+
def self.inheritance_column
|
215
|
+
nil
|
216
|
+
end
|
217
|
+
end
|
218
|
+
|
219
|
+
# === dyn_attributes
|
220
|
+
|
221
|
+
class SiteMig < ActiveRecord::Base
|
222
|
+
CHUNK_SIZE = 200
|
223
|
+
has_many :site_attributes, :class_name => 'SiteAttribute', :foreign_key => 'owner_id'
|
224
|
+
|
225
|
+
include Property
|
226
|
+
|
227
|
+
set_table_name :sites
|
228
|
+
|
229
|
+
def data_path
|
230
|
+
"/#{self[:host]}/data"
|
231
|
+
end
|
232
|
+
|
233
|
+
def migrate!
|
234
|
+
# needed by DocumentContent
|
235
|
+
$site = self
|
236
|
+
|
237
|
+
# Allow any property
|
238
|
+
class << self.prop
|
239
|
+
def validate
|
240
|
+
# do nothing
|
241
|
+
true
|
242
|
+
end
|
243
|
+
end
|
244
|
+
|
245
|
+
migrate_nodes
|
246
|
+
migrate_site
|
247
|
+
if !save
|
248
|
+
puts "Could not save site #{id} (#{host}):"
|
249
|
+
errors.each_error do |er,msg|
|
250
|
+
puts " [#{er}] #{msg}"
|
251
|
+
end
|
252
|
+
end
|
253
|
+
end
|
254
|
+
|
255
|
+
def migrate_nodes
|
256
|
+
node_count = NodeMig.count(:conditions =>['site_id = ?', id])
|
257
|
+
puts "========================================== Start data migration to 1.0 for #{host} (#{node_count} nodes)"
|
258
|
+
puts "========== creating virtual classes (Contact, Reference)"
|
259
|
+
# Create Contact + Reference virtual classes
|
260
|
+
ref_class = VClassMig.create(
|
261
|
+
:name => 'Reference',
|
262
|
+
:kpath => 'NR',
|
263
|
+
:real_class => 'Node',
|
264
|
+
:create_group_id => public_group_id,
|
265
|
+
:site_id => id
|
266
|
+
)
|
267
|
+
contact_class = VClassMig.create(
|
268
|
+
:name => 'Contact',
|
269
|
+
:kpath => 'NRC',
|
270
|
+
:real_class => 'Node',
|
271
|
+
:create_group_id => public_group_id,
|
272
|
+
:site_id => id
|
273
|
+
)
|
274
|
+
# Update nodes depending on Contact + Reference classes
|
275
|
+
execute "UPDATE nodes SET vclass_id = #{ref_class.id} WHERE type = 'Reference' AND vclass_id IS NULL AND site_id = #{id}"
|
276
|
+
execute "UPDATE nodes SET vclass_id = #{contact_class.id} WHERE type = 'Contact' AND vclass_id IS NULL AND site_id = #{id}"
|
277
|
+
execute "UPDATE nodes SET type = 'Node' WHERE (type = 'Reference' or type = 'Contact') AND site_id = #{id}"
|
278
|
+
|
279
|
+
page = 0
|
280
|
+
while true do
|
281
|
+
nodes = NodeMig.find(:all,
|
282
|
+
:conditions => ['site_id = ?', id],
|
283
|
+
:limit => CHUNK_SIZE,
|
284
|
+
:offset => page * CHUNK_SIZE,
|
285
|
+
:order => 'id ASC'
|
286
|
+
)
|
287
|
+
break if nodes == []
|
288
|
+
puts "========== migrating nodes #{(page * CHUNK_SIZE) + 1} to #{[((page+1) * CHUNK_SIZE), node_count].min}"
|
289
|
+
nodes.each do |n|
|
290
|
+
n.versions.each do |v|
|
291
|
+
v.migrate!
|
292
|
+
end
|
293
|
+
end
|
294
|
+
page += 1
|
295
|
+
end
|
296
|
+
|
297
|
+
# ============================================ nodes
|
298
|
+
# 1. Set skin_id from skin name
|
299
|
+
NodeMig.find(:all,
|
300
|
+
:conditions => ['site_id = ? AND type = ?', id, 'Skin']
|
301
|
+
).each do |skin|
|
302
|
+
execute "UPDATE nodes SET skin_id = #{skin.id} WHERE skin = '#{skin.name}' and site_id = #{id}"
|
303
|
+
end
|
304
|
+
|
305
|
+
# 2. Set _id from name
|
306
|
+
execute "UPDATE nodes SET _id = name WHERE site_id = #{id}"
|
307
|
+
|
308
|
+
# 3. move custom_a, custom_b to idx_integer1, idx_integer2
|
309
|
+
execute "UPDATE nodes SET idx_integer1 = custom_a, idx_integer2 = custom_b"
|
310
|
+
end
|
311
|
+
|
312
|
+
def migrate_site
|
313
|
+
# ============================================ site_attributes
|
314
|
+
# migrate to properties
|
315
|
+
site_attributes.each do |attribute|
|
316
|
+
attribute.migrate(self)
|
317
|
+
end
|
318
|
+
end
|
319
|
+
|
320
|
+
private
|
321
|
+
def execute(*args)
|
322
|
+
self.class.connection.execute(*args)
|
323
|
+
end
|
324
|
+
end
|
325
|
+
|
326
|
+
|
327
|
+
# This migration should be run in the 1.0 branch *AFTER* the migration
|
328
|
+
# to Zerox1Schema.
|
329
|
+
class Zerox1Data < ActiveRecord::Migration
|
330
|
+
extend Zena::Acts::Secure
|
331
|
+
def self.up
|
332
|
+
if connection.tables.include?('contact_contents') && ContactContent.first
|
333
|
+
# Need to migrate data
|
334
|
+
if $Zerox1SchemaRunning
|
335
|
+
raise "\n\n=> This is not an error !\n=> Please continue migrations (restart is needed before migrating data)\n=> rake zena:migrate\n\n"
|
336
|
+
end
|
337
|
+
else
|
338
|
+
# Nothing to be done here
|
339
|
+
puts "=> No legacy data to migrate."
|
340
|
+
return
|
341
|
+
end
|
342
|
+
|
343
|
+
# Prepare
|
344
|
+
add_column :document_contents, :attachment_id, :integer unless DocumentContent.column_names.include?('attachment_id')
|
345
|
+
|
346
|
+
DocumentContent.reset_column_information
|
347
|
+
|
348
|
+
execute "UPDATE roles SET real_class = 'Node' WHERE real_class = 'Reference' OR real_class = 'Contact'"
|
349
|
+
|
350
|
+
sites = SiteMig.all
|
351
|
+
sites.each do |site|
|
352
|
+
site.migrate!
|
353
|
+
end
|
354
|
+
|
355
|
+
# ============================================ roles
|
356
|
+
# make properties from dyn_keys list ?
|
357
|
+
|
358
|
+
execute "UPDATE roles SET type = 'VirtualClass'"
|
359
|
+
|
360
|
+
native_key = 'icon'
|
361
|
+
prop_key = 'icon'
|
362
|
+
VClassMig.all.each do |rec|
|
363
|
+
value = rec[native_key]
|
364
|
+
next if value.blank?
|
365
|
+
prop = rec.prop
|
366
|
+
prop[prop_key] = value
|
367
|
+
Zena::Db.execute "UPDATE #{rec.class.table_name} SET properties=#{Zena::Db.quote(rec.class.encode_properties(prop))} WHERE id=#{rec[:id]}"
|
368
|
+
end
|
369
|
+
|
370
|
+
puts %q{
|
371
|
+
======== Migration succeded.
|
372
|
+
***********************************************************************************
|
373
|
+
****************** You need to rebuild vhash, fullpath and index now! *************
|
374
|
+
|
375
|
+
=> rake zena:rebuild_vhash WORKER=false && rake zena:rebuild_fullpath WORKER=false && rake zena:rebuild_index WORKER=false
|
376
|
+
|
377
|
+
***********************************************************************************
|
378
|
+
}
|
379
|
+
end
|
380
|
+
end
|
data/config/database_example.yml
CHANGED
@@ -1,5 +1,5 @@
|
|
1
1
|
# Enter database configuration information here (rename this file "database.yml").
|
2
|
-
# You do not need to do any of this if you use
|
2
|
+
# You do not need to do any of this if you use capistrano (see config/deploy.rg).
|
3
3
|
# MySQL
|
4
4
|
login: &dev_login
|
5
5
|
adapter: mysql
|
data/config/environment.rb
CHANGED
@@ -1,5 +1,5 @@
|
|
1
1
|
# Specifies gem version of Rails to use when vendor/rails is not present
|
2
|
-
RAILS_GEM_VERSION = '2.3.
|
2
|
+
RAILS_GEM_VERSION = '2.3.11' unless defined? RAILS_GEM_VERSION
|
3
3
|
|
4
4
|
# Bootstrap the Rails environment, frameworks, and default configuration
|
5
5
|
require File.join(File.dirname(__FILE__), 'boot')
|
data/config/gems.yml
CHANGED
@@ -1,23 +1,24 @@
|
|
1
1
|
hpricot:
|
2
|
-
gettext: '
|
2
|
+
gettext: '= 2.1.0'
|
3
3
|
ruby-recaptcha: '= 1.0.0'
|
4
4
|
syntax: '= 1.0.0'
|
5
|
-
tzinfo: '
|
5
|
+
tzinfo: '= 0.3.26'
|
6
6
|
uuidtools: '= 2.0.0'
|
7
|
-
rails: '= 2.3.
|
8
|
-
json: '
|
7
|
+
rails: '= 2.3.11'
|
8
|
+
json: '= 1.5.1'
|
9
9
|
authlogic: '= 2.1.3'
|
10
10
|
fast_gettext: '~> 0.4.16'
|
11
11
|
will_paginate: '~> 2.3.12'
|
12
|
-
differ: '
|
12
|
+
differ: '= 0.1.2'
|
13
13
|
shoulda: '= 2.10.3'
|
14
|
+
httparty: '= 0.6.1'
|
14
15
|
|
15
|
-
querybuilder: '
|
16
|
-
yamltest: '
|
17
|
-
rubyless: '
|
18
|
-
property: '
|
19
|
-
versions: '
|
20
|
-
zafu: '
|
16
|
+
querybuilder: '= 1.0.0'
|
17
|
+
yamltest: '= 0.7.0'
|
18
|
+
rubyless: '= 0.8.2'
|
19
|
+
property: '= 2.1.2'
|
20
|
+
versions: '= 0.3.1'
|
21
|
+
zafu: '= 0.7.9'
|
21
22
|
|
22
23
|
jeweler:
|
23
24
|
|
@@ -28,19 +29,21 @@ RedCloth:
|
|
28
29
|
rmagick:
|
29
30
|
optional: yes
|
30
31
|
lib: 'RMagick'
|
31
|
-
version: '
|
32
|
+
version: '= 2.13.1'
|
32
33
|
|
33
34
|
thinking-sphinx:
|
34
35
|
optional: yes
|
35
36
|
brick: sphinx
|
36
37
|
lib: 'thinking_sphinx'
|
37
|
-
version: '
|
38
|
+
version: '= 1.3.14'
|
39
|
+
|
40
|
+
# needs riddle 1.0.10
|
38
41
|
|
39
42
|
ts-delayed-delta:
|
40
43
|
optional: yes
|
41
44
|
brick: sphinx
|
42
45
|
lib: 'thinking_sphinx/deltas/delayed_delta'
|
43
|
-
version: '
|
46
|
+
version: '= 1.0.2'
|
44
47
|
|
45
48
|
delayed_job:
|
46
49
|
optional: yes
|
@@ -1 +1,8 @@
|
|
1
|
-
<r:include template='
|
1
|
+
<r:include template='Node'>
|
2
|
+
<r:with part='context'/>
|
3
|
+
<r:with part='content' class='project'>
|
4
|
+
<r:include template='Node' part='related'/>
|
5
|
+
<r:zazen attr='text' live='true'/>
|
6
|
+
<r:include template='notes'/>
|
7
|
+
</r:with>
|
8
|
+
</r:include>
|
@@ -20,6 +20,7 @@ td { padding:5px; }
|
|
20
20
|
<body do='void' name='body'>
|
21
21
|
<div id='login_form'>
|
22
22
|
<p class='welcome' do='link'><r:t>Login for</r:t> <b do='title'/></p>
|
23
|
+
<r:flash_messages/>
|
23
24
|
<form action="/session" method="post"> <table>
|
24
25
|
<tr>
|
25
26
|
<td><label for='user_login' do='trans'>User name:</label></td>
|
@@ -6,13 +6,13 @@
|
|
6
6
|
|
7
7
|
<ul id='search_results' do='search_results'>
|
8
8
|
<li class='result_entry' do='each'>
|
9
|
-
<p class='result_image' do='Document'>
|
9
|
+
<p class='result_image' do='Document?'>
|
10
10
|
<r:link format='data' do='img' alt_src='icon' mode='pv'/>
|
11
11
|
<r:else do='link' do='img' alt_src='icon' mode='pv'/>
|
12
12
|
</p>
|
13
13
|
<p class='result_name'><r:link/></p>
|
14
14
|
<p class='result_path'><r:show attr='short_path'/></p>
|
15
|
-
<r:summary/>
|
15
|
+
<r:zazen attr='summary'/>
|
16
16
|
<div class='clear'></div>
|
17
17
|
</li>
|
18
18
|
<r:else>
|
@@ -7,7 +7,7 @@
|
|
7
7
|
<meta http-equiv="Content-type" content="text/html; charset=utf-8" />
|
8
8
|
<r:void name='stylesheets'>
|
9
9
|
<r:stylesheets media='all'/>
|
10
|
-
<link href="style.css" rel="Stylesheet" type="text/css"/>
|
10
|
+
<link href="img/style.css" rel="Stylesheet" type="text/css"/>
|
11
11
|
</r:void>
|
12
12
|
|
13
13
|
<r:javascripts/>
|
@@ -18,10 +18,10 @@
|
|
18
18
|
<div id='top' do='root' do='link'/>
|
19
19
|
<div id='header'>
|
20
20
|
<div id='login' do='login_link'/>
|
21
|
-
<div id='visitor' do='
|
21
|
+
<div id='visitor'><r:visitor_link/> <r:if test='can_edit?' do='link' mode='admin' do='t'>btn_edit</r:if></div>
|
22
22
|
<div id='search' do='search_box' type='search'/>
|
23
23
|
<ol id='menu' do='root' do='pages'>
|
24
|
-
<li do='each'
|
24
|
+
<li do='each' on_if='is_ancestor?(main)' do='link'/>
|
25
25
|
</ol>
|
26
26
|
</div>
|
27
27
|
<div id='container'>
|
@@ -34,8 +34,8 @@
|
|
34
34
|
<li class='inline_form' do='form'>
|
35
35
|
<ol>
|
36
36
|
<li><r:select name='klass' root_class='Page'/></li>
|
37
|
-
<li><input type='text' name='title' value=''/></li>
|
38
|
-
<li class='validate'><input type="submit" value='#{trans("validate")'/></li>
|
37
|
+
<li><r:input type='text' name='title' value=''/></li>
|
38
|
+
<li class='validate'><r:input type="submit" value='#{trans("validate")'/></li>
|
39
39
|
</ol>
|
40
40
|
</li>
|
41
41
|
</ol>
|
@@ -64,8 +64,8 @@
|
|
64
64
|
<li do='add' before='self'/>
|
65
65
|
<li class='inline_form' do='form'>
|
66
66
|
<p class='node_klass'> <r:select name='klass' root_class='Page'/></p>
|
67
|
-
<p class='node_title'><input type='text' name='title' value=''/></p>
|
68
|
-
<p class='btn_validate'><input type="submit" value='#{trans("validate")}'/></p>
|
67
|
+
<p class='node_title'><r:input type='text' name='title' value=''/></p>
|
68
|
+
<p class='btn_validate'><r:input type="submit" value='#{trans("validate")}'/></p>
|
69
69
|
</li>
|
70
70
|
</ol>
|
71
71
|
</r:pages>
|
@@ -75,8 +75,8 @@
|
|
75
75
|
<li do='add' before='self'/>
|
76
76
|
<li class='inline_form' do='form'>
|
77
77
|
<p class='node_klass'> <r:select name='klass' root_class='Node'/></p>
|
78
|
-
<p class='node_title'><input type='text' name='title' value=''/></p>
|
79
|
-
<p class='btn_validate'><input type="submit" value='#{trans("validate")}'/></p>
|
78
|
+
<p class='node_title'><r:input type='text' name='title' value=''/></p>
|
79
|
+
<p class='btn_validate'><r:input type="submit" value='#{trans("validate")}'/></p>
|
80
80
|
</li>
|
81
81
|
</ol>
|
82
82
|
</r:nodes>
|
File without changes
|
File without changes
|
@@ -0,0 +1,11 @@
|
|
1
|
+
translations:
|
2
|
+
add_object: "<img src='/images/add.png' title='add a new object'/> add object"
|
3
|
+
upload_document: "<img src='/images/add.png' title='upload a new document'/> upload document"
|
4
|
+
view_live: "view live <img src='/images/bullet_go.png'/>"
|
5
|
+
page: page
|
6
|
+
records: records
|
7
|
+
root_node: root node
|
8
|
+
not_found: not found
|
9
|
+
crop: crop
|
10
|
+
no_parent: no parent
|
11
|
+
admin_interface: admin interface
|
@@ -1,17 +1,15 @@
|
|
1
|
-
<div id='notes' do='
|
1
|
+
<div id='notes' do='posts' in='project' limit='10' order='date desc'>
|
2
2
|
<ul class='note_list'>
|
3
|
-
<li do='add' after='self'/>
|
3
|
+
<li do='add' after='self' klass='Post'/>
|
4
4
|
<li class='inline_form' do='form'>
|
5
|
-
<
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
<p class='validate'> <input type="submit" value='#{trans("validate")}'/></p>
|
10
|
-
</form>
|
5
|
+
<p class='node_title'><r:input type='text' name='title' size='25'/></p>
|
6
|
+
<p class='node_klass'> <r:select name='klass' root_class='Note' selected='Post'/></p>
|
7
|
+
<p class='node_date'> <r:input type='date_box' name='date'/> </p>
|
8
|
+
<p class='validate'> <r:input type="submit" value='#{trans("validate")}'/></p>
|
11
9
|
</li>
|
12
10
|
<li class='note' do='each' live='true'>
|
13
11
|
<div class='header'>
|
14
|
-
<p class='log_at' do='show'
|
12
|
+
<p class='log_at' do='show' attr='date' tformat='full_date'>04.10</p>
|
15
13
|
<h2 class='title' do='title' actions='all'/>
|
16
14
|
<div class='summary' do='zazen(summary)' live='true'/>
|
17
15
|
</div>
|
data/doc/zafu_changes.yml
CHANGED
@@ -27,3 +27,15 @@ CHANGESET2:
|
|
27
27
|
new: "<r:anchor do='link'/>"
|
28
28
|
|
29
29
|
|
30
|
+
show_path: "<ul id='path' do='ancestors'><li do='each' do='link'/></ul>"
|
31
|
+
start_node: "start"
|
32
|
+
# [v_title]: "title"
|
33
|
+
v_title: "title"
|
34
|
+
"<r:if kind_of='Section'": "<r:Section?>"
|
35
|
+
"<r:text/>": "mat"
|
36
|
+
"on_if_node='ancestor'": "on_if='is_ancestor?(main)'"
|
37
|
+
"<div do='admin_links'/>": "<ol class='admin_links' do='admin_links'>
|
38
|
+
<li do='each' do='show'><a href='#'>do this</a></li>
|
39
|
+
</ol>"
|
40
|
+
"set_class='li_s[v_status]'": "class='li_s#{v.status}'"
|
41
|
+
"<meta name='keywords' do='void' set_content='[d_keywords]'/>": "<meta name='keywords' content='#{keywords}'/>"
|