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/History.txt
CHANGED
@@ -1,3 +1,26 @@
|
|
1
|
+
== 1.0.0.rc3 2011-05-26
|
2
|
+
|
3
|
+
* major changes
|
4
|
+
* Included tag in xml serialization (tag_names)
|
5
|
+
* Added export/import support for Roles/Columns and Relations.
|
6
|
+
* Fixed bugs when changing class hierarchy (move rename VirtualClass).
|
7
|
+
* Fixed many small bugs and issues (indexing, link date, missed errors, etc).
|
8
|
+
* Fixed block edit with ajax ([edit] method).
|
9
|
+
* Removed fulltext search (no more MyISAM tables).
|
10
|
+
* Fixed SQLiss scoping in queries like "Job:project" (added kpath filter).
|
11
|
+
* Fixed Zafu calendar and timezones in dates.
|
12
|
+
* Added 'foreach' method (paginated looping in SQLiss query) for console.
|
13
|
+
* Added 'count' method (count objects with SQLiss query) for console.
|
14
|
+
* Added support for scripts with Zena::Console.
|
15
|
+
* Added support for "select" and "having" in SQLiss.
|
16
|
+
* Added button to create specialized skin for current page in dev_box.
|
17
|
+
* Added 'query_errors' to report dynamic query errors.
|
18
|
+
* Created a basic admin interface (backend).
|
19
|
+
* Added 'js' tag, fixed many ajax bugs.
|
20
|
+
* Added 'crop' tag.
|
21
|
+
* On-the-fly creation of specialized template from dev_box.
|
22
|
+
* Added 'insert' option for [link].
|
23
|
+
|
1
24
|
== 1.0.0.rc2 2011-02-14
|
2
25
|
|
3
26
|
* major changes
|
data/README.rdoc
CHANGED
@@ -60,7 +60,7 @@ You can now login with 'admin' and the password you used to make the site.
|
|
60
60
|
=== 1. Original in debian etch (might need to replace jpeg by libjpeg62)
|
61
61
|
# aptitude install build-essential apache2 mysql-server libmagick9-dev gs-gpl libssl-dev gettext libgettext-ruby libreadline5 libreadline5-dev zlib1g-dev libncurses5 libncurses5-dev unzip liburi-perl libjpeg-dev subversion ssh sudo awstats
|
62
62
|
|
63
|
-
If you want to enable LateX (
|
63
|
+
If you want to enable LateX (Pdf generation)
|
64
64
|
tetex-bin tetex-extra latex-ucs
|
65
65
|
|
66
66
|
For math mode (inline formulas), you will need
|
@@ -1,6 +1,6 @@
|
|
1
1
|
class ColumnsController < ApplicationController
|
2
2
|
before_filter :visitor_node
|
3
|
-
before_filter :find_column, :except => [:index, :create, :new
|
3
|
+
before_filter :find_column, :except => [:index, :create, :new]
|
4
4
|
before_filter :check_is_admin
|
5
5
|
layout :admin_layout
|
6
6
|
|
@@ -29,34 +29,6 @@ class ColumnsController < ApplicationController
|
|
29
29
|
end
|
30
30
|
end
|
31
31
|
|
32
|
-
def export
|
33
|
-
data = secure(Column) do
|
34
|
-
Column.export
|
35
|
-
end
|
36
|
-
|
37
|
-
### TODO
|
38
|
-
end
|
39
|
-
|
40
|
-
def import
|
41
|
-
attachment = params[:attachment]
|
42
|
-
if attachment.nil?
|
43
|
-
flass[:error] = "Upload failure: no definitions."
|
44
|
-
redirect_to :action => :index
|
45
|
-
else
|
46
|
-
data = YAML.load(attachment.read) rescue nil
|
47
|
-
if data.nil?
|
48
|
-
flash[:error] = "Could not parse yaml document"
|
49
|
-
redirect_to :action => :index
|
50
|
-
else
|
51
|
-
@columns = secure(Column) { Column.import(data) }.paginate(:per_page => 200)
|
52
|
-
@column = VirtualClass.new('')
|
53
|
-
respond_to do |format|
|
54
|
-
format.html { render :action => 'index' }
|
55
|
-
end
|
56
|
-
end
|
57
|
-
end
|
58
|
-
end
|
59
|
-
|
60
32
|
# GET /columns/1
|
61
33
|
# GET /columns/1.xml
|
62
34
|
def show
|
@@ -94,7 +66,7 @@ class ColumnsController < ApplicationController
|
|
94
66
|
|
95
67
|
respond_to do |format|
|
96
68
|
if @column.save
|
97
|
-
flash[:notice] = 'Column was successfully created.'
|
69
|
+
flash.now[:notice] = _('Column was successfully created.')
|
98
70
|
format.html { redirect_to(@column) }
|
99
71
|
format.js
|
100
72
|
format.xml { render :xml => @column, :status => :created, :location => @column }
|
@@ -111,7 +83,7 @@ class ColumnsController < ApplicationController
|
|
111
83
|
def update
|
112
84
|
respond_to do |format|
|
113
85
|
if @column.update_attributes(params[:column])
|
114
|
-
flash[:notice] = 'Column was successfully updated.'
|
86
|
+
flash.now[:notice] = _('Column was successfully updated.')
|
115
87
|
format.html { redirect_to(@column) }
|
116
88
|
format.xml { head :ok }
|
117
89
|
else
|
@@ -24,16 +24,21 @@ class CommentsController < ApplicationController
|
|
24
24
|
|
25
25
|
@comment = secure(Comment) { Comment.new(filter_attributes(params[:comment])) }
|
26
26
|
|
27
|
-
|
27
|
+
if should_save(@comment, params)
|
28
|
+
@comment.save
|
29
|
+
else
|
30
|
+
#...
|
31
|
+
end
|
28
32
|
|
29
33
|
respond_to do |format|
|
30
34
|
if @comment.errors.empty?
|
31
|
-
flash[:notice] = _('Comment was successfully created.')
|
35
|
+
flash.now[:notice] = _('Comment was successfully created.')
|
32
36
|
format.html { redirect_to zen_path(@node) } # TODO: add ':sharp => ...'
|
33
37
|
format.js
|
34
38
|
format.xml { head :created, :location => comment_path(@node) }
|
35
39
|
else
|
36
|
-
|
40
|
+
flash[:error] = error_messages_for(:comment, :object => @comment)
|
41
|
+
format.html { redirect_to zen_path(@node) }
|
37
42
|
format.js
|
38
43
|
format.xml { render :xml => @comment.errors.to_xml }
|
39
44
|
end
|
@@ -15,7 +15,7 @@ class DataEntriesController < ApplicationController
|
|
15
15
|
|
16
16
|
respond_to do |format|
|
17
17
|
if @data_entry.errors.empty?
|
18
|
-
flash[:notice] = _('Data entry was successfully created.')
|
18
|
+
flash.now[:notice] = _('Data entry was successfully created.')
|
19
19
|
format.html { redirect_to data_entry_url(@data_entry) }
|
20
20
|
format.js
|
21
21
|
format.xml { head :created, :location => data_entry_url(@data_entry) }
|
@@ -34,7 +34,7 @@ class DocumentsController < ApplicationController
|
|
34
34
|
if @node.new_record?
|
35
35
|
@node.skin_id ||= current_site.root_node.skin_id
|
36
36
|
|
37
|
-
flash[:error] = _("Upload failed.")
|
37
|
+
flash.now[:error] = _("Upload failed.")
|
38
38
|
unless @node.respond_to?('target_klass')
|
39
39
|
# Could we find another way to fake the new object as acting like a template ?
|
40
40
|
class << @node
|
@@ -43,7 +43,7 @@ class DocumentsController < ApplicationController
|
|
43
43
|
end
|
44
44
|
format.html { render :action => 'new'}
|
45
45
|
else
|
46
|
-
flash[:notice] = _("Upload succeeded.")
|
46
|
+
flash.now[:notice] = _("Upload succeeded.")
|
47
47
|
format.html { redirect_to document_url(@node[:zip]) }
|
48
48
|
end
|
49
49
|
end
|
@@ -58,7 +58,7 @@ class NodesController < ApplicationController
|
|
58
58
|
begin
|
59
59
|
do_search
|
60
60
|
rescue ::QueryBuilder::Error => err
|
61
|
-
flash[:error] = err.message
|
61
|
+
flash.now[:error] = err.message
|
62
62
|
end
|
63
63
|
render_and_cache :mode => '+search', :cache => false
|
64
64
|
end
|
@@ -132,7 +132,10 @@ class NodesController < ApplicationController
|
|
132
132
|
@errors = other.errors
|
133
133
|
end
|
134
134
|
end
|
135
|
-
elsif
|
135
|
+
elsif params[:change] == 'params'
|
136
|
+
p = params.dup
|
137
|
+
p.delete(:action)
|
138
|
+
p.delete(:controller)
|
136
139
|
params.merge!(other.replace_attributes_in_values(p))
|
137
140
|
end
|
138
141
|
|
@@ -209,14 +212,17 @@ class NodesController < ApplicationController
|
|
209
212
|
|
210
213
|
respond_to do |format|
|
211
214
|
if @node.errors.empty?
|
212
|
-
flash[:notice] = 'Node was successfully created.'
|
215
|
+
flash.now[:notice] = 'Node was successfully created.'
|
213
216
|
format.html {
|
214
217
|
redirect_to params[:redir] || zen_path(@node, :mode => params[:mode])
|
215
218
|
}
|
216
219
|
format.js
|
217
220
|
format.xml { render :xml => @node.to_xml(:root => 'node'), :status => :created, :location => node_url(@node) }
|
218
221
|
else
|
219
|
-
format.html
|
222
|
+
format.html do
|
223
|
+
flash[:error] = error_messages_for('node', :object => @node)
|
224
|
+
redirect_to request.referer
|
225
|
+
end
|
220
226
|
format.js
|
221
227
|
format.xml { render :xml => @node.errors, :status => :unprocessable_entity }
|
222
228
|
end
|
@@ -239,13 +245,13 @@ class NodesController < ApplicationController
|
|
239
245
|
|
240
246
|
def destroy
|
241
247
|
respond_to do |format|
|
242
|
-
|
243
248
|
format.html do
|
244
249
|
if @node.destroy
|
245
|
-
flash
|
246
|
-
|
250
|
+
# These flash messages tend to hang around stupidly
|
251
|
+
# flash[:notice] = _("Node destroyed.")
|
252
|
+
redirect_to params[:redir] || zen_path(@node.parent)
|
247
253
|
else
|
248
|
-
flash[:notice] = "Could not destroy node."
|
254
|
+
flash.now[:notice] = _("Could not destroy node.")
|
249
255
|
render :action => 'show'
|
250
256
|
end
|
251
257
|
end
|
@@ -276,9 +282,9 @@ class NodesController < ApplicationController
|
|
276
282
|
@node = version.node
|
277
283
|
@node.backup
|
278
284
|
if @node.errors.empty?
|
279
|
-
flash[:notice] = _("Backup created.")
|
285
|
+
flash.now[:notice] = _("Backup created.")
|
280
286
|
else
|
281
|
-
flash[:error] = _("Could not create backup.")
|
287
|
+
flash.now[:error] = _("Could not create backup.")
|
282
288
|
end
|
283
289
|
end
|
284
290
|
|
@@ -502,6 +508,16 @@ class NodesController < ApplicationController
|
|
502
508
|
# archive ---> fullpath
|
503
509
|
def find_node
|
504
510
|
if path = params[:path]
|
511
|
+
# We do not use params[:path] because Rails does url unescape
|
512
|
+
# and we want to do this ourselves.
|
513
|
+
# TEMPORARY HACK until we use the new urls with Rails 3
|
514
|
+
# If you change this, make sure to test with an image data (cachestamp)
|
515
|
+
# in a custom_base path.
|
516
|
+
if request.env['REQUEST_PATH']
|
517
|
+
# request.env['REQUEST_PATH'] is not set during testing (but this is
|
518
|
+
# a temporary hack anyway)
|
519
|
+
path = params[:path] = request.env['REQUEST_PATH'].split('/')[2..-1]
|
520
|
+
end
|
505
521
|
if path.last =~ Zena::Use::Urls::ALLOWED_REGEXP
|
506
522
|
zip = $3
|
507
523
|
name = $4
|
@@ -517,13 +533,14 @@ class NodesController < ApplicationController
|
|
517
533
|
if name =~ /^\d+$/
|
518
534
|
@node = secure!(Node) { Node.find_by_zip(name) }
|
519
535
|
elsif name
|
520
|
-
basepath = (path[0..-2] + [name]).map
|
521
|
-
@node = secure!(Node) { Node.find_by_path(basepath) }
|
536
|
+
basepath = (path[0..-2] + [name]).map {|p| String.from_url_name(p) }.join('/')
|
537
|
+
@node = secure!(Node) { Node.find_by_path(basepath) || Node.find_by_path(basepath, current_site.root_id, true) }
|
522
538
|
else
|
523
539
|
@node = secure!(Node) { Node.find_by_zip(zip) }
|
524
540
|
end
|
525
541
|
else
|
526
542
|
# bad url
|
543
|
+
Node.logger.warn "Path #{path.last.inspect} does not match #{Zena::Use::Urls::ALLOWED_REGEXP}"
|
527
544
|
raise ActiveRecord::RecordNotFound
|
528
545
|
end
|
529
546
|
elsif params[:id]
|
@@ -49,7 +49,7 @@ class RelationsController < ApplicationController
|
|
49
49
|
|
50
50
|
respond_to do |format|
|
51
51
|
if @relation.save
|
52
|
-
flash[:notice] = 'Relation was successfully created.'
|
52
|
+
flash.now[:notice] = _('Relation was successfully created.')
|
53
53
|
format.html { redirect_to relation_url(@relation) }
|
54
54
|
format.js
|
55
55
|
format.xml { render :xml => @relation, :status => :created, :location => relation_url(@relation) }
|
@@ -66,7 +66,7 @@ class RelationsController < ApplicationController
|
|
66
66
|
|
67
67
|
respond_to do |format|
|
68
68
|
if @relation.update_attributes(params[:relation])
|
69
|
-
flash[:notice] = 'Relation was successfully updated.'
|
69
|
+
flash.now[:notice] = _('Relation was successfully updated.')
|
70
70
|
format.html { redirect_to relation_url(@relation) }
|
71
71
|
format.js
|
72
72
|
format.xml { head :ok }
|
@@ -33,7 +33,7 @@ class SitesController < ApplicationController
|
|
33
33
|
def update
|
34
34
|
respond_to do |format|
|
35
35
|
if @site.update_attributes(params[:site])
|
36
|
-
flash[:notice] = 'Site was successfully updated.'
|
36
|
+
flash.now[:notice] = _('Site was successfully updated.')
|
37
37
|
format.html { redirect_to site_path(@site) }
|
38
38
|
format.js
|
39
39
|
format.xml { head :ok }
|
@@ -14,10 +14,13 @@ class UserSessionsController < ApplicationController
|
|
14
14
|
User.send(:with_scope, :find => {:conditions => ['site_id = ?', visitor.site.id]}) do
|
15
15
|
@user_session = UserSession.new(:login=>params[:login], :password=>params[:password])
|
16
16
|
if @user_session.save
|
17
|
-
flash[:notice] = "Successfully logged in."
|
17
|
+
#flash.now[:notice] = _("Successfully logged in.")
|
18
18
|
redirect_to redirect_after_login
|
19
19
|
else
|
20
|
-
flash[:notice] = "Invalid login or password."
|
20
|
+
flash[:notice] = _("Invalid login or password.")
|
21
|
+
# FIXME: find a better way to lock without blocking the process.
|
22
|
+
# Also lock longer and longer (exponentially).
|
23
|
+
sleep(2)
|
21
24
|
redirect_to login_url
|
22
25
|
end
|
23
26
|
end
|
@@ -27,7 +30,7 @@ class UserSessionsController < ApplicationController
|
|
27
30
|
if @user_session = UserSession.find
|
28
31
|
@user_session.destroy
|
29
32
|
reset_session
|
30
|
-
flash[:notice] = "Successfully logged out."
|
33
|
+
#flash.now[:notice] = _("Successfully logged out.")
|
31
34
|
redirect_to params[:redirect] || home_path(:prefix => prefix)
|
32
35
|
else
|
33
36
|
redirect_to home_path(:prefix => prefix)
|
@@ -37,7 +37,7 @@ class UsersController < ApplicationController
|
|
37
37
|
# xx ==> fixed skin
|
38
38
|
def dev_skin(skin_id = params['skin_id'])
|
39
39
|
visitor.update_attributes('dev_skin_id' => skin_id)
|
40
|
-
|
40
|
+
|
41
41
|
if request.referer && !(request.referer =~ /login/)
|
42
42
|
redirect_to request.referer
|
43
43
|
else
|
@@ -78,7 +78,6 @@ class UsersController < ApplicationController
|
|
78
78
|
end
|
79
79
|
end
|
80
80
|
|
81
|
-
# TODO: test
|
82
81
|
def update
|
83
82
|
if skin_id = params['user']['dev_skin_id']
|
84
83
|
return dev_skin(skin_id)
|
@@ -86,35 +85,38 @@ class UsersController < ApplicationController
|
|
86
85
|
|
87
86
|
@update = params.delete(:update)
|
88
87
|
|
89
|
-
|
90
|
-
unless
|
91
|
-
if
|
88
|
+
opts = params[:user]
|
89
|
+
unless opts[:password].blank?
|
90
|
+
if opts[:password].strip.size < 6
|
92
91
|
@user.errors.add('password', 'too short')
|
93
92
|
end
|
94
|
-
|
95
|
-
|
93
|
+
|
94
|
+
if !visitor.is_admin? || opts[:retype_password]
|
95
|
+
if opts[:password] != opts[:retype_password]
|
96
96
|
@user.errors.add('retype_password', 'does not match new password')
|
97
97
|
end
|
98
98
|
end
|
99
|
-
|
100
|
-
|
99
|
+
|
100
|
+
if !visitor.is_admin? || @user.id == visitor.id
|
101
|
+
if !@user.valid_password?(opts[:old_password])
|
101
102
|
@user.errors.add('old_password', "not correct")
|
102
103
|
end
|
103
104
|
end
|
105
|
+
|
104
106
|
if @user.errors.empty?
|
105
|
-
@user.password =
|
106
|
-
|
107
|
-
|
108
|
-
|
107
|
+
@user.password = opts[:password]
|
108
|
+
opts.delete(:password)
|
109
|
+
opts.delete(:retype_password)
|
110
|
+
opts.delete(:old_password)
|
109
111
|
end
|
110
112
|
end
|
111
113
|
|
112
114
|
if @user.errors.empty?
|
113
115
|
@user.update_attributes(params[:user])
|
114
116
|
if @user.errors.empty?
|
115
|
-
flash[:notice] = _('information successfully updated')
|
117
|
+
flash.now[:notice] = _('information successfully updated')
|
116
118
|
else
|
117
|
-
flash[:error ] = _('could not update user')
|
119
|
+
flash.now[:error ] = _('could not update user')
|
118
120
|
end
|
119
121
|
end
|
120
122
|
|
@@ -147,7 +149,7 @@ class UsersController < ApplicationController
|
|
147
149
|
if params[:user]
|
148
150
|
# visitor changing his/her own info : restrict fields
|
149
151
|
params[:user].keys.each do |k|
|
150
|
-
params[:user].delete(k) unless [:login, :time_zone, :lang, :password, :time_zone].include?(k.to_sym)
|
152
|
+
params[:user].delete(k) unless [:login, :time_zone, :lang, :password, :time_zone, :retype_password, :old_password].include?(k.to_sym)
|
151
153
|
end
|
152
154
|
end
|
153
155
|
else
|
@@ -57,9 +57,9 @@ class VersionsController < ApplicationController
|
|
57
57
|
def edit
|
58
58
|
if params[:drive]
|
59
59
|
if @node.redit
|
60
|
-
flash[:notice] = _("Version changed back to redaction.")
|
60
|
+
flash.now[:notice] = _("Version changed back to redaction.")
|
61
61
|
else
|
62
|
-
flash[:error] = _("Could not change version back to redaction.")
|
62
|
+
flash.now[:error] = _("Could not change version back to redaction.")
|
63
63
|
end
|
64
64
|
render :action=>'update'
|
65
65
|
else
|
@@ -161,46 +161,48 @@ class VersionsController < ApplicationController
|
|
161
161
|
|
162
162
|
def propose
|
163
163
|
if @node.propose
|
164
|
-
flash[:notice] = _("Redaction proposed for publication.")
|
164
|
+
flash.now[:notice] = _("Redaction proposed for publication.")
|
165
165
|
else
|
166
|
-
flash[:error] = _("Could not propose redaction.")
|
166
|
+
flash.now[:error] = _("Could not propose redaction.")
|
167
167
|
end
|
168
168
|
do_rendering
|
169
169
|
end
|
170
170
|
|
171
171
|
def refuse
|
172
172
|
if @node.refuse
|
173
|
-
flash[:notice] = _("Proposition refused.")
|
173
|
+
flash.now[:notice] = _("Proposition refused.")
|
174
174
|
@redirect_url = @node.can_read? ? request.env['HTTP_REFERER'] : user_path(visitor)
|
175
175
|
else
|
176
|
-
flash[:notice] = _("Could not refuse proposition.")
|
176
|
+
flash.now[:notice] = _("Could not refuse proposition.")
|
177
177
|
end
|
178
178
|
do_rendering
|
179
179
|
end
|
180
180
|
|
181
181
|
def publish
|
182
182
|
if @node.publish
|
183
|
-
flash[:notice] = "Redaction published."
|
183
|
+
flash.now[:notice] = _("Redaction published.")
|
184
184
|
else
|
185
|
-
flash[:error] = "Could not publish:
|
185
|
+
flash.now[:error] = _("Could not publish:") +
|
186
|
+
" #{error_messages_for(:node, :object => @node)}"
|
186
187
|
end
|
187
188
|
do_rendering
|
188
189
|
end
|
189
190
|
|
190
191
|
def remove
|
191
192
|
if @node.remove
|
192
|
-
flash[:notice] = "Publication removed."
|
193
|
+
flash.now[:notice] = _("Publication removed.")
|
193
194
|
else
|
194
|
-
flash[:error] = "Could not remove
|
195
|
+
flash.now[:error] = _("Could not remove publication.")
|
195
196
|
end
|
196
197
|
do_rendering
|
197
198
|
end
|
198
199
|
|
199
200
|
def redit
|
200
201
|
if @node.redit
|
201
|
-
flash[:notice] = "Rolled back to redaction."
|
202
|
+
flash.now[:notice] = _("Rolled back to redaction.")
|
202
203
|
else
|
203
|
-
flash[:error] = "Could not rollback:
|
204
|
+
flash.now[:error] = _("Could not rollback:") +
|
205
|
+
" #{error_messages_for(:node, :object => @node)}"
|
204
206
|
end
|
205
207
|
do_rendering
|
206
208
|
end
|
@@ -208,9 +210,9 @@ class VersionsController < ApplicationController
|
|
208
210
|
# TODO: test
|
209
211
|
def unpublish
|
210
212
|
if @node.unpublish
|
211
|
-
flash[:notice] = "Publication removed."
|
213
|
+
flash.now[:notice] = _("Publication removed.")
|
212
214
|
else
|
213
|
-
flash[:error] = "Could not remove publication."
|
215
|
+
flash.now[:error] = _("Could not remove publication.")
|
214
216
|
end
|
215
217
|
do_rendering
|
216
218
|
end
|
@@ -219,17 +221,17 @@ class VersionsController < ApplicationController
|
|
219
221
|
def destroy
|
220
222
|
if @node.destroy_version
|
221
223
|
if @node.versions.empty?
|
222
|
-
flash[:notice] = "Node destroyed."
|
224
|
+
flash.now[:notice] = _("Node destroyed.")
|
223
225
|
respond_to do |format|
|
224
226
|
format.html { redirect_to zen_path(@node.parent) }
|
225
227
|
format.js
|
226
228
|
end
|
227
229
|
else
|
228
|
-
flash[:notice] = "Version destroyed."
|
230
|
+
flash.now[:notice] = _("Version destroyed.")
|
229
231
|
do_rendering
|
230
232
|
end
|
231
233
|
else
|
232
|
-
flash[:error] = "Could not destroy version."
|
234
|
+
flash.now[:error] = _("Could not destroy version.")
|
233
235
|
do_rendering
|
234
236
|
end
|
235
237
|
end
|
@@ -255,7 +257,7 @@ class VersionsController < ApplicationController
|
|
255
257
|
# make the flash available to rjs helpers
|
256
258
|
@flash = flash
|
257
259
|
respond_to do |format|
|
258
|
-
format.html { redirect_to @redirect_url || request.env['HTTP_REFERER'] || {:id => 0}}
|
260
|
+
format.html { redirect_to params[:redir] || @redirect_url || request.env['HTTP_REFERER'] || {:id => 0}}
|
259
261
|
# js = call from 'drive' popup
|
260
262
|
format.js { render :action => 'update' }
|
261
263
|
end
|
@@ -1,5 +1,7 @@
|
|
1
1
|
class VirtualClassesController < ApplicationController
|
2
|
-
before_filter :find_virtual_class, :except => [
|
2
|
+
before_filter :find_virtual_class, :except => [
|
3
|
+
:index, :create, :new, :import, :import_prepare, :export
|
4
|
+
]
|
3
5
|
before_filter :visitor_node
|
4
6
|
before_filter :check_is_admin
|
5
7
|
layout :admin_layout
|
@@ -16,7 +18,7 @@ class VirtualClassesController < ApplicationController
|
|
16
18
|
@virtual_classes << klass
|
17
19
|
end
|
18
20
|
end
|
19
|
-
else
|
21
|
+
else
|
20
22
|
Node.native_classes.each do |kpath, klass|
|
21
23
|
@virtual_classes << klass
|
22
24
|
end
|
@@ -43,33 +45,69 @@ class VirtualClassesController < ApplicationController
|
|
43
45
|
end
|
44
46
|
|
45
47
|
def export
|
46
|
-
|
47
|
-
::Role.export
|
48
|
-
end
|
49
|
-
|
50
|
-
### TODO
|
48
|
+
send_data(clean_yaml(::Role.export), :filename=>"roles.yml", :type => 'text/yaml')
|
51
49
|
end
|
52
50
|
|
53
|
-
def
|
51
|
+
def import_prepare
|
54
52
|
attachment = params[:attachment]
|
55
53
|
if attachment.nil?
|
56
|
-
flass[:error] = "Upload failure: no definitions."
|
54
|
+
flass[:error] = _("Upload failure: no definitions.")
|
57
55
|
redirect_to :action => :index
|
58
56
|
else
|
59
|
-
|
57
|
+
@yaml = attachment.read rescue nil
|
58
|
+
data = YAML.load(@yaml) rescue nil
|
60
59
|
if data.nil?
|
61
|
-
flash[:error] = "Could not parse yaml document"
|
60
|
+
flash.now[:error] = "Could not parse yaml document"
|
62
61
|
redirect_to :action => :index
|
63
62
|
else
|
64
|
-
@
|
65
|
-
|
66
|
-
|
67
|
-
|
63
|
+
@yaml.gsub!(/\A---\s*\n/, "--- \n")
|
64
|
+
current = current_compared_to(data)
|
65
|
+
a = clean_yaml(current).gsub('{}', '')
|
66
|
+
#a = Zena::CodeSyntax.new(a, 'yaml').to_html
|
67
|
+
b = @yaml
|
68
|
+
#b = Zena::CodeSyntax.new(b, 'yaml').to_html
|
69
|
+
@diff = Differ.diff_by_line(b, a).format_as(:html)
|
70
|
+
|
71
|
+
# UGLY HACK to not escape <ins> and <del>
|
72
|
+
@diff.gsub!(/<((ins|del)[^>]*)>/, '[yaml_diff[\1]]')
|
73
|
+
@diff.gsub!(/<\/(ins|del)>/, '[yaml_diff[/\1]]')
|
74
|
+
@diff = Zena::CodeSyntax.new(@diff, 'yaml').to_html
|
75
|
+
@diff.gsub!(/\[yaml_diff\[([^\]]+)\]\]/) do
|
76
|
+
"<#{$1.gsub('"', '"')}>"
|
68
77
|
end
|
69
78
|
end
|
70
79
|
end
|
71
80
|
end
|
72
81
|
|
82
|
+
def import
|
83
|
+
data = YAML.load(params[:roles]) rescue nil
|
84
|
+
if data.nil?
|
85
|
+
flash.now[:error] = _("Could not parse yaml document")
|
86
|
+
redirect_to :action => :index
|
87
|
+
else
|
88
|
+
@roles_backup = clean_yaml(::Role.export)
|
89
|
+
@virtual_classes = ::Role.import(data)
|
90
|
+
class << @virtual_classes
|
91
|
+
def total_pages; 1 end
|
92
|
+
end
|
93
|
+
@virtual_class = VirtualClass.new('')
|
94
|
+
respond_to do |format|
|
95
|
+
format.html { render :action => 'index' }
|
96
|
+
end
|
97
|
+
end
|
98
|
+
rescue ActiveRecord::RecordInvalid => e
|
99
|
+
r = e.record
|
100
|
+
if r.respond_to?(:name)
|
101
|
+
flash[:error] = "#{r.class} '#{r.name}' #{e.message}"
|
102
|
+
else
|
103
|
+
flash[:error] = "#{r.class} '#{r.inspect}' #{e.message}"
|
104
|
+
end
|
105
|
+
redirect_to :action => :index
|
106
|
+
rescue Exception => e
|
107
|
+
flash.now[:error] = e.message
|
108
|
+
redirect_to :action => :index
|
109
|
+
end
|
110
|
+
|
73
111
|
def show
|
74
112
|
respond_to do |format|
|
75
113
|
format.html # show.erb
|
@@ -105,7 +143,7 @@ class VirtualClassesController < ApplicationController
|
|
105
143
|
|
106
144
|
respond_to do |format|
|
107
145
|
if @virtual_class.save
|
108
|
-
flash[:notice] = 'VirtualClass was successfully created.'
|
146
|
+
flash.now[:notice] = _('VirtualClass was successfully created.')
|
109
147
|
format.html { redirect_to virtual_class_url(@virtual_class) }
|
110
148
|
format.js
|
111
149
|
format.xml { render :xml => @virtual_class, :status => :created, :location => virtual_class_url(@virtual_class) }
|
@@ -120,7 +158,7 @@ class VirtualClassesController < ApplicationController
|
|
120
158
|
def update
|
121
159
|
respond_to do |format|
|
122
160
|
if @virtual_class.update_attributes(params[:virtual_class])
|
123
|
-
flash[:notice] = 'VirtualClass was successfully updated.'
|
161
|
+
flash.now[:notice] = _('VirtualClass was successfully updated.')
|
124
162
|
format.html { redirect_to virtual_class_url(@virtual_class) }
|
125
163
|
format.js
|
126
164
|
format.xml { head :ok }
|
@@ -146,4 +184,52 @@ class VirtualClassesController < ApplicationController
|
|
146
184
|
def find_virtual_class
|
147
185
|
@virtual_class = secure!(VirtualClass) { ::Role.find(params[:id])}
|
148
186
|
end
|
187
|
+
|
188
|
+
def clean_yaml(export)
|
189
|
+
# We use an OrderedHash so that using diff is more consistent.
|
190
|
+
export.to_yaml.gsub(/: *!map:Zafu::OrderedHash */, ':')
|
191
|
+
end
|
192
|
+
|
193
|
+
def get_roles(definitions, res = {})
|
194
|
+
definitions.each do |name, definition|
|
195
|
+
next unless name =~ /\A[A-Z]/
|
196
|
+
res[name] = definition
|
197
|
+
get_roles(definition, res)
|
198
|
+
end
|
199
|
+
res
|
200
|
+
end
|
201
|
+
# When comparing current data with imported data, ignore untouched
|
202
|
+
# classes/definitions.
|
203
|
+
def current_compared_to(definitions)
|
204
|
+
current = ::Role.export
|
205
|
+
roles = get_roles(definitions)
|
206
|
+
filter_keys(current, definitions, roles)
|
207
|
+
current
|
208
|
+
end
|
209
|
+
|
210
|
+
def filter_keys(hash_a, hash_b, roles)
|
211
|
+
remove_all = true
|
212
|
+
hash_a.keys.each do |key|
|
213
|
+
value_a, value_b = hash_a[key], hash_b[key]
|
214
|
+
if !value_b
|
215
|
+
if key =~ /\A[A-Z]/ && roles[key]
|
216
|
+
# role missing but defined elsewhere: moved
|
217
|
+
# do not remove
|
218
|
+
remove_all = false
|
219
|
+
elsif value_a.kind_of?(Hash)
|
220
|
+
if filter_keys(hash_a[key], {}, roles)
|
221
|
+
# nothing to be kept here
|
222
|
+
hash_a.delete(key)
|
223
|
+
end
|
224
|
+
else
|
225
|
+
# ignore missing key if we can ignore all
|
226
|
+
hash_a.delete(key)
|
227
|
+
end
|
228
|
+
elsif value_a.kind_of?(Hash) && value_b.kind_of?(Hash)
|
229
|
+
remove_all = false
|
230
|
+
filter_keys(hash_a[key], hash_b[key], roles)
|
231
|
+
end
|
232
|
+
end
|
233
|
+
remove_all
|
234
|
+
end
|
149
235
|
end
|