Changeset 481
- Timestamp:
- 2007-05-05 22:07:30 (2 years ago)
- Files:
-
- trunk/app/controllers/application.rb (modified) (1 diff)
- trunk/app/helpers/application_helper.rb (modified) (2 diffs)
- trunk/app/models/node.rb (modified) (1 diff)
- trunk/app/models/note.rb (modified) (1 diff)
- trunk/app/models/version.rb (modified) (1 diff)
- trunk/lib/multiversion.rb (modified) (1 diff)
- trunk/lib/parser/lib/parser.rb (modified) (2 diffs)
- trunk/lib/parser/lib/rules/zafu.rb (modified) (3 diffs)
- trunk/lib/parser/lib/rules/zena.rb (modified) (10 diffs)
- trunk/lib/parser/test/parser_test.rb (modified) (2 diffs)
- trunk/lib/parser/test/zafu.yml (modified) (1 diff)
- trunk/test/helpers/basic.yml (modified) (23 diffs)
- trunk/test/helpers/relations.yml (modified) (5 diffs)
- trunk/test/helpers/test_all.rb (modified) (3 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
trunk/app/controllers/application.rb
r479 r481 365 365 366 366 # Path for the node (as string). Options can be :format and :mode. 367 def zen_path(obj, opts={}) 368 opts = {:format => params[:format], :prefix => prefix}.merge(opts) 369 opts[:format] = 'html' if opts[:format].nil? || opts[:format] == '' 370 if obj[:id] == visitor.site[:root_id] && opts[:mode].nil? 371 "/#{opts[:prefix]}" # index page 367 def zen_path(obj, options={}) 368 opts = options.dup 369 format = opts.delete(:format) || 'html' 370 pre = opts.delete(:prefix) || prefix 371 mode = opts.delete(:mode) 372 format = 'html' if format.nil? || format == '' 373 374 params = (opts == {}) ? '' : ('?' + opts.map{ |k,v| "#{k}=#{v}"}.join('&')) 375 376 if obj[:id] == visitor.site[:root_id] && mode.nil? 377 "/#{pre}" # index page 372 378 elsif obj[:custom_base] 373 "/#{ opts[:prefix]}/" +379 "/#{pre}/" + 374 380 obj.basepath + 375 ( opts[:mode] ? "_#{opts[:mode]}" : '') +376 ".#{ opts[:format]}"377 else 378 "/#{ opts[:prefix]}/" +381 (mode ? "_#{mode}" : '') + 382 ".#{format}" 383 else 384 "/#{pre}/" + 379 385 (obj.basepath != '' ? "#{obj.basepath}/" : '') + 380 386 (obj.class.to_s.downcase ) + 381 387 (obj[:zip].to_s ) + 382 ( opts[:mode] ? "_#{opts[:mode]}" : '') +383 ".#{ opts[:format]}"384 end 388 (mode ? "_#{mode}" : '') + 389 ".#{format}" 390 end + params 385 391 end 386 392 trunk/app/helpers/application_helper.rb
r479 r481 544 544 end 545 545 if opts[:link] 546 title = link_to(title, zen_path(obj))546 title = "<a href='#{zen_path(obj)}'>#{title}</a>" 547 547 end 548 548 "<span id='v_title#{obj.zip}.#{obj.v_number}'>#{title + check_lang(obj)}</span>" … … 691 691 res = [] 692 692 if (action == :edit or action == :all) && node.can_edit? 693 res << "<a href='#' title='#{transb('btn_title_edit')}' onclick=\"editor=window.open('" + 694 edit_version_url(hash) + 695 "', '_blank', 'location=0,width=300,height=400,resizable=1');return false;\">" + 693 res << "<a href='#{edit_version_url(hash)}' target='_blank' title='#{transb('btn_title_edit')}' onclick=\"editor=window.open('#{edit_version_url(hash)}', '_blank', 'location=0,width=300,height=400,resizable=1');return false;\">" + 696 694 (text || transb('btn_edit')) + "</a>" 697 695 end trunk/app/models/node.rb
r479 r481 24 24 +-- Note (date related information, event) 25 25 | | 26 | +--- Post 26 | +--- Post (blog entry) 27 27 | | 28 28 | +--- Task trunk/app/models/note.rb
r380 r481 40 40 def select_classes 41 41 list = subclasses.inject([]) do |list, k| 42 next if k.to_s == 'Post' 42 43 list << k.to_s 43 44 list 44 45 end.sort 45 list.unshift ' Note'46 list.unshift 'Post' 46 47 end 47 48 end trunk/app/models/version.rb
r476 r481 44 44 def user_zip 45 45 user_id 46 end 47 48 def zip 49 "#{node.zip}.#{number}" 46 50 end 47 51 trunk/lib/multiversion.rb
r474 r481 68 68 # return an array of published versions 69 69 def traductions(opts={}) 70 trad = editions.map do |t| 70 if opts == {} 71 trad = editions 72 else 73 trad = editions.find(:all, opts) 74 end 75 trad.map! do |t| 71 76 t.node = self # make sure relation is kept and we do not reload a node that is not secured 72 77 t trunk/lib/parser/lib/parser.rb
r480 r481 107 107 108 108 def replace_with(obj) 109 @method = 'void' # (replacer's method is always 'with') 109 110 @blocks = obj.blocks || @blocks 110 111 @params = obj.params || @params 111 112 end 112 113 114 def empty? 115 @blocks == [] && (@params == {} || @params == {:part => @params[:part]}) 116 end 117 113 118 def render(context={}) 114 119 return '' if context["no_#{@method}".to_sym] 120 @context = context 115 121 return '' unless before_render 116 @context = context117 # name param is propagated into children (used to label parts of a large template)118 if @params && (name = @params.delete(:name))119 if @context[:name]120 @context[:name] += "/#{name}"121 else122 @context[:name] = name123 end124 if replacer = (@context[:parts] || {})[@context[:name]]125 replace_with(replacer)126 return "" unless replace_with(replacer)127 end128 end129 122 @result = "" 130 123 @pass = {} # used to pass information to the parent … … 192 185 193 186 def before_render 187 # name param is propagated into children (used to label parts of a large template) 188 if @params && (name = @params.delete(:name)) 189 if @context[:name] 190 @context[:name] += "/#{name}" 191 else 192 @context[:name] = name 193 end 194 if replacer = (@context[:parts] || {})[@context[:name]] 195 return false if replacer.empty? 196 replace_with(replacer) 197 end 198 end 194 199 true 195 200 end trunk/lib/parser/lib/rules/zafu.rb
r480 r481 6 6 7 7 def replace_with(obj) 8 return nil unless (@params && @params != {}) || (@blocks != []) # empty: do not render9 8 super 10 9 @html_tag = obj.html_tag || @html_tag … … 12 11 end 13 12 14 def render(context={}) 15 @context = context 13 def empty? 14 super && @html_tag_params == {} && @html_tag.nil? 15 end 16 17 def before_render 18 return unless super 16 19 @html_tag_done = false 17 20 unless @html_tag … … 26 29 end 27 30 end 31 true 32 end 33 34 def after_render(text) 28 35 render_html_tag(super) 29 36 end trunk/lib/parser/lib/rules/zena.rb
r480 r481 28 28 29 29 def before_render 30 return unless super 31 30 32 @var = nil # reset var counter 31 33 … … 47 49 @html_tag_params = @html_tag_params_bak 48 50 if @anchor 49 @anchor + text50 else 51 text51 render_html_tag(@anchor + super) 52 else 53 render_html_tag(super) 52 54 end 53 55 end … … 129 131 130 132 def r_anchor(obj=node) 131 "<a name='#{node_class.to_s.downcase}<%= #{obj} [:zip]%>'></a>"133 "<a name='#{node_class.to_s.downcase}<%= #{obj}.zip %>'></a>" 132 134 end 133 135 … … 305 307 end 306 308 text = get_text_for_erb 307 #if @context[:template_url]309 if @context[:template_url] 308 310 # ajax 309 311 "<%= link_to_remote(#{text || helper.trans('edit')}, :url => edit_node_path(#{node}[:zip]) + '?template_url=#{CGI.escape(@context[:template_url])}', :method => :get) %>" 310 #else311 # FIXME 312 # "<%= link_to(#{text || helper.trans('edit')}, :controller=>'zafu', :action=>'edit', :id=>#{node}[:id], :template_url=>#{@context[:template_url].inspect}) %>"313 #end312 else 313 # FIXME: we could link to some html page to edit the item. 314 "" 315 end 314 316 end 315 317 … … 561 563 # be carefull, this gives a list of 'versions', not 'nodes' 562 564 def r_traductions 563 out "<% if #{list_var} = #{node}.traductions -%>" 565 if @params[:except] 566 case @params[:except] 567 when 'current' 568 opts = "(:conditions=>\"lang != '#{helper.lang}'\")" 569 else 570 # list of lang 571 # TODO: test 572 langs = @params[:except].split(',').map{|l| l.gsub(/[^a-z]/,'').strip } 573 opts = "(:conditions=>\"lang NOT IN ('#{langs.join("','")}')\")" 574 end 575 elsif @params[:only] 576 # TODO: test 577 case @params[:only] 578 when 'current' 579 opts = "(:conditions=>\"lang = '#{helper.lang}'\")" 580 else 581 # list of lang 582 # TODO: test 583 langs = @params[:only].split(',').map{|l| l.gsub(/[^a-z]/,'').strip } 584 opts = "(:conditions=>\"lang IN ('#{langs.join("','")}')\")" 585 end 586 else 587 opts = "" 588 end 589 out "<% if #{list_var} = #{node}.traductions#{opts} -%>" 564 590 out expand_with(:list=>list_var, :node_class=>:Version) 565 591 out "<% end -%>" … … 588 614 do_var("visitor.contact") 589 615 elsif select =~ /^\d+$/ 590 do_var("secure(Node) { Node.find_by_ id(#{select.inspect})} rescue nil")616 do_var("secure(Node) { Node.find_by_zip(#{select.inspect})} rescue nil") 591 617 else 592 618 select = select[1..-1] if select[0..0] == '/' … … 686 712 if node_class == :Version 687 713 lnode = "#{node}.node" 688 url = ", : url=>{:lang=>#{node}[:lang]}"714 url = ", :lang=>#{node}.lang" 689 715 else 690 716 lnode = node … … 706 732 end 707 733 if @params[:dash] == 'true' 708 dash = ", :dash=>\"#{node_class.to_s.downcase}\#{#{node} [:zip]}\""734 dash = ", :dash=>\"#{node_class.to_s.downcase}\#{#{node}.zip}\"" 709 735 else 710 736 dash = '' … … 994 1020 "#{node}.class == #{klass}" 995 1021 elsif status = @params[:status] 996 "#{node}.version [:status]== #{Zena::Status[status.to_sym]}"1022 "#{node}.version.status == #{Zena::Status[status.to_sym]}" 997 1023 elsif lang = @params[:lang] 998 "#{node}.version [:lang]== #{lang.inspect}"1024 "#{node}.version.lang == #{lang.inspect}" 999 1025 elsif test = @params[:test] 1000 1026 value1, op, value2 = test.split(/\s+/) … … 1050 1076 1051 1077 # TODO: test 1052 # TODO: SECURITY is there a risk here ? 1078 # TODO: SECURITY is there a risk here ? We need to use the 'method' syntax instead of the [:attribute] syntax 1079 # because of how some custom methods implement 'initials' for example. 1053 1080 def node_attribute(attribute) 1054 attribute = attribute.gsub( 'id', 'zip') if node_kind_of?(Node)1081 attribute = attribute.gsub(/(^|_)id|id$/, '\1zip') if node_kind_of?(Node) 1055 1082 case attribute[0..1] 1056 1083 when 'v_' trunk/lib/parser/test/parser_test.rb
r468 r481 1 1 require File.join(File.dirname(__FILE__) , 'testhelp.rb') 2 #require 'ruby-debug' 3 #Debugger.start 4 2 5 module Zafu 3 6 module Tags … … 33 36 testfile :zafu, :zafu_asset, :zafu_insight, :zazen 34 37 def test_single 35 do_test('zafu _asset', 'change_stylesheet')38 do_test('zafu', 'include_empty') 36 39 end 37 40 trunk/lib/parser/test/zafu.yml
r463 r481 221 221 res: "include_with: title: <h1>hello world!</h1>" 222 222 223 include_empty: 224 src: "include_empty: <z:include template='/name/title'><z:with part='title'/></z:include>" 225 res: "include_empty: title: " 226 223 227 preserve_newlines: 224 228 src: | trunk/test/helpers/basic.yml
r475 r481 50 50 lang: 'fr' 51 51 src: "<z:trans><z:show attr='ref_lang'/></z:trans>" 52 tem: "<%= trans(@node [:ref_lang]) %>"52 tem: "<%= trans(@node.ref_lang) %>" 53 53 res: "anglais" 54 54 … … 57 57 lang: 'en' 58 58 src: "<z:trans attr='ref_lang'/>" 59 tem: "<%= trans(@node [:ref_lang]) %>"59 tem: "<%= trans(@node.ref_lang) %>" 60 60 res: "english" 61 61 62 62 show_tattr: 63 63 src: "<z:show tattr='ref_lang'/>" 64 tem: "<%= trans(@node [:ref_lang]) %>"64 tem: "<%= trans(@node.ref_lang) %>" 65 65 res: "english" 66 66 … … 68 68 src: "<z:link/>" 69 69 tem: "<%= node_link(:node=>@node) %>" 70 res: "<a href= \"/oo/projects/cleanWater/page12.html\">status title</a>"70 res: "<a href='/oo/projects/cleanWater/page22.html'>status title</a>" 71 71 72 72 zafu_link: 73 73 src: "<li do='link'/>" 74 res: "<li><a href= \"/oo/projects/cleanWater/page12.html\">status title</a></li>"74 res: "<li><a href='/oo/projects/cleanWater/page22.html'>status title</a></li>" 75 75 76 76 link_attr: 77 77 src: "<z:link attr='ref_lang'/>" 78 tem: "<%= node_link(:node=>@node, :text=>@node [:ref_lang]) %>"79 res: "<a href= \"/oo/projects/cleanWater/page12.html\">en</a>"78 tem: "<%= node_link(:node=>@node, :text=>@node.ref_lang) %>" 79 res: "<a href='/oo/projects/cleanWater/page22.html'>en</a>" 80 80 81 81 link_tattr: 82 82 src: "<z:link tattr='ref_lang'/>" 83 tem: "<%= node_link(:node=>@node, :text=>trans(@node [:ref_lang])) %>"84 res: "<a href= \"/oo/projects/cleanWater/page12.html\">english</a>"83 tem: "<%= node_link(:node=>@node, :text=>trans(@node.ref_lang)) %>" 84 res: "<a href='/oo/projects/cleanWater/page22.html'>english</a>" 85 85 86 86 link_trans: … … 89 89 src: "<z:link trans='Monday'/>" 90 90 tem: "<%= node_link(:node=>@node, :text=>\"lundi\") %>" 91 res: "<a href= \"/oo/projects/cleanWater/page12.html\">lundi</a>"91 res: "<a href='/oo/projects/cleanWater/page22.html'>lundi</a>" 92 92 93 93 link_parent: 94 94 src: "<z:link href='parent' text='click here'/>" 95 95 tem: "<%= node_link(:node=>@node, :text=>\"click here\", :href=>\"parent\") %>" 96 res: "<a href=\"/oo/projects/cleanWater\">click here</a>" 97 96 res: "<a href='/oo/projects/cleanWater.html'>click here</a>" 97 98 link_with_block: 99 src: "<z:link href='parent'>click here</z:link>" 100 tem: "<%= node_link(:node=>@node, :text=>\"click here\", :href=>\"parent\") %>" 101 res: "<a href='/oo/projects/cleanWater.html'>click here</a>" 102 98 103 link_project: 99 104 context: … … 101 106 src: "<z:link href='project'/>" 102 107 tem: "<%= node_link(:node=>@node, :href=>\"project\") %>" 103 res: "<a href= \"/oo/project19.html\">a wiki with zena</a>"108 res: "<a href='/oo/project29.html'>a wiki with zena</a>" 104 109 105 110 link_root: 106 111 src: "<z:link href='root'/>" 107 112 tem: "<%= node_link(:node=>@node, :href=>\"root\") %>" 108 res: "<a href= \"/oo\">Zena the wild CMS</a>"113 res: "<a href='/oo'>Zena the wild CMS</a>" 109 114 110 115 link_dash: 111 116 src: "<z:link dash='true'/>" 112 res: "<a href='#node 12'>status title</a>"117 res: "<a href='#node22'>status title</a>" 113 118 114 119 anchor: 115 120 src: "<z:anchor/>" 116 res: "<a name='node 12'></a>"121 res: "<a name='node22'></a>" 117 122 118 123 show_title_anchor: 119 124 src: "<z:title anchor='true'/>" 120 res: "<a name='node 12'></a><span id='v_title12'>status title</span>"125 res: "<a name='node22'></a><span id='v_title22.1'>status title</span>" 121 126 122 127 show_attr_anchor: 123 128 src: "<z:show attr='name' anchor='true'/>" 124 res: "<a name='node 12'></a>status"129 res: "<a name='node22'></a>status" 125 130 126 131 link_version: … … 128 133 node: 'opening' 129 134 src: "<z:traductions><z:each join=', '><z:link tattr='lang' /></z:each></z:traductions>" 130 res: "<a href= \"/oo/projects/cleanWater/note17.html?lang=fr\">french</a>"135 res: "<a href='/oo/projects/cleanWater/post27.html?lang=en'>english</a>, <a href='/oo/projects/cleanWater/post27.html?lang=fr'>french</a>" 131 136 132 137 link_version_anchor_dash: … … 134 139 node: 'opening' 135 140 src: "<z:traductions><z:each join=', '><z:link tattr='lang' dash='true' anchor='true'/></z:each></z:traductions>" 136 res: "<a name='version 17'></a><a href='#version17'>french</a>"141 res: "<a name='version27.2'></a><a href='#version27.2'>english</a>, <a name='version27.1'></a><a href='#version27.1'>french</a>" 137 142 138 143 title: 139 144 src: "<h2 do='title'>super titre</h2>" 140 tem: "<h2><%= show_title(:node=>@node , :link=>false, :project=>false)%></h2>"141 res: "<h2><span id='v_title 12'>status title</span></h2>"145 tem: "<h2><%= show_title(:node=>@node)%></h2>" 146 res: "<h2><span id='v_title22.1'>status title</span></h2>" 142 147 143 148 show_parent_title: 144 149 src: "<z:parent><h1 do='title'>parent title</h1></z:parent>" 145 tem: "<% if var1 = @node.relation(\"parent\") -%><h1><%= show_title(:node=>var1 , :link=>false, :project=>false)%></h1><% end -%>"146 res: "<h1><span id='v_title 11'>Clean Water project</span></h1>"150 tem: "<% if var1 = @node.relation(\"parent\") -%><h1><%= show_title(:node=>var1)%></h1><% end -%>" 151 res: "<h1><span id='v_title21.1'><a href='/oo/projects/cleanWater.html'>zena / Clean Water project</a></span></h1>" 147 152 148 153 show_bad_attr: … … 160 165 show_title_options: 161 166 src: "<h1 class='title' do='title' status='true' actions='all'>dummy</h1>" 162 tem: "<h1 class='title'><div class='s<%= @node.version.status %>'><%= show_title(:node=>@node , :link=>false, :project=>false) + node_actions(:node=>@node, :actions=>\"all\")%></div></h1>"163 res: "/<h1 class='title'><div class='s50'><span id='v_title 12'>status title</span><span class='actions'><a.*\/z\/version\/edit\/12.*\/images\/page_edit.png'.*/><\/a>.*<\/span><\/div><\/h1>/"167 tem: "<h1 class='title'><div class='s<%= @node.version.status %>'><%= show_title(:node=>@node) + node_actions(:node=>@node, :actions=>\"all\")%></div></h1>" 168 res: "/<h1 class='title'><div class='s50'><span id='v_title22.1'>status title</span><span class='actions'><a.*\/nodes\/22\/versions\/1\/edit.*\/images\/page_edit.png'.*/><\/a>.*<\/span><\/div><\/h1>/" 164 169 165 170 show_c_width: … … 185 190 src: "<div id='path' do='show_path'><ul><li><a href='#'>first</a></li> / <li><a href='#'>second</a></li> / <li><a href='#' class='current'>here</a></li></ul></div>" 186 191 tem: "<div id='path'><%= show_path(:node=>@node) %></div>" 187 res: "/<div id='path'><ul class='path'><li>.*zena.*<li>.*oo\/page 8.html.*<li><.*\/projects\/cleanWater.*cleanWater<\/a>.*\/oo\/projects\/cleanWater\/page12.html.*class='current'>status<\/a>/"192 res: "/<div id='path'><ul class='path'><li>.*zena.*<li>.*oo\/page18.html.*<li><.*\/projects\/cleanWater.*cleanWater<\/a>.*\/oo\/projects\/cleanWater\/page22.html.*class='current'>status<\/a>/" 188 193 189 194 uses_calendar: … … 217 222 218 223 each_traductions: 219 src: "<z:traductions ><ul><li do='each'><z:show attr='title'/></li></ul></z:traductions>"220 tem: "<% if list1 = @node.traductions -%><ul><% list1.each do |var1| -%><li><%= var1[:title]%></li><% end -%></ul><% end -%>"224 src: "<z:traductions except='current'><ul><li do='each'><z:show attr='title'/></li></ul></z:traductions>" 225 tem: "<% if list1 = @node.traductions(:conditions=>\"lang != 'en'\") -%><ul><% list1.each do |var1| -%><li><%= var1.title %></li><% end -%></ul><% end -%>" 221 226 res: "<ul><li>Etat des travaux</li></ul>" 227 228 each_traductions_except_list: 229 src: "<z:traductions except='en,ru'><ul><li do='each'><z:show attr='title'/></li></ul></z:traductions>" 230 res: "<ul><li>Etat des travaux</li></ul>" 231 232 each_traductions_only_list: 233 src: "<z:traductions only='en,ru'><ul><li do='each'><z:show attr='title'/></li></ul></z:traductions>" 234 res: "<ul><li>status title</li></ul>" 222 235 223 236 case_when: 224 237 src: "<z:case><z:when kind_of='Document'>this is a document</z:when><z:when klass='Page'>Page</z:when><z:when status='pub'>Pub</z:when>" 225 tem: "<% if false -%><% elsif @node.kind_of?(Document) -%>this is a document<% elsif @node.class == Page -%>Page<% elsif @node.version [:status]== 50 -%>Pub<% end -%>"238 tem: "<% if false -%><% elsif @node.kind_of?(Document) -%>this is a document<% elsif @node.class == Page -%>Page<% elsif @node.version.status == 50 -%>Pub<% end -%>" 226 239 res: "Page" 227 240 … … 240 253 case_ancestor: 241 254 src: "<z:root><z:pages><z:each join=', '><z:case><z:when node='ancestor'><b><z:show attr='name'/></b></z:when><z:else><z:show attr='name'/></z:else></z:case></z:each></z:pages></z:root>" 242 res: "collections, nature, people, <b>projects</b> "255 res: "collections, nature, people, <b>projects</b>, skins" 243 256 244 257 simple_each: 245 258 src: "<z:children><z:each><z:show attr='name'/></z:each></z:children>" 246 tem: "/.*if \(list1.*each.*var1\[:name\]/"259 tem: "/.*if list1.*each.*var1.name/" 247 260 res: "" 248 261 … … 255 268 edit_not_each: 256 269 src: "<li class='blah'>this is a post <z:edit>edit post</z:edit></li>" 257 tem: "/<li class='blah'>this is a post < %= link_to\(\"edit post\".*\) %><\/li>/"270 tem: "/<li class='blah'>this is a post <\/li>/" 258 271 259 272 edit_each_no_form: 260 273 src: "<z:each><li>blah <z:edit>do this and that</z:edit></li>" 261 tem: "/<li>blah < %= link_to\(\"do this and that\".* %></li>"274 tem: "/<li>blah </li>" 262 275 263 276 each_add_with_form: … … 271 284 node: 'wiki' 272 285 src: "<z:children><z:each><li><z:show attr='name'>blah</z:show> <z:edit>edit</z:edit></li>\n</z:each><z:form><li><form>this is the form</form></li></z:form></z:children>" 273 res: "/<li id='_each_edit_with_root_Node20'>bird <a href= \"#\"onclick=\"new Ajax.Request\('\/z\/zafu\/ajax_edit\/20\?template_url=%2Feach%2Fedit%2Fwith%2Froot_Node'.*flower <a href=\"#\" onclick=\"new Ajax.Request\('\/z\/zafu\/ajax_edit\/21\?template_url=%2Feach%2Fedit%2Fwith%2Froot_Node.*edit</a></li>\n/"286 res: "/<li id='_each_edit_with_root_Node20'>bird <a href='#' onclick=\"new Ajax.Request\('\/z\/zafu\/ajax_edit\/20\?template_url=%2Feach%2Fedit%2Fwith%2Froot_Node'.*flower <a href=\"#\" onclick=\"new Ajax.Request\('\/z\/zafu\/ajax_edit\/21\?template_url=%2Feach%2Fedit%2Fwith%2Froot_Node.*edit</a></li>\n/" 274 287 275 288 set_attribute: 276 289 src: "<div class='machin' do='void' set_class='node[id]'/><z:void set_class='s[v_status]i[id]'/>" 277 res: "<div class='node 12'/><div class='s50i12'/>"290 res: "<div class='node22'/><div class='s50i22'/>" 278 291 279 292 set_attribute_with_inner: 280 293 src: "<p set_id='node[id]' do='show' attr='name' set_class='s[v_status]'>some blah blah</p>" 281 res: "<p class='s50' id='node 12'>status</p>"294 res: "<p class='s50' id='node22'>status</p>" 282 295 283 296 set_in_ztag: 284 297 src: "<z:show attr='name' set_id='node[id]'/>" 285 res: "<div id='node 12'>status</div>"298 res: "<div id='node22'>status</div>" 286 299 287 300 each_join_html: … … 299 312 img_no_image: 300 313 src: "<z:img/>" 301 tem: "<%= @node.img_tag(\"std\") rescue ''%>"314 tem: "<%= img_tag(@node, :mode=>\"std\") %>" 302 315 res: "" 303 316 … … 305 318 context: 306 319 node: 'bird_jpg' 307 src: "<z:img/><z:img format='med'/>"308 res: "<img src='/ data/jpg/20/bird-std.jpg' width='440' height='400' alt='bird' class='std'/><img src='/data/jpg/20/bird-med.jpg' width='205' height='186' alt='bird' class='med'/>"320 src: "<z:img/><z:img mode='med'/>" 321 res: "<img src='/oo/image30_std.jpg' width='440' height='400' alt='bird' class='std'/><img src='/oo/image30_med.jpg' width='205' height='186' alt='bird' class='med'/>" 309 322 310 323 img_href: … … 312 325 node: 'bird_jpg' 313 326 src: "<z:img href='self'/>" 314 res: "<a href= \"/oo/image20.html\"><img src='/data/jpg/20/bird-std.jpg' width='440' height='400' alt='bird' class='std'/></a>"327 res: "<a href='/oo/image30.html'><img src='/oo/image30_std.jpg' width='440' height='400' alt='bird' class='std'/></a>" 315 328 316 329 img_src_id: 317 330 src: "<z:img src='20'/>" 318 res: "<img src='/ data/jpg/20/bird-std.jpg' width='440' height='400' alt='bird' class='std'/>"331 res: "<img src='/oo/image30_std.jpg' width='440' height='400' alt='bird' class='std'/>" 319 332 320 333 test_children_plural: … … 332 345 node: 'wiki' 333 346 src: "<z:parent do='link'/>" 334 res: "<a href= \"/oo/page8.html\">projects list</a>"347 res: "<a href='/oo/page18.html'>projects list</a>" 335 348 336 349 do_each: … … 338 351 node: 'wiki' 339 352 src: "<z:children do='each'><z:link/></z:children>" 340 res: "<a href= \"/oo/image20.html\">bird</a><a href=\"/oo/image21.html\">flower</a>"353 res: "<a href='/oo/image20.html'>bird</a><a href='/oo/image31.html'>flower</a>" 341 354 342 355 do_with_inner: … … 350 363 node: 'wiki' 351 364 src: "<ul do='children' do='each' tag='li' do='link'/>" 352 res: "<ul><li><a href= \"/oo/image20.html\">bird</a></li><li><a href=\"/oo/image21.html\">flower</a></li></ul>"365 res: "<ul><li><a href='/oo/image30.html'>bird</a></li><li><a href='/oo/image31.html'>flower</a></li></ul>" 353 366 354 367 ignore: … … 368 381 include_with: 369 382 src: "include_with: <z:include template='/name/title'><h1 do='with' part='title' do='show' attr='id'/>" 370 res: "include_with: title: <h1> 12</h1>"383 res: "include_with: title: <h1>22</h1>" 371 384 372 385 comments: … … 392 405 393 406 <ul do='tags'> 394 <li do='each' do='link' >art</li>407 <li do='each' do='link' attr='v_title'>art</li> 395 408 <li do='ignore'>life</li> 396 409 <li do='ignore'>ruby</li> … … 405 418 406 419 <ul> 407 <li><a href= "/oo/tag23.html">Art</a></li>408 <li><a href= "/oo/tag24.html">News list</a></li>420 <li><a href='/oo/tag33.html'>Art</a></li> 421 <li><a href='/oo/tag34.html'>News list</a></li> 409 422 </ul> 410 423 … … 416 429 empty_param: 417 430 src: "<z:summary text=''/>" 418 res: "<div id='v_summary 11.1' class='zazen'></div>"431 res: "<div id='v_summary22.1' class='zazen'></div>" trunk/test/helpers/relations.yml
r455 r481 37 37 node: 'cleanWater' 38 38 src: "<z:pages><z:each join=', '><z:show attr='name'/></z:each></z:pages>" 39 res: " lake,status, track"39 res: "status, track" 40 40 41 41 notes: … … 56 56 src: "<z:pages limit='3' order='random'><z:each join=', '><z:show attr='name'/></z:each></z:pages>" 57 57 58 pages_from_project:59 src: "<z: pages from='project' limit='2'><z:each join=', '><z:show attr='name'/></z:each></z:pages>"60 res: " cleanWater, lake"58 nodes_from_project: 59 src: "<z:nodes from='project' limit='2'><z:each join=', '><z:show attr='name'/></z:each></z:nodes>" 60 res: "lake, lakeAddress" 61 61 62 pages_from_site:63 src: "<z: pages from='site' limit='2'><z:each join=', '><z:show attr='name'/></z:each></z:pages>"64 res: "an t, art"62 nodes_from_site: 63 src: "<z:nodes from='site' limit='3'><z:each join=', '><z:show attr='name'/></z:each></z:nodes>" 64 res: "anonymous, ant, art" 65 65 66 66 store_context: … … 68 68 node: 'projects' 69 69 src: "<z:children store='project' limit='1'><z:each><z:pages from='site' project='stored' limit='5'><z:each join=', '><z:show attr='name'/></z:each></z:pages></z:each></z:children>" 70 res: "a nt, art, collections, lion, menu"70 res: "art, cleanWater, collections, default, menu" 71 71 72 72 store_node: 73 73 src: "<z:void store='node'><z:parent><z:show attr='name'/>: <z:node select='stored'><z:show attr='name'/></z:node> + <z:node select='main' do='show' attr='id'/></z:parent></z:void>" 74 res: "cleanWater: status + 12"74 res: "cleanWater: status + 22" 75 75 76 76 author_visitor: 77 77 src: "<z:pages from='site' author='visitor' limit='5'><z:each join=', ' do='show' attr='name'/></z:pages>" 78 res: " ant, lake,myLife, nature, status"78 res: "myLife, nature, status" 79 79 80 80 node_id: 81 src: "I (<z:show attr='name'/>) know: <z:node select=' 2'><z:show attr='name'/> with <z:children><span do='each' join=', '><z:show attr='name'>child</z:show></span></z:children></z:node>"82 res: "I (status) know: people with <span>an t</span>, <span>lion</span>, <span>tiger</span>"81 src: "I (<z:show attr='name'/>) know: <z:node select='12'><z:show attr='name'/> with <z:children><span do='each' join=', '><z:show attr='name'>child</z:show></span></z:children></z:node>" 82 res: "I (status) know: people with <span>anonymous</span>, <span>ant</span>, <span>lion</span>, <span>tiger</span>" 83 83 84 84 node_path: 85 85 src: "<z:node select='/projects/wiki'><z:link/></z:node>" 86 res: "<a href= \"/oo/project19.html\">a wiki with zena</a>"86 res: "<a href='/oo/project29.html'>a wiki with zena</a>" 87 87 88 88 node_root: … … 168 168 node: 'zena' 169 169 src: "<ul do='news' from='site' limit='5' order='updated_at DESC'><li do='each'><z:link/></li></ul>" 170 res: "<ul><li><a href= \"/oo/projects/cleanWater/note17.html\">parc opening</a></li></ul>"170 res: "<ul><li><a href='/oo/projects/cleanWater/post27.html'>parc opening</a></li></ul>" 171 171 172 172 relation_not_in_current_node: 173 173 src: "<ul do='news' from='site' limit='5' order='updated_at DESC'><li do='each'><z:link/></li></ul>" 174 res: "<ul><li><a href= \"/oo/projects/cleanWater/note17.html\">parc opening</a></li></ul>"174 res: "<ul><li><a href='/oo/projects/cleanWater/post27.html'>parc opening</a></li></ul>" 175 175 176 176 pages_anchor: 177 src: "<z:p roject><z:pages do='each' join=', '><z:show attr='name' anchor='true'/></z:pages></z:project>"178 res: "<a name='node 13'></a>lake, <a name='node12'></a>status, <a name='node27'></a>track"177 src: "<z:pages from='site' limit='3' do='each' join=', '><z:show attr='name' anchor='true'/></z:pages>" 178 res: "<a name='node33'></a>art, <a name='node21'></a>cleanWater, <a name='node32'></a>collections" 179 179 180 180 projects_from_site: … … 183 183 184 184 projects: 185 src: "<z:projects ><z:each join=', ' do='show' attr='name'/></z:projects>"186 res: "cleanWater "185 src: "<z:projects from='site'><z:each join=', ' do='show' attr='name'/></z:projects>" 186 res: "cleanWater, wiki, zena" 187 187 188 188 nodes: 189 189 src: "<z:nodes from='project'><z:each join=', ' do='show' attr='name'/></z:nodes>" 190 res: " cleanWater"190 res: "lake, lakeAddress, opening, status, water" 191 191 192 192 menu_with_favorites: 193 193 src: "<ul><z:root do='pages' only='public' cache='true' name='menu'><li do='each'><z:link/><ul do='pages'><li do='each' do='link'/></ul></li></z:root><z:node select='visitor' do='favorites'><li class='favorites'><z:trans>favorites</z:trans><ul><li do='each' do='link'/></ul></li></ul>" 194 res: "/.*tag 23.*tag25.*Clean Water.*favorites.*Nature/"194 res: "/.*tag33.*tag35.*Clean Water.*favorites.*Nature/" 195 195 196 196 visitor_favorites: 197 197 src: "<z:node select='visitor'><ul do='favorites'><li do='each' do='link'/></ul></z:node>" 198 res: "<ul><li><a href= \"/oo/page29.html\">Nature</a></li></ul>"198 res: "<ul><li><a href='/oo/page39.html'>Nature</a></li></ul>" trunk/test/helpers/test_all.rb
r474 r481 1 1 require File.join(File.dirname(__FILE__), 'testhelp') 2 3 require 'ruby-debug' 4 Debugger.start 2 5 3 6 class HelperTest … … 6 9 7 10 def test_single 8 do_test('basic', ' yield')11 do_test('basic', 'tada') 9 12 end 10 13 … … 43 46 end 44 47 45 # test rename asset (has to be called wiki to find the proper skin)46 def test_basic_wiki47 Node.connection.execute "UPDATE nodes SET parent_id = 33 WHERE id = 20;" # status, art48 do_test('basic', 'wiki')49 end50 51 48 def test_relations_updated_today 52 49 Node.connection.execute "UPDATE nodes SET updated_at = now() WHERE id IN (12, 23);" # status, art 53 do_test('relations', ' node_id')50 do_test('relations', 'updated_today') 54 51 end 55 52
