Changeset 1219

Show
Ignore:
Timestamp:
2008-10-11 08:45:14 (3 months ago)
Author:
gaspard
Message:

commit a1dc9167ff3008a31caa7a5f618d1f0d5edbdff1
Merge: 50bfde6... 6dab57d...
Author: Gaspard Bucher <gaspard@teti.ch>

Merge branch 'export_226'

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/README

    r1218 r1219  
    102102=== 3. install Gems 
    103103 
    104 Does not work with gettext > 1.90.0 or RedCloth > 3.x 
    105     # gem install gettext --version 1.90.0 --no-ri --no-rdoc 
    106 Install other gems (you can remove "--no-ri --no-rdoc" if you want the documentation) 
    107     # gem install rake hoe mongrel mongrel_cluster rmagick tzinfo syntax mongrel_upload_progress uuidtools daemons capistrano ruby-debug --no-ri --no-rdoc 
     104You can remove "--no-ri --no-rdoc" if you want the documentation 
     105    # gem install rake hoe gettext mongrel mongrel_cluster rmagick tzinfo syntax mongrel_upload_progress uuidtools daemons capistrano ruby-debug --no-ri --no-rdoc 
    108106From source 
    109107 
  • trunk/app/helpers/application_helper.rb

    r1211 r1219  
    304304  # ** [!>.14!] or [!>14!] inline image surrounded with <p class='img_right'></p> 
    305305  # ** [!=.14!] or [!=14!] inline image with <p class='img_center'></p> 
    306   # ** [!14.pv!] inline image transformed to format 'pv' (class is also set to 'pv'). Formats are defined in #ImageBuilder. 
     306  # ** [!14_pv!] inline image transformed to format 'pv' (class is also set to 'pv'). Formats are defined in #ImageBuilder. 
    307307  # ** all the options above can be used together as in [!>.14.med!] : inline image on the right, size 'med'. 
    308308  # ** [![2,3,5]!] gallery : inline preview with javascript inline viewer 
     
    334334   
    335335  # Find a node's zip based on a query shortcut. Used by zazen to create a link for ""::art for example. 
    336   def find_node_by_shortcut(string,offset=0) 
    337     secure(Node) { Node.find_node_by_shortcut(string,offset) } 
    338   end 
     336  def find_node_by_pseudo(string, start_path = nil) 
     337    start_path ||= @node ? @node.fullpath : nil 
     338    secure(Node) { Node.find_node_by_pseudo(string, start_path) } 
     339  end 
     340   
     341   
    339342 
    340343  # Parse the text in the given context (used by zazen) 
  • trunk/app/models/node.rb

    r1215 r1219  
    258258      native_classes[kp] || VirtualClass.find(:first, :conditions=>["site_id = ? AND kpath = ?",current_site[:id], kp]) 
    259259    end 
    260  
    261     def translate_pseudo_id(id,sym=:id) 
     260     
     261    # Find a node's attribute based on a pseudo (id or path). Used by zazen to create a link for ""::art or "":(people/ant) for example. 
     262    def translate_pseudo_id(id, sym = :id, base_path = nil) 
     263      if id.to_s =~ /\A\d+\Z/ 
     264        # zip 
     265        # FIXME: this is not secure 
     266        res = Node.connection.execute( "SELECT #{sym} FROM nodes WHERE site_id = #{current_site[:id]} AND zip = '#{id}'" ).fetch_row 
     267        res ? res[0].to_i : nil 
     268      elsif node = find_node_by_pseudo(id,base_path) 
     269        node[sym] 
     270      else 
     271        nil 
     272      end 
     273    end 
     274     
     275    # Find a node based on a query shortcut. Used by zazen to create a link for ""::art for example. 
     276    def find_node_by_pseudo(id, base_path = nil) 
     277      raise Zena::AccessViolation if self.scoped_methods == [] 
    262278      str = id.to_s 
    263279      if str =~ /\A\d+\Z/ 
    264280        # zip 
    265         res = Node.connection.execute( "SELECT #{sym} FROM nodes WHERE site_id = #{current_site[:id]} AND zip = '#{str}'" ).fetch_row 
    266         res ? res[0].to_i : nil 
    267       elsif str =~ /\A([a-zA-Z ]+)(\+*)\Z/ 
    268         node = find_node_by_shortcut($1,$2.size) 
    269         node ? node[sym] : nil 
    270       else 
    271         nil 
     281        find_by_zip(str) 
     282      elsif str =~ /\A:?([0-9a-zA-Z ]+)(\+*)\Z/ 
     283        offset = $2.to_s.size 
     284        find(:first, Node.match_query($1.gsub('-',' '), :offset => offset)) 
     285      elsif path = str[/\A\(([^\)]+)\)\Z/,1] 
     286        if path[0..0] == '/' 
     287          find_by_path(path[1..-1]) 
     288        elsif base_path 
     289          find_by_path("#{base_path}/#{path}") 
     290        else 
     291          find_by_path(path) 
     292        end 
    272293      end 
    273294    end 
     
    414435          name   = "#{$1}#{$4}" 
    415436          lang   = $2.blank? ? nil : $2[1..-1] 
    416           attrs  = defaults.merge(get_attributes_from_yaml(path)) 
     437          attrs  = defaults.merge(get_attributes_from_yaml(path)) # FIXME: this should be done with proper 'start_path' [#226] 
    417438          attrs['name']     = name 
    418439          attrs['v_lang']   = lang || attrs['v_lang'] || visitor.lang 
     
    433454           
    434455          # we have a zml file. Create a version with this file 
    435           attrs = defaults.merge(get_attributes_from_yaml(path)) 
     456          attrs = defaults.merge(get_attributes_from_yaml(path)) # FIXME: this should be done with proper 'start_path' (= parent.path) [#226] 
    436457          attrs['name']     = name 
    437458          attrs['v_lang'] ||= lang 
     
    541562      node 
    542563    end 
    543  
    544     # Find a node's zip based on a query shortcut. Used by zazen to create a link for ""::art for example. 
    545     def find_node_by_shortcut(string,offset=0) 
    546       raise Zena::AccessViolation if self.scoped_methods == [] 
    547       find(:first, Node.match_query(string.gsub('-',' '), :offset => offset)) 
    548     end 
    549564     
    550565    # Paginate found results. Returns [previous_page, collection, next_page]. You can specify page and items per page in the query hash : 
     
    636651    # Translate attributes from the visitor's reference to the application. 
    637652    # This method translates dates, zazen shortcuts and zips and returns a stringified hash. 
    638     def transform_attributes(new_attributes
     653    def transform_attributes(new_attributes, start_path = nil
    639654      res = {} 
    640655      res['parent_id'] = new_attributes[:_parent_id] if new_attributes[:_parent_id] # real id set inside zena. 
     
    649664       
    650665      if !res['parent_id'] && p = attributes['parent_id'] 
    651         res['parent_id'] = Node.translate_pseudo_id(p) || p 
     666        res['parent_id'] = Node.translate_pseudo_id(p, :id, start_path) || p 
    652667      end 
    653668       
     
    656671         
    657672        if ['rgroup_id', 'wgroup_id', 'pgroup_id'].include?(key) 
    658           res[key] = Group.translate_pseudo_id(attributes[key]) || attributes[key] 
     673          res[key] = Group.translate_pseudo_id(attributes[key], :id) || attributes[key] 
    659674        elsif ['rgroup', 'wgroup', 'pgroup'].include?(key) 
    660           res["#{key}_id"] = Group.translate_pseudo_id(attributes[key]) || attributes[key] 
     675          res["#{key}_id"] = Group.translate_pseudo_id(attributes[key], :id) || attributes[key] 
    661676        elsif ['user_id'].include?(key) 
    662           res[key] = User.translate_pseudo_id(attributes[key]) || attributes[key] 
     677          res[key] = User.translate_pseudo_id(attributes[key], :id) || attributes[key] 
    663678        elsif ['v_publish_from', 'log_at', 'event_at'].include?(key) 
    664679          if attributes[key].kind_of?(Time) 
     
    670685        elsif key =~ /^(\w+)_id$/ 
    671686          if key[0..1] == 'd_' 
    672             res[key] = Node.translate_pseudo_id(attributes[key],:zip) || attributes[key] 
     687            res[key] = Node.translate_pseudo_id(attributes[key], :zip, start_path) || attributes[key] 
    673688          else 
    674             res[key] = Node.translate_pseudo_id(attributes[key]) || attributes[key] 
     689            res[key] = Node.translate_pseudo_id(attributes[key],  :id, start_path) || attributes[key] 
    675690          end 
    676691        elsif key =~ /^(\w+)_ids$/ 
     
    678693          values = attributes[key].kind_of?(Array) ? attributes[key] : attributes[key].split(',') 
    679694          if key[0..1] == 'd_' 
    680             values.map! {|v| Node.translate_pseudo_id(v,:zip) } 
     695            values.map! {|v| Node.translate_pseudo_id(v, :zip, start_path) } 
    681696          else 
    682             values.map! {|v| Node.translate_pseudo_id(v,:id ) } 
     697            values.map! {|v| Node.translate_pseudo_id(v,  :id, start_path) } 
    683698          end 
    684699          res[key] = values.compact 
     
    701716    end 
    702717 
    703     def get_attributes_from_yaml(filepath
     718    def get_attributes_from_yaml(filepath, start_path = nil
    704719      attributes = YAML::load( File.read( filepath ) ) 
    705720      attributes.delete(:_parent_id) 
    706       transform_attributes(attributes
     721      transform_attributes(attributes, start_path
    707722    end 
    708723     
  • trunk/config/awstats.conf.rhtml

    r1103 r1219  
    166166# Example: "www.myserver.com localhost 127.0.0.1 REGEX[mydomain\.(net|org)$]" 
    167167# 
    168 HostAliases="localhost 127.0.0.1 <%= host %>
     168HostAliases="localhost 127.0.0.1 <%= host %> stats.<%= host %>
    169169 
    170170 
  • trunk/db/init/base/help.en.zml

    r1031 r1219  
    2525  |_. markup |_. result | 
    2626  | @!37!@ | image '37' in std format | 
    27   | @!37.pv!@ | image '37' in 'pv' format | 
    28   | @!37.pv/fig. 3!@ | image '37' in 'pv' format with 'fig. 3' as title | 
    29   | @!37.pv/!@ | image '37' in 'pv' format with it's summary as title | 
     27  | @!37_pv!@ | image '37' in 'pv' format | 
     28  | @!37_pv/fig. 3!@ | image '37' in 'pv' format with 'fig. 3' as title | 
     29  | @!37_pv/!@ | image '37' in 'pv' format with it's summary as title | 
    3030  | @!<.37!@ | image '37', float left (see below) | 
    3131  | @!37!:http://example.org@ | image '37', link to 'example.org' | 
     
    7575  |_. markup |_. result | 
    7676  | @!37!@ | image '37' in std format | 
    77   | @!37.pv!@ | image '37' in 'pv' format | 
    78   | @!37.pv/fig. 3!@ | image '37' in 'pv' format with 'fig. 3' as title | 
    79   | @!37.pv/!@ | image '37' in 'pv' format with it's summary as title | 
     77  | @!37_pv!@ | image '37' in 'pv' format | 
     78  | @!37_pv/fig. 3!@ | image '37' in 'pv' format with 'fig. 3' as title | 
     79  | @!37_pv/!@ | image '37' in 'pv' format with it's summary as title | 
    8080  | @!<.37!@ | image '37', float left (see below) | 
    8181  | @!37!:http://example.org@ | image '37', link to 'example.org' | 
  • trunk/db/init/base/help.fr.zml

    r1031 r1219  
    2323  |_. markup |_. result | 
    2424  | @!37!@ | image '37' in std format | 
    25   | @!37.pv!@ | image '37' in 'pv' format | 
    26   | @!37.pv/fig. 3!@ | image '37' in 'pv' format with 'fig. 3' as title | 
    27   | @!37.pv/!@ | image '37' in 'pv' format with it's summary as title | 
     25  | @!37_pv!@ | image '37' in 'pv' format | 
     26  | @!37_pv/fig. 3!@ | image '37' in 'pv' format with 'fig. 3' as title | 
     27  | @!37_pv/!@ | image '37' in 'pv' format with it's summary as title | 
    2828  | @!<.37!@ | image '37', float left (see below) | 
    2929  | @!37!:http://example.org@ | image '37', link to 'example.org' | 
     
    6969  |_. markup |_. result | 
    7070  | @!37!@ | image '37' in std format | 
    71   | @!37.pv!@ | image '37' in 'pv' format | 
    72   | @!37.pv/fig. 3!@ | image '37' in 'pv' format with 'fig. 3' as title | 
    73   | @!37.pv/!@ | image '37' in 'pv' format with it's summary as title | 
     71  | @!37_pv!@ | image '37' in 'pv' format | 
     72  | @!37_pv/fig. 3!@ | image '37' in 'pv' format with 'fig. 3' as title | 
     73  | @!37_pv/!@ | image '37' in 'pv' format with it's summary as title | 
    7474  | @!<.37!@ | image '37', float left (see below) | 
    7575  | @!37!:http://example.org@ | image '37', link to 'example.org' | 
  • trunk/lib/parser/lib/rules/zazen.rb

    r1105 r1219  
    66module Zazen 
    77  module Tags 
    8      
    98    # This is not exactly how compile/render is meant to work with Parser, but there is no real need for a two step 
    109    # rendering, so we compile here (enter(:void)) instead of doing this whith 'start'. This also lets us have the 
     
    4847module Zazen 
    4948  module Rules 
     49    PSEUDO_ID_REGEXP = ":[0-9a-zA-Z-]+\\+*|\\([^\\)]+\\)" 
     50     
    5051    def start(mode) 
    5152      @helper = @options[:helper] 
     
    150151          store @helper._('[documents]') 
    151152        end 
    152       elsif @text =~ /\A\!([^0-9]{0,2}):([a-zA-Z-]+)(\+*)(\.([^\/\!]+)|)(\/([^\!]*)|)\!(:([^\s]+)|)/m 
    153         # image !<.:art++.pv/blah blah!:12 
    154         #puts "SHORCUT IMAGE:[#{$&}]" 
    155         eat $& 
    156         style, id, offset, other_opts, mode, title_opts, title, link = $1, $2, $3, $4, $5, $6, $7, $9 
    157         if node = @helper.find_node_by_shortcut(id,offset.size) 
    158            
    159           if link && link =~ /^:([a-zA-Z-]+)(\+*)(.*)$/ 
    160             rest = $3 
    161             if link_node = @helper.find_node_by_shortcut($1,$2.size) 
     153      elsif @text =~ /\A\!([^0-9]{0,2})(#{PSEUDO_ID_REGEXP})(_([^\/\!]+)|)(\/([^\!]*)|)\!(:([^\s]+)|)/m 
     154        # image !<.:art++_pv/blah blah!:12 
     155        #puts "SHORCUT IMAGE:#{$~.to_a.inspect}" 
     156        eat $& 
     157        style, id, other_opts, mode, title_opts, title, link = $1, $2, $3, $4, $5, $6, $8 
     158        if node = @helper.find_node_by_pseudo(id) 
     159          if link && link =~ /^(#{PSEUDO_ID_REGEXP})(.*)$/ 
     160            rest = $2 
     161            if link_node = @helper.find_node_by_pseudo($1) 
    162162              link = link_node[:zip].to_s + rest 
    163163            end 
     
    181181          store $& 
    182182        else 
    183           store "[#{id}#{offset != '' ? offset.size+1 : ''} not found]" 
    184         end 
    185       elsif @text =~ /\A\!([^0-9]{0,2})([0-9]+)(\.([^\/\!]+)|)(\/([^\!]*)|)\!(:([^\s]+)|)/m 
    186         # image !<.12.pv/blah blah!:12 
     183          store "[#{id} not found]" 
     184        end 
     185      elsif @text =~ /\A\!([^0-9]{0,2})([0-9]+)(_([^\/\!]+)|)(\/([^\!]*)|)\!(:([^\s]+)|)/m 
     186        # image !<.12_pv/blah blah!:12 
    187187        #puts "IMAGE:[#{$&}]" 
    188188        eat $& 
    189189        style, id, other_opts, mode, title_opts, title, link = $1, $2, $3, $4, $5, $6, $8 
    190         if link && link =~ /^:([a-zA-Z-]+)(\+*)(.*)
    191           rest = $3 
    192           if link_node = @helper.find_node_by_shortcut($1,$2.size
     190        if link && link =~ /^(#{PSEUDO_ID_REGEXP})(.*)$
     191          rest = $2 
     192          if link_node = @helper.find_node_by_pseudo($1
    193193            link = link_node[:zip].to_s + rest 
    194194          end 
     
    221221          store @helper.make_link(:title=>title,:id=>id,:sharp=>sharp) 
    222222        end 
    223       elsif @text =~ /\A"([^"]*)"::([a-zA-Z-]+)(\+*)((_[a-z]+|)(\.[a-z]+|)(#[a-z_\/\[\]]*|))/m 
     223      elsif @text =~ /\A"([^"]*)":(#{PSEUDO_ID_REGEXP})((_[a-z]+|)(\.[a-z]+|)(#[a-z_\/\[\]]*|))/m 
    224224        #puts "SHORTCUT_LINK:[#{$&}]" 
    225225        eat $& 
    226         title, id, offset, mode = $1, $2, $3, $4 
    227         if node = @helper.find_node_by_shortcut(id,offset.size
    228           id = "#{node.zip}#{mode}" 
     226        title, pseudo_id, mode_format, mode, format, dash = $1, $2, $3, $4, $5, $6 
     227        if node = @helper.find_node_by_pseudo(pseudo_id
     228          id = "#{node.zip}#{mode_format}" 
    229229          if @parse_shortcuts 
    230230            # replace shortcut 
    231231            store "\"#{title}\":#{id}" 
    232232          else 
    233             title = node.fullpath 
     233            if format == '.data' 
     234              title = "#{node.fullpath}#{mode}.#{node.c_ext}#{dash}" 
     235            else 
     236              title = "#{node.fullpath}#{mode_format}" 
     237            end 
    234238            if id =~ /(.*?)#(.*)/ 
    235239              id, sharp = $1, $2 
     
    241245          store $& 
    242246        else 
    243           store "[#{id}#{offset != '' ? offset.size+1 : ''} not found]" 
     247          pseudo_id = pseudo_id[1..-1] if pseudo_id[0..0] == ':' 
     248          store "[#{pseudo_id} not found]" 
    244249        end 
    245250      else 
     
    381386    def parse_document_ids(str) 
    382387      str.split(',').map do |id| 
    383         if id =~ /\A:([a-zA-Z-]+)(\+*)/ 
    384           id, offset = $1, $2 
    385           if node = @helper.find_node_by_shortcut(id.strip,offset.size) 
     388        if id =~ /\A(#{PSEUDO_ID_REGEXP})/ 
     389          if node = @helper.find_node_by_pseudo($1) 
    386390            if node.kind_of?(Document) 
    387391              # replace shortcut 
     
    393397            end 
    394398          elsif @parse_shortcuts 
    395             ":#{id}#{offset}" 
     399            id 
    396400          else 
    397401            nil # document not found 
  • trunk/lib/parser/test/parser/zazen.yml

    r1100 r1219  
    3636    Text updated in [July 2008]. 
    3737     
    38     !30.full! 
     38    !30_full! 
    3939  res: "<p>Text updated in [July 2008].</p>\n\n\n\t<p>[make_image id:|30| images:true mode:|full| style:||]</p>" 
    4040 
     
    8383   
    8484image_with_format: 
    85   src: "!21.mini!" 
     85  src: "!21_mini!" 
    8686  res: "<p>[make_image id:|21| images:true mode:|mini| style:||]</p>" 
    8787   
     
    9999   
    100100image_with_link: 
    101   src: "!12.pv!:12" 
     101  src: "!12_pv!:12" 
    102102  res: "<p>[make_image id:|12| images:true link:|12| mode:|pv| style:||]</p>" 
    103103   
    104104image_with_link_mode: 
    105   src: "!12.pv!:20_changes" 
     105  src: "!12_pv!:20_changes" 
    106106  res: "<p>[make_image id:|12| images:true link:|20_changes| mode:|pv| style:||]</p>" 
    107107   
    108108image_with_link_mode_and_format: 
    109   src: "!12.pv!:20_med.data" 
     109  src: "!12_pv!:20_med.data" 
    110110  res: "<p>[make_image id:|12| images:true link:|20_med.data| mode:|pv| style:||]</p>" 
    111111   
    112112image_with_http_link: 
    113   src: "!12.pv!:http://www.example.org" 
     113  src: "!12_pv!:http://www.example.org" 
    114114  res: "<p>[make_image id:|12| images:true link:|http://www.example.org| mode:|pv| style:||]</p>" 
    115115 
  • trunk/test/helpers/zazen_test.rb

    r1212 r1219  
    88    super 
    99  end 
    10    
     10 
    1111  # all these additions are replaced by the traduction of 'unknown link' if the user does not have read access to the linked node. 
    1212  def test_bad_link 
    1313    assert_match %r{unknown link}, zazen('"hello":99') 
    1414  end 
    15    
     15 
    1616  def test_wiki_link 
    1717    login(:tiger) 
     
    1919    assert_match %r{<cite>blah</cite> <cite>blih <a.*>test</a> it</cite>}, zazen('??blah?? ??blih ?test? it??') 
    2020  end 
    21    
     21 
    2222  def test_image_title 
    23     preserving_files('test.host/data/jpg/20') do 
    24       login(:tiger) 
    25       assert_match %r{<div class='img_with_title'><img[^>]*><div class='img_title'><p>blah <a href=.*projects/cleanWater.*Clean Water.*/a></p></div></div>}, 
    26        zazen("!30/blah \"\":21!") 
    27      assert_match %r{<div class='img_with_title'><img.*class.*pv.*><div class='img_title'><p>blah <a href=.*projects/cleanWater.*Clean Water.*/a></p></div></div>}, 
    28         zazen("!30.pv/blah \"\":21!") 
    29      assert_match %r{<div class='img_with_title'><img.*class.*std.*><div class='img_title'><p>Photo taken from.*</p></div></div>}, zazen("!30/!") 
    30      
    31     end 
     23    login(:tiger) 
     24    assert_match %r{<div class='img_with_title'><img[^>]*><div class='img_title'><p>blah <a href=.*projects/cleanWater.*Clean Water.*/a></p></div></div>}, 
     25    zazen("!30/blah \"\":21!") 
     26    assert_match %r{<div class='img_with_title'><img.*class.*pv.*><div class='img_title'><p>blah <a href=.*projects/cleanWater.*Clean Water.*/a></p></div></div>}, 
     27    zazen("!30_pv/blah \"\":21!") 
     28    assert_match %r{<div class='img_with_title'><img.*class.*std.*><div class='img_title'><p>Photo taken from.*</p></div></div>}, zazen("!30/!") 
     29 
    3230  end 
    33    
     31 
    3432  def test_make_link 
    3533    login(:tiger) 
     
    4341 
    4442  def test_make_image 
    45     preserving_files('test.host/data/jpg/14') do 
    46       login(:tiger) 
    47       # * [!24!] inline image 24. (default format is 'pv' defined in #ImageBuilder). Options are : 
    48       assert_equal "<p><img src='/en/projects/cleanWater/image24_std.jpg' width='545' height='400' alt='it&apos;s a lake' class='std'/></p>", zazen('!24!') 
    49       # ** [!024!] inline image, default format, link to full image. 
    50       assert_equal "<p><a href='/oo/projects/cleanWater/image24.jpg'><img src='/en/projects/cleanWater/image24_std.jpg' width='545' height='400' alt='it&apos;s a lake' class='std'/></a></p>", zazen('!024!') 
    51     end 
     43    login(:tiger) 
     44    # * [!24!] inline image 24. (default format is 'pv' defined in #ImageBuilder). Options are : 
     45    assert_equal "<p><img src='/en/projects/cleanWater/image24_std.jpg' width='545' height='400' alt='it&apos;s a lake' class='std'/></p>", zazen('!24!') 
     46    # ** [!024!] inline image, default format, link to full image. 
     47    assert_equal "<p><a href='/oo/projects/cleanWater/image24.jpg'><img src='/en/projects/cleanWater/image24_std.jpg' width='545' height='400' alt='it&apos;s a lake' class='std'/></a></p>", zazen('!024!') 
    5248  end 
    5349 
     
    5652    assert_match %r{<p><a.*href=.*oo/projects/cleanWater/document25\.pdf.*img src='/images/ext/pdf.png' width='32' height='32' alt='pdf document' class='doc'/></a></p>}, zazen('!25!') 
    5753    assert_match %r{<p><a.*href=.*oo/projects/cleanWater/document25\.pdf.*img src='/images/ext/pdf.png' width='32' height='32' alt='pdf document' class='doc'/></a></p>}, zazen('!025!') # same as '!25!' 
    58     assert_match %r{<p><a.*href=.*oo/projects/cleanWater/document25\.pdf.*img src='/images/ext/pdf_pv.png' width='70' height='70' alt='pdf document' class='doc'/></a></p>}, zazen('!25.pv!') 
     54    assert_match %r{<p><a.*href=.*oo/projects/cleanWater/document25\.pdf.*img src='/images/ext/pdf_pv.png' width='70' height='70' alt='pdf document' class='doc'/></a></p>}, zazen('!25_pv!') 
    5955  end 
    6056 
     
    6460 
    6561  def test_make_image_align 
    66     preserving_files('test.host/data/jpg/14') do 
    67       # ** [!<.24!] or [!<24!] inline image surrounded with <p class='float_left'></p> 
    68       assert_match %r{class='img_left'.*img.*/en/projects/cleanWater/image24_std.jpg.*class='std'}, zazen('!<.24!') 
    69       assert_match %r{class='img_left'.*img.*/en/projects/cleanWater/image24_std.jpg.*class='std'}, zazen('!<24!') 
    70       # ** [!>.24!] inline image surrounded with <p class='float_right'></p> 
    71       assert_match %r{class='img_right'.*img.*/en/projects/cleanWater/image24_std.jpg.*class='std'}, zazen('!>.24!') 
    72       assert_match %r{class='img_right'.*img.*/en/projects/cleanWater/image24_std.jpg.*class='std'}, zazen('!>24!') 
    73       # ** [!=.24!] inline image with <p class='center'></p> 
    74       assert_match %r{class='img_center'.*img.*/en/projects/cleanWater/image24_std.jpg.*class='std'}, zazen('!=.24!') 
    75       assert_match %r{class='img_center'.*img.*/en/projects/cleanWater/image24_std.jpg.*class='std'}, zazen('!=24!') 
    76     end 
     62    # ** [!<.24!] or [!<24!] inline image surrounded with <p class='float_left'></p> 
     63    assert_match %r{class='img_left'.*img.*/en/projects/cleanWater/image24_std.jpg.*class='std'}, zazen('!<.24!') 
     64    assert_match %r{class='img_left'.*img.*/en/projects/cleanWater/image24_std.jpg.*class='std'}, zazen('!<24!') 
     65    # ** [!>.24!] inline image surrounded with <p class='float_right'></p> 
     66    assert_match %r{class='img_right'.*img.*/en/projects/cleanWater/image24_std.jpg.*class='std'}, zazen('!>.24!') 
     67    assert_match %r{class='img_right'.*img.*/en/projects/cleanWater/image24_std.jpg.*class='std'}, zazen('!>24!') 
     68    # ** [!=.24!] inline image with <p class='center'></p> 
     69    assert_match %r{class='img_center'.*img.*/en/projects/cleanWater/image24_std.jpg.*class='std'}, zazen('!=.24!') 
     70    assert_match %r{class='img_center'.*img.*/en/projects/cleanWater/image24_std.jpg.*class='std'}, zazen('!=24!') 
    7771  end 
    7872 
    7973  def test_make_iformat 
    80     preserving_files('test.host/data/jpg/14') do 
    81       # ** [!24.pv!] inline image transformed to format 'pv'. Formats are defined in #ImageBuilder. 
    82       assert_match %r{.*img.*/en/projects/cleanWater/image24.jpg.*600.*440.*class='full'}, zazen('!24.full!') 
    83       assert_match %r{.*img.*/en/projects/cleanWater/image24_tiny.jpg.*16.*16.*class='tiny'}, zazen('!24.tiny!') 
    84     end 
     74    # ** [!24_pv!] inline image transformed to format 'pv'. Formats are defined in #ImageBuilder. 
     75    assert_match %r{.*img.*/en/projects/cleanWater/image24.jpg.*600.*440.*class='full'}, zazen('!24_full!') 
     76    assert_match %r{.*img.*/en/projects/cleanWater/image24_tiny.jpg.*16.*16.*class='tiny'}, zazen('!24_tiny!') 
    8577  end 
    8678 
    8779  def test_all_options 
    88     preserving_files('test.host/data/jpg/14') do 
    89       # ** all the options above can be used together as in [!>.26.std!] : inline image on the right, size 'med'. 
    90       assert_match %r{class='img_right'.*img.*/en/projects/cleanWater/image24_mini.jpg.*32.*32.*class='mini'}, zazen('!>24.mini!') 
    91       assert_match %r{class='img_right'.*img.*/en/projects/cleanWater/image24_mini.jpg.*32.*32.*class='mini'}, zazen('!>.24.mini!') 
    92     end 
     80    # ** all the options above can be used together as in [!>.26.std!] : inline image on the right, size 'med'. 
     81    assert_match %r{class='img_right'.*img.*/en/projects/cleanWater/image24_mini.jpg.*32.*32.*class='mini'}, zazen('!>24_mini!') 
     82    assert_match %r{class='img_right'.*img.*/en/projects/cleanWater/image24_mini.jpg.*32.*32.*class='mini'}, zazen('!>.24_mini!') 
    9383  end 
    9484 
    9585  def test_make_gallery 
    9686    login(:anon) 
    97     preserving_files('test.host/data/jpg') do 
    98       # ** [![2,3,5]!] gallery : inline preview with javascript inline viewer 
    99       assert_match %r{table.*gallery.*Zena.transfer.*image24_pv.jpg.*image24_std.jpg.*image30_pv.jpg.*image30_std.jpg}m, zazen('![24,30]!') 
    100       @node = secure!(Node) { Node.find(nodes_id(:wiki)) } 
    101       # ** [![]!] gallery with all images contained in the current node 
    102       assert_match %r{table.*gallery.*Zena.transfer.*image30_pv.jpg.*image30_std.jpg.*image31_pv.jpg.*image31_std.jpg}m, zazen('![]!') 
    103     end 
     87    # ** [![2,3,5]!] gallery : inline preview with javascript inline viewer 
     88    assert_match %r{table.*gallery.*Zena.transfer.*image24_pv.jpg.*image24_std.jpg.*image30_pv.jpg.*image30_std.jpg}m, zazen('![24,30]!') 
     89    @node = secure!(Node) { Node.find(nodes_id(:wiki)) } 
     90    # ** [![]!] gallery with all images contained in the current node 
     91    assert_match %r{table.*gallery.*Zena.transfer.*image30_pv.jpg.*image30_std.jpg.*image31_pv.jpg.*image31_std.jpg}m, zazen('![]!') 
    10492  end 
    10593 
    10694  def test_list_nodes 
    107     preserving_files('test.host/data/jpg') do 
    108       login(:lion) 
    109       # * [!{7,9}!] documents listing for documents 7 and 9 
    110       assert_match %r{table.*tr.*bird.*tr.*water}m, zazen('!{30,25}!') # water, forest 
    111       # * [!{}!] list all documents (with images) for the current node 
    112       @node = secure!(Node) { Node.find(nodes_id(:cleanWater))} 
    113       assert_match %r{table.*tr.*water}m, zazen('!{}!') 
    114       # * [!{i}!] list all images for the current node 
    115       assert_no_match %r{water}m, (i=zazen('!{i}!')) 
    116       # * [!{d}!] list all documents (without images) for the current node 
    117       @node = secure!(Node) { Node.find(nodes_id(:wiki)) } 
    118       assert_no_match %r{flower}m, (d=zazen('!{d}!')) 
    119     end 
     95    login(:lion) 
     96    # * [!{7,9}!] documents listing for documents 7 and 9 
     97    assert_match %r{table.*tr.*bird.*tr.*water}m, zazen('!{30,25}!') # water, forest 
     98    # * [!{}!] list all documents (with images) for the current node 
     99    @node = secure!(Node) { Node.find(nodes_id(:cleanWater))} 
     100    assert_match %r{table.*tr.*water}m, zazen('!{}!') 
     101    # * [!{i}!] list all images for the current node 
     102    assert_no_match %r{water}m, (i=zazen('!{i}!')) 
     103    # * [!{d}!] list all documents (without images) for the current node 
     104    @node = secure!(Node) { Node.find(nodes_id(:wiki)) } 
     105    assert_no_match %r{flower}m, (d=zazen('!{d}!')) 
    120106  end 
    121107 
    122108  def test_image_as_link 
    123     preserving_files('test.host/data/jpg/14') do 
    124       # * [!26!:37] you can use an image as the source for a link 
    125       assert_match %r{<p><a href.*en/projects/cleanWater.*img src.*image24_std.jpg.*545.*400.*class='std'}, zazen('!24!:21') 
    126       # * [!26!:www.example.com] use an image for an outgoing link 
    127       assert_match %r{<p><a href.*http://www.example.com.*img src.*image24_std.jpg.*545.*400.*class='std'}, zazen('!24!:http://www.example.com') 
    128       assert_match %r{<p><a href.*http://www.example.com.*img src.*image24_std.jpg.*545.*400.*class='std'}, zazen('!24!:www.example.com') 
    129     end 
     109    # * [!26!:37] you can use an image as the source for a link 
     110    assert_match %r{<p><a href.*en/projects/cleanWater.*img src.*image24_std.jpg.*545.*400.*class='std'}, zazen('!24!:21') 
     111    # * [!26!:www.example.com] use an image for an outgoing link 
     112    assert_match %r{<p><a href.*http://www.example.com.*img src.*image24_std.jpg.*545.*400.*class='std'}, zazen('!24!:http://www.example.com') 
     113    assert_match %r{<p><a href.*http://www.example.com.*img src.*image24_std.jpg.*545.*400.*class='std'}, zazen('!24!:www.example.com') 
    130114  end 
    131115 
    132116  def test_full 
    133     preserving_files('test.host/data/jpg/14') do 
    134       assert_match %r{class='img_left'.*href.*/en/projects/cleanWater.*window.open\(this.href\).*img src.*image24_std.jpg.*545.*400.*class='std'}, zazen('!<.24.3!:021') 
    135     end 
     117    assert_match %r{class='img_left'.*href.*/en/projects/cleanWater.*window.open\(this.href\).*img src.*image24_std.jpg.*545.*400.*class='std'}, zazen('!<.24_3!:021') 
    136118  end 
    137    
     119 
    138120  def test_empty_image_ref 
    139121    assert_equal '<p>!!</p>', zazen('!!') 
     
    141123    assert_equal "<p>!!!</p>", zazen('!!!') 
    142124  end 
    143    
     125 
    144126  def test_no_images 
    145     preserving_files('test.host/data/jpg/20') do 
    146       assert_match %r{salut les \[image: bird\]}, zazen('salut les !30.pv!', :images=>false) 
    147     end 
     127    assert_match %r{salut les \[image: bird\]}, zazen('salut les !30_pv!', :images=>false) 
    148128  end 
    149129   
     130  def test_pseudo_id 
     131    assert_equal '<p>This is a <a href="/en/contact15.html">people/lion</a>.</p>', zazen('This is a "link"::lio.') 
     132    assert_equal '<p>This is a <a href="/en/image30_pv.jpg">projects/wiki/bird_pv.jpg</a>.</p>', zazen('This is a "link"::bir_pv.data.') 
     133  end 
     134   
     135  def test_pseudo_id_numbers_only 
     136    login(:lion) 
     137    lion = secure!(Node) { nodes(:lion) } 
     138    assert lion.update_attributes(:name => '1234') 
     139    login(:anon) 
     140    assert_equal '<p>This is a <a href="/en/contact15.html">people/1234</a>.</p>', zazen('This is a "link"::123.') 
     141  end 
     142   
     143  def test_pseudo_path 
     144    login(:lion) 
     145    lion = secure!(Node) { nodes(:lion) } 
     146    assert lion.update_attributes(:name => 'status') 
     147     
     148    @node = secure!(Node) { nodes(:cleanWater) } 
     149    assert_equal '<p>Read <a href="/oo/projects/cleanWater/page22.html">projects/cleanWater/status</a></p>', zazen('Read "":(/projects/cleanWater/status)') 
     150    assert_equal '<p>Read <a href="/oo/projects/cleanWater/page22.html">projects/cleanWater/status</a></p>', zazen('Read "":(status)') 
     151     
     152    @node = secure!(Node) { nodes(:people) } 
     153    assert_equal '<p>Read <a href="/oo/projects/cleanWater/page22.html">projects/cleanWater/status</a></p>', zazen('Read "":(/projects/cleanWater/status)') 
     154    assert_equal "<p>See <img src='/en/image30_med.jpg' width='220' height='200' alt='bird' class='med'/></p>", zazen('See !:(/projects/wiki/bird)_med!') 
     155    assert_equal "<p>See <a href=\"/oo/contact15.html\"><img src='/en/image30_med.jpg' width='220' height='200' alt='bird' class='med'/></a></p>", zazen('See !:(/projects/wiki/bird)_med!:(status)') 
     156    assert_equal '<p>Read <a href="/oo/contact15.html">people/status</a></p>', zazen('Read "":(status)') 
     157     
     158    @node = secure!(Node) { nodes(:wiki) } 
     159    assert_equal "<p>See <a href=\"/oo/projects/cleanWater\"><img src='/en/image30_med.jpg' width='220' height='200' alt='bird' class='med'/></a></p>", zazen('See !:(bird)_med!:(/projects/cleanWater)') 
     160  end 
     161 
    150162end 
  • trunk/test/helpers/zena_parser/zazen.yml

    r1101 r1219  
    2929   
    3030complex_link: 
    31   tem: <%= zazen("p<. !<.31.pv!:22\n\nh4(clear). \"\":22") %> 
     31  tem: <%= zazen("p<. !<.31_pv!:22\n\nh4(clear). \"\":22") %> 
    3232  res: "<p style=\"text-align:left;\"><div class='img_left'><a href=\"/oo/projects/cleanWater/page22.html\"><img src='/en/image31_pv.jpg' width='70' height='70' alt='flower' class='pv'/></a></div></p>\n\n\n\t<h4 class=\"clear\"><a href=\"/oo/projects/cleanWater/page22.html\">status title</a></h4>" 
    3333 
     
    5050zip_shortcut_link_with_mode_format: 
    5151  tem: "<%= zazen('Look \"here\"::lake_life.rss, \"\"::lake+_life.data.') %>" 
    52   res: "/<p>Look <a href.*contact23_life.rss.*projects/cleanWater/lakeAddress</a>, <a href=.*image24_life.jpg.*projects/cleanWater/lake</a>./" 
     52  res: "/<p>Look <a href.*contact23_life.rss.*projects/cleanWater/lakeAddress_life.rss</a>, <a href=.*image24_life.jpg.*projects/cleanWater/lake_life.jpg</a>./" 
    5353 
    5454zip_shortcut_image: 
     
    5757 
    5858zip_shortcut_image_with_options: 
    59   tem: "<%= zazen('Look !<.:lake.med! or !=.:lake+.pv!') %>" 
     59  tem: "<%= zazen('Look !<.:lake_med! or !=.:lake+_pv!') %>" 
    6060  res: "/<p>Look \[projects/cleanWater/lakeAddress is not a document\] or .*center.*<img src=.*image24_pv.jpg/" 
    6161 
  • trunk/test/sites/zena/versions.yml

    r1217 r1219  
    7878    Fusce erat erat, nonummy non, facilisis ut, tristique quis, risus. Vestibulum libero sem, aliquet id, varius at, pellentesque in, diam. Fusce in diam. Quisque congue eros pellentesque leo. Phasellus tortor odio, cursus sed, ullamcorper sed, luctus et, velit. Etiam consectetuer. In luctus, quam eget dictum euismod, mi dui sollicitudin ante, nec nonummy erat dui nec tellus. Quisque quam. Curabitur in orci. Vivamus eu turpis. 
    7979     
    80     !<.31.med! 
     80    !<.31_med! 
    8181     
    8282    Maecenas at est. Morbi sem enim, posuere in, commodo vel, imperdiet non, augue. Cum sociis natoque penatibus et magnis dis parturient montes, nascetur ridiculus mus. Phasellus consequat pharetra elit. Pellentesque purus ante, ornare ac, tristique vitae, congue sit amet, pede. Curabitur eu nibh at lorem luctus lacinia. Proin lobortis. Nullam leo. Fusce fermentum facilisis erat. Nam dolor. 
  • trunk/test/unit/iformat_test.rb

    r964 r1219  
    156156    imf = Iformat.create(:name => 'header', :height=>'34', :width => '500', :size => 'force') 
    157157    assert imf.new_record?, "New record" 
    158     assert_equal "%{fn} has already been taken", imf.errors['name'] 
     158    assert_equal "Name has already been taken", imf.errors['name'] 
    159159  end 
    160160   
  • trunk/test/unit/node_test.rb

    r1217 r1219  
    3232    login(:tiger) 
    3333    [ 
    34       ["Hi, this is just a simple \"test\"::w or \"\"::w+_life.rss. OK ?\n\n!:lake+.pv!", 
    35        "Hi, this is just a simple \"test\":25 or \"\":29_life.rss. OK ?\n\n!24.pv!"], 
     34      ["Hi, this is just a simple \"test\"::w or \"\"::w+_life.rss. OK ?\n\n!:lake+_pv!", 
     35       "Hi, this is just a simple \"test\":25 or \"\":29_life.rss. OK ?\n\n!24_pv!"], 
    3636        
    3737      ["Hi ![30,:lake+]! ![]!", 
     
    4141       "Hi !{30,24}! !{}!"], 
    4242 
    43       ["Hi !30!::clean !:bird!::clean !:bird/nice bird!:21 !30.pv/hello ladies!:21", 
    44        "Hi !30!:21 !30!:21 !30/nice bird!:21 !30.pv/hello ladies!:21"], 
     43      ["Hi !30!::clean !:bird!::clean !:bird/nice bird!:21 !30_pv/hello ladies!:21", 
     44       "Hi !30!:21 !30!:21 !30/nice bird!:21 !30_pv/hello ladies!:21"], 
    4545        
    4646      ["Hi, this is normal "":1/ just a\n\n* asf\n* asdf ![23,33]!", 
     
    13331333  end 
    13341334   
     1335  def test_translate_pseudo_id_path 
     1336    login(:lion) 
     1337    lion = secure!(Node) { nodes(:lion) } 
     1338    assert lion.update_attributes(:name => 'status') 
     1339       # path                           base_path 
     1340    { ['(/projects/cleanWater/status)', nil]  => nodes_id(:status),  
     1341      ['(/projects/cleanWater/status)', 'people']  => nodes_id(:status), 
     1342      ['(status)', 'people']  => nodes_id(:lion), 
     1343      ['(status)', 'projects/cleanWater']  => nodes_id(:status), 
     1344    }.each do |k,v| 
     1345      assert_equal v, secure(Node) { Node.translate_pseudo_id(k[0],:id,k[1]) }, "'#{k.inspect}' should translate to '#{v}'" 
     1346    end 
     1347  end 
     1348   
    13351349  def test_safe_attribute 
    13361350    login(:ant)