Changeset 1083
- Timestamp:
- 2008-07-01 01:22:30 (6 months ago)
- Files:
-
- trunk/app/models/node.rb (modified) (1 diff)
- trunk/app/views/templates/edit_tabs/_title.rhtml (modified) (2 diffs)
- trunk/app/views/virtual_classes/_form.erb (modified) (1 diff)
- trunk/db/migrate/000_zena/041_add_attributes_to_v_class.rb (added)
- trunk/db/schema.rb (modified) (1 diff)
- trunk/lib/parser/lib/rules/zena.rb (modified) (4 diffs)
- trunk/lib/query_builder/lib/query_builder.rb (modified) (1 diff)
- trunk/public/stylesheets/admin.css (modified) (1 diff)
- trunk/public/stylesheets/popup.css (modified) (1 diff)
- trunk/test/fixtures/files/ajax_test.zafu (modified) (1 diff)
- trunk/test/helpers/zena_parser/ajax.yml (modified) (4 diffs)
- trunk/test/helpers/zena_parser/basic.yml (modified) (1 diff)
- trunk/test/sites/zena/virtual_classes.yml (modified) (1 diff)
- trunk/test/unit/virtual_class_test.rb (modified) (1 diff)
- trunk/vendor/plugins/dyn_attributes/lib/dyn_attributes.rb (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
trunk/app/models/node.rb
r1081 r1083 726 726 def klass 727 727 vclass.to_s 728 end 729 730 def dyn_attribute_keys 731 (version.dyn.keys + (virtual_class ? virtual_class.dyn_keys.split(',').map(&:strip) : [])).uniq.sort 728 732 end 729 733 trunk/app/views/templates/edit_tabs/_title.rhtml
r810 r1083 1 1 <label for="v_title"><%= _("title") %></label> 2 <%= text_field 'node', 'v_title', :size=>nil %>2 <%= text_field 'node', 'v_title', :size=>nil, :class => 'full_width' %> 3 3 4 4 <label for='v_lang'><%= _("language") %></label> … … 12 12 <%= date_box('node', 'v_publish_from') %> 13 13 <label for="v_summary"><%= _("summary") %></label> 14 <%= text_area 'node', 'v_summary', :cols=>nil, :rows=>6, :value=>@node.v_summary %>14 <%= text_area 'node', 'v_summary', :cols=>nil, :rows=>6, :value=>@node.v_summary, :class => 'full_width' %> 15 15 16 16 <label for="v_comment"><%= _("comment") %></label> 17 <%= text_area 'node', 'v_comment', :cols=>nil, :rows=>2 %> 17 <%= text_area 'node', 'v_comment', :cols=>nil, :rows=>2, :class => 'full_width' %> 18 19 <% (@node.version.dyn.keys + (@node.virtual_class ? @node.virtual_class.attributes.split(',').map(&:strip) : [])).uniq.sort do |k| -%> 20 <label for="d_<%= k %>"><%= _(k) %></label> 21 <%= text_area 'node', "d_#{k}", :cols=>nil, :rows=>2, :class => 'full_width' %> 22 <% end -%> trunk/app/views/virtual_classes/_form.erb
r1060 r1083 19 19 <tr><td class='label'><%= _("create group")%></td><td><%= select('virtual_class', 'create_group_id', visitor.groups.map{|g| [g.name, g.id]} ) %></td></tr> 20 20 <tr><td class='label'><%= _("auto create discussion")%></td><td><%= check_box('virtual_class', 'auto_create_discussion') %></td></tr> 21 <tr><td class='label'><%= _("attributes")%></td><td><%= text_field('virtual_class', 'attributes') %></td></tr> 21 22 <tr><td colspan='2'><p class='btn_validate'><input type='submit' value='<%= _('validate') %>'/></p></td></tr> 22 23 </table> trunk/db/schema.rb
r1069 r1083 291 291 t.column "site_id", :integer, :null => false 292 292 t.column "auto_create_discussion", :boolean 293 t.column "dyn_keys", :text 293 294 end 294 295 trunk/lib/parser/lib/rules/zena.rb
r1082 r1083 1392 1392 out render_html_tag(@params[:text]) 1393 1393 else 1394 out render_html_tag(expand_with(:in_if=>false ))1394 out render_html_tag(expand_with(:in_if=>false, :only => nil)) # do not propagate :only from ancestor 'if' clause 1395 1395 end 1396 1396 else … … 1406 1406 return parser_error("condition error") unless cond 1407 1407 out "<% elsif #{cond} -%>" 1408 out render_html_tag(expand_with(:in_if=>false ))1408 out render_html_tag(expand_with(:in_if=>false, :only => nil)) # do not propagate :only from ancestor 'if' clause 1409 1409 end 1410 1410 … … 2216 2216 res = prefix + dom_prefix 2217 2217 end 2218 if method == 'each' 2218 if method == 'each' && !@context[:make_form] 2219 2219 "#{res}_\#{#{var}.zip}" 2220 2220 elsif method == 'unlink' … … 2241 2241 res = prefix + dom_prefix 2242 2242 end 2243 if method == 'each' 2243 if method == 'each' && @context[:make_form] 2244 2244 "#{res}_<%= #{var}.zip %>" 2245 elsif method == 'unlink' 2246 target = nil 2247 parent = self.parent 2248 while parent 2249 if ['block', 'each', 'context', 'icon'].include?(parent.method) 2250 target = parent 2251 break 2252 end 2253 parent = parent.parent 2254 end 2255 target ? target.erb_dom_id : res 2245 2256 else 2246 2257 res trunk/lib/query_builder/lib/query_builder.rb
r1081 r1083 212 212 op = $1.strip 213 213 rest = rest[$1.size..-1] 214 op = {'lt' => '<','le' => '<=','eq' => '=','ne' => '<>','ge' => '>=','gt' => '>','like' => 'LIKE', 'not like' => 'NOT LIKE'}[ $1] || $1214 op = {'lt' => '<','le' => '<=','eq' => '=','ne' => '<>','ge' => '>=','gt' => '>','like' => 'LIKE', 'not like' => 'NOT LIKE'}[op] || $1 215 215 res << op 216 216 allowed = [:value, :par_open] trunk/public/stylesheets/admin.css
r1008 r1083 39 39 .admin .btn_validate { float:right; margin-right:30px; } 40 40 .btn_validate input { background:#C8D8C7; border:1px outset black;} 41 .admin .label {width: 80px; line-height:1.9em;}41 .admin .label {width:150px; line-height:1.9em;} 42 42 .admin th { color:#450009; } 43 43 .admin .source, .admin .source_role { background:#DBBFBF;} trunk/public/stylesheets/popup.css
r1065 r1083 53 53 54 54 /* title */ 55 #node_v_title, #node_v_comment, #node_v_summary{ width:96%; font:inherit; font-size:0.9em; padding:2px;}55 .full_width { width:96%; font:inherit; font-size:0.9em; padding:2px;} 56 56 #title_tab select, #title_tab input {font:inherit; font-size:0.86em;} 57 57 .v_publish_from, .log_at, .event_at { padding:1px 2px; width:65%; text-align:center;} trunk/test/fixtures/files/ajax_test.zafu
r1081 r1083 14 14 15 15 <r:with part='context'/> 16 16 17 <r:with part='content' class='project'> 17 <r:include template='Node' part='related'/> 18 <div id='related'> 19 <ul do='pages'> 20 <li do='each'><p><b do='show' attr='v_title' edit='true' publish='true'/> <r:edit/></p> 21 <r:zazen attr='v_summary' edit='true' publish='true'/> 22 </li> 23 </ul> 24 This filter updates the "distant filter block test" 25 <r:filter live='true' update='upfi'/> 26 </div> 18 27 19 20 <h3>calendar test</h3> 21 <div do='calendar' find='notes in site'/> 28 <div id='edit' do='block'> 29 <h3>edit block test</h3> 30 <r:text/> 31 <r:edit publish='true'><r:if test='1 eq 2'>blue<r:else>edit in else</r:else></r:if></r:edit> 32 </div> 22 33 23 <h3>week calendar</h3> 24 <div do='calendar' find='notes in site' type='week'/> 34 <hr/> 25 35 26 <h3>tiny calendar</h3> 27 <div do='calendar' find='notes in site' size='tiny'/> 36 <h2>update target test</h2> 37 <div id='bozo' do='block'><h3 do='title' actions='all'/><r:img mode='pv'/> 38 <r:summary/> 39 </div> 28 40 29 <div id='edit'> 30 <h3>edit block test</h3> 31 <r:block> 32 <r:text/> 33 <r:edit><r:if test='1 eq 2'>blue<r:else>edit in else</r:else></r:if></r:edit> 34 </r:block> 35 </div> 41 <ul do='images in site'><r:each join=', ' do='link' update='bozo'/></ul> 36 42 37 <div id='filter'> 38 <h2>filter block test</h2> 39 <r:filter live='true'/> 40 <r:block do='pages where name like "[param:f]%"'> 41 <ol><li do='each' do='[name]'/></ol> 42 </r:block> 43 </div> 43 <hr/> 44 44 45 <h2>data test</h2> 46 <ol do='data'> 47 <li do='each'><r:edit/> <b do='[text]'/> <r:show attr='value_a'/> <r:show attr='value_b'/><r:unlink/></li> 48 <li do='form'><r:cancel/> <input name='text'/> <input name='value_a'/> <input name='value_b'/> <input type='submit'/></li> 49 <li do='add'/> 50 <r:set var='hours' do='stat' find='sum' from='value_a'/> <r:set var='exp' do='stat' find='sum' of='value_b'/> 51 <li><b><r:show var='hours'/> * 150.00 = <r:show eval='hours * 150'/> + <r:show var='exp'/> = <r:show eval='( hours * 150 ) + exp'/></b></li> 52 </ol> 45 <div id='upfi' do='block'> 46 <h2>distant filter block test</h2> 47 <ol do='pages where name like "[param:f]%" limit 5'><li do='each' do='[name]'/></ol> 48 </div> 49 50 <hr/> 51 52 <div id='filter'> 53 <h2>filter block test</h2> 54 <r:filter live='true'/> 55 <r:block do='pages where name like "[param:f]%" limit 5'> 56 <ol><li do='each' do='[name]'/></ol> 57 </r:block> 58 </div> 59 60 <hr/> 53 61 54 62 55 <h2>data blocktest</h2>56 <ol do='block'do='data'>57 <li do='each'><r:edit/> <b do='[text]'/> <r:show attr='value_a'/> <r:show attr='value_b'/><r:unlink/></li>58 <li do='form'><r:cancel/> <input name='text'/> <input name='value_a'/> <input name='value_b'/> <input type='submit'/></li>59 <li do='add'/>60 <r:set var='hours' do='stat' find='sum' from='value_a'/> <r:set var='exp' do='stat' find='sum' of='value_b'/>61 <li><b><r:show var='hours'/> * 150.00 = <r:show eval='hours * 150'/> + <r:show var='exp'/> = <r:show eval='( hours * 150 ) + exp'/></b></li>62 </ol>63 <h2>data test</h2> 64 <ol do='data'> 65 <li do='each'><r:edit/> <b do='[text]'/> <r:show attr='value_a'/> <r:show attr='value_b'/><r:unlink/></li> 66 <li do='form'><r:cancel/> <input name='text'/> <input name='value_a'/> <input name='value_b'/> <input type='submit'/></li> 67 <li do='add' done='focus'/> 68 <r:set var='hours' do='stat' find='sum' from='value_a'/> <r:set var='exp' do='stat' find='sum' of='value_b'/> 69 <li><b><r:show var='hours'/> * 150.00 = <r:show eval='hours * 150'/> + <r:show var='exp'/> = <r:show eval='( hours * 150 ) + exp'/></b></li> 70 </ol> 63 71 64 <h2>drag & drop</h2> 65 66 <r:images in='site' do='each' draggable='true' do='img' mode='pv'/> 67 68 <ul do='projects in site'> 69 <li style='border:1px solid #400; width:100px; height:100px;' do='each'><r:drop set='icon'><b do='[name]'/><r:icon where='1'><r:unlink do='img' mode='pv'/></r:icon></r:drop></li> 70 </ul> 71 72 <h2>notes & comments</h2> 73 74 <r:include template='notes'/> 72 <hr/> 75 73 76 74 75 76 77 <h2>data block test</h2> 78 <ol id='bdata' do='block' do='data'> 79 <li do='each'><r:edit/> <b do='[text]'/> <r:show attr='value_a'/> <r:show attr='value_b'/><r:unlink/></li> 80 <li do='form'><r:cancel/> <input name='text'/> <input name='value_a'/> <input name='value_b'/> <input type='submit'/></li> 81 <li do='add' done='focus'/> 82 <r:set var='hours' do='stat' find='sum' from='value_a'/> <r:set var='exp' do='stat' find='sum' of='value_b'/> 83 <li><b><r:show var='hours'/> * 150.00 = <r:show eval='hours * 150'/> + <r:show var='exp'/> = <r:show eval='( hours * 150 ) + exp'/></b></li> 84 </ol> 85 86 <hr/> 87 88 <h2>drag & drop</h2> 89 90 <r:images in='site' do='each' draggable='true' do='img' mode='tiny'/> 91 92 <ul do='tags in site'> 93 <li style='border:1px solid #400; min_width:100px; min_height:100px;' do='each' do='drop' set='set_tag'> 94 <b do='[v_title]'/> 95 <ul do='tagged'><li do='each' do='unlink' do='img' mode='tiny'/></ul> 96 </li> 97 </ul> 98 99 <ul do='projects in site'> 100 <li style='border:1px solid #400; min_width:100px; min_height:100px;' do='each'><r:drop d_foo='I am an icon for [v_title]' icon_for_id='[id]'><b do='title' actions='all'/><r:icon where='1'><r:unlink do='img' mode='pv'/> <r:show attr='d_foo'/> </r:icon></r:drop> 101 </li> 102 </ul> 103 104 <hr/> 105 106 107 <h2>notes & comments</h2> 108 109 <r:include template='notes'/> 110 111 <hr/> 77 112 </r:with> 78 113 </r:include> trunk/test/helpers/zena_parser/ajax.yml
r1080 r1083 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_ 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>/"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>/" 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_ 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"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" 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_ 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>/"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>/" 32 32 33 33 each_add_with_form: … … 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_ 22_add'.*li id='things_22_form'.*form.*hidden.*name='node\[v_status\]' value=\"50\"/"81 res: "/<ul><li.*id='things_add'.*li id='things_form'.*form.*hidden.*name='node\[v_status\]' value=\"50\"/" 82 82 83 83 block_edit_form: … … 103 103 default_focus_field: 104 104 src: "<ol do='comments'><li do='each'/><li do='form'><input name='author_name'/> ... <input name='text'/></li><li do='add'/></ol>" 105 res: "/\$\(\"list_ 22_form_t\"\).focusFirstElement\(\)/"105 res: "/\$\(\"list_form_t\"\).focusFirstElement\(\)/" 106 106 107 107 live_filter: … … 123 123 draggable_do_syntax: 124 124 src: "<r:images in='site' do='each' draggable='true' do='img' mode='pv'/>" 125 res: "/div id='list_ 22_30'><img src='/en/image30_pv.jpg'.*list_22_30.*.each\(Zena.draggable/"125 res: "/div id='list_30'><img src='/en/image30_pv.jpg'.*list_30.*.each\(Zena.draggable/" 126 126 127 127 trunk/test/helpers/zena_parser/basic.yml
r1081 r1083 81 81 82 82 zazen_shortcut: 83 src: "<div do='{v_title}'>hello</div>"84 tem: "<div ><%= zazen(@node.version.title, :node=>@node) %></div>"85 res: "<div ><p>status title</p></div>"83 src: "<div class='foo' do='{v_title}'>hello</div>" 84 tem: "<div class='foo'><%= zazen(@node.version.title, :node=>@node) %></div>" 85 res: "<div class='foo'><p>status title</p></div>" 86 86 87 87 show_url: trunk/test/sites/zena/virtual_classes.yml
r1060 r1083 10 10 kpath: NNP 11 11 real_class: Note 12 dyn_keys: reading, book 12 13 auto_create_discussion: yes 13 14 trunk/test/unit/virtual_class_test.rb
r1059 r1083 200 200 assert virtual_classes(:Post).auto_create_discussion 201 201 end 202 203 def test_attributes 204 login(:lion) 205 post = secure!(Node) { nodes(:opening) } 206 assert_equal ["book", "reading"], post.dyn_attribute_keys 207 assert post.update_attributes(:d_foo => 'bar', :d_book => 'Alice In Wonderland') 208 assert_equal ["book", "foo", "reading"], post.dyn_attribute_keys 209 end 202 210 end trunk/vendor/plugins/dyn_attributes/lib/dyn_attributes.rb
r1061 r1083 42 42 return unless valid_key?(key) 43 43 hash[key.to_s] = (value && value != '') ? value : nil 44 end 45 46 def keys 47 hash.keys 44 48 end 45 49
