zena 1.2.1 → 1.2.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/History.txt +38 -1
- data/app/controllers/documents_controller.rb +7 -5
- data/app/controllers/nodes_controller.rb +47 -6
- data/app/controllers/user_sessions_controller.rb +12 -3
- data/app/controllers/virtual_classes_controller.rb +8 -2
- data/app/models/acl.rb +5 -2
- data/app/models/cached_page.rb +5 -5
- data/app/models/column.rb +27 -4
- data/app/models/group.rb +1 -1
- data/app/models/node.rb +106 -24
- data/app/models/note.rb +2 -1
- data/app/models/relation.rb +9 -4
- data/app/models/relation_proxy.rb +2 -2
- data/app/models/role.rb +12 -5
- data/app/models/site.rb +10 -9
- data/app/models/skin.rb +8 -0
- data/app/models/string_hash.rb +65 -0
- data/app/models/text_document.rb +1 -1
- data/app/models/user.rb +2 -0
- data/app/models/virtual_class.rb +43 -10
- data/app/views/comments/create.rjs +1 -32
- data/app/views/comments/edit.rjs +1 -1
- data/app/views/comments/update.rjs +1 -1
- data/app/views/documents/show.rhtml +1 -1
- data/app/views/groups/_form.rhtml +7 -0
- data/app/views/groups/_li.rhtml +1 -1
- data/app/views/nodes/500.html +2 -1
- data/app/views/nodes/destroy.rjs +2 -0
- data/app/views/sites/jobs.erb +2 -3
- data/app/views/templates/document_create_tabs/_file.rhtml +1 -1
- data/app/views/templates/document_create_tabs/_import.rhtml +4 -1
- data/app/views/templates/document_create_tabs/_template.rhtml +3 -0
- data/app/views/templates/document_create_tabs/_text_document.rhtml +3 -0
- data/app/views/versions/custom_tab.rhtml +1 -1
- data/app/views/versions/edit.rhtml +1 -1
- data/bricks/acls/lib/bricks/acls.rb +3 -3
- data/bricks/acls/zena/test/unit/acl_test.rb +15 -0
- data/bricks/fs_skin/lib/bricks/fs_skin.rb +190 -0
- data/bricks/fs_skin/zena/init.rb +1 -0
- data/bricks/fs_skin/zena/migrate/20110702010330_add_fs_skin_to_idx_templates.rb +12 -0
- data/bricks/{static → fs_skin}/zena/skins/blog/Image-edit.zafu +0 -0
- data/bricks/{static → fs_skin}/zena/skins/blog/Image.zafu +0 -0
- data/bricks/{static → fs_skin}/zena/skins/blog/Node-+index.zafu +0 -0
- data/bricks/{static → fs_skin}/zena/skins/blog/Node-+notFound.zafu +0 -0
- data/bricks/{static → fs_skin}/zena/skins/blog/Node-+search.zafu +0 -0
- data/bricks/{static → fs_skin}/zena/skins/blog/Node.zafu +1 -1
- data/bricks/{static → fs_skin}/zena/skins/blog/Post.zafu +0 -0
- data/bricks/{static → fs_skin}/zena/skins/blog/Project--kml.zafu +0 -0
- data/bricks/{static → fs_skin}/zena/skins/blog/Project.zafu +0 -0
- data/bricks/{static → fs_skin}/zena/skins/blog/comments.zafu +0 -0
- data/bricks/{static → fs_skin}/zena/skins/blog/dict.yml +0 -0
- data/bricks/{static → fs_skin}/zena/skins/blog/img/dateBg.jpg +0 -0
- data/bricks/{static → fs_skin}/zena/skins/blog/img/header.png +0 -0
- data/bricks/{static → fs_skin}/zena/skins/blog/img/mapPin.png +0 -0
- data/bricks/{static → fs_skin}/zena/skins/blog/img/menu.gif +0 -0
- data/bricks/{static → fs_skin}/zena/skins/blog/img/menuover.gif +0 -0
- data/bricks/{static → fs_skin}/zena/skins/blog/img/style.css +0 -0
- data/bricks/fs_skin/zena/tasks.rb +26 -0
- data/bricks/{static/zena/test/integration/static_integration_test.rb → fs_skin/zena/test/integration/fs_skin_integration_test.rb} +6 -6
- data/bricks/fs_skin/zena/test/unit/fs_skin_test.rb +33 -0
- data/bricks/grid/lib/bricks/grid.rb +4 -3
- data/bricks/tags/lib/bricks/tags.rb +1 -7
- data/bricks/zena/zena/migrate/20120605091558_add_ssl_login_to_site.rb +7 -0
- data/bricks/zena/zena/migrate/20120630123551_add_auto_publish_to_group.rb +9 -0
- data/config/bricks.yml +3 -3
- data/config/gems.yml +2 -3
- data/lib/tasks/zena.rake +7 -3
- data/lib/zafu.rb +7 -0
- data/lib/zafu/all.rb +21 -0
- data/lib/zafu/compiler.rb +7 -0
- data/lib/zafu/controller_methods.rb +58 -0
- data/lib/zafu/handler.rb +57 -0
- data/lib/zafu/info.rb +4 -0
- data/lib/zafu/markup.rb +309 -0
- data/lib/zafu/mock_helper.rb +42 -0
- data/lib/zafu/node_context.rb +203 -0
- data/lib/zafu/ordered_hash.rb +53 -0
- data/lib/zafu/parser.rb +676 -0
- data/lib/zafu/parsing_rules.rb +382 -0
- data/lib/zafu/process/ajax.rb +530 -0
- data/lib/zafu/process/conditional.rb +92 -0
- data/lib/zafu/process/context.rb +186 -0
- data/lib/zafu/process/forms.rb +143 -0
- data/lib/zafu/process/html.rb +186 -0
- data/lib/zafu/process/ruby_less_processing.rb +321 -0
- data/lib/zafu/security.rb +15 -0
- data/lib/zafu/template.rb +25 -0
- data/lib/zafu/test_helper.rb +19 -0
- data/lib/zafu/view_methods.rb +6 -0
- data/lib/zena.rb +1 -1
- data/lib/zena/acts/enrollable.rb +1 -1
- data/lib/zena/app.rb +4 -17
- data/lib/zena/console.rb +18 -1
- data/lib/zena/core_ext/file_utils.rb +13 -1
- data/lib/zena/core_ext/fixnum.rb +4 -0
- data/lib/zena/core_ext/float.rb +7 -0
- data/lib/zena/deploy.rb +4 -2
- data/lib/zena/deploy/app_init.rhtml +2 -1
- data/lib/zena/deploy/database.rhtml +1 -1
- data/lib/zena/info.rb +1 -1
- data/lib/zena/parser/zazen_rules.rb +4 -4
- data/lib/zena/routes.rb +1 -1
- data/lib/zena/test_controller.rb +1 -1
- data/lib/zena/use.rb +14 -1
- data/lib/zena/use/action.rb +4 -2
- data/lib/zena/use/ajax.rb +86 -38
- data/lib/zena/use/authlogic.rb +16 -1
- data/lib/zena/use/calendar.rb +37 -17
- data/lib/zena/use/conditional.rb +2 -2
- data/lib/zena/use/context.rb +30 -9
- data/lib/zena/use/dates.rb +39 -3
- data/lib/zena/use/display.rb +6 -19
- data/lib/zena/use/forms.rb +100 -79
- data/lib/zena/use/i18n.rb +40 -16
- data/lib/zena/use/query_builder.rb +0 -6
- data/lib/zena/use/query_node.rb +17 -4
- data/lib/zena/use/relations.rb +1 -3
- data/lib/zena/use/rendering.rb +10 -8
- data/lib/zena/use/scope_index.rb +5 -1
- data/lib/zena/use/search.rb +2 -1
- data/lib/zena/use/urls.rb +82 -77
- data/lib/zena/use/workflow.rb +12 -4
- data/lib/zena/use/zafu_safe_definitions.rb +37 -9
- data/lib/zena/use/zafu_templates.rb +49 -20
- data/lib/zena/use/zazen.rb +6 -2
- data/locale/it/LC_MESSAGES/zena.mo +0 -0
- data/locale/it/zena.mo +0 -0
- data/locale/it/zena.po +1982 -0
- data/public/images/arrow_back.png +0 -0
- data/public/images/remove_tag.png +0 -0
- data/public/javascripts/grid.js +800 -199
- data/public/javascripts/window.js +1 -1
- data/public/javascripts/zena.js +130 -21
- data/public/stylesheets/grid.css +11 -2
- data/public/stylesheets/zena.css +2 -1
- data/test/custom_queries/complex.host.yml +5 -0
- data/test/fixtures/files/TestNode.zafu +36 -0
- data/test/functional/nodes_controller_test.rb +18 -1
- data/test/integration/zafu_compiler/action.yml +2 -2
- data/test/integration/zafu_compiler/ajax.yml +44 -26
- data/test/integration/zafu_compiler/asset.yml +12 -2
- data/test/integration/zafu_compiler/basic.yml +0 -16
- data/test/integration/zafu_compiler/calendar.yml +6 -6
- data/test/integration/zafu_compiler/complex_ok.yml +23 -1
- data/test/integration/zafu_compiler/conditional.yml +5 -5
- data/test/integration/zafu_compiler/context.yml +6 -5
- data/test/integration/zafu_compiler/dates.yml +23 -2
- data/test/integration/zafu_compiler/display.yml +46 -2
- data/test/integration/zafu_compiler/errors.yml +2 -2
- data/test/integration/zafu_compiler/eval.yml +35 -7
- data/test/integration/zafu_compiler/forms.yml +47 -13
- data/test/integration/zafu_compiler/i18n.yml +2 -2
- data/test/integration/zafu_compiler/meta.yml +35 -1
- data/test/integration/zafu_compiler/query.yml +23 -4
- data/test/integration/zafu_compiler/relations.yml +10 -6
- data/test/integration/zafu_compiler/roles.yml +4 -4
- data/test/integration/zafu_compiler/rubyless.yml +11 -1
- data/test/integration/zafu_compiler/safe_definitions.yml +23 -5
- data/test/integration/zafu_compiler/security.yml +10 -6
- data/test/integration/zafu_compiler/urls.yml +23 -6
- data/test/integration/zafu_compiler/zafu_attributes.yml +1 -1
- data/test/integration/zafu_compiler/zazen.yml +14 -0
- data/test/selenium/Add/add3.rsel +8 -8
- data/test/selenium/Destroy/0setup.rsel +12 -0
- data/test/selenium/Destroy/destroy1.rsel +16 -0
- data/test/selenium/Edit/edit2.rsel +9 -9
- data/test/selenium/Edit/edit5.rsel +9 -9
- data/test/selenium/Edit/edit6.rsel +9 -9
- data/test/selenium/Form/form4.rsel +17 -0
- data/test/selenium/Toggle/toggle1.rsel +2 -0
- data/test/selenium/Toggle/toggle2.rsel +18 -0
- data/test/sites/zena/columns.yml +3 -0
- data/test/sites/zena/versions.yml +7 -0
- data/test/unit/cached_page_test.rb +13 -13
- data/test/unit/column_test.rb +26 -0
- data/test/unit/node_test.rb +16 -1
- data/test/unit/project_test.rb +6 -1
- data/test/unit/relation_test.rb +1 -1
- data/test/unit/role_test.rb +1 -1
- data/test/unit/string_hash_test.rb +30 -0
- data/test/unit/virtual_class_test.rb +31 -17
- data/test/unit/zafu_markup_test.rb +414 -0
- data/test/unit/zafu_node_context_test.rb +375 -0
- data/test/unit/zafu_ordered_hash_test.rb +69 -0
- data/test/unit/zena/acts/enrollable_test.rb +1 -1
- data/test/unit/zena/parser/zafu_asset.yml +0 -10
- data/test/unit/zena/parser/zazen.yml +1 -1
- data/test/unit/zena/parser_test.rb +1 -72
- data/test/unit/zena/use/dates_test.rb +1 -1
- data/test/unit/zena/use/rendering_test.rb +24 -7
- data/test/unit/zena/use/scope_index_test.rb +17 -0
- data/test/unit/zena/use/zazen_test.rb +2 -1
- data/zena.gemspec +71 -37
- metadata +104 -83
- data/app/views/nodes/destroy.erb +0 -0
- data/bricks/static/lib/bricks/static.rb +0 -151
- data/bricks/static/zena/init.rb +0 -1
- data/bricks/static/zena/migrate/20110702010330_add_static_to_idx_templates.rb +0 -12
- data/bricks/static/zena/test/unit/static_test.rb +0 -33
- data/lib/zena/parser/zafu_rules.rb +0 -244
- data/lib/zena/parser/zafu_tags.rb +0 -198
- data/lib/zena/parser/zena_rules.rb +0 -23
data/lib/zena/use/i18n.rb
CHANGED
|
@@ -8,7 +8,7 @@ module Zena
|
|
|
8
8
|
::ENV['LANG'] = 'C'
|
|
9
9
|
|
|
10
10
|
class TranslationDict
|
|
11
|
-
attr_reader :last_error, :node_id
|
|
11
|
+
attr_reader :last_error, :node_id, :static
|
|
12
12
|
|
|
13
13
|
include Zena::Acts::Secure
|
|
14
14
|
include RubyLess
|
|
@@ -16,8 +16,9 @@ module Zena
|
|
|
16
16
|
# never returns nil
|
|
17
17
|
safe_method [:get, String] => {:class => String, :accept_nil => true}
|
|
18
18
|
|
|
19
|
-
def initialize(node_id)
|
|
19
|
+
def initialize(node_id, static = nil)
|
|
20
20
|
@node_id = node_id
|
|
21
|
+
@static = static
|
|
21
22
|
end
|
|
22
23
|
|
|
23
24
|
def get(key, use_global = true)
|
|
@@ -31,21 +32,30 @@ module Zena
|
|
|
31
32
|
|
|
32
33
|
def load!(text = nil)
|
|
33
34
|
unless text
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
35
|
+
if @node_id
|
|
36
|
+
if dict = secure(Node) { Node.find(:first, :conditions => {:id => @node_id}) }
|
|
37
|
+
text = dict.prop['text']
|
|
38
|
+
else
|
|
39
|
+
@dict = {}
|
|
40
|
+
error("missing 'dictionary'")
|
|
41
|
+
return false
|
|
42
|
+
end
|
|
43
|
+
else
|
|
44
|
+
text, ignore = ::Skin.text_from_fs_skin(@static[:brick_name], @static[:skin_name], @static[:path], :ext => 'yml')
|
|
45
|
+
unless text
|
|
46
|
+
@dict = {}
|
|
47
|
+
error("missing 'dictionary'")
|
|
48
|
+
return false
|
|
49
|
+
end
|
|
38
50
|
end
|
|
39
|
-
text = dict.prop['text']
|
|
40
51
|
end
|
|
41
|
-
|
|
52
|
+
|
|
42
53
|
begin
|
|
43
54
|
definitions = YAML::load(text)
|
|
44
55
|
if translations = definitions['translations']
|
|
45
56
|
if translations.kind_of?(Hash)
|
|
46
57
|
# ok
|
|
47
58
|
@dict = translations
|
|
48
|
-
true
|
|
49
59
|
else
|
|
50
60
|
return error("bad 'translations' content (should be a dictionary)")
|
|
51
61
|
end
|
|
@@ -218,8 +228,8 @@ module Zena
|
|
|
218
228
|
ApplicationController.send(:_, str)
|
|
219
229
|
end
|
|
220
230
|
|
|
221
|
-
def load_dictionary(node_id)
|
|
222
|
-
Zena::Use::I18n::TranslationDict.new(node_id)
|
|
231
|
+
def load_dictionary(node_id, static=nil)
|
|
232
|
+
Zena::Use::I18n::TranslationDict.new(node_id, static)
|
|
223
233
|
end
|
|
224
234
|
|
|
225
235
|
# show language selector
|
|
@@ -284,10 +294,19 @@ module Zena
|
|
|
284
294
|
def r_load
|
|
285
295
|
if dict = @params[:dictionary]
|
|
286
296
|
# FIXME: replace @options[:base_path] by @options[:skin_id]
|
|
287
|
-
dict_content, absolute_url, base_path, doc = @options[:helper].send(:get_template_text, dict, @options[:base_path])
|
|
288
|
-
if
|
|
297
|
+
dict_content, absolute_url, base_path, doc = @options[:helper].send(:get_template_text, dict, @options[:base_path], :ext => 'yml')
|
|
298
|
+
if dict_content
|
|
289
299
|
# Lazy dictionary used for literal resolution
|
|
290
|
-
|
|
300
|
+
if doc
|
|
301
|
+
dict = TranslationDict.new(doc.id)
|
|
302
|
+
else
|
|
303
|
+
if absolute_url =~ /^\$([a-zA-Z_]+)-([a-zA-Z_]+)\/(.+)$/
|
|
304
|
+
static = {:brick_name => $1, :skin_name => $2, :path => $3}
|
|
305
|
+
else
|
|
306
|
+
return parser_error("Invalid absolute_url for static asset ('#{absolute_url}')")
|
|
307
|
+
end
|
|
308
|
+
dict = TranslationDict.new(nil, static)
|
|
309
|
+
end
|
|
291
310
|
|
|
292
311
|
if dict.load!(dict_content)
|
|
293
312
|
# Save dictionary in template for dynamic uses
|
|
@@ -297,7 +316,11 @@ module Zena
|
|
|
297
316
|
set_context_var('set_var', 'dictionary', RubyLess::TypedString.new(dict_name, :class => TranslationDict, :literal => dict))
|
|
298
317
|
|
|
299
318
|
# Lazy loading (loads file on first request)
|
|
300
|
-
|
|
319
|
+
if doc
|
|
320
|
+
out "<% #{dict_name} = load_dictionary(#{doc.id}) %>"
|
|
321
|
+
else
|
|
322
|
+
out "<% #{dict_name} = load_dictionary(nil, #{static.inspect}) %>"
|
|
323
|
+
end
|
|
301
324
|
else
|
|
302
325
|
return parser_error(dict.last_error)
|
|
303
326
|
end
|
|
@@ -390,7 +413,8 @@ module Zena
|
|
|
390
413
|
# Lazy loading (loads file on first request)
|
|
391
414
|
dict_name = get_var_name('dictionary', 'dict', cleared_context)
|
|
392
415
|
set_context_var('set_var', 'dictionary', dict, cleared_context)
|
|
393
|
-
|
|
416
|
+
d = dict.literal
|
|
417
|
+
prefix += "<% #{dict_name} = load_dictionary(#{d.node_id.inspect},#{d.static.inspect}) %>"
|
|
394
418
|
return cleared_context, prefix
|
|
395
419
|
else
|
|
396
420
|
return cleared_context, nil
|
|
@@ -458,12 +458,6 @@ module Zena
|
|
|
458
458
|
finders = [parts.join(' from ')]
|
|
459
459
|
if params[:or]
|
|
460
460
|
finders << params[:or]
|
|
461
|
-
|
|
462
|
-
key_counter = 1
|
|
463
|
-
while sub_or = params["or#{key_counter}".to_sym]
|
|
464
|
-
key_counter += 1
|
|
465
|
-
finders << sub_or
|
|
466
|
-
end
|
|
467
461
|
else
|
|
468
462
|
or_clause = nil
|
|
469
463
|
end
|
data/lib/zena/use/query_node.rb
CHANGED
|
@@ -80,11 +80,11 @@ module Zena
|
|
|
80
80
|
visitor.site.host
|
|
81
81
|
end
|
|
82
82
|
|
|
83
|
-
def sfind(sqliss)
|
|
83
|
+
def sfind(sqliss, arity=:all)
|
|
84
84
|
query = Node.build_query(:all, sqliss,
|
|
85
85
|
:default => {:scope => 'site'}
|
|
86
86
|
)
|
|
87
|
-
Node.do_find(
|
|
87
|
+
Node.do_find(arity, eval(query.to_s(arity == :count ? :count : :find)))
|
|
88
88
|
end
|
|
89
89
|
|
|
90
90
|
# Find a node and propagate visitor
|
|
@@ -205,7 +205,13 @@ module Zena
|
|
|
205
205
|
def process_field(field_name)
|
|
206
206
|
if fld = @query.attributes_alias[field_name]
|
|
207
207
|
# use custom query alias value defined in select clause: 'custom_a AS validation'
|
|
208
|
-
|
|
208
|
+
if processing_filter?
|
|
209
|
+
# We need to use the full original clause, except when the clause contains group functions (MAX, MIN, etc).
|
|
210
|
+
# If the clause is too complex, we need to use something simpler or it will break (custom queries).
|
|
211
|
+
"(#{fld})"
|
|
212
|
+
else
|
|
213
|
+
fld
|
|
214
|
+
end
|
|
209
215
|
elsif processing_filter? && map_def = self.class.filter_fields[field_name]
|
|
210
216
|
# Special filter fields such as 'role', 'tag' or 'class'
|
|
211
217
|
if map_def.kind_of?(String)
|
|
@@ -378,7 +384,7 @@ module Zena
|
|
|
378
384
|
# ******** And maybe overwrite these **********
|
|
379
385
|
def parse_custom_query_argument(key, value)
|
|
380
386
|
return nil unless value
|
|
381
|
-
super.gsub(/(RELATION_ID|NODE_ATTR|SECURE_TABLE)\(([^)]+)\)|(REF_DATE|NODE_ID|VISITOR_LANG)/) do
|
|
387
|
+
super.gsub(/(RELATION_ID|KPATH_VALUE|NODE_ATTR|SECURE_TABLE)\(([^)]+)\)|(REF_DATE|NODE_ID|VISITOR_LANG)/) do
|
|
382
388
|
type, value = $1, $2
|
|
383
389
|
type ||= $3
|
|
384
390
|
case type
|
|
@@ -389,6 +395,13 @@ module Zena
|
|
|
389
395
|
else
|
|
390
396
|
raise ::QueryBuilder::Error.new("Custom query: could not find Relation '#{role}'")
|
|
391
397
|
end
|
|
398
|
+
when 'KPATH_VALUE'
|
|
399
|
+
klass_name = value
|
|
400
|
+
if rel = VirtualClass[klass_name]
|
|
401
|
+
rel.kpath
|
|
402
|
+
else
|
|
403
|
+
raise ::QueryBuilder::Error.new("Custom query kpath: could not find VirtualClass '#{role}'")
|
|
404
|
+
end
|
|
392
405
|
when 'SECURE_TABLE'
|
|
393
406
|
table_name = value
|
|
394
407
|
add_filter "\#{secure_scope('#{table_name}')}"
|
data/lib/zena/use/relations.rb
CHANGED
|
@@ -370,9 +370,7 @@ module Zena
|
|
|
370
370
|
|
|
371
371
|
# Destroy all links related to this node
|
|
372
372
|
def destroy_links
|
|
373
|
-
|
|
374
|
-
l.destroy
|
|
375
|
-
end
|
|
373
|
+
Zena::Db.execute "DELETE FROM #{Link.table_name} WHERE source_id = #{self[:id].to_i} OR target_id = #{self[:id].to_i}"
|
|
376
374
|
end
|
|
377
375
|
end # ModelMethods
|
|
378
376
|
end # Relations
|
data/lib/zena/use/rendering.rb
CHANGED
|
@@ -207,14 +207,16 @@ module Zena
|
|
|
207
207
|
headers['Cache-Control'] = (!current_site.authentication? && @node.public?) ? 'public' : 'private'
|
|
208
208
|
end
|
|
209
209
|
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
210
|
+
if perform_caching && caching_allowed(:authenticated => opts.delete(:authenticated))
|
|
211
|
+
|
|
212
|
+
url = page_cache_file(opts.delete(:url))
|
|
213
|
+
opts = {:expire_after => nil,
|
|
214
|
+
:path => (current_site.public_path + url),
|
|
215
|
+
:content_data => response.body,
|
|
216
|
+
:node_id => @node[:id]
|
|
217
|
+
}.merge(opts)
|
|
218
|
+
secure!(CachedPage) { CachedPage.create(opts) }
|
|
219
|
+
end
|
|
218
220
|
end
|
|
219
221
|
|
|
220
222
|
# Return true if we can cache the current page
|
data/lib/zena/use/scope_index.rb
CHANGED
|
@@ -135,6 +135,7 @@ module Zena
|
|
|
135
135
|
keys.each do |group_key|
|
|
136
136
|
next unless list = groups[group_key]
|
|
137
137
|
next unless should_clear_group?(group_key, deleted_node)
|
|
138
|
+
attrs["#{group_key}_id"] = nil
|
|
138
139
|
list.each do |key|
|
|
139
140
|
attrs["#{group_key}_#{key}"] = nil
|
|
140
141
|
end
|
|
@@ -160,7 +161,7 @@ module Zena
|
|
|
160
161
|
def set_site_id
|
|
161
162
|
self[:site_id] = current_site.id
|
|
162
163
|
end
|
|
163
|
-
end #
|
|
164
|
+
end # IndexMethods
|
|
164
165
|
|
|
165
166
|
module ModelMethods
|
|
166
167
|
def self.included(base)
|
|
@@ -232,6 +233,9 @@ module Zena
|
|
|
232
233
|
update_scope_indices_on_prop_change(true)
|
|
233
234
|
# How can we handle this ?
|
|
234
235
|
# update_scope_indices_on_link_change
|
|
236
|
+
if s = scope_index
|
|
237
|
+
s.destroy
|
|
238
|
+
end
|
|
235
239
|
end
|
|
236
240
|
|
|
237
241
|
def update_scope_indices_on_prop_change(deleted=false)
|
data/lib/zena/use/search.rb
CHANGED
|
@@ -76,9 +76,10 @@ module Zena
|
|
|
76
76
|
|
|
77
77
|
# Execute a fulltext search using default fulltext support from the database (MyISAM on MySQL).
|
|
78
78
|
def search_text(query, options = {})
|
|
79
|
+
options[:order] ||= 'zip desc'
|
|
79
80
|
if offset = options[:offset]
|
|
80
81
|
limit = options[:limit] || 20
|
|
81
|
-
Node.find(:all, match_query(query).merge(:offset => offset, :limit => limit))
|
|
82
|
+
Node.find(:all, match_query(query).merge(:offset => offset, :limit => limit, :order => options[:order]))
|
|
82
83
|
else
|
|
83
84
|
# :default argument not used here
|
|
84
85
|
options.delete(:default)
|
data/lib/zena/use/urls.rb
CHANGED
|
@@ -395,7 +395,7 @@ module Zena
|
|
|
395
395
|
steal_and_eval_html_params_for(markup, @params)
|
|
396
396
|
|
|
397
397
|
href = make_href(remote_target, options)
|
|
398
|
-
|
|
398
|
+
|
|
399
399
|
# This is to make sure live_id is set *inside* the <a> tag.
|
|
400
400
|
if @live_param
|
|
401
401
|
text = add_live_id(text_for_link, markup)
|
|
@@ -405,9 +405,9 @@ module Zena
|
|
|
405
405
|
end
|
|
406
406
|
|
|
407
407
|
http_method = http_method_from_action(options[:action])
|
|
408
|
-
|
|
409
|
-
if http_method == 'delete'
|
|
410
|
-
confirm ||= '#{t("Destroy
|
|
408
|
+
|
|
409
|
+
if http_method == 'delete' && method != 'unlink'
|
|
410
|
+
confirm ||= '#{t("Destroy")} #{h title} ?'
|
|
411
411
|
end
|
|
412
412
|
|
|
413
413
|
if confirm
|
|
@@ -426,9 +426,64 @@ module Zena
|
|
|
426
426
|
# Add href to non-ajax method.
|
|
427
427
|
markup.set_dyn_param(:href, "<%= #{make_href(nil, options.merge(:update => false))} %>")
|
|
428
428
|
|
|
429
|
+
if true
|
|
430
|
+
# Use onclick with Ajax.
|
|
431
|
+
if confirm
|
|
432
|
+
markup.set_dyn_param(:onclick, "if(confirm(\"<%= #{confirm} %>\")) {new Ajax.Request(\"<%= #{href} %>\", {asynchronous:true, evalScripts:true, method:\"#{http_method}\"});} return false;")
|
|
433
|
+
else
|
|
434
|
+
markup.set_dyn_param(:onclick, "new Ajax.Request(\"<%= #{href} %>\", {asynchronous:true, evalScripts:true, method:\"#{http_method}\"}); return false;")
|
|
435
|
+
end
|
|
436
|
+
else
|
|
437
|
+
#### FIXME: We need the 'update' parameter to trigger a js response for delete but we ignore
|
|
438
|
+
#### the content.
|
|
439
|
+
|
|
440
|
+
|
|
441
|
+
if remote_target.kind_of?(String)
|
|
442
|
+
# YUCK. We should have a way to have dom_ids that do not need
|
|
443
|
+
# us to look for remote_target !
|
|
444
|
+
remote_target = find_target(remote_target)
|
|
445
|
+
end
|
|
446
|
+
# Experimental new model for javascript actions.
|
|
447
|
+
# Works for 'swap' but needs more adaptations for 'edit' or other links
|
|
448
|
+
|
|
449
|
+
hash_params = []
|
|
450
|
+
(options[:query_params] || @params).each do |key, value|
|
|
451
|
+
next if [:update, :href, :eval, :text, :attr, :t, :host].include?(key)
|
|
452
|
+
case key
|
|
453
|
+
when :anchor
|
|
454
|
+
# Get anchor and force string interpolation
|
|
455
|
+
value = "%Q{#{get_anchor_name(value)}}"
|
|
456
|
+
when :publish
|
|
457
|
+
if value == 'true'
|
|
458
|
+
key = 'node[v_status]'
|
|
459
|
+
value = Zena::Status::Pub
|
|
460
|
+
else
|
|
461
|
+
next
|
|
462
|
+
end
|
|
463
|
+
when :encode_params, :format, :mode, :insert, :states
|
|
464
|
+
# Force string interpolation
|
|
465
|
+
value = "%Q{#{value}}"
|
|
466
|
+
else
|
|
467
|
+
if value.blank?
|
|
468
|
+
value = "''"
|
|
469
|
+
end
|
|
470
|
+
end
|
|
471
|
+
hash_params << "#{key.inspect} => #{value}"
|
|
472
|
+
end
|
|
429
473
|
|
|
430
|
-
|
|
431
|
-
|
|
474
|
+
if host = param(:host)
|
|
475
|
+
hash_params << ":host => %Q{#{host}}"
|
|
476
|
+
end
|
|
477
|
+
|
|
478
|
+
if !hash_params.blank?
|
|
479
|
+
query = RubyLess.translate(self, "{#{hash_params.join(', ')}}.to_json")
|
|
480
|
+
else
|
|
481
|
+
query = ''
|
|
482
|
+
end
|
|
483
|
+
|
|
484
|
+
dom_id, dom_prefix = get_dom_id(remote_target)
|
|
485
|
+
markup.set_dyn_param(:onclick, %Q{return Zena.#{http_method}("<%= #{dom_id} %>",<%= #{query} %>)})
|
|
486
|
+
end
|
|
432
487
|
else
|
|
433
488
|
markup.set_dyn_param(:href, "<%= #{href} %>")
|
|
434
489
|
|
|
@@ -581,7 +636,7 @@ module Zena
|
|
|
581
636
|
method = 'zafu_node_path'
|
|
582
637
|
elsif NODE_ACTIONS[opts[:action]]
|
|
583
638
|
method = "#{opts[:action]}_node_path"
|
|
584
|
-
elsif remote_target
|
|
639
|
+
elsif remote_target && opts[:action] != 'destroy'
|
|
585
640
|
method = 'zafu_node_path'
|
|
586
641
|
else
|
|
587
642
|
method = 'zen_path'
|
|
@@ -593,10 +648,10 @@ module Zena
|
|
|
593
648
|
if href = @params[:href]
|
|
594
649
|
method_args << href
|
|
595
650
|
elsif node.will_be?(Version)
|
|
596
|
-
method_args << "node"
|
|
651
|
+
method_args << "this.node"
|
|
597
652
|
hash_params << ":lang => this.lang"
|
|
598
653
|
else
|
|
599
|
-
method_args << '
|
|
654
|
+
method_args << '@node'
|
|
600
655
|
end
|
|
601
656
|
|
|
602
657
|
insert_ajax_args(remote_target, hash_params, opts[:action]) if remote_target
|
|
@@ -632,30 +687,16 @@ module Zena
|
|
|
632
687
|
unless hash_params.empty?
|
|
633
688
|
method_args << hash_params.join(', ')
|
|
634
689
|
end
|
|
635
|
-
|
|
690
|
+
|
|
636
691
|
method = "#{method}(#{method_args.join(', ')})"
|
|
637
|
-
|
|
692
|
+
|
|
638
693
|
::RubyLess.translate(self, method)
|
|
639
694
|
end
|
|
640
695
|
|
|
641
696
|
def insert_ajax_args(target, hash_params, action)
|
|
642
697
|
hash_params << ":s => start_id"
|
|
643
698
|
hash_params << ":link_id => this.link_id" if @context[:has_link_id] && node.will_be?(Node)
|
|
644
|
-
|
|
645
|
-
# reload full page
|
|
646
|
-
hash_params << ":udom_id => '_page'"
|
|
647
|
-
return
|
|
648
|
-
elsif target.kind_of?(String)
|
|
649
|
-
# named target
|
|
650
|
-
if target_block = find_target(target)
|
|
651
|
-
target = target_block
|
|
652
|
-
else
|
|
653
|
-
out parser_error("Could not find target name '#{target}'.")
|
|
654
|
-
return nil
|
|
655
|
-
end
|
|
656
|
-
end
|
|
657
|
-
|
|
658
|
-
|
|
699
|
+
|
|
659
700
|
# FIXME: when we have proper markup.dyn_params[:id] support,
|
|
660
701
|
# we should not need this crap anymore.
|
|
661
702
|
case action
|
|
@@ -667,63 +708,28 @@ module Zena
|
|
|
667
708
|
hash_params << ":t_url => %Q{#{form_url(node.dom_prefix)}}"
|
|
668
709
|
# To enable link edit fix the following line:
|
|
669
710
|
# hash_params << "'node[link_id]' => link_id"
|
|
670
|
-
when 'unlink', '
|
|
711
|
+
when 'unlink', 'destroy'
|
|
671
712
|
@insert_dom_id = %Q{"#{node.dom_id(:erb => false)}"}
|
|
672
713
|
hash_params << ":dom_id => insert_dom_id"
|
|
673
714
|
hash_params << ":t_url => %Q{#{template_url(node.dom_prefix)}}"
|
|
674
715
|
else #drop, #swap
|
|
716
|
+
if target == '_page'
|
|
717
|
+
# reload full page
|
|
718
|
+
hash_params << ":udom_id => '_page'"
|
|
719
|
+
return
|
|
720
|
+
elsif target.kind_of?(String)
|
|
721
|
+
# named target
|
|
722
|
+
if target_block = find_target(target)
|
|
723
|
+
target = target_block
|
|
724
|
+
else
|
|
725
|
+
out parser_error("Could not find target name '#{target}'.")
|
|
726
|
+
return nil
|
|
727
|
+
end
|
|
728
|
+
end
|
|
675
729
|
@insert_dom_id, dom_prefix = get_dom_id(target)
|
|
676
730
|
hash_params << ":dom_id => insert_dom_id"
|
|
677
731
|
hash_params << ":t_url => %Q{#{template_url(dom_prefix)}}"
|
|
678
732
|
end
|
|
679
|
-
|
|
680
|
-
# method = opts[:method] || :get
|
|
681
|
-
#
|
|
682
|
-
# html_params = opts[:html_params] || {}
|
|
683
|
-
# node_id = opts[:node_id] || self.node_id
|
|
684
|
-
#
|
|
685
|
-
# url = opts[:url] || "/#{base_class.to_s.pluralize.underscore}/\#{#{node_id}}#{method == :get ? '/zafu' : ''}"
|
|
686
|
-
# opts[:cond] ||= "#{node}.can_write?" if method != :get
|
|
687
|
-
#
|
|
688
|
-
# query_params = [opts[:query_params]].flatten.compact
|
|
689
|
-
#
|
|
690
|
-
# if method == :get
|
|
691
|
-
# if target
|
|
692
|
-
# query_params << "t_url=#{CGI.escape(target.template_url)}"
|
|
693
|
-
# query_params << "dom_id=#{target.dom_id}"
|
|
694
|
-
# else
|
|
695
|
-
# query_params << "dom_id=_page"
|
|
696
|
-
# end
|
|
697
|
-
# else
|
|
698
|
-
# query_params << "t_url=#{CGI.escape(template_url)}" if method != :delete
|
|
699
|
-
#
|
|
700
|
-
# query_params << "dom_id=#{dom_id}"
|
|
701
|
-
# if target != self
|
|
702
|
-
# if target
|
|
703
|
-
# query_params << "u_url=#{CGI.escape(target.template_url)}"
|
|
704
|
-
# query_params << "udom_id=#{target.dom_id}"
|
|
705
|
-
# else
|
|
706
|
-
# query_params << "udom_id=_page"
|
|
707
|
-
# end
|
|
708
|
-
# end
|
|
709
|
-
# end
|
|
710
|
-
#
|
|
711
|
-
# query_params << "node[v_status]=#{Zena::Status::Pub}" if @params[:publish] # FIXME: this acts like publish = 'force'
|
|
712
|
-
# query_params << start_node_s_param(:string)
|
|
713
|
-
#
|
|
714
|
-
# res = ''
|
|
715
|
-
# res += "<% if #{opts[:cond]} %>" if opts[:cond]
|
|
716
|
-
# res += "<%= tag_to_remote({:url => \"#{url}?#{query_params.join('&')}\", :method => #{method.inspect}}#{params_to_erb(html_params)}) %>"
|
|
717
|
-
# res += text_for_link(opts[:default_text])
|
|
718
|
-
# res += "</a>"
|
|
719
|
-
# if opts[:cond]
|
|
720
|
-
# if opts[:else] != :void
|
|
721
|
-
# res += "<% else %>"
|
|
722
|
-
# res += text_for_link(opts[:default_text])
|
|
723
|
-
# end
|
|
724
|
-
# res += "<% end %>"
|
|
725
|
-
# end
|
|
726
|
-
# res
|
|
727
733
|
end
|
|
728
734
|
|
|
729
735
|
# <r:link page='next'/> <r:link page='previous'/> <r:link page='list'/>
|
|
@@ -792,13 +798,12 @@ module Zena
|
|
|
792
798
|
end
|
|
793
799
|
|
|
794
800
|
if !descendant('else')
|
|
795
|
-
else_tag = {:method => 'else', :text =>
|
|
801
|
+
else_tag = {:method => 'else', :text => "#{@markup.space_before}<r:this/>"}
|
|
796
802
|
else_tag[:tag] = tag if tag
|
|
797
803
|
add_block else_tag
|
|
798
804
|
# Clear cached descendants
|
|
799
805
|
@all_descendants = nil
|
|
800
806
|
end
|
|
801
|
-
|
|
802
807
|
out "<% page_numbers(#{curr_page}, #{page_count}, #{(@params[:join] || ' ').inspect}, #{@params[:page_count] ? @params[:page_count].to_i : 'nil'}) do |#{page_number}, #{page_join}, #{page_name}| %>"
|
|
803
808
|
out "<%= #{page_join} %>"
|
|
804
809
|
with_context(:node => node.move_to(page_number, Number)) do
|