Changeset 591
- Timestamp:
- 2007-06-01 17:14:29 (2 years ago)
- Files:
-
- trunk/app/helpers/application_helper.rb (modified) (3 diffs)
- trunk/lib/parser/lib/rules/zafu.rb (modified) (2 diffs)
- trunk/lib/parser/lib/rules/zena.rb (modified) (2 diffs)
- trunk/lib/parser/test/parser_test.rb (modified) (1 diff)
- trunk/lib/parser/test/zafu.yml (modified) (1 diff)
- trunk/test/helpers/basic.yml (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
trunk/app/helpers/application_helper.rb
r590 r591 874 874 def show_path(opts={}) 875 875 node = opts[:node] || @node 876 tag = opts[:tag] || 'li' 877 join = opts[:join] || ' / ' 876 878 nav = [] 877 879 node.ancestors.each do |obj| … … 880 882 881 883 nav << "<a href='#{url_for(zen_path(node))}' class='current'>#{node.name}</a>" 882 res = "<ul class='path'>" 883 "#{res}<li>#{nav.join(" / </li><li>")}</li></ul>" 884 res = "#{res}<#{tag}>#{nav.join("</#{tag}>#{join}<#{tag}>")}</#{tag}>" 884 885 end 885 886 … … 969 970 "" 970 971 else 972 if opts[:tag] 973 tag_in = "<#{opts[:tag]}>" 974 tag_out = "</#{opts[:tag]}>" 975 else 976 tag_in = tag_out = '' 977 end 971 978 res = [] 972 979 visitor.site.lang_list.sort.each do |l| 973 980 if l == lang 974 res << "<b>#{l}</b>" 981 if opts[:tag] 982 res << "<#{opts[:tag]} class='on'>#{l}" + tag_out 983 else 984 res << "<em>#{l}</em>" 985 end 975 986 else 976 987 if visitor.is_anon? && params[:prefix] 977 res << link_to(l, :overwrite_params => {:prefix => l})988 res << tag_in + link_to(l, :overwrite_params => {:prefix => l}) + tag_out 978 989 else 979 res << link_to(l, :overwrite_params => {:lang => l})990 res << tag_in + link_to(l, :overwrite_params => {:lang => l}) + tag_out 980 991 end 981 992 end 982 993 end 983 res.join( ' | ')994 res.join(opts[:join] || ' | ') 984 995 end 985 996 end trunk/lib/parser/lib/rules/zafu.rb
r560 r591 80 80 81 81 def r_ignore 82 super83 82 @html_tag_done = true 84 "" 85 end 83 '' 84 end 85 86 alias r_ r_ignore 86 87 87 88 def r_rename_asset … … 247 248 # puts "TAG(#{@method}): [#{@text}]" 248 249 if @text =~ /\A<r:([\w_]+)([^>]*?)(\/?)>/ 249 # puts "RTAG:#{$~.to_a.inspect} }" # ztag250 # puts "RTAG:#{$~.to_a.inspect}" # ztag 250 251 eat $& 251 252 opts.merge!(:method=>$1, :params=>$2) 252 253 opts.merge!(:text=>'') if $3 != '' 253 254 make(:void, opts) 254 elsif @text =~ /\A<(\w+)([^>]*?)do\s*=(' |")([^\3]*?[^\\])\3([^>]*?)(\/?)>/255 # puts "DO: [#{$&}]}" # do tag255 elsif @text =~ /\A<(\w+)([^>]*?)do\s*=('([^>]*?[^\\]|)'|"([^>]*?[^\\]|)")([^>]*?)(\/?)>/ 256 # puts "DO:#{$~.to_a.inspect}" # do tag 256 257 eat $& 257 opts.merge!(:method=> $4, :html_tag=>$1, :html_tag_params=>$2, :params=>$5)258 opts.merge!(:text=>'') if $ 6!= ''258 opts.merge!(:method=>($4||$5), :html_tag=>$1, :html_tag_params=>$2, :params=>$6) 259 opts.merge!(:text=>'') if $7 != '' 259 260 make(:void, opts) 260 261 elsif @end_tag && @text =~ /\A<#{@end_tag}([^>]*?)(\/?)>/ 261 # puts "SAME: [#{$&}]}" # simple html tag same as end_tag262 # puts "SAME:#{$~.to_a.inspect}" # simple html tag same as end_tag 262 263 flush $& 263 264 @end_tag_count += 1 unless $2 == '/' 264 265 elsif @text =~ /\A<(link|img|script)/ 265 # puts "HTML:[#{$&}] }" # html266 # puts "HTML:[#{$&}]" # html 266 267 make(:asset) 267 268 elsif @text =~ /\A[^>]*?>/ trunk/lib/parser/lib/rules/zena.rb
r590 r591 1 class ActiveRecord::Base 2 @@_zafu_readable ||= {} # defined for each class 3 @@_zafu_readable_attributes ||= {} # full list with inherited attributes 1 begin 2 class ActiveRecord::Base 3 @@_zafu_readable ||= {} # defined for each class 4 @@_zafu_readable_attributes ||= {} # full list with inherited attributes 4 5 5 def self.zafu_readable(*list) 6 @@_zafu_readable[self] ||= [] 7 @@_zafu_readable[self] = (@@_zafu_readable[self] + list.map{|l| l.to_s}).uniq 6 def self.zafu_readable(*list) 7 @@_zafu_readable[self] ||= [] 8 @@_zafu_readable[self] = (@@_zafu_readable[self] + list.map{|l| l.to_s}).uniq 9 end 10 11 def self.zafu_readable_attributes 12 @@_zafu_readable_attributes[self] ||= if superclass == ActiveRecord::Base 13 @@_zafu_readable[self] || [] 14 else 15 (superclass.zafu_readable_attributes + (@@_zafu_readable[self] || [])).uniq.sort 16 end 17 end 18 19 def self.zafu_readable?(sym) 20 if sym.to_s =~ /(.*_for)_zips$/ 21 return true if defined_role[$1] 22 elsif sym.to_s =~ /(.*)_zips$/ 23 return true if defined_role[$1.pluralize] 24 elsif sym.to_s =~ /(.*)_zip$/ 25 return true if defined_role[$1] 26 end 27 self.zafu_readable_attributes.include?(sym.to_s) 28 end 29 30 def zafu_read(sym) 31 return "'#{sym}' not readable" unless self.class.zafu_readable?(sym) 32 self.send(sym) 33 end 8 34 end 9 10 def self.zafu_readable_attributes 11 @@_zafu_readable_attributes[self] ||= if superclass == ActiveRecord::Base 12 @@_zafu_readable[self] || [] 13 else 14 (superclass.zafu_readable_attributes + (@@_zafu_readable[self] || [])).uniq.sort 15 end 16 end 17 18 def self.zafu_readable?(sym) 19 if sym.to_s =~ /(.*_for)_zips$/ 20 return true if defined_role[$1] 21 elsif sym.to_s =~ /(.*)_zips$/ 22 return true if defined_role[$1.pluralize] 23 elsif sym.to_s =~ /(.*)_zip$/ 24 return true if defined_role[$1] 25 end 26 self.zafu_readable_attributes.include?(sym.to_s) 27 end 28 29 def zafu_read(sym) 30 return "'#{sym}' not readable" unless self.class.zafu_readable?(sym) 31 self.send(sym) 32 end 35 rescue NameError 36 puts "Testing out of Rails, ActiveRecord uninitialized." 33 37 end 34 38 … … 42 46 class_eval <<-END 43 47 def r_#{name} 44 "<%= #{name}(:node=>\#{node} ) %>"48 "<%= #{name}(:node=>\#{node}\#{params_to_erb(@params)}) %>" 45 49 end 46 50 END trunk/lib/parser/test/parser_test.rb
r560 r591 44 44 testfile :zafu, :zafu_asset, :zafu_insight, :zazen 45 45 def test_single 46 do_test('zafu', 'i nclude_part_far_away')46 do_test('zafu', 'ignore_do_empty') 47 47 end 48 48 trunk/lib/parser/test/zafu.yml
r560 r591 14 14 src: "<div class='test'><p>some <i>funny</i> text</p></div>" 15 15 res: "<div class='test'><p>some <i>funny</i> text</p></div>" 16 17 ignore_tag: 18 src: "there is <li do='ignore'>delete me</li>nothing" 19 res: "there is nothing" 20 21 ignore_do_empty: 22 src: "there is <li do=''>delete me</li>nothing left" 23 res: "there is nothing left" 16 24 17 25 hello_skip_content: trunk/test/helpers/basic.yml
r590 r591 225 225 src: "<div id='lang' do='lang_links'><a>en</a> | <b>fr</b></div>" 226 226 tem: "<div id='lang'><%= lang_links(:node=>@node) %></div>" 227 res: "/<div id='lang'>< b>en.*\|.*test_render.*=fr/"227 res: "/<div id='lang'><em>en.*\|.*test_render.*=fr/" 228 228 229 229 show_path:
