Changeset 496

Show
Ignore:
Timestamp:
2007-05-08 09:15:14 (2 years ago)
Author:
gaspard
Message:

[fix] small bug fixes to clean tests.

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/app/controllers/versions_controller.rb

    r493 r496  
    166166    def find_node 
    167167      @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 number 
     168      @node.version(params[:id]) if params[:id].to_i != 0 # try to set current version from version number 
    169169    end 
    170170     
  • trunk/app/helpers/application_helper.rb

    r493 r496  
    212212  # * [!14!:www.example.com] use an image for an outgoing link 
    213213  def zazen(text, opt={}) 
     214    return '' unless text 
    214215    opt = {:images=>true, :pretty_code=>true}.merge(opt) 
    215216    img = opt[:images] 
     
    231232  # Creates a link to the node referenced by id 
    232233  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 
    233240    node = secure(Node) { Node.find_by_zip(opts[:id]) } 
    234241    title = (opts[:title] && opts[:title] != '') ? opts[:title] : node.v_title 
     242     
     243    link_opts[:format] = node.c_ext if link_opts[:format] == 'data' 
    235244    if opts[:id][0..0] == '0' 
    236       link_to title, zen_path(node), :popup=>true 
    237     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
    239248    end 
    240249  rescue ActiveRecord::RecordNotFound 
     
    299308    if link.nil? 
    300309      prefix + image + suffix 
    301     elsif link =~ /^\d+$
     310    elsif link =~ /^\d+
    302311      prefix + make_link(:id=>link,:title=>image) + suffix 
    303312    else 
  • trunk/app/models/image.rb

    r455 r496  
    6565  # 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). 
    6666  def c_crop=(format) 
    67     x, y, w, h = format[:x].to_i, format[:y].to_i, format[:w].to_i, format[:h].to_i 
    68     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) 
    6969      # do crop 
    7070      if file = version.content.crop(format) 
  • trunk/app/views/documents/show.rhtml

    r455 r496  
    1313      <tr> 
    1414        <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> 
    1616    </table> 
    1717    <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  
    1515    <div><%# FIXME = submit_to_remote('backup', transb('backup'), :url=>{:action => 'backup', :controller=>'version', :id=>@node.v_id}, :loading=>"$('loader').style.visibility = 'visible';") %></div> 
    1616    <% 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> 
    1818  </div> 
    1919  <div class='readers'> 
  • trunk/db/init/base/skins/default/notes.html

    r494 r496  
    44    <z:form><li class='inline_form'><form> 
    55      <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'/> 
    77      <z:input type='date_box' attr='log_at'/> 
    88      <input type='text' name='node[v_title]' do='void' set_value='[v_title]' size='25'/> 
  • trunk/lib/multiversion.rb

    r495 r496  
    290290           
    291291          if number && !new_record? && can_drive? 
    292             # TODO: test 
     292            # FIXME: IS NOT SECURE !!! does not work: test 
    293293            @version = versions.find_by_number(number) 
    294294          else 
  • trunk/lib/parser/lib/rules/zazen.rb

    r470 r496  
    8989     
    9090    def scan_quote 
    91       if @text =~ /\A"([^"]*)":([0-9]+)/m 
     91      if @text =~ /\A"([^"]*)":([0-9]+[^\s]*)/m 
    9292        eat $& 
    9393        # link inside the cms "":34 
  • trunk/lib/parser/lib/rules/zena.rb

    r494 r496  
    191191    end 
    192192     
    193     # TODO: test 
    194193    # TODO: replace with a more general 'zazen' or 'show' with id ? 
    195194    def r_summary 
    196195      unless @params[:or] 
    197196        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>" 
    199198      else 
    200199        first_name = 'v_summary' 
     
    210209        "<% end %>" 
    211210      end 
    212          
    213       # if opt[:as] 
    214       #   key = "#{opt[:as]}#{obj.v_id}" 
    215       #   preview_for = opt[:as] 
    216       #   opt.delete(:as) 
    217       # else 
    218       #   key = "#{sym}#{obj.v_id}" 
    219       # end 
    220       # if opt[:text] 
    221       #   text = opt[:text] 
    222       #   opt.delete(:text) 
    223       # else 
    224       #   text = obj.send(sym) 
    225       #   if (text.nil? || text == '') && sym == :v_summary 
    226       #     text = obj.v_text 
    227       #     opt[:images] = false 
    228       #   else 
    229       #     opt.delete(:limit) 
    230       #   end 
    231       # end 
    232       # if [:v_text, :v_summary].include?(sym) 
    233       #   if obj.kind_of?(TextDocument) && sym == :v_text 
    234       #     lang = obj.content_lang 
    235       #     lang = lang ? " lang='#{lang}'" : "" 
    236       #     text = "<code#{lang} class='full'>#{text}</code>" 
    237       #   end 
    238       #   text  = zazen(text, opt) 
    239       #   klass = " class='text'" 
    240       # else 
    241       #   klass = "" 
    242       # end 
    243       # if preview_for 
    244       #   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       # else 
    247       #   "<div id='#{key}'#{klass}>#{text}</div>" 
    248       # end 
    249211    end 
    250212     
  • trunk/lib/parser/test/parser_test.rb

    r481 r496  
    3636  testfile :zafu, :zafu_asset, :zafu_insight, :zazen 
    3737  def test_single 
    38     do_test('zafu', 'include_empty') 
     38    do_test('zazen', 'link_with_mode_and_format') 
    3939  end 
    4040   
  • trunk/lib/parser/test/zazen.yml

    r359 r496  
    8484  res: "<p>[make_image id:|12| images:true link:|12| size:|pv| style:||]</p>" 
    8585   
     86image_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   
     90image_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   
    8694image_with_http_link: 
    8795  src: "!12.pv!:http://www.example.org" 
     
    95103  src: '"this is a title":23' 
    96104  res: '<p>[make_link id:|23| title:|this is a title|]</p>' 
     105 
     106link_with_mode: 
     107  src: 'I like "":20_med' 
     108  res: '<p>I like [make_link id:|20_med| title:||]</p>' 
     109 
     110link_with_format: 
     111  src: 'look "here":30.data' 
     112  res: '<p>look [make_link id:|30.data| title:|here|]</p>' 
     113     
     114link_with_mode_and_format: 
     115  src: 'look "here":30_med.data' 
     116  res: '<p>look [make_link id:|30_med.data| title:|here|]</p>' 
    97117 
    98118link_no_title: 
  • trunk/public/images/ext

    • Property svn:ignore changed from
      *_pv.png
      *_std.png
      *_mini.png
      to *_*.png
  • trunk/test/fixtures/versions.yml

    r480 r496  
    99  comment:        no comment yet 
    1010  title:          Zena the wild CMS 
    11   summary:        no summary yet 
    12   text:           nothing written yet 
     11  summary:        '' 
     12  text:           This is the root of your peaceful tests. 
    1313  lang:           en 
    1414  number:         1 
  • trunk/test/fixtures/zips.yml

    r455 r496  
    11zena_counter: 
    22  site_id:      1 
    3   zip:          48 
     3  zip:          62 
    44   
    55ocean_counter: 
  • trunk/test/helpers/basic.yml

    r494 r496  
    449449        <p>You are all invited to <strong>Romanel</strong> for a great party this weekend.</p></div> 
    450450 
     451summary: 
     452  context: 
     453    node: 'zena' 
     454  src: "<z:summary/>" 
     455  res: "<div id='v_summary11' class='zazen'></div>" 
     456 
     457summary_exists: 
     458  src: "<z:summary/>" 
     459  res: "<div id='v_summary22' class='zazen'><p>status summary</p></div>" 
     460 
    451461empty_summary: 
    452462  src: "<z:summary text=''/>" 
    453463  res: "<div id='v_summary22' class='zazen'></div>" 
     464 
     465summary_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 
     469summary_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>"