Changeset 496
- Timestamp:
- 2007-05-08 09:15:14 (2 years ago)
- Files:
-
- trunk/app/controllers/versions_controller.rb (modified) (1 diff)
- trunk/app/helpers/application_helper.rb (modified) (3 diffs)
- trunk/app/models/image.rb (modified) (1 diff)
- trunk/app/views/documents/show.rhtml (modified) (1 diff)
- trunk/app/views/versions/edit.rhtml (modified) (1 diff)
- trunk/db/init/base/skins/default/notes.html (modified) (1 diff)
- trunk/lib/multiversion.rb (modified) (1 diff)
- 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) (2 diffs)
- trunk/public/images/ext (modified) (1 prop)
- trunk/test/fixtures/versions.yml (modified) (1 diff)
- trunk/test/fixtures/zips.yml (modified) (1 diff)
- trunk/test/helpers/basic.yml (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
trunk/app/controllers/versions_controller.rb
r493 r496 166 166 def find_node 167 167 @node = secure(Node) { Node.find_by_zip(params[:node_id]) } 168 @node.version(params[:id]) if params[:id].to_i != 0 # set current version from version number168 @node.version(params[:id]) if params[:id].to_i != 0 # try to set current version from version number 169 169 end 170 170 trunk/app/helpers/application_helper.rb
r493 r496 212 212 # * [!14!:www.example.com] use an image for an outgoing link 213 213 def zazen(text, opt={}) 214 return '' unless text 214 215 opt = {:images=>true, :pretty_code=>true}.merge(opt) 215 216 img = opt[:images] … … 231 232 # Creates a link to the node referenced by id 232 233 def make_link(opts) 234 link_opts = {} 235 if opts[:id] =~ /(\d+)(_\w+|)(\.\w+|)/ 236 opts[:id] = $1 237 link_opts[:mode] = ($2 != '') ? $2[1..-1] : nil 238 link_opts[:format] = ($3 != '') ? $3[1..-1] : nil 239 end 233 240 node = secure(Node) { Node.find_by_zip(opts[:id]) } 234 241 title = (opts[:title] && opts[:title] != '') ? opts[:title] : node.v_title 242 243 link_opts[:format] = node.c_ext if link_opts[:format] == 'data' 235 244 if opts[:id][0..0] == '0' 236 link_to title, zen_path(node ), :popup=>true237 else 238 link_to title, zen_path(node )245 link_to title, zen_path(node, link_opts), :popup=>true 246 else 247 link_to title, zen_path(node, link_opts) 239 248 end 240 249 rescue ActiveRecord::RecordNotFound … … 299 308 if link.nil? 300 309 prefix + image + suffix 301 elsif link =~ /^\d+ $/310 elsif link =~ /^\d+/ 302 311 prefix + make_link(:id=>link,:title=>image) + suffix 303 312 else trunk/app/models/image.rb
r455 r496 65 65 # Be carefull as this method changes the current file. So you should make a backup version before croping the image (the popup editor displays a warning). 66 66 def c_crop=(format) 67 x, y, w, h = format[:x].to_i, format[:y].to_i, format[:w].to_i, format[:h].to_i68 if (x >= 0 && y >= 0 && w <= c_width && h <= c_height) && !(x==0 && y==0 && w == c_width && h == c_height)67 x, y, w, h = [format[:x].to_i, 0].max, [format[:y].to_i,0].max, [format[:w].to_i, c_width].min, [format[:h].to_i, c_height].min 68 if (x < c_width && y < c_height && w > 0 && h > 0) && !(x==0 && y==0 && w == c_width && h == c_height) 69 69 # do crop 70 70 if file = version.content.crop(format) trunk/app/views/documents/show.rhtml
r455 r496 13 13 <tr> 14 14 <td class='preview'><p><%= img_tag(@node, :mode=>'pv') %></p><p class='size'><%= fsize(@node.c_size) %></p></td> 15 <td class='description'><h3 class='title'><span class='doc_id'><%= @node[: id] %></span> <%= @node.name %></h3><p class='summary'><%= zazen(@node.v_summary) %></p></td></tr>15 <td class='description'><h3 class='title'><span class='doc_id'><%= @node[:zip] %></span> <%= @node.name %></h3><p class='summary'><%= zazen(@node.v_summary) %></p></td></tr> 16 16 </table> 17 17 <p class='btn_validate'><%= link_to transb("upload more"), new_document_path(:parent_id => @node.parent_zip) %> // <%= node_actions(:actions => :edit) %> </p> trunk/app/views/versions/edit.rhtml
r469 r496 15 15 <div><%# FIXME = submit_to_remote('backup', transb('backup'), :url=>{:action => 'backup', :controller=>'version', :id=>@node.v_id}, :loading=>"$('loader').style.visibility = 'visible';") %></div> 16 16 <% end -%> 17 <div><a href='#' onclick='uploader=window.open("<% # FIXME = url_for :controller=>'document', :action=>'new', :parent_id=>@node%>", "uploader", "location=1,width=400,height=300");uploader.opener = opener;return false;'><%= transb('btn_add_document')%></a></div>17 <div><a href='#' onclick='uploader=window.open("<%= new_document_path(:parent_id=>@node[:zip])%>", "uploader", "location=1,width=400,height=300");uploader.opener = opener;return false;'><%= transb('btn_add_document')%></a></div> 18 18 </div> 19 19 <div class='readers'> trunk/db/init/base/skins/default/notes.html
r494 r496 4 4 <z:form><li class='inline_form'><form> 5 5 <input type='hidden' name='node[parent_id]' value='' do='void' set_value='[project_id]'/> 6 <z:input type='select' attr='klass' options=' Note,Letter'/>6 <z:input type='select' attr='klass' options='Post,Letter'/> 7 7 <z:input type='date_box' attr='log_at'/> 8 8 <input type='text' name='node[v_title]' do='void' set_value='[v_title]' size='25'/> trunk/lib/multiversion.rb
r495 r496 290 290 291 291 if number && !new_record? && can_drive? 292 # TODO: test292 # FIXME: IS NOT SECURE !!! does not work: test 293 293 @version = versions.find_by_number(number) 294 294 else trunk/lib/parser/lib/rules/zazen.rb
r470 r496 89 89 90 90 def scan_quote 91 if @text =~ /\A"([^"]*)":([0-9]+ )/m91 if @text =~ /\A"([^"]*)":([0-9]+[^\s]*)/m 92 92 eat $& 93 93 # link inside the cms "":34 trunk/lib/parser/lib/rules/zena.rb
r494 r496 191 191 end 192 192 193 # TODO: test194 193 # TODO: replace with a more general 'zazen' or 'show' with id ? 195 194 def r_summary 196 195 unless @params[:or] 197 196 text = @params[:text] ? @params[:text].inspect : node_attribute('v_summary') 198 "<div id='v_summary<%= #{node}.zip %>' class='zazen'><%= zazen(#{ @params[:text].inspect}) %></div>"197 "<div id='v_summary<%= #{node}.zip %>' class='zazen'><%= zazen(#{text}) %></div>" 199 198 else 200 199 first_name = 'v_summary' … … 210 209 "<% end %>" 211 210 end 212 213 # if opt[:as]214 # key = "#{opt[:as]}#{obj.v_id}"215 # preview_for = opt[:as]216 # opt.delete(:as)217 # else218 # key = "#{sym}#{obj.v_id}"219 # end220 # if opt[:text]221 # text = opt[:text]222 # opt.delete(:text)223 # else224 # text = obj.send(sym)225 # if (text.nil? || text == '') && sym == :v_summary226 # text = obj.v_text227 # opt[:images] = false228 # else229 # opt.delete(:limit)230 # end231 # end232 # if [:v_text, :v_summary].include?(sym)233 # if obj.kind_of?(TextDocument) && sym == :v_text234 # lang = obj.content_lang235 # lang = lang ? " lang='#{lang}'" : ""236 # text = "<code#{lang} class='full'>#{text}</code>"237 # end238 # text = zazen(text, opt)239 # klass = " class='text'"240 # else241 # klass = ""242 # end243 # if preview_for244 # render_to_string :partial=>'node/show_attr', :locals=>{:id=>obj[:id], :text=>text, :preview_for=>preview_for, :key=>key, :klass=>klass,245 # :key_on=>"#{key}#{Time.now.to_i}_on", :key_off=>"#{key}#{Time.now.to_i}_off"}246 # else247 # "<div id='#{key}'#{klass}>#{text}</div>"248 # end249 211 end 250 212 trunk/lib/parser/test/parser_test.rb
r481 r496 36 36 testfile :zafu, :zafu_asset, :zafu_insight, :zazen 37 37 def test_single 38 do_test('za fu', 'include_empty')38 do_test('zazen', 'link_with_mode_and_format') 39 39 end 40 40 trunk/lib/parser/test/zazen.yml
r359 r496 84 84 res: "<p>[make_image id:|12| images:true link:|12| size:|pv| style:||]</p>" 85 85 86 image_with_link_mode: 87 src: "!12.pv!:20_changes" 88 res: "<p>[make_image id:|12| images:true link:|20_changes| size:|pv| style:||]</p>" 89 90 image_with_link_mode_and_format: 91 src: "!12.pv!:20_med.data" 92 res: "<p>[make_image id:|12| images:true link:|20_med.data| size:|pv| style:||]</p>" 93 86 94 image_with_http_link: 87 95 src: "!12.pv!:http://www.example.org" … … 95 103 src: '"this is a title":23' 96 104 res: '<p>[make_link id:|23| title:|this is a title|]</p>' 105 106 link_with_mode: 107 src: 'I like "":20_med' 108 res: '<p>I like [make_link id:|20_med| title:||]</p>' 109 110 link_with_format: 111 src: 'look "here":30.data' 112 res: '<p>look [make_link id:|30.data| title:|here|]</p>' 113 114 link_with_mode_and_format: 115 src: 'look "here":30_med.data' 116 res: '<p>look [make_link id:|30_med.data| title:|here|]</p>' 97 117 98 118 link_no_title: trunk/public/images/ext
- Property svn:ignore changed from
*_pv.png
*_std.png
*_mini.png to *_*.png
- Property svn:ignore changed from
trunk/test/fixtures/versions.yml
r480 r496 9 9 comment: no comment yet 10 10 title: Zena the wild CMS 11 summary: no summary yet12 text: nothing written yet11 summary: '' 12 text: This is the root of your peaceful tests. 13 13 lang: en 14 14 number: 1 trunk/test/fixtures/zips.yml
r455 r496 1 1 zena_counter: 2 2 site_id: 1 3 zip: 483 zip: 62 4 4 5 5 ocean_counter: trunk/test/helpers/basic.yml
r494 r496 449 449 <p>You are all invited to <strong>Romanel</strong> for a great party this weekend.</p></div> 450 450 451 summary: 452 context: 453 node: 'zena' 454 src: "<z:summary/>" 455 res: "<div id='v_summary11' class='zazen'></div>" 456 457 summary_exists: 458 src: "<z:summary/>" 459 res: "<div id='v_summary22' class='zazen'><p>status summary</p></div>" 460 451 461 empty_summary: 452 462 src: "<z:summary text=''/>" 453 463 res: "<div id='v_summary22' class='zazen'></div>" 464 465 summary_or_text_has_summary: 466 src: "<z:summary or='v_text'/>" 467 res: "<div id='v_summary22' class='zazen'><p>status summary</p></div>" 468 469 summary_or_text_no_summary: 470 context: 471 node: 'zena' 472 src: "<z:summary or='v_text'/>" 473 res: "<div id='v_text11' class='zazen'><p>This is the root of your peaceful tests.</p></div>"
