zena 1.2.3 → 1.2.4
Sign up to get free protection for your applications and to get access to all the features.
- data/History.txt +29 -1
- data/Rakefile +0 -1
- data/app/controllers/documents_controller.rb +1 -1
- data/app/controllers/nodes_controller.rb +34 -8
- data/app/controllers/sites_controller.rb +8 -1
- data/app/controllers/user_sessions_controller.rb +13 -3
- data/app/models/acl.rb +16 -0
- data/app/models/document.rb +33 -14
- data/app/models/idx_nodes_integer.rb +5 -0
- data/app/models/image.rb +16 -4
- data/app/models/node.rb +16 -3
- data/app/models/relation_proxy.rb +3 -3
- data/app/models/site.rb +11 -1
- data/app/models/string_hash.rb +1 -1
- data/app/models/template.rb +1 -1
- data/app/models/user.rb +6 -1
- data/app/models/virtual_class.rb +36 -1
- data/app/views/acls/_form.rhtml +5 -1
- data/app/views/acls/_li.rhtml +1 -1
- data/app/views/templates/document_create_tabs/_file.rhtml +1 -0
- data/app/views/templates/document_create_tabs/_template.rhtml +1 -1
- data/app/views/users/_form.rhtml +1 -0
- data/app/views/virtual_classes/_form.erb +8 -7
- data/bricks/acls/lib/bricks/acls.rb +43 -15
- data/bricks/acls/zena/migrate/20130313110443_add_create_kpath_to_acl.rb +13 -0
- data/bricks/acls/zena/migrate/20130429073432_fix_create_kpath_default.rb +8 -0
- data/bricks/acls/zena/test/integration/acl_integration_test.rb +53 -1
- data/bricks/acls/zena/test/sites/erebus/acls.yml +21 -0
- data/bricks/acls/zena/test/unit/acl_test.rb +35 -2
- data/bricks/math/lib/bricks/math.rb +1 -1
- data/bricks/sphinx/zena/tasks.rb +1 -1
- data/bricks/spreadsheet/lib/bricks/spreadsheet.rb +1 -1
- data/bricks/worker/zena/worker +25 -0
- data/config/environment.rb +1 -1
- data/config/environments/production.rb +1 -1
- data/config/gems.yml +6 -5
- data/lib/bricks/requirements_validation.rb +1 -1
- data/lib/log_recorder/lib/log_recorder.rb +1 -1
- data/lib/tasks/zena.rake +10 -2
- data/lib/zena.rb +4 -3
- data/lib/zena/app.rb +1 -0
- data/lib/zena/deploy/httpd.rhtml +2 -2
- data/lib/zena/deploy/template.rb +15 -5
- data/lib/zena/info.rb +1 -1
- data/lib/zena/parser/zazen_rules.rb +9 -2
- data/lib/zena/remote/connection.rb +2 -2
- data/lib/zena/remote/interface.rb +8 -2
- data/lib/zena/remote/node.rb +1 -1
- data/lib/zena/routes.rb +2 -1
- data/lib/zena/use/action.rb +8 -2
- data/lib/zena/use/ajax.rb +31 -20
- data/lib/zena/use/calendar.rb +2 -0
- data/lib/zena/use/conditional.rb +15 -14
- data/lib/zena/use/dates.rb +5 -2
- data/lib/zena/use/display.rb +3 -2
- data/lib/zena/use/forms.rb +36 -9
- data/lib/zena/use/i18n.rb +8 -2
- data/lib/zena/use/image_builder.rb +7 -0
- data/lib/zena/use/query_node.rb +24 -8
- data/lib/zena/use/relations.rb +2 -6
- data/lib/zena/use/rendering.rb +10 -6
- data/lib/zena/use/upload.rb +6 -4
- data/lib/zena/use/urls.rb +13 -5
- data/lib/zena/use/zafu_safe_definitions.rb +1 -1
- data/public/javascripts/grid.js +11 -2
- data/public/javascripts/upload-progress.js +5 -3
- data/public/javascripts/zena.js +6 -2
- data/public/stylesheets/upload-progress.css +1 -0
- data/test/fixtures/files/TestNode.zafu +2 -2
- data/test/fixtures/files/translations_fr.yml +2 -1
- data/test/functional/acls_controller_test.rb +6 -0
- data/test/functional/nodes_controller_test.rb +1 -1
- data/test/functional/sites_controller_test.rb +19 -0
- data/test/integration/navigation_test.rb +7 -0
- data/test/integration/query_node/filters.yml +10 -0
- data/test/integration/zafu_compiler/action.yml +8 -4
- data/test/integration/zafu_compiler/ajax.yml +4 -4
- data/test/integration/zafu_compiler/calendar.yml +8 -15
- data/test/integration/zafu_compiler/context.yml +1 -1
- data/test/integration/zafu_compiler/dates.yml +5 -1
- data/test/integration/zafu_compiler/display.yml +1 -2
- data/test/integration/zafu_compiler/forms.yml +37 -10
- data/test/integration/zafu_compiler/query.yml +5 -5
- data/test/integration/zafu_compiler/relations.yml +8 -8
- data/test/integration/zafu_compiler/safe_definitions.yml +7 -2
- data/test/integration/zafu_compiler/urls.yml +24 -3
- data/test/integration/zafu_compiler/zazen.yml +9 -1
- data/test/selenium/Destroy/destroy1.rsel +2 -1
- data/test/selenium/Destroy/destroy2.rsel +17 -0
- data/test/unit/document_test.rb +17 -4
- data/test/unit/relation_proxy_test.rb +19 -8
- data/test/unit/string_hash_test.rb +1 -1
- data/test/unit/template_test.rb +3 -3
- data/test/unit/virtual_class_test.rb +77 -0
- data/test/unit/zena/use/urls_test.rb +9 -1
- data/vendor/plugins/selenium-on-rails/lib/selenium_on_rails_config.rb +1 -1
- data/zena.gemspec +60 -53
- metadata +145 -125
@@ -5,9 +5,9 @@ class AclTest < Zena::Unit::TestCase
|
|
5
5
|
def base_node
|
6
6
|
visitor.node_without_secure
|
7
7
|
end
|
8
|
-
MockRequest = Struct.new(:method, :params, :port)
|
8
|
+
MockRequest = Struct.new(:method, :params, :port, :path)
|
9
9
|
|
10
|
-
def mock_request(method = :get, params = {}, port = 0)
|
10
|
+
def mock_request(method = :get, params = {}, port = 0, path = '/nodes/33')
|
11
11
|
MockRequest.new(method, params, port)
|
12
12
|
end
|
13
13
|
|
@@ -81,6 +81,21 @@ class AclTest < Zena::Unit::TestCase
|
|
81
81
|
end
|
82
82
|
end # saving an acl with asset_host in query
|
83
83
|
|
84
|
+
context 'saving an acl with a wrong create_kpath' do
|
85
|
+
subject do
|
86
|
+
acls(:rap)
|
87
|
+
end
|
88
|
+
|
89
|
+
should 'return an error' do
|
90
|
+
erebus_id = groups_id(:erebus)
|
91
|
+
visitor.instance_eval do
|
92
|
+
@group_ids = self.group_ids + [erebus_id]
|
93
|
+
end
|
94
|
+
assert !subject.update_attributes(:query => "nodes in site")
|
95
|
+
assert_equal 'parse error on value ["in", 1] (kIN)', subject.errors[:query]
|
96
|
+
end
|
97
|
+
end # saving an acl with asset_host in query
|
98
|
+
|
84
99
|
|
85
100
|
context 'a visitor' do
|
86
101
|
context 'with normal access' do
|
@@ -110,6 +125,24 @@ class AclTest < Zena::Unit::TestCase
|
|
110
125
|
nil, nodes_zip(:queen), nil, mock_request(:get)
|
111
126
|
).id
|
112
127
|
end
|
128
|
+
|
129
|
+
context 'creating an object' do
|
130
|
+
|
131
|
+
should 'not find node if kpath does not match' do
|
132
|
+
assert_raise(ActiveRecord::RecordNotFound) do
|
133
|
+
subject.find_node(
|
134
|
+
nil, nodes_zip(:queen), nil, mock_request(:post, {'node' => {'klass' => 'Page'}})
|
135
|
+
).id
|
136
|
+
end
|
137
|
+
end
|
138
|
+
|
139
|
+
should 'find node if kpath matches' do
|
140
|
+
assert_equal nodes(:queen).id,
|
141
|
+
subject.find_node(
|
142
|
+
nil, nodes_zip(:queen), nil, mock_request(:post, {'node' => {'klass' => 'Contact'}})
|
143
|
+
).id
|
144
|
+
end
|
145
|
+
end
|
113
146
|
|
114
147
|
should 'not find node out of acl scope' do
|
115
148
|
assert_raise(ActiveRecord::RecordNotFound) do
|
data/bricks/sphinx/zena/tasks.rb
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
# The ThinkingSphinx::Configuration needs RAILS_ROOT and RAILS_ENV in order to function. Only 'setup' needs the
|
2
2
|
# environment since it needs to get configuration settings from the classes in zena.
|
3
3
|
require 'tempfile'
|
4
|
-
require '
|
4
|
+
require 'safe_yaml'
|
5
5
|
require 'thinking_sphinx'
|
6
6
|
require 'zlib'
|
7
7
|
|
@@ -84,6 +84,7 @@ module Bricks
|
|
84
84
|
def render_html
|
85
85
|
html = []
|
86
86
|
@sheets.each do |s|
|
87
|
+
html << "<h3>#{s.name}</h3>"
|
87
88
|
html << '<table>'
|
88
89
|
s.rows.each do |r|
|
89
90
|
html << '<tr>'
|
@@ -189,7 +190,6 @@ td{border:1px solid #444; padding:2px;}
|
|
189
190
|
</style>
|
190
191
|
</head>
|
191
192
|
<body>
|
192
|
-
<h1>Render as #{type}</h1>
|
193
193
|
#{data}
|
194
194
|
</body>
|
195
195
|
</html>
|
data/bricks/worker/zena/worker
CHANGED
@@ -38,6 +38,31 @@ Daemons.run_proc('worker', daemon_options) do
|
|
38
38
|
require File.join('config', 'environment')
|
39
39
|
|
40
40
|
require 'delayed/worker'
|
41
|
+
class Delayed::Job
|
42
|
+
private
|
43
|
+
# FIX Delayed Job to work with safe_yaml
|
44
|
+
# TODO: Remove this when we upgrade to Ruby 1.9
|
45
|
+
def deserialize(source)
|
46
|
+
handler = YAML.load(source, :safe => false) rescue nil
|
47
|
+
|
48
|
+
unless handler.respond_to?(:perform)
|
49
|
+
if handler.nil? && source =~ ParseObjectFromYaml
|
50
|
+
handler_class = $1
|
51
|
+
end
|
52
|
+
attempt_to_load(handler_class || handler.class)
|
53
|
+
handler = YAML.load(source, :safe => false)
|
54
|
+
end
|
55
|
+
|
56
|
+
return handler if handler.respond_to?(:perform)
|
57
|
+
|
58
|
+
raise DeserializationError,
|
59
|
+
'Job failed to load: Unknown handler. Try to manually require the appropriate file.'
|
60
|
+
rescue TypeError, LoadError, NameError => e
|
61
|
+
raise DeserializationError,
|
62
|
+
"Job failed to load: #{e.message}. Try to manually require the required file."
|
63
|
+
end
|
64
|
+
end
|
65
|
+
|
41
66
|
begin
|
42
67
|
require 'thinking_sphinx'
|
43
68
|
require 'thinking_sphinx/deltas/delayed_delta'
|
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.18' 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
@@ -4,23 +4,24 @@ ruby-recaptcha: '= 1.0.3'
|
|
4
4
|
syntax: '= 1.0.0'
|
5
5
|
tzinfo:
|
6
6
|
uuidtools: '= 2.0.0'
|
7
|
-
rails: '= 2.3.
|
7
|
+
rails: '= 2.3.18'
|
8
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
12
|
differ: '= 0.1.2'
|
13
13
|
shoulda: '= 2.10.3'
|
14
|
-
|
14
|
+
httmultiparty : '= 0.3.8'
|
15
15
|
open4:
|
16
16
|
daemons: # upload progress
|
17
17
|
gem_plugin: # upload progress
|
18
18
|
simple_xlsx_writer: # spreadsheet
|
19
19
|
lib: 'simple_xlsx'
|
20
20
|
|
21
|
-
querybuilder: '= 1.2.
|
21
|
+
querybuilder: '= 1.2.2'
|
22
22
|
yamltest: '= 0.7.0'
|
23
|
-
|
23
|
+
safe_yaml: '= 0.8.0'
|
24
|
+
rubyless: '= 0.8.10'
|
24
25
|
property: '= 2.3.2'
|
25
26
|
versions: '= 0.3.1'
|
26
27
|
|
@@ -44,7 +45,7 @@ thinking-sphinx:
|
|
44
45
|
optional: yes
|
45
46
|
brick: sphinx
|
46
47
|
lib: 'thinking_sphinx'
|
47
|
-
version: '
|
48
|
+
version: '~> 1.3.14'
|
48
49
|
|
49
50
|
# needs riddle 1.0.10
|
50
51
|
|
data/lib/tasks/zena.rake
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
require '
|
1
|
+
require 'safe_yaml'
|
2
2
|
require 'fileutils'
|
3
3
|
|
4
4
|
# We need to make sure the RAILS_ENV is set before brick activation or the wrong bricks will
|
@@ -373,7 +373,7 @@ namespace :zena do
|
|
373
373
|
nodes = Node.find(:all,
|
374
374
|
:conditions => ['site_id = ?', site.id]
|
375
375
|
)
|
376
|
-
site.rebuild_index(secure_result(nodes))
|
376
|
+
site.rebuild_index(secure_result(nodes), 1)
|
377
377
|
else
|
378
378
|
# We try to use the site worker.
|
379
379
|
site.rebuild_index
|
@@ -562,6 +562,14 @@ namespace :zena do
|
|
562
562
|
exec cmd
|
563
563
|
end
|
564
564
|
end
|
565
|
+
|
566
|
+
desc "Remove rdoc warning/error"
|
567
|
+
task :fix_rakefile do
|
568
|
+
# Fix Rakefile
|
569
|
+
path = "#{RAILS_ROOT}/Rakefile"
|
570
|
+
text = File.read(path)
|
571
|
+
File.open(path, 'wb') {|f| f.puts text.gsub("require 'rake/rdoctask'\n", '')}
|
572
|
+
end
|
565
573
|
end # zena
|
566
574
|
|
567
575
|
namespace :gettext do
|
data/lib/zena.rb
CHANGED
@@ -1,10 +1,11 @@
|
|
1
|
-
|
2
|
-
|
1
|
+
require 'safe_yaml'
|
2
|
+
SafeYAML::OPTIONS[:default_mode] = :safe
|
3
3
|
require 'date'
|
4
4
|
require 'fileutils'
|
5
5
|
require 'zena/info'
|
6
6
|
require 'bricks'
|
7
7
|
|
8
|
+
# FIXME: ========== cleanup
|
8
9
|
SITES_ROOT = "#{RAILS_ROOT}/sites"
|
9
10
|
AUTHENTICATED_PREFIX = "oo"
|
10
11
|
PASSWORD_SALT = "jf93jfnvnas09093nas0923" # type anything here (but change this line !)
|
@@ -303,8 +304,8 @@ EXT_TYPE = [
|
|
303
304
|
[ "gz" , "application/x-gzip" ],
|
304
305
|
[ "hdf" , "application/x-hdf" ],
|
305
306
|
[ "hqx" , "application/mac-binhex40" ],
|
306
|
-
[ "htm" , "text/html" ],
|
307
307
|
[ "html" , "text/html" ],
|
308
|
+
[ "htm" , "text/html" ],
|
308
309
|
[ "ice" , "x-conference/x-cooltalk" ],
|
309
310
|
[ "ief" , "image/ief" ],
|
310
311
|
[ "iges" , "model/iges" ],
|
data/lib/zena/app.rb
CHANGED
data/lib/zena/deploy/httpd.rhtml
CHANGED
@@ -12,8 +12,8 @@ NameVirtualHost *
|
|
12
12
|
<% end %>
|
13
13
|
|
14
14
|
<% if config[:app_type] == :passenger %>
|
15
|
-
LoadModule passenger_module /usr/lib/ruby/gems/1.8/gems/<%= config[:passenger_version] || 'passenger-3.0.
|
16
|
-
PassengerRoot /usr/lib/ruby/gems/1.8/gems/<%= config[:passenger_version] || 'passenger-3.0.
|
15
|
+
LoadModule passenger_module /usr/lib/ruby/gems/1.8/gems/<%= config[:passenger_version] || 'passenger-3.0.19' %>/ext/apache2/mod_passenger.so
|
16
|
+
PassengerRoot /usr/lib/ruby/gems/1.8/gems/<%= config[:passenger_version] || 'passenger-3.0.19' %>
|
17
17
|
PassengerRuby /usr/bin/ruby1.8
|
18
18
|
PassengerDefaultUser www-data
|
19
19
|
<% elsif config[:app_type] == :mongrel %>
|
data/lib/zena/deploy/template.rb
CHANGED
@@ -9,7 +9,11 @@ else
|
|
9
9
|
end
|
10
10
|
|
11
11
|
gem 'zena', :version => Zena::VERSION
|
12
|
+
route '# Insert custom routes here.'
|
13
|
+
route ''
|
12
14
|
route 'map.zen_routes'
|
15
|
+
route ''
|
16
|
+
route '# Routes below this are never reached.'
|
13
17
|
|
14
18
|
rakefile("zena_tasks.rake") do
|
15
19
|
<<-TASK
|
@@ -32,13 +36,19 @@ end
|
|
32
36
|
end
|
33
37
|
|
34
38
|
inside('app/controllers') do
|
35
|
-
app = File.read('application_controller.rb')
|
36
|
-
app.gsub!(/class\s+ApplicationController\s+<\s+ActionController::Base/, "class ApplicationController < ActionController::Base\n include Zena::App")
|
37
|
-
app.gsub!(/^(\s+)protect_from_forgery/, '\1# protect_from_forgery')
|
38
39
|
File.open('application_controller.rb', 'wb') do |f|
|
39
|
-
f.write
|
40
|
+
f.write %q{
|
41
|
+
# Filters added to this controller apply to all controllers in the application.
|
42
|
+
# Likewise, all the methods added will be available for all controllers.
|
43
|
+
|
44
|
+
class ApplicationController < ActionController::Base
|
45
|
+
include Zena::App
|
46
|
+
helper :all # include all helpers, all the time
|
47
|
+
# protect_from_forgery # See ActionController::RequestForgeryProtection for details
|
48
|
+
end
|
49
|
+
}
|
40
50
|
end
|
41
51
|
end
|
42
52
|
|
43
53
|
rake 'zena:assets OVERWRITE_ASSETS=true'
|
44
|
-
|
54
|
+
rake 'zena:fix_rakefile'
|
data/lib/zena/info.rb
CHANGED
@@ -334,11 +334,18 @@ module Zena
|
|
334
334
|
def extract_code(fulltext)
|
335
335
|
@escaped_code = []
|
336
336
|
@block_counter = -1
|
337
|
-
fulltext.gsub!( /<code([^>]*)>(.*?)
|
337
|
+
fulltext.gsub!( /<(code|notextile|html)([^>]*)>(.*?)<\/\1>/m ) do
|
338
338
|
if @translate_ids
|
339
339
|
raw_content([nil, $&])
|
340
|
+
elsif $1 == 'notextile' || $1 == 'html'
|
341
|
+
# FIXME: SECURITY. How to avoid the use of notextile in comments and such ?
|
342
|
+
if @context[:notextile] == 'true'
|
343
|
+
raw_content($3)
|
344
|
+
else
|
345
|
+
''
|
346
|
+
end
|
340
347
|
else
|
341
|
-
params, text = $
|
348
|
+
params, text = $2, $3
|
342
349
|
pre_params = []
|
343
350
|
if params =~ /\A(.*)lang\s*=\s*("|')([^"']+)\2(.*)\Z/m
|
344
351
|
pre, lang, post = $1.strip, $3, $4.strip
|
@@ -1,4 +1,4 @@
|
|
1
|
-
require '
|
1
|
+
require 'httmultiparty'
|
2
2
|
|
3
3
|
module Zena
|
4
4
|
module Remote
|
@@ -10,7 +10,7 @@ module Zena
|
|
10
10
|
# We create a new class because HTTParty works this way (class globals).
|
11
11
|
def self.connect(uri, token)
|
12
12
|
Class.new(self) do
|
13
|
-
include
|
13
|
+
include HTTMultiParty
|
14
14
|
extend Zena::Remote::Interface::ConnectionMethods
|
15
15
|
|
16
16
|
class << self
|
@@ -284,7 +284,7 @@ module Zena
|
|
284
284
|
node
|
285
285
|
elsif errors = result['errors']
|
286
286
|
@errors = errors
|
287
|
-
log_message errors
|
287
|
+
log_message errors.inspect
|
288
288
|
false
|
289
289
|
else
|
290
290
|
log_message "Could not save:"
|
@@ -293,7 +293,7 @@ module Zena
|
|
293
293
|
end
|
294
294
|
elsif errors = result['errors']
|
295
295
|
log_message "Could not save:"
|
296
|
-
log_message errors
|
296
|
+
log_message errors.inspect
|
297
297
|
false
|
298
298
|
else
|
299
299
|
log_message "Could not save:"
|
@@ -305,6 +305,12 @@ module Zena
|
|
305
305
|
def new_record?
|
306
306
|
id.nil?
|
307
307
|
end
|
308
|
+
|
309
|
+
def save!
|
310
|
+
if !save
|
311
|
+
raise Exception.new("Could not save.")
|
312
|
+
end
|
313
|
+
end
|
308
314
|
end
|
309
315
|
end # Update
|
310
316
|
|
data/lib/zena/remote/node.rb
CHANGED
data/lib/zena/routes.rb
CHANGED
@@ -63,7 +63,8 @@ module Zena
|
|
63
63
|
|
64
64
|
resources :columns
|
65
65
|
|
66
|
-
resources :sites, :
|
66
|
+
resources :sites, :collection => { :clear_cache => :get },
|
67
|
+
:member => { :action => :put, :jobs => :get }
|
67
68
|
|
68
69
|
resources :comments,
|
69
70
|
:collection => { :empty_bin => :delete },
|
data/lib/zena/use/action.rb
CHANGED
@@ -198,11 +198,14 @@ class #{node.klass}: #{Array(node.klass).first.columns.keys.join(', ')}
|
|
198
198
|
else_markup.set_dyn_param('href', '<%= logout_path %>')
|
199
199
|
|
200
200
|
markup.set_dyn_param('href', '<%= login_path %>')
|
201
|
+
unless markup.params[:rel]
|
202
|
+
markup.set_param(:rel, 'nofollow')
|
203
|
+
end
|
201
204
|
|
202
205
|
out markup.wrap(expand_if("visitor.is_anon?", self.node, else_markup))
|
203
206
|
else
|
204
207
|
out "<% if visitor.is_anon? %>"
|
205
|
-
out "<%= link_to #{_('login').inspect}, login_path %>"
|
208
|
+
out "<%= link_to #{_('login').inspect}, login_path, :rel => 'nofollow' %>"
|
206
209
|
out "<% else %>"
|
207
210
|
out "<%= link_to #{_('logout').inspect}, logout_path %>"
|
208
211
|
out "<% end %>"
|
@@ -265,7 +268,10 @@ class #{node.klass}: #{Array(node.klass).first.columns.keys.join(', ')}
|
|
265
268
|
end
|
266
269
|
end
|
267
270
|
end
|
268
|
-
|
271
|
+
|
272
|
+
def r_versions_list
|
273
|
+
out "<%= render :partial=>'versions/list' %>"
|
274
|
+
end
|
269
275
|
|
270
276
|
# TODO: test
|
271
277
|
def r_swap
|
data/lib/zena/use/ajax.rb
CHANGED
@@ -9,10 +9,13 @@ module Zena
|
|
9
9
|
# to avoid the clash with Rails' dom_id method.
|
10
10
|
def ndom_id(node = @node, append_form = true)
|
11
11
|
if node.kind_of?(Node) && !node.new_record?
|
12
|
-
if params[:action] == 'create' && !params[:udom_id]
|
12
|
+
if params[:action] == 'create' && !params[:udom_id] && !params[:s]
|
13
|
+
# !params[:s] is to not use this when executing Zena.post
|
14
|
+
|
15
|
+
# We cannot filter with params[:zadd] because this breaks when editing in lists.
|
13
16
|
return "#{params[:dom_id]}_#{node.zip}"
|
14
17
|
end
|
15
|
-
elsif append_form && node.kind_of?(Node) && params[:zadd]
|
18
|
+
elsif append_form && node.kind_of?(Node) && params[:zadd]
|
16
19
|
return "#{params[:dom_id]}_#{node.zip.to_i}"
|
17
20
|
end
|
18
21
|
|
@@ -68,7 +71,7 @@ module Zena
|
|
68
71
|
end
|
69
72
|
end
|
70
73
|
end
|
71
|
-
page.replace params[:udom_id], :file => template_path_from_template_url('', params[:u_url])
|
74
|
+
page.replace params[:udom_id], :file => template_path_from_template_url('', params[:u_url] || params[:t_url])
|
72
75
|
if params[:upd_both]
|
73
76
|
@dom_id = params[:dom_id]
|
74
77
|
page.replace params[:dom_id], :file => template_path_from_template_url
|
@@ -92,19 +95,26 @@ module Zena
|
|
92
95
|
page.replace params[:dom_id], :file => template_path_from_template_url
|
93
96
|
page << "$('#{params[:dom_id]}_form_t').focusFirstElement();"
|
94
97
|
when 'create'
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
98
|
+
if params[:zadd]
|
99
|
+
# ADD WITH FORM...
|
100
|
+
pos = params[:position] || :before
|
101
|
+
ref = params[:reference] || "#{params[:dom_id]}_add"
|
102
|
+
page.insert_html pos.to_sym, ref, :file => template_path_from_template_url
|
103
|
+
if obj.kind_of?(Node)
|
104
|
+
@node = obj.parent.new_child(:class => obj.class)
|
105
|
+
else
|
106
|
+
instance_variable_set("@#{base_class.to_s.underscore}", obj.clone)
|
107
|
+
end
|
108
|
+
page.replace ndom_id, :file => template_path_from_template_url('_form')
|
109
|
+
if params[:done]
|
110
|
+
page << params[:done]
|
111
|
+
elsif params[:zadd]
|
112
|
+
page.toggle "#{params[:dom_id]}_0", "#{params[:dom_id]}_add"
|
113
|
+
end
|
100
114
|
else
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
if params[:done]
|
105
|
-
page << params[:done]
|
106
|
-
elsif params[:zadd]
|
107
|
-
page.toggle "#{params[:dom_id]}_0", "#{params[:dom_id]}_add"
|
115
|
+
# Zena.post operation
|
116
|
+
page.replace ndom_id, :file => template_path_from_template_url
|
117
|
+
page << params[:done] if params[:done]
|
108
118
|
end
|
109
119
|
when 'update'
|
110
120
|
page.replace ndom_id, :file => template_path_from_template_url
|
@@ -410,6 +420,7 @@ module Zena
|
|
410
420
|
return parser_error("Invalid class 'for' parameter: #{finder.klass}") unless finder.klass <= Node
|
411
421
|
|
412
422
|
node.dom_prefix = dom_name
|
423
|
+
var = root.get_unique_name('tog')
|
413
424
|
dom_id = node.dom_id(:erb => false)
|
414
425
|
markup.set_id(node.dom_id)
|
415
426
|
markup.append_param(:class, 'toggle')
|
@@ -453,16 +464,16 @@ module Zena
|
|
453
464
|
|
454
465
|
markup.append_param(:class, 'toggle')
|
455
466
|
|
456
|
-
opts =
|
467
|
+
opts = []
|
457
468
|
if arity = @params.delete(:arity)
|
458
|
-
opts
|
469
|
+
opts << ":arity => #{RubyLess.translate_string(self, arity)}"
|
459
470
|
end
|
460
471
|
|
461
472
|
if js = @params.delete(:js)
|
462
|
-
opts
|
473
|
+
opts << ":js => #{RubyLess.translate_string(self, js)}"
|
463
474
|
end
|
464
|
-
|
465
|
-
markup.pre_wrap[:toggle] = "<% add_toggle_id(\"#{dom_id}\", #{
|
475
|
+
var = root.get_unique_name('tog')
|
476
|
+
markup.pre_wrap[:toggle] = "<% add_toggle_id(\"#{dom_id}\", #{var.inspect}, #{RubyLess.translate_string(self, role)},{#{opts.join(', ')}}) { #{finder} } %>"
|
466
477
|
end
|
467
478
|
|
468
479
|
def r_unlink
|