Changeset 481

Show
Ignore:
Timestamp:
2007-05-05 22:07:30 (2 years ago)
Author:
gaspard
Message:

[test] tested zafu and zena parser (not all tests pass)

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/app/controllers/application.rb

    r479 r481  
    365365   
    366366    # 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 
    372378      elsif obj[:custom_base] 
    373         "/#{opts[:prefix]}/" + 
     379        "/#{pre}/" + 
    374380        obj.basepath + 
    375         (opts[:mode]    ? "_#{opts[:mode]}" : '') + 
    376         ".#{opts[:format]}" 
    377       else 
    378         "/#{opts[:prefix]}/" + 
     381        (mode         ? "_#{mode}" : '') + 
     382        ".#{format}" 
     383      else 
     384        "/#{pre}/" + 
    379385        (obj.basepath != '' ? "#{obj.basepath}/"    : '') + 
    380386        (obj.class.to_s.downcase               ) + 
    381387        (obj[:zip].to_s                        ) + 
    382         (opts[:mode]    ? "_#{opts[:mode]}" : '') + 
    383         ".#{opts[:format]}" 
    384       end 
     388        (mode          ? "_#{mode}" : '') + 
     389        ".#{format}" 
     390      end + params 
    385391    end 
    386392   
  • trunk/app/helpers/application_helper.rb

    r479 r481  
    544544    end 
    545545    if opts[:link] 
    546       title = link_to(title, zen_path(obj)) 
     546      title = "<a href='#{zen_path(obj)}'>#{title}</a>" 
    547547    end 
    548548    "<span id='v_title#{obj.zip}.#{obj.v_number}'>#{title + check_lang(obj)}</span>" 
     
    691691    res  = [] 
    692692    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;\">" +  
    696694             (text || transb('btn_edit')) + "</a>" 
    697695    end 
  • trunk/app/models/node.rb

    r479 r481  
    2424  +-- Note (date related information, event) 
    2525  |     | 
    26   |     +--- Post 
     26  |     +--- Post (blog entry) 
    2727  |     | 
    2828  |     +--- Task 
  • trunk/app/models/note.rb

    r380 r481  
    4040    def select_classes 
    4141      list = subclasses.inject([]) do |list, k| 
     42        next if k.to_s == 'Post' 
    4243        list << k.to_s 
    4344        list 
    4445      end.sort 
    45       list.unshift 'Note
     46      list.unshift 'Post
    4647    end 
    4748  end 
  • trunk/app/models/version.rb

    r476 r481  
    4444  def user_zip 
    4545    user_id 
     46  end 
     47   
     48  def zip 
     49    "#{node.zip}.#{number}" 
    4650  end 
    4751   
  • trunk/lib/multiversion.rb

    r474 r481  
    6868        # return an array of published versions 
    6969        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| 
    7176            t.node = self # make sure relation is kept and we do not reload a node that is not secured 
    7277            t 
  • trunk/lib/parser/lib/parser.rb

    r480 r481  
    107107   
    108108  def replace_with(obj) 
     109    @method   = 'void' # (replacer's method is always 'with') 
    109110    @blocks   = obj.blocks || @blocks 
    110111    @params   = obj.params || @params 
    111112  end 
    112113   
     114  def empty? 
     115    @blocks == [] && (@params == {} || @params == {:part => @params[:part]}) 
     116  end 
     117   
    113118  def render(context={}) 
    114119    return '' if context["no_#{@method}".to_sym] 
     120    @context = context 
    115121    return '' unless before_render 
    116     @context = context 
    117     # 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       else 
    122         @context[:name] = name 
    123       end 
    124       if replacer = (@context[:parts] || {})[@context[:name]] 
    125         replace_with(replacer) 
    126         return "" unless replace_with(replacer) 
    127       end 
    128     end 
    129122    @result  = "" 
    130123    @pass    = {} # used to pass information to the parent 
     
    192185   
    193186  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 
    194199    true 
    195200  end 
  • trunk/lib/parser/lib/rules/zafu.rb

    r480 r481  
    66     
    77    def replace_with(obj) 
    8       return nil unless (@params && @params != {}) || (@blocks != []) # empty: do not render  
    98      super 
    109      @html_tag          = obj.html_tag        || @html_tag 
     
    1211    end 
    1312     
    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 
    1619      @html_tag_done = false 
    1720      unless @html_tag 
     
    2629        end 
    2730      end 
     31      true 
     32    end 
     33     
     34    def after_render(text) 
    2835      render_html_tag(super) 
    2936    end 
  • trunk/lib/parser/lib/rules/zena.rb

    r480 r481  
    2828 
    2929    def before_render 
     30      return unless super 
     31       
    3032      @var = nil # reset var counter 
    3133       
     
    4749      @html_tag_params = @html_tag_params_bak 
    4850      if @anchor 
    49         @anchor + text 
    50       else 
    51         text 
     51        render_html_tag(@anchor + super) 
     52      else 
     53        render_html_tag(super) 
    5254      end 
    5355    end 
     
    129131     
    130132    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>" 
    132134    end 
    133135     
     
    305307      end 
    306308      text = get_text_for_erb 
    307       #if @context[:template_url] 
     309      if @context[:template_url] 
    308310        # ajax 
    309311        "<%= link_to_remote(#{text || helper.trans('edit')}, :url => edit_node_path(#{node}[:zip]) + '?template_url=#{CGI.escape(@context[:template_url])}', :method => :get) %>" 
    310       #else 
    311         # FIXME 
    312       #  "<%= link_to(#{text || helper.trans('edit')}, :controller=>'zafu', :action=>'edit', :id=>#{node}[:id], :template_url=>#{@context[:template_url].inspect}) %>
    313       #end 
     312      else 
     313        # FIXME: we could link to some html page to edit the item. 
     314        "
     315      end 
    314316    end 
    315317     
     
    561563    # be carefull, this gives a list of 'versions', not 'nodes' 
    562564    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} -%>" 
    564590      out expand_with(:list=>list_var, :node_class=>:Version) 
    565591      out "<% end -%>" 
     
    588614        do_var("visitor.contact") 
    589615      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") 
    591617      else 
    592618        select = select[1..-1] if select[0..0] == '/' 
     
    686712      if node_class == :Version 
    687713        lnode = "#{node}.node" 
    688         url = ", :url=>{:lang=>#{node}[:lang]}
     714        url = ", :lang=>#{node}.lang
    689715      else 
    690716        lnode = node 
     
    706732      end 
    707733      if @params[:dash] == 'true' 
    708         dash = ", :dash=>\"#{node_class.to_s.downcase}\#{#{node}[:zip]}\"" 
     734        dash = ", :dash=>\"#{node_class.to_s.downcase}\#{#{node}.zip}\"" 
    709735      else 
    710736        dash = '' 
     
    9941020        "#{node}.class == #{klass}" 
    9951021      elsif status = @params[:status] 
    996         "#{node}.version[:status] == #{Zena::Status[status.to_sym]}" 
     1022        "#{node}.version.status == #{Zena::Status[status.to_sym]}" 
    9971023      elsif lang = @params[:lang] 
    998         "#{node}.version[:lang] == #{lang.inspect}" 
     1024        "#{node}.version.lang == #{lang.inspect}" 
    9991025      elsif test = @params[:test] 
    10001026        value1, op, value2 = test.split(/\s+/) 
     
    10501076     
    10511077    # 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. 
    10531080    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) 
    10551082      case attribute[0..1] 
    10561083      when 'v_' 
  • trunk/lib/parser/test/parser_test.rb

    r468 r481  
    11require File.join(File.dirname(__FILE__) , 'testhelp.rb') 
     2#require 'ruby-debug' 
     3#Debugger.start 
     4 
    25module Zafu 
    36  module Tags 
     
    3336  testfile :zafu, :zafu_asset, :zafu_insight, :zazen 
    3437  def test_single 
    35     do_test('zafu_asset', 'change_stylesheet') 
     38    do_test('zafu', 'include_empty') 
    3639  end 
    3740   
  • trunk/lib/parser/test/zafu.yml

    r463 r481  
    221221  res: "include_with: title: <h1>hello world!</h1>" 
    222222 
     223include_empty: 
     224  src: "include_empty: <z:include template='/name/title'><z:with part='title'/></z:include>" 
     225  res: "include_empty: title: " 
     226 
    223227preserve_newlines: 
    224228  src: | 
  • trunk/test/helpers/basic.yml

    r475 r481  
    5050    lang: 'fr' 
    5151  src: "<z:trans><z:show attr='ref_lang'/></z:trans>" 
    52   tem: "<%= trans(@node[:ref_lang]) %>" 
     52  tem: "<%= trans(@node.ref_lang) %>" 
    5353  res: "anglais" 
    5454 
     
    5757    lang: 'en' 
    5858  src: "<z:trans attr='ref_lang'/>" 
    59   tem: "<%= trans(@node[:ref_lang]) %>" 
     59  tem: "<%= trans(@node.ref_lang) %>" 
    6060  res: "english" 
    6161   
    6262show_tattr: 
    6363  src: "<z:show tattr='ref_lang'/>" 
    64   tem: "<%= trans(@node[:ref_lang]) %>" 
     64  tem: "<%= trans(@node.ref_lang) %>" 
    6565  res: "english" 
    6666 
     
    6868  src: "<z:link/>" 
    6969  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>" 
    7171 
    7272zafu_link: 
    7373  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>" 
    7575 
    7676link_attr: 
    7777  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>" 
    8080 
    8181link_tattr: 
    8282  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>" 
    8585 
    8686link_trans: 
     
    8989  src: "<z:link trans='Monday'/>" 
    9090  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>" 
    9292 
    9393link_parent: 
    9494  src: "<z:link href='parent' text='click here'/>" 
    9595  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 
     98link_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   
    98103link_project: 
    99104  context: 
     
    101106  src: "<z:link href='project'/>" 
    102107  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>" 
    104109 
    105110link_root: 
    106111  src: "<z:link href='root'/>" 
    107112  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>" 
    109114 
    110115link_dash: 
    111116  src: "<z:link dash='true'/>" 
    112   res: "<a href='#node12'>status title</a>" 
     117  res: "<a href='#node22'>status title</a>" 
    113118 
    114119anchor: 
    115120  src: "<z:anchor/>" 
    116   res: "<a name='node12'></a>" 
     121  res: "<a name='node22'></a>" 
    117122 
    118123show_title_anchor: 
    119124  src: "<z:title anchor='true'/>" 
    120   res: "<a name='node12'></a><span id='v_title12'>status title</span>" 
     125  res: "<a name='node22'></a><span id='v_title22.1'>status title</span>" 
    121126   
    122127show_attr_anchor: 
    123128  src: "<z:show attr='name' anchor='true'/>" 
    124   res: "<a name='node12'></a>status" 
     129  res: "<a name='node22'></a>status" 
    125130 
    126131link_version: 
     
    128133    node: 'opening' 
    129134  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>" 
    131136   
    132137link_version_anchor_dash: 
     
    134139    node: 'opening' 
    135140  src: "<z:traductions><z:each join=', '><z:link tattr='lang' dash='true' anchor='true'/></z:each></z:traductions>" 
    136   res: "<a name='version17'></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>" 
    137142   
    138143title: 
    139144  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_title12'>status title</span></h2>" 
     145  tem: "<h2><%= show_title(:node=>@node)%></h2>" 
     146  res: "<h2><span id='v_title22.1'>status title</span></h2>" 
    142147 
    143148show_parent_title: 
    144149  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_title11'>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>" 
    147152 
    148153show_bad_attr: 
     
    160165show_title_options: 
    161166  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_title12'>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>/" 
    164169 
    165170show_c_width: 
     
    185190  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>" 
    186191  tem: "<div id='path'><%= show_path(:node=>@node) %></div>" 
    187   res: "/<div id='path'><ul class='path'><li>.*zena.*<li>.*oo\/page8.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>/" 
    188193 
    189194uses_calendar: 
     
    217222 
    218223each_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 -%>" 
    221226  res: "<ul><li>Etat des travaux</li></ul>" 
     227 
     228each_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 
     232each_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>" 
    222235 
    223236case_when: 
    224237  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 -%>" 
    226239  res: "Page" 
    227240 
     
    240253case_ancestor: 
    241254  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
    243256 
    244257simple_each: 
    245258  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/" 
    247260  res: "" 
    248261   
     
    255268edit_not_each: 
    256269  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>/" 
    258271 
    259272edit_each_no_form: 
    260273  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>" 
    262275 
    263276each_add_with_form: 
     
    271284    node: 'wiki' 
    272285  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/" 
    274287 
    275288set_attribute: 
    276289  src: "<div class='machin' do='void' set_class='node[id]'/><z:void set_class='s[v_status]i[id]'/>" 
    277   res: "<div class='node12'/><div class='s50i12'/>" 
     290  res: "<div class='node22'/><div class='s50i22'/>" 
    278291 
    279292set_attribute_with_inner: 
    280293  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='node12'>status</p>" 
     294  res: "<p class='s50' id='node22'>status</p>" 
    282295 
    283296set_in_ztag: 
    284297  src: "<z:show attr='name' set_id='node[id]'/>" 
    285   res: "<div id='node12'>status</div>" 
     298  res: "<div id='node22'>status</div>" 
    286299 
    287300each_join_html: 
     
    299312img_no_image: 
    300313  src: "<z:img/>" 
    301   tem: "<%= @node.img_tag(\"std\") rescue '' %>" 
     314  tem: "<%= img_tag(@node, :mode=>\"std\") %>" 
    302315  res: "" 
    303316 
     
    305318  context: 
    306319    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'/>" 
    309322 
    310323img_href: 
     
    312325    node: 'bird_jpg' 
    313326  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>" 
    315328 
    316329img_src_id: 
    317330  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'/>" 
    319332   
    320333test_children_plural: 
     
    332345    node: 'wiki' 
    333346  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>" 
    335348 
    336349do_each: 
     
    338351    node: 'wiki' 
    339352  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>" 
    341354 
    342355do_with_inner: 
     
    350363    node: 'wiki' 
    351364  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>" 
    353366 
    354367ignore: 
     
    368381include_with: 
    369382  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>" 
    371384 
    372385comments: 
     
    392405 
    393406    <ul do='tags'> 
    394       <li do='each' do='link'>art</li> 
     407      <li do='each' do='link' attr='v_title'>art</li> 
    395408      <li do='ignore'>life</li> 
    396409      <li do='ignore'>ruby</li> 
     
    405418     
    406419    <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> 
    409422    </ul> 
    410423     
     
    416429empty_param: 
    417430  src: "<z:summary text=''/>" 
    418   res: "<div id='v_summary11.1' class='zazen'></div>" 
     431  res: "<div id='v_summary22.1' class='zazen'></div>" 
  • trunk/test/helpers/relations.yml

    r455 r481  
    3737    node: 'cleanWater' 
    3838  src: "<z:pages><z:each join=', '><z:show attr='name'/></z:each></z:pages>" 
    39   res: "lake, status, track" 
     39  res: "status, track" 
    4040 
    4141notes: 
     
    5656  src: "<z:pages limit='3' order='random'><z:each join=', '><z:show attr='name'/></z:each></z:pages>" 
    5757 
    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
     58nodes_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
    6161 
    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: "ant, art" 
     62nodes_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" 
    6565 
    6666store_context: 
     
    6868    node: 'projects' 
    6969  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: "ant, art, collections, lion, menu" 
     70  res: "art, cleanWater, collections, default, menu" 
    7171 
    7272store_node: 
    7373  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" 
    7575 
    7676author_visitor: 
    7777  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" 
    7979 
    8080node_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>ant</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>" 
    8383 
    8484node_path: 
    8585  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>" 
    8787 
    8888node_root: 
     
    168168    node: 'zena' 
    169169  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>" 
    171171 
    172172relation_not_in_current_node: 
    173173  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>" 
    175175   
    176176pages_anchor: 
    177   src: "<z:project><z:pages do='each' join=', '><z:show attr='name' anchor='true'/></z:pages></z:project>" 
    178   res: "<a name='node13'></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
    179179 
    180180projects_from_site: 
     
    183183 
    184184projects: 
    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
    187187 
    188188nodes: 
    189189  src: "<z:nodes from='project'><z:each join=', ' do='show' attr='name'/></z:nodes>" 
    190   res: "cleanWater" 
     190  res: "lake, lakeAddress, opening, status, water" 
    191191 
    192192menu_with_favorites: 
    193193  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: "/.*tag23.*tag25.*Clean Water.*favorites.*Nature/" 
     194  res: "/.*tag33.*tag35.*Clean Water.*favorites.*Nature/" 
    195195   
    196196visitor_favorites: 
    197197  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  
    11require File.join(File.dirname(__FILE__), 'testhelp') 
     2 
     3require 'ruby-debug' 
     4Debugger.start 
    25 
    36class HelperTest 
     
    69   
    710  def test_single 
    8     do_test('basic', 'yield') 
     11    do_test('basic', 'tada') 
    912  end 
    1013 
     
    4346  end 
    4447   
    45   # test rename asset (has to be called wiki to find the proper skin) 
    46   def test_basic_wiki 
    47     Node.connection.execute "UPDATE nodes SET parent_id = 33 WHERE id = 20;" # status, art 
    48     do_test('basic', 'wiki') 
    49   end 
    50    
    5148  def test_relations_updated_today 
    5249    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') 
    5451  end 
    5552