Changeset 1063
- Timestamp:
- 2008-06-16 12:49:04 (7 months ago)
- Files:
-
- trunk/README (modified) (1 diff)
- trunk/app/controllers/nodes_controller.rb (modified) (1 diff)
- trunk/app/helpers/application_helper.rb (modified) (2 diffs)
- trunk/app/views/data_entries/edit.rjs (modified) (1 diff)
- trunk/app/views/nodes/create.rjs (modified) (1 diff)
- trunk/lib/parser/lib/rules/zena.rb (modified) (15 diffs)
- trunk/lib/parser/test/parser/zafu.yml (modified) (1 diff)
- trunk/test/helpers/zena_parser/ajax.yml (modified) (4 diffs)
- trunk/test/helpers/zena_parser/basic.yml (modified) (6 diffs)
- trunk/test/helpers/zena_parser/relations.yml (modified) (1 diff)
- trunk/test/unit/site_test.rb (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
trunk/README
r1061 r1063 94 94 # make && make install 95 95 96 === 3. Gems96 === 3. install Gems 97 97 98 98 # does not work with gettext > 1.90.0 trunk/app/controllers/nodes_controller.rb
r1053 r1063 272 272 positions.each_with_index do |zip,idx| 273 273 child = secure!(Node) { Node.find_by_zip(zip) } 274 child.position = idx 274 child.position = idx.to_f + 1.0 275 275 allOk = child.save && allOK 276 276 end trunk/app/helpers/application_helper.rb
r1061 r1063 743 743 end 744 744 745 # TODO: test745 # TODO: is this still used ? 746 746 def show(obj, sym, opt={}) 747 747 return show_title(obj, opt) if sym == :v_title … … 769 769 lang = obj.content_lang 770 770 lang = lang ? " lang='#{lang}'" : "" 771 text = "<code#{lang} class='full'> HEYHEY#{text.gsub("\n", '<br/>')}</code>"771 text = "<code#{lang} class='full'>#{text}</code>" 772 772 end 773 773 text = zazen(text, opt) trunk/app/views/data_entries/edit.rjs
r1062 r1063 1 page.replace "#{params[:dom_id]} .#{@data_entry.zip}", :file => fullpath_from_template_url + "_form.erb"1 page.replace "#{params[:dom_id]}_#{@data_entry.zip}", :file => fullpath_from_template_url + "_form.erb" trunk/app/views/nodes/create.rjs
r1062 r1063 8 8 @node = @node.parent.new_child(:class => @node.class) 9 9 page.replace "#{params[:dom_id]}_form", :file => fullpath_from_template_url + "_form.erb" 10 puts params[:done]11 10 if params[:done] 12 11 page << params[:done] trunk/lib/parser/lib/rules/zena.rb
r1062 r1063 360 360 # Define a block of elements to be used by ajax calls (edit/filter) 361 361 def r_block 362 @context[:dom_id] = "#{self.dom_id} .\#{#{node_id}}"363 @context[:erb_dom_id] = "#{self.dom_id} .#{erb_node_id}"362 @context[:dom_id] = "#{self.dom_id}_\#{#{node_id}}" 363 @context[:erb_dom_id] = "#{self.dom_id}_#{erb_node_id}" 364 364 365 365 if @context[:block] == self … … 374 374 template_url = get_template_url 375 375 form_url = template_url + '_form' 376 @context[:dom_id] = "#{self.dom_id} .\#{#{node_id}}"377 @context[:erb_dom_id] = "#{self.dom_id} .#{erb_node_id}"376 @context[:dom_id] = "#{self.dom_id}_\#{#{node_id}}" 377 @context[:erb_dom_id] = "#{self.dom_id}_#{erb_node_id}" 378 378 379 379 @html_tag ||= 'div' … … 581 581 unless @params[:empty] == 'true' 582 582 out "<% if #{node}.kind_of?(TextDocument); l = #{node}.content_lang -%>" 583 out "<%= zazen(\"<code\#{l ? \" lang='\#{l}'\" : ''} class=\\'full\\'>\#{#{text}}</code>\") %> </div>"583 out "<%= zazen(\"<code\#{l ? \" lang='\#{l}'\" : ''} class=\\'full\\'>\#{#{text}}</code>\") %>" 584 584 out "<% else -%>" 585 585 out "<%= zazen(#{text}#{limit}, :node=>#{node}) %>" … … 865 865 form << "<%= error_messages_for(#{node}) %>" 866 866 867 unless descendant('cancel') || descendant('edit') || descendant('form_tag') 868 # add a descendant before blocks. 869 blocks_bak = @blocks.dup # I do not understand why we need 'dup' (but we sure do...) 870 @blocks = [make(:void, :method=>'void', :text=>cancel)] + blocks_bak 867 if !descendant('cancel') && !descendant('edit') 868 if !descendant('form_tag') 869 # add a descendant before blocks. 870 blocks_bak = @blocks.dup # I do not understand why we need 'dup' (but we sure do...) 871 @blocks = [make(:void, :method=>'void', :text=>cancel)] + blocks_bak 872 else 873 form = cancel + form 874 cancel = '' 875 blocks_bak = @blocks 876 end 871 877 else 872 878 blocks_bak = @blocks 873 end874 875 if !descendant('cancel') && !descendant('edit')876 form = cancel + form877 879 end 878 880 … … 1026 1028 @html_tag_params ||= {} 1027 1029 dom_id = parent.method == 'each' ? @context[:erb_dom_id] : unique_name 1028 @html_tag_params[:id] = "#{dom_id} .#{erb_node_id}"1030 @html_tag_params[:id] = "#{dom_id}_#{erb_node_id}" 1029 1031 @html_tag_params[:class] ||= 'drop' 1030 1032 … … 1050 1052 @html_tag_params ||= {} 1051 1053 dom_id = unique_name 1052 @html_tag_params[:id] = "#{dom_id} .#{erb_node_id}"1054 @html_tag_params[:id] = "#{dom_id}_#{erb_node_id}" 1053 1055 case @params[:revert] 1054 1056 when 'move' … … 1074 1076 end 1075 1077 #dom_id = "#{@context[:dom_id]}.\#{#{node_id}}" 1076 erb_dom_id = "#{@context[:erb_dom_id]} .#{erb_node_id}"1078 erb_dom_id = "#{@context[:erb_dom_id]}_#{erb_node_id}" 1077 1079 if node_kind_of?(Node) 1078 1080 out "<% if #{node}[:link_id] -%>" … … 1085 1087 out "</a><% end -%>" 1086 1088 elsif node_kind_of?(DataEntry) 1087 dom_id = "#{@context[:dom_id]} .\#{#{node_id}}"1089 dom_id = "#{@context[:dom_id]}_\#{#{node_id}}" 1088 1090 out "<%= link_to_remote(#{text.inspect}, {:url => \"/data_entries/\#{#{node}[:id]}?remove=#{dom_id}\", :method => :delete}, :class=>#{(@params[:class] || 'unlink').inspect}) %>" 1089 1091 end … … 1183 1185 join = @params[:join] || '' 1184 1186 join = join.gsub(/<([^%])/, '<\1').gsub(/([^%])>/, '\1>') 1185 out "<% #{list}.each_ index do |#{var}_index| -%>"1186 out "<%= #{var} =#{list}[#{var}_index]; #{var}_index > 0 ? #{join.inspect} : '' %>"1187 out "<% #{list}.each_with_index do |#{var},#{var}_index| -%>" 1188 out "<%= #{var}_index > 0 ? #{join.inspect} : '' %>" 1187 1189 1188 1190 if alt_class = @params[:alt_class] 1189 1191 if html_class = @html_tag_params.delete(:class) 1190 html_append = " class=' <%= #{var}_index % 2 != 0 ? #{alt_class.inspect} : #{html_class.inspect}%>'"1192 html_append = " class='#{html_class}<%= #{var}_index % 2 != 0 ? #{(' ' + alt_class).inspect} : '' %>'" 1191 1193 else 1192 1194 html_append = "<%= #{var}_index % 2 != 0 ? ' class=#{alt_class.inspect}' : '' %>" … … 1206 1208 1207 1209 if @params[:draggable] == 'true' 1208 out "<% #{var}_dom_ids << \"#{dom_id} .\#{#{node_id(var)}}\" -%>"1210 out "<% #{var}_dom_ids << \"#{dom_id}_\#{#{node_id(var)}}\" -%>" 1209 1211 end 1210 1212 … … 1215 1217 if @context[:template_url] || @params[:draggable] == 'true' || descendant('unlink') 1216 1218 # ajax, set id, class 1217 id_hash = {:id=> "#{erb_dom_id} .#{erb_node_id(var)}"}1219 id_hash = {:id=> "#{erb_dom_id}_#{erb_node_id(var)}"} 1218 1220 if @html_tag 1219 1221 @html_tag_params.merge!(id_hash) … … 1235 1237 erb_dom_id = "<%= params[:dom_id] %>" 1236 1238 dom_id = "\#{params[:dom_id]}" 1237 id_hash = {:id=>"#{erb_dom_id} .<%= @#{base_class.to_s.underscore}.zip %>"}1239 id_hash = {:id=>"#{erb_dom_id}_<%= @#{base_class.to_s.underscore}.zip %>"} 1238 1240 if @html_tag 1239 1241 @html_tag_params.merge!(id_hash) … … 1243 1245 end 1244 1246 if @params[:draggable] == 'true' 1245 out "<script type='text/javascript'>\n//<![CDATA[\nZena.draggable('#{@context[:erb_dom_id]} .<%= @#{base_class.to_s.underscore}.zip %>')\n//]]>\n</script>"1247 out "<script type='text/javascript'>\n//<![CDATA[\nZena.draggable('#{@context[:erb_dom_id]}_<%= @#{base_class.to_s.underscore}.zip %>')\n//]]>\n</script>" 1246 1248 end 1247 1249 else … … 1937 1939 1938 1940 @context.merge!(opts) # pass options from 'zafu_known_contexts' to @context 1939 @context[:dom_id] = "#{self.dom_id} .\#{#{node_id}}"1940 @context[:erb_dom_id] = "#{self.dom_id} .#{erb_node_id}"1941 @context[:dom_id] = "#{self.dom_id}_\#{#{node_id}}" 1942 @context[:erb_dom_id] = "#{self.dom_id}_#{erb_node_id}" 1941 1943 if (each_block = descendant('each')) && (descendant('edit') || descendant('add') || descendant('add_document') || (descendant('swap') && descendant('swap').parent.method != 'block')) 1942 1944 # ajax, build template. We could merge the following code with 'r_block'. … … 1947 1949 end 1948 1950 1949 template_url = each_block.get_template_url(@context)1951 template_url = get_template_url(@context) # each_block.get_template_url(@context) 1950 1952 1951 1953 # should we publish ? trunk/lib/parser/test/parser/zafu.yml
r1055 r1063 242 242 res: "[test][hello/]<!-- this is nothing > <r:hello/> -->[/test]" 243 243 244 html_comments_not_greedy: 245 src: "<r:test><!-- first --><r:hello/><!-- this is nothing > <r:hello/> --></r:test>" 246 res: "[test]<!-- first -->[hello/]<!-- this is nothing > <r:hello/> -->[/test]" 247 244 248 html_do_comment: 245 249 src: "<r:test><r:hello/><!--|this is not a comment <r:hello/> --></r:test>" trunk/test/helpers/zena_parser/ajax.yml
r1061 r1063 21 21 add_each_no_form: 22 22 src: "<ul do='children' id='things'><li do='each'>I <p do='[name]'>blah</p></li><li do='add'/></ul>" 23 res: "/<ul><li.*id='things_ add'.*li id='things_form'.*form.*hidden.*I <p><input type='text' id='things_name' name='node\[name\]' value=''\/><\/p><\/form><\/li>/"23 res: "/<ul><li.*id='things_22_add'.*li id='things_22_form'.*form.*hidden.*I <p><input type='text' id='things_22_name' name='node\[name\]' value=''\/><\/p><\/form><\/li>/" 24 24 25 25 add_each_no_form_date: 26 26 src: "<ul do='children' id='things'><li do='each'>I <p do='show' date='event_at' tformat='short_date'>blah</p></li><li do='add'/></ul>" 27 res: "/<ul><li.*id='things_ add'.*li id='things_form'.*form.*hidden.*I <p>.*date_box.*<input id='things_event_at' name='node\[event_at\]' type='text' value.*/m"27 res: "/<ul><li.*id='things_22_add'.*li id='things_22_form'.*form.*hidden.*I <p>.*date_box.*<input id='things_22_event_at' name='node\[event_at\]' type='text' value.*/m" 28 28 29 29 add_each_no_form_focus: 30 30 src: "<ul do='children' id='test'><li do='each'>I <p do='[v_title]'>blah</p></li><li do='add' focus='v_title'/></ul>" 31 res: "/<ul><li.*id=.*_add.*onclick.*toggle.*test_ v_title.*focus.*li id=.*_form.*form.*hidden.*I <p><input type='text' id='test_v_title' name='node\[v_title\]' value=''\/><\/p><\/form><\/li>/"31 res: "/<ul><li.*id=.*_add.*onclick.*toggle.*test_22_v_title.*focus.*li id=.*_form.*form.*hidden.*I <p><input type='text' id='test_22_v_title' name='node\[v_title\]' value=''\/><\/p><\/form><\/li>/" 32 32 33 33 each_add_with_form: … … 40 40 <li do='form'><input name='v_title'/> this is the form</li> 41 41 </r:children> 42 res: "/<li.*list .29.30.*>bird.*<li.*list.29.31.*>flower.*<li.*list_add.*list_form.*toggle.*<li .*list_form.*style.*none.*Ajax.Request.*input type='hidden' name='template_url' value=\"/each/add/with/form/list\".*input type='hidden' name='node\[parent_id\]' value=\"29\"/"42 res: "/<li.*list_29_30.*>bird.*<li.*list_29_31.*>flower.*<li.*list_29_add.*list_29_form.*toggle.*<li .*list_29_form.*style.*none.*Ajax.Request.*input type='hidden' name='template_url' value=\"/each/add/with/form/list\".*input type='hidden' name='node\[parent_id\]' value=\"29\"/" 43 43 44 44 each_add_with_form_klass_set: … … 66 66 make_form: 67 67 src: "<ul do='children'><li do='each' do='[name]'/><li do='add'/></ul>" 68 tem: "/<li id='list_ form' style='display:none;'><%= form_remote_tag\(:url => nodes_path\) %>/"69 'make/form/en/list.erb': "<li id=' list.<%= @node.zip %>'><%= @node.name %></li>"70 'make/form/en/list_form.erb': "/<li id=' list<%= @node.new_record\? \? '_form' : \".#\{@node.zip\}\"%>'>/"68 tem: "/<li id='list_<%= @node.zip %>_form' style='display:none;'><%= form_remote_tag\(:url => nodes_path\) %>/" 69 'make/form/en/list.erb': "<li id='<%= params[:dom_id] %>_<%= @node.zip %>'><%= @node.name %></li>" 70 'make/form/en/list_form.erb': "/<li id='<%= params\[:dom_id\] %><%= @node.new_record\? \? '_form' : '' %>'>/" 71 71 72 72 each_edit_cannot_write: … … 79 79 add_each_publish: 80 80 src: "<ul do='children' id='things'><li do='each'>I <p do='[name]'>blah</p></li><li do='add' publish='true'/></ul>" 81 res: "/<ul><li.*id='things_ add'.*li id='things_form'.*form.*hidden.*name='node\[v_status\]' value=\"50\"/"81 res: "/<ul><li.*id='things_22_add'.*li id='things_22_form'.*form.*hidden.*name='node\[v_status\]' value=\"50\"/" 82 82 83 83 block_edit_form: trunk/test/helpers/zena_parser/basic.yml
r1061 r1063 398 398 context: 399 399 node: 'collections' 400 src: "<ol do='pages'><li class=' one' alt_class='two' do='each' do='[name]'/></ol>"401 res: "<ol><li class=' one'>art</li><li class='two'>menu</li><li class='one'>news</li><li class='two'>wiki_skin</li></ol>"400 src: "<ol do='pages'><li class='post' alt_class='stripe' do='each' do='[name]'/></ol>" 401 res: "<ol><li class='post'>art</li><li class='post stripe'>menu</li><li class='post'>news</li><li class='post stripe'>wiki_skin</li></ol>" 402 402 403 403 each_alternate_class_ajax: … … 730 730 res: "<div id='v_summary11' class='zazen'><p>This is the root of your peaceful tests.</p></div>" 731 731 732 text: 733 src: "<r:text/>" 734 res: "<div id='v_text22' class='zazen'><p>status text</p></div>" 735 736 text_code: 737 context: 738 node: 'Project_zafu' 739 src: "<r:text/>" 740 res: "/\\A<div id='v_text60' class='zazen'><pre class='full'><code class='zafu'>.*</code></pre></div>\\Z/" 741 732 742 ztag_in_do: 733 743 src: "<ol do='parent'><r:children>no error</r:children></ol>" … … 790 800 input_set_value: 791 801 src: "<r:input type='hidden' name='icon_id' set_value='[main.id]'/>" 792 tem: "<input name='node[icon_id]' type='hidden' value='<%= @node.zip %>'/>"793 res: "<input name='node[icon_id]' type='hidden' value='22'/>"802 tem: "<input id='node_icon_id' name='node[icon_id]' type='hidden' value='<%= @node.zip %>'/>" 803 res: "<input id='node_icon_id' name='node[icon_id]' type='hidden' value='22'/>" 794 804 795 805 input: … … 797 807 node: 'ant' 798 808 src: "<r:input name='c_first_name'/>" 799 tem: "<input name='node[c_first_name]' type='text' value='<%= @node.c_zafu_read(\"first_name\") %>'/>"800 res: "<input name='node[c_first_name]' type='text' value='Solenopsis'/>"809 tem: "<input id='node_c_first_name' name='node[c_first_name]' type='text' value='<%= @node.c_zafu_read(\"first_name\") %>'/>" 810 res: "<input id='node_c_first_name' name='node[c_first_name]' type='text' value='Solenopsis'/>" 801 811 802 812 input_new: … … 811 821 <tr do='add'><td><b><r:add_btn/></b></td></tr> 812 822 </table>" 813 res: "/<tr class='btn_add' id='list_ add'><td><b><a href='#' onclick/"823 res: "/<tr class='btn_add' id='list_22_add'><td><b><a href='#' onclick/" 814 824 815 825 read_no_content: … … 903 913 lang: 'fr' 904 914 src: "<r:captcha theme='clean'/>" 905 res: "/RecaptchaOptions = . lang : .fr., theme : .clean., tabindex : 0/"915 res: "/RecaptchaOptions .* theme : .clean./" trunk/test/helpers/zena_parser/relations.yml
r1059 r1063 96 96 store_in_block: 97 97 src: "<r:block><r:node select='18' store='found' do='pages'><r:show attr='name'/>: <r:node select='found' do='[name]'/></r:node></r:block>" 98 res: "<div id='list .22'>projects: status</div>"98 res: "<div id='list_22'>projects: status</div>" 99 99 100 100 store_outside_block: 101 101 src: "<r:node select='18' store='found' do='pages'><r:block><r:show attr='name'/>: <r:node select='found' do='[name]'/></r:block></r:node>" 102 res: "<div id='list .18'>projects: status</div>"103 'store/outside/en/block/list .erb': "/unknown relation 'found'/"102 res: "<div id='list1_18'>projects: status</div>" 103 'store/outside/en/block/list1.erb': "/unknown relation 'found'/" 104 104 105 105 store_node_as_relation: trunk/test/unit/site_test.rb
r1061 r1063 228 228 229 229 def test_attributes_for_form 230 puts Site.attributes_for_form.inspect 230 assert Site.attributes_for_form[:bool].include?(:authentication) 231 assert Site.attributes_for_form[:text].include?(:default_lang) 231 232 end 232 233 end
