Changeset 313

Show
Ignore:
Timestamp:
2007-02-25 22:52:24 (2 years ago)
Author:
gaspard
Message:

Zafu: Added anchor tag
Skin: now working ! Integration with render_and_cache done. Started testing.

Files:

Legend:

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

    r285 r313  
    1212  private 
    1313  def render_and_cache(opts={}) 
    14     opts = {:template=>opts} if opts.kind_of?(String) 
    15     opts = {:template=>@node[:template], :cache=>true}.merge(opts) 
    1614    @node  ||= secure(Node) { Node.find(ZENA_ENV[:root_id]) } 
     15    opts = {:mode=>opts} if opts.kind_of?(String) 
     16    opts = {:skin=>@node[:skin], :cache=>true}.merge(opts) 
    1717       
    1818    @project = @node.project 
     19    @date  ||= params[:date] ? parse_date(params[:date]) : Time.now 
    1920    render :template=>template_url(opts), :layout=>false 
    2021     
     
    2627   
    2728  def template_url(opts={}) 
    28     template_name = opts[:template] || 'default' 
    29     return '/templates/default' if template_name == 'default' # while testing 
    30     template = secure(Template) { Template.best_match(:template=>template_name, :class=>@node.class, :mode=>opts[:mode]) } 
    31     return '/templates/default' unless template 
    32     sess = @session 
    33     response.template.instance_eval { @session = sess } 
    34     template.template_url(response.template) 
     29    skin  = opts[:skin] || 'default' 
     30    skin_obj = nil 
     31    skin_helper = nil 
     32    # find best match 
     33    mode  = opts[:mode] 
     34    mode  = nil if (mode.nil? || mode == '') 
     35    klass = @node.class.to_s.downcase 
     36    template = nil 
     37    choices = [] 
     38     
     39    if skin == 'default' 
     40      #   3. default_class_mode  (101) 
     41      choices << ["default","any_#{klass}_#{mode}"] if mode && klass 
     42      #   4. default__mode       (100) 
     43      choices << ["default","any__#{mode}"] if mode 
     44      #   7. default_class       (  1) 
     45      choices << ["default","any_#{klass}"] if klass 
     46      #   8. default             (  0) 
     47      choices << ["default","any"] 
     48    else 
     49      #                          (mode / template / class) 
     50      #   1. template_class_mode (111) 
     51      choices << [skin,"any_#{klass}_#{mode}"] if mode && skin && klass 
     52      #   2. template__mode      (110) 
     53      choices << [skin,"any__#{mode}"] if mode && skin 
     54      #   3. default_class_mode  (101) 
     55      choices << ["default","any_#{klass}_#{mode}"] if mode && klass 
     56      #   4. default__mode       (100) 
     57      choices << ["default","any__#{mode}"] if mode 
     58      #   5. template_class      ( 11) 
     59      choices << [skin,"any_#{klass}"] if skin && klass 
     60      #   6. template            ( 10) 
     61      choices << [skin,"any"] if skin 
     62      #   7. default_class       (  1) 
     63      choices << ["default","any_#{klass}"] if klass 
     64      #   8. default             (  0) 
     65      choices << ["default","any"] 
     66    end 
     67    if skin 
     68      begin 
     69        skin_obj = secure(Skin) { Skin.find_by_name(skin) } 
     70        sess = @session 
     71        response.template.instance_eval { @session = sess } 
     72        skin_helper = response.template 
     73      rescue 
     74        skin_obj = nil 
     75      end 
     76    end 
     77    choices.each do |skin, template_name| 
     78      # find the fixed template 
     79      template = "/templates/fixed/#{skin}/#{template_name}" 
     80      break if File.exist?("#{RAILS_ROOT}/app/views#{template}.rhtml") 
     81      # find the compiled version 
     82      template = "/templates/compiled/#{skin}/#{template_name}_#{lang}.rhtml" 
     83      break if File.exist?("#{RAILS_ROOT}/app/views#{template}") 
     84      # search in the skin_obj 
     85      if skin_obj 
     86        break if template = skin_obj.template_url_for_name(template_name, skin_helper) 
     87      end 
     88      # continue search 
     89    end 
     90    return template 
     91  rescue ActiveRecord::RecordNotFound 
     92    # skin name was bad 
     93    return '/templates/fixed/default/any' 
    3594  end 
    3695   
  • trunk/app/helpers/application_helper.rb

    r309 r313  
    571571  #TODO: test 
    572572  # Return the list of possible templates 
    573   def form_templates 
    574     return @form_templates if @form_templates 
    575     @form_templates = [] 
    576     Dir.foreach(File.join(RAILS_ROOT, 'app', 'views', 'templates')) do |file| 
    577       next unless file =~ /^([a-zA-Z0-9]+)\.rhtml$/ 
    578       next if ['index', 'not_found'].include?($1) 
    579       @form_templates << $1 
    580     end 
    581     @form_templates 
     573  def form_skins 
     574    return @form_skins if @form_skins 
     575    @form_skins = secure(Skin) { Skin.find(:all, :order=>'name ASC') }.map {|r| r[:name]} 
     576    Dir.foreach(File.join(RAILS_ROOT, 'app', 'views', 'templates', 'fixed')) do |file| 
     577      next unless file =~ /^([a-zA-Z0-9_]+)$/ 
     578      @form_skins << $1 unless @form_skins.include?($1) 
     579    end 
     580    @form_skins 
    582581  end 
    583582   
     
    620619   
    621620   
    622   # Used by edit_buttons 
     621  # Used by node_actions 
    623622  def form_action(action, version_id=nil, link_text=nil) 
    624623    version_id ||= @node.v_id 
     
    664663      res << form_action('drive',version_id, opts[:text]) 
    665664    end 
    666     "<ul class='actions'><li>#{res.join("</li>\n<li>")}</li></ul>" 
     665    if res != [] 
     666      "<ul class='actions'><li>#{res.join("</li>\n<li>")}</li></ul>" 
     667    else 
     668      "" 
     669    end 
    667670  end 
    668671   
     
    793796  # size can be either :small or :large, options are 
    794797  # :node=>object 
    795   def author(opts={}) 
     798  def show_author(opts={}) 
    796799    obj  = opts[:node] || @node 
    797800      res = [] 
     
    826829    if options[:href] 
    827830      node = node.relation(options[:href]) || node 
    828     end 
    829     url = node_url(node) 
     831    end   
    830832    text = options[:text] || node.version.title 
    831     link_to(text,url.merge(options[:url])) 
     833    if opts[:dash] 
     834      "<a href='##{opts[:dash]}'>#{text}</a>" 
     835    else 
     836      url = node_url(node) 
     837      link_to(text,url.merge(options[:url])) 
     838    end 
    832839  end 
    833840   
  • trunk/app/helpers/version_helper.rb

    r213 r313  
    11module VersionHelper 
    22  def form_tabs 
    3     tmplt = @node.template || 'default' 
     3    tmplt = @node.skin || 'default' 
    44    tabs = [['text','text'],['title','title'],['help','help']] 
    55    ["#{tmplt}_#{@node.class.to_s.downcase}", "any_#{@node.class.to_s.downcase}"].each do |filename| 
  • trunk/app/models/skin.rb

    r280 r313  
    22# of a site. 
    33class Skin < Template 
     4  # opts can be :mode and :klass 
     5  def template_url_for_name(template_name, helper) 
     6    if template_name == 'any' 
     7      template = self 
     8    else 
     9      template = secure(Template) { Template.find(:conditions=>["parent_id = ? AND name = ?", self[:id], template_name])} 
     10    end 
     11    tmpl_name = "#{template_name}_#{visitor_lang}.rhtml" 
     12    tmpl_dir = "/templates/compiled/#{self[:name]}" 
     13    FileUtils::mkpath("#{RAILS_ROOT}/app/views#{tmpl_dir}") 
     14    # render for the current lang 
     15    res = ZafuParser.new(template.version.text, :helper=>helper).render 
     16    File.open("#{RAILS_ROOT}/app/views#{tmpl_dir}/#{tmpl_name}", "wb") { |f| f.syswrite(res) } 
     17    return "#{tmpl_dir}/#{tmpl_name}" 
     18  rescue ActiveRecord::RecordNotFound 
     19    nil 
     20  end 
    421end 
  • trunk/app/models/template.rb

    r280 r313  
    11class Template < TextDocument 
    2   class << self 
    3     # Return the best template for the current :mode, :class and :template. Must be used within 'secure' scope. 
    4     def best_match(opts={}) 
    5       mode  = opts[:mode] 
    6       mode  = nil if (mode.nil? || mode == '') 
    7       klass = opts[:class] ? opts[:class].to_s.downcase : nil 
    8       tmpl  = opts[:template] 
    9       template = nil 
    10       choices = [] 
    11       #                          (mode / template / class) 
    12       #   1. template_class_mode (111) 
    13       choices << "#{tmpl}_#{klass}_#{mode}" if mode && tmpl && klass 
    14       #   2. template__mode      (110) 
    15       choices << "#{tmpl}__#{mode}" if mode && tmpl 
    16       #   3. default_class_mode  (101) 
    17       choices << "default_#{klass}_#{mode}" if mode && klass 
    18       #   4. default__mode       (100) 
    19       choices << "default__#{mode}" if mode 
    20       #   5. template_class      ( 11) 
    21       choices << "#{tmpl}_#{klass}" if tmpl && klass 
    22       #   6. template            ( 10) 
    23       choices << tmpl if tmpl 
    24       #   7. default_class       (  1) 
    25       choices << "default_#{klass}" if klass 
    26       #   8. default             (  0) 
    27       choices << "default" 
    28       choices.each do |template_name| 
    29         # we are in secure scope already 
    30         break if template = Template.find_by_name(template_name) 
     2   
     3  # TODO: test 
     4  def sweep_cache 
     5    super 
     6    if self.kind_of?(Skin) 
     7      tmpl = "#{name}/any" 
     8    else 
     9      tmpl = "#{parent[:name]}/#{name}" 
     10    end 
     11    ZENA_ENV[:languages].each do |lang| 
     12      filepath = File.join(RAILS_ROOT,'app', 'views', 'templates', 'compiled') 
     13      filepath = "#{filepath}/#{tmpl}_#{lang}.rhtml" 
     14      if File.exist?(filepath) 
     15        File.delete(filepath) 
    3116      end 
    32       return template 
    3317    end 
    34   end  
    35    
    36   # opts can be :mode and :klass 
    37   def template_url(helper) 
    38     temp_url = "#{self[:name]}_#{visitor_lang}" 
    39      
    40     # 2. does the file for the current lang exist ? 
    41     path = File.join(RAILS_ROOT, 'app', 'views', 'templates', "#{temp_url}.rhtml") 
    42     if File.exist?(path) && (File.stat(path).mtime > version.updated_at) 
    43       # we are done 
    44       return "/templates/#{temp_url}" 
    45     end 
    46     # render for the current lang 
    47     res = ZafuParser.new(version.text, :helper=>helper).render 
    48     File.open(path, "wb") { |f| f.syswrite(res) } 
    49     return "/templates/#{temp_url}" 
    5018  end 
    5119end 
  • trunk/app/models/text_document_version.rb

    r266 r313  
    33    TextDocumentContent 
    44  end 
    5    
    65  private 
    76end 
  • trunk/app/views/contact/_title.rhtml

    r182 r313  
    33    <div class='title'>       
    44      <h1 class="s<%= @node.v_status %>"><%= show_title %><br/> 
    5         <ul class='node_actions'><%= edit_button(:all) %></ul> 
     5        <ul class='node_actions'><%= node_actions(:actions=>:all) %></ul> 
    66      </h1> 
    77      <%= author(:large) %> 
  • trunk/app/views/document/_title.rhtml

    r182 r313  
    77      <td class='subtitle'>       
    88        <h1 class="s<%= @node.v_status %>"><%= show_title %><br/> 
    9           <ul class='node_actions'><%= edit_button(:all) %></ul> 
     9          <ul class='node_actions'><%= node_actions(:actions=>:all) %></ul> 
    1010        </h1> 
    1111        <%= author(:large) %><%#= plug :links %> 
  • trunk/app/views/image/_title.rhtml

    r182 r313  
    22  <div class='header'> 
    33    <h1 class='s<%= @node.v_status %>'><%= show_title %> 
    4       <ul class='node_actions'><%= edit_button(:all) %></ul> 
     4      <ul class='node_actions'><%= node_actions(:actions=>:all) %></ul> 
    55    </h1> 
    66    <div class='subtitle'><%= author(:large) %><%#= plug :links %></div> 
  • trunk/app/views/main/_branch_title.rhtml

    r199 r313  
    11<div class='s<%= branch.class.to_s.downcase %>' ><%= link_to branch.name, :prefix => prefix, :controller => 'main', :action=>'site_tree', :id=>branch[:id], :prefix=>prefix %> 
    2   <% if session[:user] %><span class='readers'><%= edit_button(:drive, :node => branch, :text=>readers_for(branch)) %></span><% end %> 
     2  <% if session[:user] %><span class='readers'><%= node_actions(:actions=>:drive, :node => branch, :text=>readers_for(branch)) %></span><% end %> 
    33  <span class='class'><%= link_to(branch.class.to_s.downcase, node_url(branch)) %></span></div> 
  • trunk/app/views/main/_content_title.rhtml

    r132 r313  
    66    <td class='subtitle'>       
    77      <h1 class="s<%= @node.v_status %>"><span id='v_title<%= @node.v_id %>'><%= @node.v_title %></span><br/> 
    8         <ul class='node_actions'><%= edit_button(:all) %></ul> 
     8        <ul class='node_actions'><%= node_actions(:actions=>:all) %></ul> 
    99      </h1> 
    1010      <%= author(:large) %><%#= plug :links %> 
  • trunk/app/views/node/_groups.rhtml

    r299 r313  
    1414<% if inherit_modes %> 
    1515<%= form_remote_tag(:with=>'groups', :url=>{:controller=>'node', :action=>'update', :id=>@node[:id], :rnd=>rnd}) %> 
    16   <li><label><%= trans('mode') %></label><%= select('node', 'inherit', inherit_modes, {}, {:onchange=>"Zena.update_rwp(this.value,'#{groups_list.index(@node.ref[:rgroup_id])}','#{groups_list.index(@node.ref[:wgroup_id])}','#{groups_list.index(@node.ref[:pgroup_id])}', '#{form_templates.index(@node.ref[:template])}'); return false;"}) %></li> 
     16  <li><label><%= trans('mode') %></label><%= select('node', 'inherit', inherit_modes, {}, {:onchange=>"Zena.update_rwp(this.value,'#{groups_list.index(@node.ref[:rgroup_id])}','#{groups_list.index(@node.ref[:wgroup_id])}','#{groups_list.index(@node.ref[:pgroup_id])}', '#{form_skins.index(@node.ref[:skin])}'); return false;"}) %></li> 
    1717  <li><label><%= trans('publishers') %></label><%= select('node', 'pgroup_id', form_groups, { :include_blank => true }, {:disabled=>(@node[:inherit] != 0)}) %></li> 
    1818  <li><label><%= trans('writers') %></label><%= select('node', 'wgroup_id',    form_groups, { :include_blank => true }, {:disabled=>(@node[:inherit] != 0)}) %></li> 
    1919  <li><label><%= trans('readers') %></label><%= select('node', 'rgroup_id',    form_groups, { :include_blank => true }, {:disabled=>(@node[:inherit] != 0)}) %></li> 
    20   <li><label><%= trans('template') %></label><%= select('node', 'template',    form_templates,{}, {:disabled=>(@node[:inherit] != 0)}) %></li> 
     20  <li><label><%= trans('skin') %></label><%= select('node', 'skin',    form_skins,{}, {:disabled=>(@node[:inherit] != 0)}) %></li> 
    2121  <li class='submit'><%= submit_tag transb('change') %></li> 
    2222<%= end_form_tag %> 
  • trunk/app/views/node/_title.rhtml

    r182 r313  
    22  <div class='header'> 
    33    <h1 class='s<%= @node.v_status %>'><%= show_title %> 
    4       <ul class='node_actions'><%= edit_button(:all) %></ul> 
     4      <ul class='node_actions'><%= node_actions(:actions=>:all) %></ul> 
    55    </h1> 
    66    <div class='subtitle'><%= author(:large) %><%#= plug :links %></div> 
  • trunk/app/views/note/_li.rhtml

    r240 r313  
    33    <div class='li_s<%= li.v_status %>'> 
    44      <p class='log_at'><%= @note_date ? short_time(li.event_at) : short_date(li.log_at) %></p> 
    5       <p class='title'><%= show_title(li, :project=>(li.project != @node.project)) %></p> 
     5      <p class='title'><%= show_title(:node=>li, :project=>(li.project != @node.project)) %></p> 
    66      <p class='sign'><%= li.v_author.initials %></p> 
    7       <ul class='node_actions'><%= edit_button(:all, :node=>li) %></ul> 
     7      <ul class='node_actions'><%= node_actions(:actions=>:all, :node=>li) %></ul> 
    88    </div> 
    99  </div> 
  • trunk/db/initialize/zena/base.yml

    r302 r313  
    4545    max_status:     50 
    4646    inherit:        0 
    47     template:       default 
     47    skin:           default 
    4848    rgroup_id:      1 
    4949    wgroup_id:      2 
     
    6262    max_status:     50 
    6363    inherit:        1 
    64     template:       default 
     64    skin:           default 
    6565    rgroup_id:      1 
    6666    wgroup_id:      2 
     
    7878    max_status:     50 
    7979    inherit:        1 
    80     template:       default 
     80    skin:           default 
    8181    rgroup_id:      1 
    8282    wgroup_id:      2 
  • trunk/db/schema.rb

    r297 r313  
    120120    t.column "basepath", :text 
    121121    t.column "dgroup_id", :integer 
    122     t.column "template", :string 
     122    t.column "skin", :string 
    123123  end 
    124124 
  • trunk/lib/parser/lib/parser.rb

    r311 r313  
    8585    @context = context 
    8686    # name param is propagated into children (used to label parts of a large template) 
    87     if name = @params[:name] 
     87    if @params && name = @params[:name] 
    8888      @params.delete(:name) 
    8989      if @context[:name] 
     
    111111      res = @method 
    112112    end 
    113     res + @text 
     113    after_render(res + @text) 
    114114  end 
    115115   
     
    165165  def before_render 
    166166    true 
     167  end 
     168   
     169  def after_render(text) 
     170    text 
    167171  end 
    168172   
  • trunk/lib/parser/lib/rules/zena.rb

    r312 r313  
    3232        @params.delete(:store) 
    3333      end 
     34      if @params[:anchor] && !@context[:preflight] 
     35        @anchor = r_anchor 
     36        @params.delete(:anchor) 
     37      end 
    3438      true 
     39    end 
     40     
     41    def after_render(text) 
     42      if @anchor 
     43        @anchor + text 
     44      else 
     45        text 
     46      end 
    3547    end 
    3648 
     
    8294        "<%= trans(#{text}) %>" 
    8395      end 
     96    end 
     97     
     98    def r_anchor(obj=node) 
     99      "<a name='#{node_class.to_s.downcase}<%= #{obj}[:id] %>'/>" 
    84100    end 
    85101     
     
    289305          out "<% #{list}.each do |#{var}| -%>" 
    290306        end 
     307        out r_anchor(var) if @anchor # insert anchor inside the each loop 
     308        @anchor = nil 
    291309        res = expand_with(:node=>var) 
    292310        if @context[:template_url] && @pass[:edit] 
     
    469487    def r_link 
    470488      # text 
     489      @blocks = [] # do not use block content for link. 
    471490      text = get_text_for_erb 
    472491      if text 
     
    488507        url = '' 
    489508      end 
     509      if @params[:dash] == 'true' 
     510        dash = ", :dash=>\"#{node_class.to_s.downcase}\#{#{node}[:id]}\"" 
     511      else 
     512        dash = '' 
     513      end 
    490514      # link 
    491       "<%= node_link(:node=>#{lnode}#{text}#{href}#{url}) %>" 
     515      "<%= node_link(:node=>#{lnode}#{text}#{href}#{url}#{dash}) %>" 
    492516    end 
    493517     
  • trunk/lib/parser/test/parser_test.rb

    r311 r313  
    88    def r_text 
    99      @params[:text] 
     10    end 
     11     
     12    def r_repeat 
     13      count = @params[:count] || 2 
     14      count.to_i.times do 
     15        out expand_with 
     16      end 
    1017    end 
    1118     
     
    2431end 
    2532class ZazenTest < Test::Unit::TestCase 
    26   testfile :zafu, :zafu_asset, :zafu_insight 
     33  testfile :zafu, :zafu_asset, :zafu_insight, :zazen 
    2734  def test_single 
    28     do_test('zafu_insight', 'simple') 
     35    do_test('zafu', 'preserve_newlines') 
     36  end 
     37  def test_zazen_image_no_image 
     38    file = 'zazen' 
     39    test = 'image_no_image' 
     40    res = @@test_parsers[file].new_with_url("/#{test.gsub('_', '/')}", :helper=>DummyHelper.new(@@test_strings[file])).render(:images=>false) 
     41    assert_equal @@test_strings[file][test]['res'], res 
    2942  end 
    3043  make_tests 
  • trunk/lib/parser/test/testhelp.rb

    r279 r313  
    9090  def do_test(file, test) 
    9191    res = @@test_parsers[file].new_with_url("/#{test.gsub('_', '/')}", :helper=>DummyHelper.new(@@test_strings[file])).render 
    92     if @@test_strings[file][test]['res'][0..0] == "/" 
    93       assert_match %r{@@test_strings[file][test]['res'][1..-2]}, res 
    94     else 
    95       assert_equal @@test_strings[file][test]['res'], res 
     92    if @@test_strings[file][test]['res'] 
     93      if @@test_strings[file][test]['res'][0..0] == "/" 
     94        assert_match %r{#{@@test_strings[file][test]['res'][1..-2]}}m, res 
     95      else 
     96        assert_equal @@test_strings[file][test]['res'], res 
     97      end 
    9698    end 
    9799  end 
  • trunk/lib/parser/test/zafu.yml

    r311 r313  
    219219  src: "include_with: <z:include template='/name/title'><h1 do='with' part='title' do='hello'/></z:include>" 
    220220  res: "include_with: title: <h1>hello world!</h1>" 
     221 
     222preserve_newlines: 
     223  src: | 
     224    <z:repeat><p do='test'>blah</p> 
     225    </z:repeat>ok 
     226     
     227  res: | 
     228    [test]<p>blah</p>[/test] 
     229    [test]<p>blah</p>[/test] 
     230    ok 
     231     
  • trunk/lib/secure.rb

    r299 r313  
    336336            return false 
    337337          end 
    338           [:rgroup_id, :wgroup_id, :pgroup_id, :template].each do |sym| 
     338          [:rgroup_id, :wgroup_id, :pgroup_id, :skin].each do |sym| 
    339339            # not defined = inherit 
    340340            self[sym] ||= ref[sym] 
     
    354354            self[:wgroup_id] = ref.wgroup_id 
    355355            self[:pgroup_id] = ref.pgroup_id 
    356             self[:template ] = ref.template 
     356            self[:skin ] = ref.skin 
    357357          when -1 
    358358            # private 
     
    376376              errors.add('wgroup_id', "you cannot change this") unless wgroup_id == ref.wgroup_id 
    377377              errors.add('pgroup_id', "you cannot change this") unless pgroup_id == ref.pgroup_id 
    378               errors.add('template' , "you cannot change this") unless template  == ref.template 
     378              errors.add('skin' , "you cannot change this") unless skin  == ref.skin 
    379379            end 
    380380          else 
    381381            errors.add('inherit', "bad inheritance mode") 
    382           end   
    383           errors.add('template', "unknown template '#{template}.rhtml'") unless File.exist?(File.join(RAILS_ROOT, 'app','views', 'templates', "#{template}.rhtml")) 
     382          end 
    384383 
    385384          # publish_from can only be set by the object itself by setting @publish_from 
     
    498497            unless inherit == old.inherit 
    499498              if old.can_visible? || ( old.can_manage? && (old.max_status_with_heirs < Zena::Status[:pub]) ) 
    500                 [:rgroup_id, :wgroup_id, :pgroup_id, :template].each do |sym| 
     499                [:rgroup_id, :wgroup_id, :pgroup_id, :skin].each do |sym| 
    501500                  self[sym] = ref[sym] 
    502501                end 
     
    539538                errors.add('wgroup_id', "you cannot change this") unless wgroup_id == old.wgroup_id 
    540539                errors.add('pgroup_id', "you cannot change this") unless pgroup_id == old.pgroup_id 
    541                 # but you can change templates and name 
     540                # but you can change skins and name 
    542541              end 
    543542            else 
     
    547546              errors.add('wgroup_id', "you cannot change this") unless wgroup_id == old.wgroup_id 
    548547              errors.add('pgroup_id', "you cannot change this") unless pgroup_id == old.pgroup_id 
    549               errors.add('template', "you cannot change this") unless  template  == old.template 
     548              errors.add('skin', "you cannot change this") unless  skin  == old.skin 
    550549            end 
    551550          else 
    552551            errors.add('inherit', "bad inheritance mode") 
    553           end   
    554           errors.add('template', "unknown template") unless template == old[:template] || File.exist?(File.join(RAILS_ROOT, 'app', 'views', 'templates', "#{template}.rhtml")) 
    555           @needs_inheritance_spread = (rgroup_id != old.rgroup_id || wgroup_id != old.wgroup_id || pgroup_id != old.pgroup_id || template != old.template)         
     552          end 
     553          @needs_inheritance_spread = (rgroup_id != old.rgroup_id || wgroup_id != old.wgroup_id || pgroup_id != old.pgroup_id || skin != old.skin)         
    556554          return errors.empty? 
    557555        end 
     
    617615            h[:wgroup_id] = wgroup_id 
    618616            h[:pgroup_id] = pgroup_id 
    619             h[:template ] = template 
     617            h[:skin ] = skin 
    620618            # there should never be errors here (if we had the correct rights to change 
    621619            # the current node, we can change it's children), so we skip validation 
  • trunk/test/fixtures/document_contents.yml

    r61 r313  
    5656  ext:            'pdf' 
    5757  size:           63569 
     58 
     59wiki_skin: 
     60  id:             7 
     61  version_id:     38 
     62  type:           TextDocumentContent 
     63  content_type:   "text/html" 
     64  name:           "wiki" 
     65  ext:            'zafu' 
     66  size:            
  • trunk/test/fixtures/nodes.yml

    r301 r313  
    11<% @dates = "  created_at:  2006-03-10\n  updated_at:  2006-04-11\n  publish_from:  2006-03-10" %> 
    2 <% @defaults = "#@dates\n  ref_lang:  en\n  max_status:  50\n  template: default" %> 
     2<% @defaults = "#@dates\n  ref_lang:  en\n  max_status:  50\n  skin:    default" %> 
    33<% @rights = "  rgroup_id:  1\n  wgroup_id:  3\n  pgroup_id:  4" %> 
    44zena: 
     
    1616  max_status:     50 
    1717  inherit:        0 
    18   template:       default 
     18  skin:           default 
    1919<%= @rights %> 
    2020 
     
    213213  max_status:     30 
    214214  inherit:        1 
    215   template:       default 
     215  skin:           default 
    216216<%= @rights %> 
    217217 
     
    228228  max_status:     50 
    229229  log_at:         2006-03-15 
    230   template:       default 
     230  skin:           default 
    231231<%= @dates %> 
    232232<%= @rights %> 
     
    258258  ref_lang:       en 
    259259  max_status:     50 
    260   template:       wiki 
     260  skin:           wiki 
    261261  rgroup_id:      1 
    262262  wgroup_id:      1 
     
    275275  ref_lang:       en 
    276276  max_status:     50 
    277   template:       wiki 
     277  skin:           wiki 
    278278  rgroup_id:      1 
    279279  wgroup_id:      1 
     
    292292  ref_lang:       en 
    293293  max_status:     50 
    294   template:       wiki 
     294  skin:           wiki 
    295295  rgroup_id:      1 
    296296  wgroup_id:      1 
     
    354354  user_id:        5 
    355355  inherit:        0 
    356   template:       default 
     356  skin:           default 
    357357<%= @dates %> 
    358358  ref_lang:       en 
     
    383383  user_id:        4 
    384384  inherit:        0 
    385   template:       default 
     385  skin:           default 
    386386<%= @dates %> 
    387387  ref_lang:       en 
     
    405405  ref_lang:       en 
    406406  max_status:     30 
    407   template:       default 
     407  skin:           default 
    408408  rgroup_id:      1 
    409409  wgroup_id:      3 
     
    424424  ref_lang:       en 
    425425  max_status:     30 
    426   template:       default 
     426  skin:           default 
    427427  rgroup_id:      1 
    428428  wgroup_id:      3 
     
    443443  ref_lang:       en 
    444444  max_status:     30 
    445   template:       default 
     445  skin:           default 
    446446  rgroup_id:      1 
    447447  wgroup_id:      3 
     
    460460<%= @defaults %> 
    461461<%= @rights %> 
     462 
     463wiki_skin: 
     464  id:             33 
     465  type:           Skin 
     466  kpath:          NPDTTS 
     467  name:           wiki 
     468  project_id:     1 
     469  parent_id:      5 
     470  user_id:        4 
     471  inherit:        1 
     472  log_at:         2006-10-03 
     473<%= @defaults %> 
     474<%= @rights %> 
  • trunk/test/fixtures/versions.yml

    r302 r313  
    517517  number:         1 
    518518<%= @defaults %> 
     519 
     520wiki_template_en: 
     521  type:           TextDocumentVersion 
     522  id:             38 
     523  node_id:        33 
     524  user_id:        4 
     525  comment:        very simple template for wiki 
     526  title:          wiki template 
     527  summary:        This page is a *Letter*. 
     528  text:           | 
     529    <html> 
     530      <head> 
     531        <title do='show' attr='v_title'>some title</title> 
     532      </head> 
     533      <body> 
     534        <h1 do='show_title'>super title</h1> 
     535        <h2><a name='contents'/>contents</h2> 
     536        <ul do='pages'> 
     537          <li do='each' do='link' dash='true'>some link</li> 
     538        </ul> 
     539         
     540        <z:pages do='each'> 
     541          <h3><z:title anchor='true' actions='all'/> <a href='#contents'>top</a></h3> 
     542          <z:text/> 
     543        </z:pages> 
     544      </body> 
     545    </html> 
     546  lang:           en 
     547  number:         1 
     548<%= @defaults %> 
  • trunk/test/functional/application_controller_test.rb

    r219 r313  
    2020  # render_and_cache and authorize tested in MainControllerTest 
    2121   
    22   def test_template 
     22  def test_skin 
    2323    wiki = @controller.send(:secure,Node) { Node.find(nodes_id(:wiki)) } 
    24     assert_equal 'wiki', wiki.template 
     24    assert_equal 'wiki', wiki.skin 
    2525    @controller.instance_eval{ @node = wiki } 
    26     assert_equal 'wiki', @controller.send(:template
     26    assert_equal 'wiki', @controller.send(:skin
    2727  end 
    2828   
    29   def test_class_template 
     29  def test_class_skin 
    3030    proj = @controller.send(:secure,Node) { Node.find(nodes_id(:cleanWater)) } 
    31     assert_equal 'default', proj.template 
     31    assert_equal 'default', proj.skin 
    3232    @controller.instance_eval{ @node = proj } 
    33     assert_equal 'default_project', @controller.send(:template
    34     proj.template = 'truc' 
    35     assert_equal 'truc', proj.template 
    36     assert_equal 'default', @controller.send(:template
     33    assert_equal 'default_project', @controller.send(:skin
     34    proj.skin = 'truc' 
     35    assert_equal 'truc', proj.skin 
     36    assert_equal 'default', @controller.send(:skin
    3737  end 
    3838   
    39   def test_general_class_template 
     39  def test_general_class_skin 
    4040    letter = @controller.send(:secure, Node) { Node.find(nodes_id(:letter)) } 
    41     assert_equal 'default', letter.template 
     41    assert_equal 'default', letter.skin 
    4242    @controller.instance_eval{ @node = letter } 
    43     assert_equal 'any_letter', @controller.send(:template
     43    assert_equal 'any_letter', @controller.send(:skin
    4444  end 
    4545   
    46   def test_custom_template 
    47     assert_equal 'index', @controller.send(:template,'index') 
     46  def test_custom_skin 
     47    assert_equal 'index', @controller.send(:skin,'index') 
    4848  end 
    4949   
    50   def test_mode_template 
     50  def test_mode_skin 
    5151    @controller.instance_eval { @params = {:mode=>'wiki'} } 
    5252    proj = @controller.send(:secure,Node) { Node.find(nodes_id(:cleanWater)) } 
    5353    @controller.instance_eval { @node = proj } 
    54     assert_equal 'wiki', @controller.send(:template
     54    assert_equal 'wiki', @controller.send(:skin
    5555  end 
    5656   
     
    5959    doc  = @controller.send(:secure, Node) { Node.find(nodes_id(:water_pdf)) } 
    6060    @controller.instance_eval{ @node = page } 
    61     assert_equal 'forms/default', @controller.send(:form_template
     61    assert_equal 'forms/default', @controller.send(:form_skin
    6262    @controller.instance_eval{ @node = doc  } 
    63     assert_equal 'forms/any_document', @controller.send(:form_template
     63    assert_equal 'forms/any_document', @controller.send(:form_skin
    6464  end 
    6565   
  • trunk/test/functional/main_controller_test.rb

    r219 r313  
    1414  end 
    1515   
    16   def test_index 
    17     assert_routing '/en', {:controller=>'main', :action=>'index', :prefix=>'en'} 
    18     assert_routing '/',   {:controller=>'main', :action=>'redirect'} 
    19     get 'index', :prefix=>'en' 
    20     assert_response :success 
    21     assert_template 'index' 
    22   end 
    23    
    2416  def test_render_and_cache 
    2517    get 'index'