Changeset 1219
- Timestamp:
- 2008-10-11 08:45:14 (3 months ago)
- Files:
-
- trunk/README (modified) (1 diff)
- trunk/app/helpers/application_helper.rb (modified) (2 diffs)
- trunk/app/models/node.rb (modified) (10 diffs)
- trunk/config/awstats.conf.rhtml (modified) (1 diff)
- trunk/db/init/base/help.en.zml (modified) (2 diffs)
- trunk/db/init/base/help.fr.zml (modified) (2 diffs)
- trunk/db/migrate/000_zena/046_fix_zazen_image_tag.rb (added)
- trunk/lib/parser/lib/rules/zazen.rb (modified) (8 diffs)
- trunk/lib/parser/test/parser/zazen.yml (modified) (3 diffs)
- trunk/test/helpers/zazen_test.rb (modified) (6 diffs)
- trunk/test/helpers/zena_parser/zazen.yml (modified) (3 diffs)
- trunk/test/sites/zena/versions.yml (modified) (1 diff)
- trunk/test/unit/iformat_test.rb (modified) (1 diff)
- trunk/test/unit/node_test.rb (modified) (3 diffs)
- trunk/vendor/gettext-1.90.0.zip (deleted)
- trunk/vendor/plugins/gettext_fix (added)
- trunk/vendor/plugins/gettext_fix/patch (added)
- trunk/vendor/plugins/gettext_fix/patch/base_additions.rb (added)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
trunk/README
r1218 r1219 102 102 === 3. install Gems 103 103 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 104 You 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 108 106 From source 109 107 trunk/app/helpers/application_helper.rb
r1211 r1219 304 304 # ** [!>.14!] or [!>14!] inline image surrounded with <p class='img_right'></p> 305 305 # ** [!=.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. 307 307 # ** all the options above can be used together as in [!>.14.med!] : inline image on the right, size 'med'. 308 308 # ** [![2,3,5]!] gallery : inline preview with javascript inline viewer … … 334 334 335 335 # 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 339 342 340 343 # Parse the text in the given context (used by zazen) trunk/app/models/node.rb
r1215 r1219 258 258 native_classes[kp] || VirtualClass.find(:first, :conditions=>["site_id = ? AND kpath = ?",current_site[:id], kp]) 259 259 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 == [] 262 278 str = id.to_s 263 279 if str =~ /\A\d+\Z/ 264 280 # 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 272 293 end 273 294 end … … 414 435 name = "#{$1}#{$4}" 415 436 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] 417 438 attrs['name'] = name 418 439 attrs['v_lang'] = lang || attrs['v_lang'] || visitor.lang … … 433 454 434 455 # 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] 436 457 attrs['name'] = name 437 458 attrs['v_lang'] ||= lang … … 541 562 node 542 563 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 end549 564 550 565 # Paginate found results. Returns [previous_page, collection, next_page]. You can specify page and items per page in the query hash : … … 636 651 # Translate attributes from the visitor's reference to the application. 637 652 # 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) 639 654 res = {} 640 655 res['parent_id'] = new_attributes[:_parent_id] if new_attributes[:_parent_id] # real id set inside zena. … … 649 664 650 665 if !res['parent_id'] && p = attributes['parent_id'] 651 res['parent_id'] = Node.translate_pseudo_id(p ) || p666 res['parent_id'] = Node.translate_pseudo_id(p, :id, start_path) || p 652 667 end 653 668 … … 656 671 657 672 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] 659 674 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] 661 676 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] 663 678 elsif ['v_publish_from', 'log_at', 'event_at'].include?(key) 664 679 if attributes[key].kind_of?(Time) … … 670 685 elsif key =~ /^(\w+)_id$/ 671 686 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] 673 688 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] 675 690 end 676 691 elsif key =~ /^(\w+)_ids$/ … … 678 693 values = attributes[key].kind_of?(Array) ? attributes[key] : attributes[key].split(',') 679 694 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) } 681 696 else 682 values.map! {|v| Node.translate_pseudo_id(v, :id) }697 values.map! {|v| Node.translate_pseudo_id(v, :id, start_path) } 683 698 end 684 699 res[key] = values.compact … … 701 716 end 702 717 703 def get_attributes_from_yaml(filepath )718 def get_attributes_from_yaml(filepath, start_path = nil) 704 719 attributes = YAML::load( File.read( filepath ) ) 705 720 attributes.delete(:_parent_id) 706 transform_attributes(attributes )721 transform_attributes(attributes, start_path) 707 722 end 708 723 trunk/config/awstats.conf.rhtml
r1103 r1219 166 166 # Example: "www.myserver.com localhost 127.0.0.1 REGEX[mydomain\.(net|org)$]" 167 167 # 168 HostAliases="localhost 127.0.0.1 <%= host %> "168 HostAliases="localhost 127.0.0.1 <%= host %> stats.<%= host %>" 169 169 170 170 trunk/db/init/base/help.en.zml
r1031 r1219 25 25 |_. markup |_. result | 26 26 | @!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 | 30 30 | @!<.37!@ | image '37', float left (see below) | 31 31 | @!37!:http://example.org@ | image '37', link to 'example.org' | … … 75 75 |_. markup |_. result | 76 76 | @!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 | 80 80 | @!<.37!@ | image '37', float left (see below) | 81 81 | @!37!:http://example.org@ | image '37', link to 'example.org' | trunk/db/init/base/help.fr.zml
r1031 r1219 23 23 |_. markup |_. result | 24 24 | @!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 | 28 28 | @!<.37!@ | image '37', float left (see below) | 29 29 | @!37!:http://example.org@ | image '37', link to 'example.org' | … … 69 69 |_. markup |_. result | 70 70 | @!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 | 74 74 | @!<.37!@ | image '37', float left (see below) | 75 75 | @!37!:http://example.org@ | image '37', link to 'example.org' | trunk/lib/parser/lib/rules/zazen.rb
r1105 r1219 6 6 module Zazen 7 7 module Tags 8 9 8 # This is not exactly how compile/render is meant to work with Parser, but there is no real need for a two step 10 9 # rendering, so we compile here (enter(:void)) instead of doing this whith 'start'. This also lets us have the … … 48 47 module Zazen 49 48 module Rules 49 PSEUDO_ID_REGEXP = ":[0-9a-zA-Z-]+\\+*|\\([^\\)]+\\)" 50 50 51 def start(mode) 51 52 @helper = @options[:helper] … … 150 151 store @helper._('[documents]') 151 152 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) 162 162 link = link_node[:zip].to_s + rest 163 163 end … … 181 181 store $& 182 182 else 183 store "[#{id} #{offset != '' ? offset.size+1 : ''}not found]"184 end 185 elsif @text =~ /\A\!([^0-9]{0,2})([0-9]+)( \.([^\/\!]+)|)(\/([^\!]*)|)\!(:([^\s]+)|)/m186 # image !<.12 .pv/blah blah!:12183 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 187 187 #puts "IMAGE:[#{$&}]" 188 188 eat $& 189 189 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 = $ 3192 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) 193 193 link = link_node[:zip].to_s + rest 194 194 end … … 221 221 store @helper.make_link(:title=>title,:id=>id,:sharp=>sharp) 222 222 end 223 elsif @text =~ /\A"([^"]*)": :([a-zA-Z-]+)(\+*)((_[a-z]+|)(\.[a-z]+|)(#[a-z_\/\[\]]*|))/m223 elsif @text =~ /\A"([^"]*)":(#{PSEUDO_ID_REGEXP})((_[a-z]+|)(\.[a-z]+|)(#[a-z_\/\[\]]*|))/m 224 224 #puts "SHORTCUT_LINK:[#{$&}]" 225 225 eat $& 226 title, id, offset, mode = $1, $2, $3, $4227 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}" 229 229 if @parse_shortcuts 230 230 # replace shortcut 231 231 store "\"#{title}\":#{id}" 232 232 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 234 238 if id =~ /(.*?)#(.*)/ 235 239 id, sharp = $1, $2 … … 241 245 store $& 242 246 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]" 244 249 end 245 250 else … … 381 386 def parse_document_ids(str) 382 387 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) 386 390 if node.kind_of?(Document) 387 391 # replace shortcut … … 393 397 end 394 398 elsif @parse_shortcuts 395 ":#{id}#{offset}"399 id 396 400 else 397 401 nil # document not found trunk/lib/parser/test/parser/zazen.yml
r1100 r1219 36 36 Text updated in [July 2008]. 37 37 38 !30 .full!38 !30_full! 39 39 res: "<p>Text updated in [July 2008].</p>\n\n\n\t<p>[make_image id:|30| images:true mode:|full| style:||]</p>" 40 40 … … 83 83 84 84 image_with_format: 85 src: "!21 .mini!"85 src: "!21_mini!" 86 86 res: "<p>[make_image id:|21| images:true mode:|mini| style:||]</p>" 87 87 … … 99 99 100 100 image_with_link: 101 src: "!12 .pv!:12"101 src: "!12_pv!:12" 102 102 res: "<p>[make_image id:|12| images:true link:|12| mode:|pv| style:||]</p>" 103 103 104 104 image_with_link_mode: 105 src: "!12 .pv!:20_changes"105 src: "!12_pv!:20_changes" 106 106 res: "<p>[make_image id:|12| images:true link:|20_changes| mode:|pv| style:||]</p>" 107 107 108 108 image_with_link_mode_and_format: 109 src: "!12 .pv!:20_med.data"109 src: "!12_pv!:20_med.data" 110 110 res: "<p>[make_image id:|12| images:true link:|20_med.data| mode:|pv| style:||]</p>" 111 111 112 112 image_with_http_link: 113 src: "!12 .pv!:http://www.example.org"113 src: "!12_pv!:http://www.example.org" 114 114 res: "<p>[make_image id:|12| images:true link:|http://www.example.org| mode:|pv| style:||]</p>" 115 115 trunk/test/helpers/zazen_test.rb
r1212 r1219 8 8 super 9 9 end 10 10 11 11 # all these additions are replaced by the traduction of 'unknown link' if the user does not have read access to the linked node. 12 12 def test_bad_link 13 13 assert_match %r{unknown link}, zazen('"hello":99') 14 14 end 15 15 16 16 def test_wiki_link 17 17 login(:tiger) … … 19 19 assert_match %r{<cite>blah</cite> <cite>blih <a.*>test</a> it</cite>}, zazen('??blah?? ??blih ?test? it??') 20 20 end 21 21 22 22 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 32 30 end 33 31 34 32 def test_make_link 35 33 login(:tiger) … … 43 41 44 42 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'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'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'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's a lake' class='std'/></a></p>", zazen('!024!') 52 48 end 53 49 … … 56 52 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!') 57 53 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!') 59 55 end 60 56 … … 64 60 65 61 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!') 77 71 end 78 72 79 73 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!') 85 77 end 86 78 87 79 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!') 93 83 end 94 84 95 85 def test_make_gallery 96 86 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('![]!') 104 92 end 105 93 106 94 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}!')) 120 106 end 121 107 122 108 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') 130 114 end 131 115 132 116 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') 136 118 end 137 119 138 120 def test_empty_image_ref 139 121 assert_equal '<p>!!</p>', zazen('!!') … … 141 123 assert_equal "<p>!!!</p>", zazen('!!!') 142 124 end 143 125 144 126 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) 148 128 end 149 129 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 150 162 end trunk/test/helpers/zena_parser/zazen.yml
r1101 r1219 29 29 30 30 complex_link: 31 tem: <%= zazen("p<. !<.31 .pv!:22\n\nh4(clear). \"\":22") %>31 tem: <%= zazen("p<. !<.31_pv!:22\n\nh4(clear). \"\":22") %> 32 32 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>" 33 33 … … 50 50 zip_shortcut_link_with_mode_format: 51 51 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>./" 53 53 54 54 zip_shortcut_image: … … 57 57 58 58 zip_shortcut_image_with_options: 59 tem: "<%= zazen('Look !<.:lake .med! or !=.:lake+.pv!') %>"59 tem: "<%= zazen('Look !<.:lake_med! or !=.:lake+_pv!') %>" 60 60 res: "/<p>Look \[projects/cleanWater/lakeAddress is not a document\] or .*center.*<img src=.*image24_pv.jpg/" 61 61 trunk/test/sites/zena/versions.yml
r1217 r1219 78 78 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. 79 79 80 !<.31 .med!80 !<.31_med! 81 81 82 82 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 156 156 imf = Iformat.create(:name => 'header', :height=>'34', :width => '500', :size => 'force') 157 157 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'] 159 159 end 160 160 trunk/test/unit/node_test.rb
r1217 r1219 32 32 login(:tiger) 33 33 [ 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!"], 36 36 37 37 ["Hi ![30,:lake+]! ![]!", … … 41 41 "Hi !{30,24}! !{}!"], 42 42 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"], 45 45 46 46 ["Hi, this is normal "":1/ just a\n\n* asf\n* asdf ![23,33]!", … … 1333 1333 end 1334 1334 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 1335 1349 def test_safe_attribute 1336 1350 login(:ant)
