zena 1.0.0 → 1.1.0
Sign up to get free protection for your applications and to get access to all the features.
- data/History.txt +28 -0
- data/README.rdoc +6 -6
- data/Rakefile +3 -0
- data/app/controllers/users_controller.rb +4 -2
- data/app/models/acl.rb +6 -0
- data/app/models/cached_page.rb +2 -1
- data/app/models/document.rb +3 -4
- data/app/models/node.rb +8 -5
- data/app/models/site.rb +1 -1
- data/app/models/template.rb +2 -2
- data/app/models/user.rb +5 -3
- data/app/views/acls/_add.rhtml +2 -1
- data/app/views/acls/_form.rhtml +15 -7
- data/app/views/acls/_li.rhtml +2 -0
- data/app/views/acls/index.rhtml +3 -1
- data/app/views/acls/show.html.erb +1 -1
- data/app/views/links/destroy.rjs +16 -2
- data/app/views/versions/destroy.rjs +1 -1
- data/app/views/zafu/default/Node-admin.zafu +1 -1
- data/bin/zena +5 -3
- data/bricks/acls/lib/bricks/acls.rb +11 -4
- data/bricks/acls/zena/migrate/20110627193757_add_allowed_mode_and_format_to_acl.rb +11 -0
- data/bricks/acls/zena/test/integration/acl_integration_test.rb +42 -0
- data/bricks/acls/zena/test/sites/erebus/acls.yml +8 -0
- data/bricks/mongrel/zena/deploy.rb +19 -0
- data/bricks/single/lib/bricks/single.rb +15 -0
- data/bricks/single/zena/init.rb +1 -0
- data/bricks/sphinx/zena/tasks.rb +1 -1
- data/bricks/static/lib/bricks/static.rb +151 -0
- data/bricks/static/zena/init.rb +1 -0
- data/bricks/static/zena/migrate/20110702010330_add_static_to_idx_templates.rb +12 -0
- data/bricks/static/zena/skins/blog/Image-edit.zafu +6 -0
- data/bricks/static/zena/skins/blog/Image.zafu +19 -0
- data/bricks/static/zena/skins/blog/Node-+index.zafu +1 -0
- data/bricks/static/zena/skins/blog/Node-+notFound.zafu +7 -0
- data/bricks/static/zena/skins/blog/Node-+search.zafu +19 -0
- data/bricks/static/zena/skins/blog/Node.zafu +66 -0
- data/bricks/static/zena/skins/blog/Post.zafu +12 -0
- data/bricks/static/zena/skins/blog/Project--kml.zafu +30 -0
- data/bricks/static/zena/skins/blog/Project.zafu +45 -0
- data/bricks/static/zena/skins/blog/comments.zafu +30 -0
- data/bricks/static/zena/skins/blog/dict.yml +11 -0
- data/bricks/static/zena/skins/blog/img/dateBg.jpg +0 -0
- data/bricks/static/zena/skins/blog/img/header.png +0 -0
- data/bricks/static/zena/skins/blog/img/mapPin.png +0 -0
- data/bricks/static/zena/skins/blog/img/menu.gif +0 -0
- data/bricks/static/zena/skins/blog/img/menuover.gif +0 -0
- data/bricks/static/zena/skins/blog/img/style.css +110 -0
- data/bricks/static/zena/test/integration/static_integration_test.rb +30 -0
- data/bricks/static/zena/test/unit/static_test.rb +33 -0
- data/bricks/zena/zena/migrate/01_base.rb +1 -2
- data/bricks/zena/zena/migrate/20110623072048_fix_cached_path_index.rb +10 -0
- data/bricks/zena/zena/migrate/20110710113731_remove_icon_field.rb +18 -0
- data/config/bricks.yml +4 -0
- data/config/deploy.rb +17 -2
- data/config/gems.yml +9 -7
- data/config/selenium.yml +38 -0
- data/lib/bricks/requirements_validation.rb +8 -2
- data/lib/gettext_strings.rb +2 -1
- data/lib/tasks/zena.rake +5 -0
- data/lib/zena/app.rb +12 -0
- data/lib/zena/console.rb +9 -1
- data/lib/zena/core_ext/string.rb +7 -2
- data/lib/zena/deploy.rb +60 -6
- data/lib/zena/deploy/app_init.rhtml +56 -0
- data/lib/zena/deploy/haproxy.cnf.rhtml +34 -0
- data/lib/zena/deploy/httpd.rhtml +6 -0
- data/lib/zena/deploy/start_stop.rhtml +35 -0
- data/lib/zena/info.rb +1 -1
- data/lib/zena/remote/connection.rb +1 -1
- data/lib/zena/site_worker.rb +9 -5
- data/lib/zena/use.rb +1 -1
- data/lib/zena/use/action.rb +2 -2
- data/lib/zena/use/ajax.rb +22 -9
- data/lib/zena/use/conditional.rb +5 -0
- data/lib/zena/use/context.rb +6 -1
- data/lib/zena/use/dates.rb +17 -2
- data/lib/zena/use/display.rb +14 -3
- data/lib/zena/use/forms.rb +37 -47
- data/lib/zena/use/html_tags.rb +3 -0
- data/lib/zena/use/node_context.rb +17 -17
- data/lib/zena/use/rendering.rb +1 -1
- data/lib/zena/use/urls.rb +11 -2
- data/lib/zena/use/zafu_attributes.rb +1 -0
- data/lib/zena/use/zafu_safe_definitions.rb +16 -1
- data/lib/zena/use/zafu_templates.rb +39 -24
- data/lib/zena/use/zazen.rb +1 -0
- data/locale/de/LC_MESSAGES/zena.mo +0 -0
- data/locale/de/zena.po +105 -89
- data/locale/en/LC_MESSAGES/zena.mo +0 -0
- data/locale/en/zena.mo +0 -0
- data/locale/en/zena.po +188 -253
- data/locale/fr/LC_MESSAGES/zena.mo +0 -0
- data/locale/fr/zena.mo +0 -0
- data/locale/fr/zena.po +200 -257
- data/locale/zena.pot +95 -85
- data/public/javascripts/zena.js +2 -2
- data/test/fixtures/files/{Node-test.zafu → TestNode.zafu} +206 -4
- data/test/functional/nodes_controller_test.rb +2 -2
- data/test/integration/navigation_test.rb +9 -3
- data/test/integration/query_node/basic.yml +4 -4
- data/test/integration/query_node/filters.yml +2 -2
- data/test/integration/zafu_compiler/ajax.yml +6 -6
- data/test/integration/zafu_compiler/basic.yml +1 -1
- data/test/integration/zafu_compiler/calendar.yml +4 -3
- data/test/integration/zafu_compiler/conditional.yml +3 -10
- data/test/integration/zafu_compiler/context.yml +1 -1
- data/test/integration/zafu_compiler/dates.yml +9 -1
- data/test/integration/zafu_compiler/display.yml +7 -1
- data/test/integration/zafu_compiler/eval.yml +12 -46
- data/test/integration/zafu_compiler/forms.yml +1 -1
- data/test/integration/zafu_compiler/query.yml +2 -2
- data/test/integration/zafu_compiler/relations.yml +19 -9
- data/test/integration/zafu_compiler/roles.yml +12 -0
- data/test/integration/zafu_compiler/safe_definitions.yml +1 -1
- data/test/integration/zafu_compiler/urls.yml +13 -5
- data/test/integration/zafu_compiler/version.yml +6 -0
- data/test/integration/zafu_compiler/zafu_attributes.yml +4 -4
- data/test/integration/zafu_compiler_test.rb +1 -1
- data/test/selenium.readme +8 -0
- data/test/selenium/Add/0setup.rsel +12 -0
- data/test/selenium/Add/add1.rsel +22 -0
- data/test/selenium/Add/add2.rsel +22 -0
- data/test/selenium/Add/add3.rsel +22 -0
- data/test/selenium/Drop/0setup.rsel +12 -0
- data/test/selenium/Drop/drop1.rsel +25 -0
- data/test/selenium/Drop/drop2.rsel +25 -0
- data/test/selenium/Drop/drop3.rsel +51 -0
- data/test/selenium/Drop/drop4.rsel +44 -0
- data/test/selenium/Drop/drop5.rsel +16 -0
- data/test/selenium/Edit/0setup.rsel +12 -0
- data/test/selenium/Edit/edit1.rsel +31 -0
- data/test/selenium/Edit/edit2.rsel +39 -0
- data/test/selenium/Edit/edit3.rsel +40 -0
- data/test/selenium/Form/0setup.rsel +12 -0
- data/test/selenium/Form/form1.rsel +9 -0
- data/test/selenium/Form/form2.rsel +9 -0
- data/test/selenium/Paginate/0setup.rsel +12 -0
- data/test/selenium/Paginate/paginate1.rsel +24 -0
- data/test/selenium/Toggle/0setup.rsel +12 -0
- data/test/selenium/Toggle/toggle1.rsel +21 -0
- data/test/sites/zena/nodes.yml +4 -4
- data/test/sites/zena/roles.yml +3 -2
- data/test/sites/zena/versions.yml +12 -11
- data/test/unit/core_ext_test.rb +23 -5
- data/test/unit/document_test.rb +6 -2
- data/test/unit/node_test.rb +2 -2
- data/test/unit/remote_test.rb +1 -2
- data/test/unit/role_test.rb +2 -2
- data/test/unit/user_test.rb +48 -1
- data/test/unit/virtual_class_test.rb +7 -7
- data/test/unit/zena/acts/secure_test.rb +1 -1
- data/test/unit/zena/use/rendering_test.rb +1 -1
- data/test/unit/zena/use/urls_test.rb +3 -3
- data/zena.gemspec +65 -101
- metadata +67 -103
- data/vendor/TextMate/Ruby Shoulda.tmbundle/Commands/Run 2.tmCommand +0 -24
- data/vendor/TextMate/Ruby Shoulda.tmbundle/Commands/Run Context.tmCommand +0 -58
- data/vendor/TextMate/Ruby Shoulda.tmbundle/Commands/Run Focused Should.tmCommand +0 -88
- data/vendor/TextMate/Ruby Shoulda.tmbundle/Commands/Run.tmCommand +0 -27
- data/vendor/TextMate/Ruby Shoulda.tmbundle/Commands/YAML to Shoulda.tmCommand +0 -23
- data/vendor/TextMate/Ruby Shoulda.tmbundle/Preferences/Symbol List: Context.tmPreferences +0 -19
- data/vendor/TextMate/Ruby Shoulda.tmbundle/Preferences/Symbol List: Should.tmPreferences +0 -19
- data/vendor/TextMate/Ruby Shoulda.tmbundle/Snippets/Factory attributes for.tmSnippet +0 -16
- data/vendor/TextMate/Ruby Shoulda.tmbundle/Snippets/Factory build.tmSnippet +0 -16
- data/vendor/TextMate/Ruby Shoulda.tmbundle/Snippets/Factory.tmSnippet +0 -16
- data/vendor/TextMate/Ruby Shoulda.tmbundle/Snippets/Factory_define with class.tmSnippet +0 -18
- data/vendor/TextMate/Ruby Shoulda.tmbundle/Snippets/Factory_define.tmSnippet +0 -18
- data/vendor/TextMate/Ruby Shoulda.tmbundle/Snippets/Factory_next.tmSnippet +0 -16
- data/vendor/TextMate/Ruby Shoulda.tmbundle/Snippets/Factory_sequence.tmSnippet +0 -18
- data/vendor/TextMate/Ruby Shoulda.tmbundle/Snippets/assert_bad_value.tmSnippet +0 -16
- data/vendor/TextMate/Ruby Shoulda.tmbundle/Snippets/assert_contains.tmSnippet +0 -16
- data/vendor/TextMate/Ruby Shoulda.tmbundle/Snippets/assert_does_not_contain.tmSnippet +0 -16
- data/vendor/TextMate/Ruby Shoulda.tmbundle/Snippets/assert_good_value.tmSnippet +0 -16
- data/vendor/TextMate/Ruby Shoulda.tmbundle/Snippets/assert_same_elements.tmSnippet +0 -16
- data/vendor/TextMate/Ruby Shoulda.tmbundle/Snippets/assert_save.tmSnippet +0 -16
- data/vendor/TextMate/Ruby Shoulda.tmbundle/Snippets/assert_sent_email.tmSnippet +0 -18
- data/vendor/TextMate/Ruby Shoulda.tmbundle/Snippets/assert_valid.tmSnippet +0 -16
- data/vendor/TextMate/Ruby Shoulda.tmbundle/Snippets/association.tmSnippet +0 -17
- data/vendor/TextMate/Ruby Shoulda.tmbundle/Snippets/attribute.tmSnippet +0 -17
- data/vendor/TextMate/Ruby Shoulda.tmbundle/Snippets/before_should block.tmSnippet +0 -18
- data/vendor/TextMate/Ruby Shoulda.tmbundle/Snippets/context block get.tmSnippet +0 -22
- data/vendor/TextMate/Ruby Shoulda.tmbundle/Snippets/context block post.tmSnippet +0 -23
- data/vendor/TextMate/Ruby Shoulda.tmbundle/Snippets/context block with setup.tmSnippet +0 -25
- data/vendor/TextMate/Ruby Shoulda.tmbundle/Snippets/setup.tmSnippet +0 -18
- data/vendor/TextMate/Ruby Shoulda.tmbundle/Snippets/should block with before proc.tmSnippet +0 -18
- data/vendor/TextMate/Ruby Shoulda.tmbundle/Snippets/should block.tmSnippet +0 -18
- data/vendor/TextMate/Ruby Shoulda.tmbundle/Snippets/should_allow_values_for.tmSnippet +0 -16
- data/vendor/TextMate/Ruby Shoulda.tmbundle/Snippets/should_assign_to.tmSnippet +0 -16
- data/vendor/TextMate/Ruby Shoulda.tmbundle/Snippets/should_be_restful denied.tmSnippet +0 -20
- data/vendor/TextMate/Ruby Shoulda.tmbundle/Snippets/should_be_restful.tmSnippet +0 -20
- data/vendor/TextMate/Ruby Shoulda.tmbundle/Snippets/should_belong_to.tmSnippet +0 -16
- data/vendor/TextMate/Ruby Shoulda.tmbundle/Snippets/should_change by.tmSnippet +0 -16
- data/vendor/TextMate/Ruby Shoulda.tmbundle/Snippets/should_change from to.tmSnippet +0 -16
- data/vendor/TextMate/Ruby Shoulda.tmbundle/Snippets/should_ensure_length_at_least.tmSnippet +0 -16
- data/vendor/TextMate/Ruby Shoulda.tmbundle/Snippets/should_ensure_length_in_range.tmSnippet +0 -16
- data/vendor/TextMate/Ruby Shoulda.tmbundle/Snippets/should_ensure_length_is.tmSnippet +0 -16
- data/vendor/TextMate/Ruby Shoulda.tmbundle/Snippets/should_ensure_value_in_range.tmSnippet +0 -16
- data/vendor/TextMate/Ruby Shoulda.tmbundle/Snippets/should_eventually.tmSnippet +0 -18
- data/vendor/TextMate/Ruby Shoulda.tmbundle/Snippets/should_filter_params.tmSnippet +0 -16
- data/vendor/TextMate/Ruby Shoulda.tmbundle/Snippets/should_have_and_belong_to_many.tmSnippet +0 -16
- data/vendor/TextMate/Ruby Shoulda.tmbundle/Snippets/should_have_class_methods.tmSnippet +0 -16
- data/vendor/TextMate/Ruby Shoulda.tmbundle/Snippets/should_have_db_column.tmSnippet +0 -16
- data/vendor/TextMate/Ruby Shoulda.tmbundle/Snippets/should_have_db_columns.tmSnippet +0 -16
- data/vendor/TextMate/Ruby Shoulda.tmbundle/Snippets/should_have_index.tmSnippet +0 -16
- data/vendor/TextMate/Ruby Shoulda.tmbundle/Snippets/should_have_indices.tmSnippet +0 -16
- data/vendor/TextMate/Ruby Shoulda.tmbundle/Snippets/should_have_instance_methods.tmSnippet +0 -16
- data/vendor/TextMate/Ruby Shoulda.tmbundle/Snippets/should_have_many.tmSnippet +0 -16
- data/vendor/TextMate/Ruby Shoulda.tmbundle/Snippets/should_have_named_scope.tmSnippet +0 -16
- data/vendor/TextMate/Ruby Shoulda.tmbundle/Snippets/should_have_one.tmSnippet +0 -16
- data/vendor/TextMate/Ruby Shoulda.tmbundle/Snippets/should_have_readonly_attributes.tmSnippet +0 -16
- data/vendor/TextMate/Ruby Shoulda.tmbundle/Snippets/should_not_allow_mass_assignment_of.tmSnippet +0 -16
- data/vendor/TextMate/Ruby Shoulda.tmbundle/Snippets/should_not_allow_values_for.tmSnippet +0 -16
- data/vendor/TextMate/Ruby Shoulda.tmbundle/Snippets/should_not_assign_to.tmSnippet +0 -16
- data/vendor/TextMate/Ruby Shoulda.tmbundle/Snippets/should_not_change.tmSnippet +0 -16
- data/vendor/TextMate/Ruby Shoulda.tmbundle/Snippets/should_not_set_the_flash.tmSnippet +0 -16
- data/vendor/TextMate/Ruby Shoulda.tmbundle/Snippets/should_redirect_to.tmSnippet +0 -16
- data/vendor/TextMate/Ruby Shoulda.tmbundle/Snippets/should_render_a_form.tmSnippet +0 -16
- data/vendor/TextMate/Ruby Shoulda.tmbundle/Snippets/should_render_template.tmSnippet +0 -16
- data/vendor/TextMate/Ruby Shoulda.tmbundle/Snippets/should_render_with_layout.tmSnippet +0 -16
- data/vendor/TextMate/Ruby Shoulda.tmbundle/Snippets/should_render_without_layout.tmSnippet +0 -16
- data/vendor/TextMate/Ruby Shoulda.tmbundle/Snippets/should_respond_with.tmSnippet +0 -16
- data/vendor/TextMate/Ruby Shoulda.tmbundle/Snippets/should_respond_with_content_type.tmSnippet +0 -16
- data/vendor/TextMate/Ruby Shoulda.tmbundle/Snippets/should_return_from_session.tmSnippet +0 -16
- data/vendor/TextMate/Ruby Shoulda.tmbundle/Snippets/should_route.tmSnippet +0 -16
- data/vendor/TextMate/Ruby Shoulda.tmbundle/Snippets/should_set_the_flash_to.tmSnippet +0 -16
- data/vendor/TextMate/Ruby Shoulda.tmbundle/Snippets/should_validate_acceptance_of.tmSnippet +0 -16
- data/vendor/TextMate/Ruby Shoulda.tmbundle/Snippets/should_validate_numericality_of.tmSnippet +0 -16
- data/vendor/TextMate/Ruby Shoulda.tmbundle/Snippets/should_validate_presence_of.tmSnippet +0 -16
- data/vendor/TextMate/Ruby Shoulda.tmbundle/Snippets/should_validate_uniqueness_of with scope.tmSnippet +0 -16
- data/vendor/TextMate/Ruby Shoulda.tmbundle/Snippets/should_validate_uniqueness_of.tmSnippet +0 -16
- data/vendor/TextMate/Ruby Shoulda.tmbundle/Support/RubyMate/catch_exception.rb +0 -39
- data/vendor/TextMate/Ruby Shoulda.tmbundle/Support/RubyMate/run_script.rb +0 -104
- data/vendor/TextMate/Ruby Shoulda.tmbundle/Support/RubyMate/stdin_dialog.rb +0 -14
- data/vendor/TextMate/Ruby Shoulda.tmbundle/Support/RubyMate/test.rb +0 -17
- data/vendor/TextMate/Ruby Shoulda.tmbundle/Support/RubyMate/todo.txt +0 -13
- data/vendor/TextMate/Ruby Shoulda.tmbundle/Support/bin/yaml_to_shoulda.rb +0 -25
- data/vendor/TextMate/Ruby Shoulda.tmbundle/Syntaxes/Ruby on Rails (Shoulda).tmLanguage +0 -166
- data/vendor/TextMate/Ruby Shoulda.tmbundle/info.plist +0 -304
- data/vendor/TextMate/Zena.tmbundle/Commands/Run all yaml tests.tmCommand +0 -37
- data/vendor/TextMate/Zena.tmbundle/Commands/Run focused yaml test.tmCommand +0 -52
- data/vendor/TextMate/Zena.tmbundle/Support/RubyMate/catch_exception.rb +0 -39
- data/vendor/TextMate/Zena.tmbundle/Support/RubyMate/run_script.rb +0 -118
- data/vendor/TextMate/Zena.tmbundle/Support/RubyMate/stdin_dialog.rb +0 -14
- data/vendor/TextMate/Zena.tmbundle/info.plist +0 -17
data/lib/zena/use.rb
CHANGED
@@ -2,7 +2,7 @@ module Zena
|
|
2
2
|
# This module is used to declare and manage the list of features used by Zena.
|
3
3
|
module Use
|
4
4
|
SUFFIX_NAME = 'Methods'
|
5
|
-
MODULE_NAMES = %w{Controller View Zafu User}
|
5
|
+
MODULE_NAMES = %w{Controller View Zafu User Site Skin}
|
6
6
|
# "Controller" => "ControllerMethods"
|
7
7
|
MODULE_NAME = Hash[*MODULE_NAMES.map {|n| [n, "#{n}#{SUFFIX_NAME}"]}.flatten]
|
8
8
|
|
data/lib/zena/use/action.rb
CHANGED
@@ -151,7 +151,7 @@ module Zena
|
|
151
151
|
|
152
152
|
def login_path
|
153
153
|
if params[:controller] == 'nodes'
|
154
|
-
|
154
|
+
zen_path(@node, :prefix => AUTHENTICATED_PREFIX)
|
155
155
|
else
|
156
156
|
super
|
157
157
|
end
|
@@ -159,7 +159,7 @@ module Zena
|
|
159
159
|
|
160
160
|
def logout_path
|
161
161
|
if params[:controller] == 'nodes' && @node.public?
|
162
|
-
super :redirect =>
|
162
|
+
super :redirect => zen_path(@node, :prefix => visitor.lang)
|
163
163
|
else
|
164
164
|
super
|
165
165
|
end
|
data/lib/zena/use/ajax.rb
CHANGED
@@ -7,11 +7,13 @@ module Zena
|
|
7
7
|
|
8
8
|
# Return the DOM id for a node. We had to name this method 'ndom_id' because we want
|
9
9
|
# to avoid the clash with Rails' dom_id method.
|
10
|
-
def ndom_id(node)
|
10
|
+
def ndom_id(node = @node, append_form = true)
|
11
11
|
if node.kind_of?(Node) && !node.new_record?
|
12
12
|
if params[:action] == 'create' && !params[:udom_id]
|
13
13
|
return "#{params[:dom_id]}_#{node.zip}"
|
14
14
|
end
|
15
|
+
elsif append_form && node.kind_of?(Node) && params[:zadd]
|
16
|
+
return "#{params[:dom_id]}_form"
|
15
17
|
end
|
16
18
|
|
17
19
|
@dom_id || params[:udom_id] || params[:dom_id]
|
@@ -42,12 +44,12 @@ module Zena
|
|
42
44
|
|
43
45
|
if obj.new_record?
|
44
46
|
# A. could not create object: show form with errors
|
45
|
-
page.replace
|
47
|
+
page.replace ndom_id, :file => template_path_from_template_url + "_form.erb"
|
46
48
|
elsif @errors || !obj.errors.empty?
|
47
49
|
# B. could not update/delete: show errors
|
48
50
|
form_file = template_path_from_template_url + "_form.erb"
|
49
51
|
if File.exist?(form_file)
|
50
|
-
page.replace
|
52
|
+
page.replace ndom_id, :file => form_file
|
51
53
|
else
|
52
54
|
page.insert_html :top, params[:dom_id], :inline => render_errors
|
53
55
|
end
|
@@ -71,7 +73,7 @@ module Zena
|
|
71
73
|
@dom_id = params[:dom_id]
|
72
74
|
page.replace params[:dom_id], :file => template_path_from_template_url + ".erb"
|
73
75
|
end
|
74
|
-
if params[:done] && params[:
|
76
|
+
if params[:done] && params[:zadd]
|
75
77
|
page.toggle "#{params[:dom_id]}_form", "#{params[:dom_id]}_add"
|
76
78
|
page << params[:done]
|
77
79
|
elsif params[:done]
|
@@ -98,18 +100,29 @@ module Zena
|
|
98
100
|
else
|
99
101
|
instance_variable_set("@#{base_class.to_s.underscore}", obj.clone)
|
100
102
|
end
|
101
|
-
page.replace
|
103
|
+
page.replace ndom_id, :file => template_path_from_template_url + "_form.erb"
|
102
104
|
if params[:done]
|
103
105
|
page << params[:done]
|
104
|
-
|
106
|
+
elsif params[:zadd]
|
105
107
|
page.toggle "#{params[:dom_id]}_form", "#{params[:dom_id]}_add"
|
106
108
|
end
|
107
109
|
when 'update'
|
108
|
-
page.replace
|
110
|
+
page.replace ndom_id, :file => template_path_from_template_url + ".erb"
|
109
111
|
page << params[:done] if params[:done]
|
110
112
|
when 'destroy'
|
111
|
-
page
|
112
|
-
|
113
|
+
page << %Q{
|
114
|
+
new Effect.Highlight('#{ndom_id}', {
|
115
|
+
duration: 0.3,
|
116
|
+
afterFinish: function() {
|
117
|
+
new Effect.Fade('#{ndom_id}', {
|
118
|
+
duration: 0.5,
|
119
|
+
afterFinish: function() {
|
120
|
+
$('#{ndom_id}').remove();
|
121
|
+
}
|
122
|
+
});
|
123
|
+
}
|
124
|
+
});
|
125
|
+
}
|
113
126
|
when 'drop'
|
114
127
|
case params[:done]
|
115
128
|
when 'remove'
|
data/lib/zena/use/conditional.rb
CHANGED
@@ -1,6 +1,11 @@
|
|
1
1
|
module Zena::Use::Conditional
|
2
2
|
module ZafuMethods
|
3
3
|
|
4
|
+
def r_selenium
|
5
|
+
return parser_error("missing 'id'.") if @name.blank?
|
6
|
+
out expand_if("params[:test]==#{@name.inspect} || params[:test]=='all'")
|
7
|
+
end
|
8
|
+
|
4
9
|
def rubyless_class_scope(class_name)
|
5
10
|
return parser_error("Cannot scope class in list (use each before filtering).") if node.list_context?
|
6
11
|
# capital letter ==> class conditional
|
data/lib/zena/use/context.rb
CHANGED
@@ -191,7 +191,12 @@ module Zena
|
|
191
191
|
typed_string = ::RubyLess.translate(self, code)
|
192
192
|
name = get_var_name('set_var', var)
|
193
193
|
out "<% #{name} = #{typed_string} %>"
|
194
|
-
|
194
|
+
var_setting = {}
|
195
|
+
set_context_var('set_var', var, RubyLess::TypedString.new(name, typed_string.opts), var_setting)
|
196
|
+
# Leak into following siblings
|
197
|
+
self.pass(var_setting)
|
198
|
+
# Set inside
|
199
|
+
@context.merge!(var_setting)
|
195
200
|
rescue RubyLess::NoMethodError => err
|
196
201
|
parser_error(err.message, code)
|
197
202
|
end
|
data/lib/zena/use/dates.rb
CHANGED
@@ -306,8 +306,8 @@ module Zena
|
|
306
306
|
safe_method :date => :get_date
|
307
307
|
safe_method [:date, TZInfo::Timezone] => :get_date
|
308
308
|
safe_method :tz => :get_tz
|
309
|
-
safe_method [:parse_date, String] =>
|
310
|
-
safe_method [:parse_date, String, String] =>
|
309
|
+
safe_method [:parse_date, String] => :get_parse_date
|
310
|
+
safe_method [:parse_date, String, String] => :get_parse_date
|
311
311
|
safe_method [:parse_date, String, String, TZInfo::Timezone] => {:class => Time, :nil => true, :accept_nil => true}
|
312
312
|
|
313
313
|
def get_date(signature)
|
@@ -326,6 +326,21 @@ module Zena
|
|
326
326
|
end
|
327
327
|
end
|
328
328
|
|
329
|
+
def get_parse_date(signature)
|
330
|
+
tz_var = get_context_var('set_var', 'tz')
|
331
|
+
if signature == ['parse_date', String]
|
332
|
+
append = [
|
333
|
+
RubyLess::TypedString.new(_(DATETIME).inspect, :class => String),
|
334
|
+
tz_var || RubyLess::TypedString.new('visitor.tz', :class => TZInfo::Timezone),
|
335
|
+
]
|
336
|
+
elsif signature = ['parse_date', String, String]
|
337
|
+
append = tz_var || RubyLess::TypedString.new('visitor.tz', :class => TZInfo::Timezone)
|
338
|
+
else
|
339
|
+
append = nil
|
340
|
+
end
|
341
|
+
{:method => 'parse_date', :class => Time, :nil => true, :accept_nil => true, :append_args => append}
|
342
|
+
end
|
343
|
+
|
329
344
|
def r_default
|
330
345
|
if tz_name = @params.delete(:tz)
|
331
346
|
set_tz_code, tz_var = set_tz_var(tz_name)
|
data/lib/zena/use/display.rb
CHANGED
@@ -492,6 +492,9 @@ module Zena
|
|
492
492
|
"<label>#{attribute}</label> <span>#{res}</span>"
|
493
493
|
when 't'
|
494
494
|
"<label>#{trans(attribute)}</label> <span>#{res}</span>"
|
495
|
+
when '','false'
|
496
|
+
# no label
|
497
|
+
res
|
495
498
|
else
|
496
499
|
if @params[:tlabel]
|
497
500
|
code = ::RubyLess.translate(self, "t(%Q{#{label}})")
|
@@ -599,13 +602,21 @@ module Zena
|
|
599
602
|
|
600
603
|
# Find icon through a relation named 'icon' or use first image child
|
601
604
|
def r_icon
|
602
|
-
|
603
|
-
|
605
|
+
if node.will_be?(Node)
|
606
|
+
finder = build_finder(:first, icon_finder)
|
607
|
+
expand_with_finder(finder)
|
608
|
+
else
|
609
|
+
rubyless_eval
|
610
|
+
end
|
604
611
|
end
|
605
612
|
|
606
613
|
# Display an image
|
607
614
|
def r_img
|
608
|
-
|
615
|
+
if node.will_be?(VirtualClass)
|
616
|
+
return "<img src='<%= #{node}.prop['icon'] %>'/>"
|
617
|
+
elsif !node.will_be?(Node)
|
618
|
+
return
|
619
|
+
end
|
609
620
|
|
610
621
|
if src = @params[:src]
|
611
622
|
finder = ::RubyLess.translate(self, @params[:src]) #build_finder(:first, @params[:src])
|
data/lib/zena/use/forms.rb
CHANGED
@@ -86,14 +86,14 @@ module Zena
|
|
86
86
|
return parser_error("invalid 'klass' parameter (not a Node)") unless klass <= Node
|
87
87
|
|
88
88
|
res = []
|
89
|
-
keys = {:klass => 'klass'}
|
89
|
+
keys = {:klass => 'this.klass', :parent_id => "#{node(Node)}.zip"}
|
90
90
|
@params.each do |key, value|
|
91
91
|
next if key == :klass
|
92
92
|
# TODO: maybe it would be safer to check with [:"key="] and change safe_property to
|
93
93
|
# authorize both ?
|
94
94
|
next unless type = klass.safe_method_type([key.to_s])
|
95
95
|
# Store how to access current value to show hidden field in form.
|
96
|
-
keys[key] = type[:method]
|
96
|
+
keys[key] = "this.#{type[:method]}"
|
97
97
|
code = RubyLess.translate(self, value)
|
98
98
|
if code.klass == type[:class]
|
99
99
|
res << ":#{key} => #{code}"
|
@@ -112,7 +112,6 @@ module Zena
|
|
112
112
|
:method => method,
|
113
113
|
:class => klass,
|
114
114
|
:nil => true,
|
115
|
-
:new_record => true,
|
116
115
|
:new_keys => keys
|
117
116
|
)
|
118
117
|
end
|
@@ -206,10 +205,20 @@ module Zena
|
|
206
205
|
opts[:form_cancel] = "#{cancel_pre}<a href='#' onclick='[\"#{dom_name}_add\", \"#{dom_name}_form\"].each(Element.toggle);return false;'>#{cancel_text}</a>#{cancel_post}\n"
|
207
206
|
else
|
208
207
|
# Saved form
|
209
|
-
|
208
|
+
if @markup.tag == 'table'
|
209
|
+
# the normal id goes to the form wrapping the table
|
210
|
+
opts[:id] = "#{node.dom_prefix}_tbl"
|
211
|
+
str_form_id = "\#{ndom_id(#{node})}"
|
212
|
+
else
|
213
|
+
opts[:id] = "<%= ndom_id(#{node}) %>"
|
214
|
+
str_form_id = "\#{ndom_id(#{node})}_form_t"
|
215
|
+
end
|
216
|
+
|
217
|
+
form_id ||= "#{node.dom_prefix}_form_t"
|
218
|
+
opts[:id] = "<%= ndom_id(#{node}) %>"
|
210
219
|
|
211
220
|
opts[:form_tag] = %Q{
|
212
|
-
<% remote_form_for(:#{node.form_name}, #{node}, :url => #{node}.new_record? ? #{node.form_name.pluralize}_path : #{node.form_name}_path(#{node}.zip), :html => {:method => #{node}.new_record? ? :post : :put, :id => \"
|
221
|
+
<% remote_form_for(:#{node.form_name}, #{node}, :url => #{node}.new_record? ? #{node.form_name.pluralize}_path : #{node.form_name}_path(#{node}.zip), :html => {:method => #{node}.new_record? ? :post : :put, :id => \"#{str_form_id}\"}) do |f| %>
|
213
222
|
}
|
214
223
|
|
215
224
|
opts[:form_cancel] = %Q{
|
@@ -246,16 +255,15 @@ module Zena
|
|
246
255
|
set_fields << "#{node.form_name}[#{tag.params[:name]}]"
|
247
256
|
end
|
248
257
|
|
258
|
+
if (descendants('input') || []).detect {|elem| elem.params[:type] == 'submit'}
|
259
|
+
# has submit
|
260
|
+
else
|
261
|
+
# Hidden submit for Firefox compatibility
|
262
|
+
hidden_fields['submit'] = ["<input type='submit'/>"]
|
263
|
+
end
|
264
|
+
|
249
265
|
if template_url = @context[:template_url]
|
250
266
|
# Ajax
|
251
|
-
|
252
|
-
if (descendants('input') || []).detect {|elem| elem.params[:type] == 'submit'}
|
253
|
-
# has submit
|
254
|
-
else
|
255
|
-
# Hidden submit for Firefox compatibility
|
256
|
-
hidden_fields['submit'] = ["<input type='submit'/>"]
|
257
|
-
end
|
258
|
-
|
259
267
|
hidden_fields['link_id'] = "<%= #{node}.link_id %>" if @context[:has_link_id] && node.will_be?(Node)
|
260
268
|
|
261
269
|
if upd = @params[:update]
|
@@ -273,26 +281,11 @@ module Zena
|
|
273
281
|
|
274
282
|
hidden_fields['t_url'] = template_url
|
275
283
|
# This is a hack to fix wrong dom_prefix in drop+add.
|
276
|
-
erb_dom_id = @context[:saved_template] ? "<%= ndom_id(#{node}) %>" : (@context[:dom_prefix] || node.dom_prefix)
|
284
|
+
erb_dom_id = @context[:saved_template] ? "<%= ndom_id(#{node}, false) %>" : (@context[:dom_prefix] || node.dom_prefix)
|
277
285
|
|
278
286
|
hidden_fields['dom_id'] = erb_dom_id
|
279
287
|
|
280
|
-
if node.will_be?(
|
281
|
-
# Nested contexts:
|
282
|
-
# 1. @node
|
283
|
-
# 2. var1 = @node.children
|
284
|
-
# 3. var1_new = Node.new
|
285
|
-
if node.opts[:new_record] #|| @context[:saved_template]
|
286
|
-
if @context[:saved_template] || !@context[:in_add]
|
287
|
-
# TODO: we should not add parent_id on every saved_template. Why is this needed ?
|
288
|
-
parent_id = "#{node}.parent_zip"
|
289
|
-
else
|
290
|
-
parent_id = "#{node.up.up}.zip"
|
291
|
-
end
|
292
|
-
|
293
|
-
hidden_fields['node[parent_id]'] = "<%= #{parent_id} %>"
|
294
|
-
end
|
295
|
-
elsif node.will_be?(Comment)
|
288
|
+
if node.will_be?(Comment)
|
296
289
|
# FIXME: the "... || '@node'" is a hack and I don't understand why it's needed...
|
297
290
|
hidden_fields['node_id'] = "<%= #{node.get(Node) || '@node'}.zip %>"
|
298
291
|
elsif node.will_be?(DataEntry)
|
@@ -302,6 +295,7 @@ module Zena
|
|
302
295
|
|
303
296
|
if add_block = @context[:add]
|
304
297
|
params = add_block.params
|
298
|
+
hidden_fields['zadd'] = 'true'
|
305
299
|
[:after, :before, :top, :bottom].each do |sym|
|
306
300
|
if value = params[sym]
|
307
301
|
hidden_fields['position'] = sym.to_s
|
@@ -332,16 +326,6 @@ module Zena
|
|
332
326
|
end
|
333
327
|
else
|
334
328
|
# no ajax
|
335
|
-
|
336
|
-
if node.will_be?(Node)
|
337
|
-
# Nested contexts:
|
338
|
-
# 1. @node
|
339
|
-
# 2. var1 = @node.children
|
340
|
-
# 3. var1_new = Node.new
|
341
|
-
if node.opts[:new_record]
|
342
|
-
hidden_fields['node[parent_id]'] = "<%= #{node.up}.zip %>"
|
343
|
-
end
|
344
|
-
end
|
345
329
|
cancel = "" # link to normal node ?
|
346
330
|
end
|
347
331
|
|
@@ -356,6 +340,7 @@ module Zena
|
|
356
340
|
hidden_fields['node[v_status]'] = Zena::Status::Pub.to_s if add_params[:publish] || auto_publish_param || @context[:publish_after_save]
|
357
341
|
|
358
342
|
# All default values set in the <r:new> field should at least appear as hidden fields
|
343
|
+
|
359
344
|
if new_keys = node.opts[:new_keys]
|
360
345
|
input_keys = (
|
361
346
|
(descendants('input') || []).map {|e| e.params[:name]} +
|
@@ -369,22 +354,26 @@ module Zena
|
|
369
354
|
).compact.uniq
|
370
355
|
|
371
356
|
new_keys.each do |key, value|
|
372
|
-
|
373
|
-
|
357
|
+
# Security: make sure value does not come from user input !
|
358
|
+
# TINT !
|
359
|
+
next if input_keys.include?(key) || value.nil?
|
360
|
+
hidden_fields["node[#{key}]"] = "<%= #{value.sub(/^this\./, "#{node}.")} %>"
|
374
361
|
end
|
375
362
|
end
|
376
363
|
|
377
364
|
# Read @params
|
378
|
-
@params.each do |key, value|
|
365
|
+
add_params.merge(@params).each do |key, value|
|
366
|
+
# r_add params
|
367
|
+
next if [:after, :before, :top, :bottom, :focus, :publish,
|
379
368
|
# r_form params
|
380
|
-
|
369
|
+
:klass, :done, :on, :update,
|
381
370
|
# r_each params (make_form)
|
382
|
-
|
371
|
+
:join].include?(key)
|
383
372
|
code = ::RubyLess.translate(self, value)
|
384
373
|
if code.literal.kind_of?(String) || code.literal.kind_of?(Number)
|
385
|
-
hidden_fields[key] = "#{code.literal}"
|
374
|
+
hidden_fields[key.to_s] = "#{code.literal}"
|
386
375
|
else
|
387
|
-
hidden_fields[key] = "<%= #{code} %>"
|
376
|
+
hidden_fields[key.to_s] = "<%= #{code} %>"
|
388
377
|
end
|
389
378
|
end
|
390
379
|
|
@@ -514,6 +503,7 @@ module Zena
|
|
514
503
|
return parser_error("select id without name") unless attribute
|
515
504
|
name = "#{attribute}_id" unless attribute[-3..-1] == '_id'
|
516
505
|
input_id = @context[:erb_dom_id] ? ", :input_id =>\"#{erb_dom_id}_#{attribute}\"" : ''
|
506
|
+
# FIXME: pass object
|
517
507
|
"<%= select_id('#{node.form_name}', #{attribute.inspect}#{input_id}) %>"
|
518
508
|
when 'time_zone'
|
519
509
|
out parser_error("please use [select] here")
|
data/lib/zena/use/html_tags.rb
CHANGED
@@ -32,23 +32,23 @@ module Zena
|
|
32
32
|
end
|
33
33
|
|
34
34
|
# Get an uppers NodeContext that is of the given class kind.
|
35
|
-
def get(klass)
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
end
|
35
|
+
# def get(klass)
|
36
|
+
# if real_single_class <= klass
|
37
|
+
# return self unless list_context?
|
38
|
+
#
|
39
|
+
# res_class = self.klass
|
40
|
+
# method = self.name
|
41
|
+
# while res_class.kind_of?(Array)
|
42
|
+
# method = "#{method}.first"
|
43
|
+
# res_class = res_class.first
|
44
|
+
# end
|
45
|
+
# move_to(method, res_class)
|
46
|
+
# elsif @up
|
47
|
+
# @up.get(klass)
|
48
|
+
# else
|
49
|
+
# nil
|
50
|
+
# end
|
51
|
+
# end
|
52
52
|
|
53
53
|
# Return the 'real' class name or the superclass name if the current class is an anonymous class.
|
54
54
|
def class_name
|
data/lib/zena/use/rendering.rb
CHANGED
data/lib/zena/use/urls.rb
CHANGED
@@ -65,7 +65,6 @@ module Zena
|
|
65
65
|
# Path for a node. Options can be :format, :host and :mode.
|
66
66
|
# ex '/en/document34_print.html'
|
67
67
|
def zen_path(node, options={})
|
68
|
-
|
69
68
|
return '#' unless node
|
70
69
|
|
71
70
|
if anchor = options.delete(:anchor)
|
@@ -151,6 +150,7 @@ module Zena
|
|
151
150
|
path
|
152
151
|
else
|
153
152
|
cachestamp = opts.delete(:cachestamp)
|
153
|
+
tz = opts.delete(:tz)
|
154
154
|
list = opts.keys.map do |k|
|
155
155
|
# FIXME: DOC
|
156
156
|
if k.to_s == 'encode_params'
|
@@ -166,7 +166,7 @@ module Zena
|
|
166
166
|
end
|
167
167
|
elsif value = opts[k]
|
168
168
|
if value.respond_to?(:strftime_tz)
|
169
|
-
"#{k}=#{CGI.escape(value.strftime_tz(_(Zena::Use::Dates::DATETIME)))}"
|
169
|
+
"#{k}=#{CGI.escape(value.strftime_tz(_(Zena::Use::Dates::DATETIME), tz))}"
|
170
170
|
elsif value.kind_of?(Hash)
|
171
171
|
"#{k}=#{value.to_query}"
|
172
172
|
elsif value.kind_of?(Node)
|
@@ -348,6 +348,15 @@ module Zena
|
|
348
348
|
# <r:link update='dom_id'/>
|
349
349
|
# <r:link page='next'/> <r:link page='previous'/> <r:link page='list'/>
|
350
350
|
def r_link
|
351
|
+
# If we have a contextual timezone set, pass it to @params
|
352
|
+
if tz_name = @params[:tz]
|
353
|
+
tz_result, tz_var = set_tz_var(tz_name)
|
354
|
+
return tz_result unless tz_var
|
355
|
+
@params[:tz] = 'tz'
|
356
|
+
elsif tz_var = get_context_var('set_var', 'tz')
|
357
|
+
@params[:tz] = 'tz'
|
358
|
+
end
|
359
|
+
|
351
360
|
if @params[:page] && @params[:page] != '[page_page]' # lets users use 'page' as pagination key
|
352
361
|
pagination_links
|
353
362
|
else
|