Changeset 612
- Timestamp:
- 2007-06-07 17:23:27 (2 years ago)
- Files:
-
- trunk/app/controllers/application.rb (modified) (1 diff)
- trunk/app/helpers/application_helper.rb (modified) (2 diffs)
- trunk/lib/parser/lib/rules/zazen.rb (modified) (1 diff)
- trunk/lib/parser/lib/rules/zena.rb (modified) (2 diffs)
- trunk/lib/parser/test/parser_test.rb (modified) (1 diff)
- trunk/lib/parser/test/zazen.yml (modified) (1 diff)
- trunk/public/stylesheets/reset.css (modified) (1 diff)
- trunk/test/helpers/basic.yml (modified) (2 diffs)
- trunk/test/helpers/zena_parser_test.rb (modified) (1 diff)
- trunk/test/unit/multiversion_test.rb (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
trunk/app/controllers/application.rb
r599 r612 42 42 def visitor 43 43 @visitor ||= returning(User.make_visitor(:host => request.host, :id => session[:user])) do |user| 44 session[:user] = user[:id] 44 if session[:user] != user[:id] 45 # changed user (login/logout) 46 session[:user] = user[:id] 47 session[:lang] = user.lang 48 end 45 49 end 46 50 end trunk/app/helpers/application_helper.rb
r607 r612 701 701 text = opts[:text] 702 702 node = opts[:node] 703 hash = { :node_id => node[:zip], :id => node.v_number } 703 # hash = { :node_id => node[:zip], :id => node.v_number } = this is bad: we should not preload a specific version when doing 704 # node actions 705 hash = { :node_id => node[:zip], :id => 0 } 704 706 705 707 res = [] … … 902 904 end 903 905 904 url = if dash = options.delete(:dash)905 if dash=~ /\[(.+)\]/906 dash_value = node.zafu_read($1)907 else 908 dash_value = "node#{node[:zip]}"909 end 910 if dash_in = options.delete(:dash_in)911 dash_node = node.relation(dash_in) || node912 "#{zen_path( dash_node, options)}##{dash_value}"913 else 914 "##{ dash_value}"906 url = if sharp = options.delete(:sharp) 907 if sharp =~ /\[(.+)\]/ 908 sharp_value = node.zafu_read($1) 909 else 910 sharp_value = "node#{node[:zip]}" 911 end 912 if sharp_in = options.delete(:sharp_in) 913 sharp_node = node.relation(sharp_in) || node 914 "#{zen_path(sharp_node, options)}##{sharp_value}" 915 else 916 "##{sharp_value}" 915 917 end 916 918 else trunk/lib/parser/lib/rules/zazen.rb
r611 r612 96 96 title, id = $1, $2 97 97 if id =~ /(.*)#(.*)/ 98 id, dash= $1, $299 dash = title if dash.blank?100 end 101 store @helper.make_link(:title=>title,:id=>id,: dash=>dash)98 id, sharp = $1, $2 99 sharp = title if sharp.blank? 100 end 101 store @helper.make_link(:title=>title,:id=>id,:sharp=>sharp) 102 102 else 103 103 flush @text[0..0] trunk/lib/parser/lib/rules/zena.rb
r611 r612 885 885 mode = '' 886 886 end 887 if dash = @params[:dash]888 dash = ", :dash=>#{dash.inspect}"889 else 890 dash= ''891 end 892 if dash_in = @params[:in]893 dash_in = ", :dash_in=>#{dash_in.inspect}"894 else 895 dash_in = ''887 if sharp = @params[:sharp] 888 sharp = ", :sharp=>#{sharp.inspect}" 889 else 890 sharp = '' 891 end 892 if sharp_in = @params[:in] 893 sharp_in = ", :sharp_in=>#{sharp_in.inspect}" 894 else 895 sharp_in = '' 896 896 end 897 897 898 898 html_tags = {} 899 899 if @html_tag && @html_tag != 'a' 900 # html attributes do not belong to anchor900 # html attributes do not belong to sharp 901 901 pre_space = '' 902 902 else … … 908 908 909 909 if text_mode == :raw 910 pre_space + "<a#{params_to_html(html_tags)} href='<%= node_link(:url_only=>true, :node=>#{lnode}#{href}#{url}#{ dash}#{dash_in}#{fmt}#{mode}) %>'>#{text}</a>"910 pre_space + "<a#{params_to_html(html_tags)} href='<%= node_link(:url_only=>true, :node=>#{lnode}#{href}#{url}#{sharp}#{sharp_in}#{fmt}#{mode}) %>'>#{text}</a>" 911 911 else 912 912 text = text.blank? ? '' : ", :text=>#{text}" 913 pre_space + "<%= node_link(:node=>#{lnode}#{text}#{href}#{url}#{ dash}#{dash_in}#{fmt}#{mode}#{params_to_erb(html_tags)}) %>"913 pre_space + "<%= node_link(:node=>#{lnode}#{text}#{href}#{url}#{sharp}#{sharp_in}#{fmt}#{mode}#{params_to_erb(html_tags)}) %>" 914 914 end 915 915 end trunk/lib/parser/test/parser_test.rb
r605 r612 56 56 testfile :zafu, :zafu_asset, :zafu_insight, :zazen 57 57 def test_single 58 do_test('zazen', 'link_ dash')58 do_test('zazen', 'link_sharp') 59 59 end 60 60 trunk/lib/parser/test/zazen.yml
r605 r612 124 124 res: '<p>[make_link id:|23| title:||]</p>' 125 125 126 link_ dash:126 link_sharp: 127 127 src: '"hello":23#world of fame' 128 res: "<p>[make_link dash:|world| id:|23| title:|hello|] of fame</p>"128 res: "<p>[make_link sharp:|world| id:|23| title:|hello|] of fame</p>" 129 129 130 link_ dash_same_as_title:130 link_sharp_same_as_title: 131 131 src: '"hello":23# I love you' 132 res: "<p>[make_link dash:|hello| id:|23| title:|hello|] I love you</p>"132 res: "<p>[make_link sharp:|hello| id:|23| title:|hello|] I love you</p>" 133 133 134 134 wiki_link: trunk/public/stylesheets/reset.css
r480 r612 31 31 } 32 32 input, textarea { font:inherit; } 33 pre, code { font:inherit; } trunk/test/helpers/basic.yml
r611 r612 136 136 res: "<a href='/oo'>Zena the wild CMS</a>" 137 137 138 link_ dash:139 src: "<r:link dash='true'/>"138 link_sharp: 139 src: "<r:link sharp='true'/>" 140 140 res: "<a href='#node22'>status title</a>" 141 141 142 link_ dash_name:143 src: "<r:link dash='[name]'/>"142 link_sharp_name: 143 src: "<r:link sharp='[name]'/>" 144 144 res: "<a href='#status'>status title</a>" 145 145 146 link_ dash_in:147 src: "<r:link dash='true' in='project' mode='tree'/>"146 link_sharp_in: 147 src: "<r:link sharp='true' in='project' mode='tree'/>" 148 148 res: "<a href='/oo/projects/cleanWater_tree.html#node22'>status title</a>" 149 149 150 link_ dash_name_in:151 src: "<r:link dash='[name]' in='parent'/>"150 link_sharp_name_in: 151 src: "<r:link sharp='[name]' in='parent'/>" 152 152 res: "<a href='/oo/projects/cleanWater.html#status'>status title</a>" 153 153 … … 223 223 src: "<h1 class='title' do='title' status='true' actions='all'>dummy</h1>" 224 224 tem: "<h1 class='title'><div class='s<%= @node.version.status %>'><%= show_title(:node=>@node) + node_actions(:node=>@node, :actions=>\"all\")%></div></h1>" 225 res: "/<h1 class='title'><div class='s50'><span id='v_title22'>status title</span><span class='actions'><a.*/nodes/22/versions/ 1/edit.*/images/page_edit.png'.*/></a>.*</span></div></h1>/"225 res: "/<h1 class='title'><div class='s50'><span id='v_title22'>status title</span><span class='actions'><a.*/nodes/22/versions/0/edit.*/images/page_edit.png'.*/></a>.*</span></div></h1>/" 226 226 227 227 show_c_width: trunk/test/helpers/zena_parser_test.rb
r608 r612 9 9 10 10 def test_single 11 do_test('basic', ' case_when_test_attribute')11 do_test('basic', 'show_title_options') 12 12 end 13 13 trunk/test/unit/multiversion_test.rb
r589 r612 36 36 node = secure(Node) { nodes(:lake) } # reload 37 37 assert_equal versions_id(:lake_en), node.version(:pub)[:id] 38 end 39 40 def test_find_version_latest_replaced 41 login(:tiger) 42 node = secure(Node) { nodes(:status) } 43 pub_version_id = node.v_id 44 assert_equal 2, node.versions.size 45 assert_equal Zena::Status[:pub], node.v_status 46 assert node.update_attributes(:v_title => 'great', :v_text => 'mind') 47 node = secure(Node) { nodes(:status) } 48 assert_equal Zena::Status[:red], node.v_status 49 red_version_id = node.v_id 50 assert_not_equal pub_version_id, red_version_id 51 assert node.remove 52 node = secure(Node) { nodes(:status) } 53 assert_equal pub_version_id, node.v_id 54 assert node.update_attributes(:v_title => 'slow') 55 assert_not_equal pub_version_id, node.v_id 56 assert_not_equal red_version_id, node.v_id 57 assert_not_equal 'mind', node.v_text 58 assert_equal 4, node.versions.size 38 59 end 39 60
