Changeset 637

Show
Ignore:
Timestamp:
2007-06-18 16:54:11 (2 years ago)
Author:
gaspard
Message:

r425@bison: gaspard | 2007-06-18 09:41:04 +0200


r427@bison: gaspard | 2007-06-18 09:46:34 +0200
[locales] update
r429@bison: gaspard | 2007-06-18 10:04:49 +0200
[fix] css
r431@bison: gaspard | 2007-06-18 10:15:29 +0200
[fix] replace 'next page' by icon
r432@bison: gaspard | 2007-06-18 10:21:12 +0200
[fix] locales
r434@bison: gaspard | 2007-06-18 10:28:55 +0200


r436@bison: gaspard | 2007-06-18 10:42:00 +0200


r438@bison: gaspard | 2007-06-18 12:19:00 +0200
[fix] Better set/change relations. Update icons
r441@bison: gaspard | 2007-06-18 12:35:21 +0200


r443@bison: gaspard | 2007-06-18 14:33:04 +0200
[new] added 'root_class' parameter to zafu input tag when using select <r:input type='select' root_class='Note'/>
r445@bison: gaspard | 2007-06-18 14:46:36 +0200


r447@bison: gaspard | 2007-06-18 14:49:15 +0200


r449@bison: gaspard | 2007-06-18 15:30:57 +0200
[new] added 'without' option on select class
r451@bison: gaspard | 2007-06-18 15:47:10 +0200
[fix] virtual classes create and template selection
r453@bison: gaspard | 2007-06-18 16:53:52 +0200
updated rake tasks to allow full backup

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/TODO

    r633 r637  
    1717 
    1818* replace 'link_to_remote, :method => post/put' by 'button_to_remote' 
     19* make application_helper 'img_tag' use virtual_classes's icon. or superclass's icon.... 
     20* open calendar : use stored zafu and pass template_url as argument instead of all find,date,(_tiny.rhtml) 
    1921* if mksite fails (password too short, etc): rollback ! 
    2022* What if a Note/Contact contains pages and one of these pages has 'custom_base' set ? 
  • trunk/app/controllers/application.rb

    r619 r637  
    106106      mode      = opts[:mode] 
    107107      format    = opts[:format] || 'html' 
    108       klass     = @node.class 
     108      klass     = @node.vclass 
    109109       
    110110      # possible classes for the master template : 
     
    362362        params[:lang],  
    363363        params[:prefix] == AUTHENTICATED_PREFIX ? nil : params[:prefix], 
     364        (visitor.is_anon? ? nil : visitor.lang), # visitor.lang comes before session[:lang] and before http headers if logged in 
    364365        session[:lang], 
    365         (visitor.is_anon? ? nil : visitor.lang), # visitor.lang comes before http headers if logged in 
    366366        (request.headers['HTTP_ACCEPT_LANGUAGE'] || '').split(',').sort {|a,b| (b.split(';q=')[1] || 1.0).to_f <=> (a.split(';q=')[1] || 1.0).to_f }.map {|l| l.split(';')[0].split('-')[0] }, 
    367367        (visitor.is_anon? ? visitor.lang : nil), # anonymous user's lang comes last 
  • trunk/app/controllers/relations_controller.rb

    r633 r637  
    1010    @relation_pages, @relations = nil, nil 
    1111    secure(Relation) do 
    12       @relation_pages, @relations = paginate :relations, :per_page => 20 
     12      @relation_pages, @relations = paginate :relations, :per_page => 20, :order => 'source_role' 
    1313    end 
    1414    respond_to do |format| 
  • trunk/app/controllers/users_controller.rb

    r636 r637  
    7070        @user.errors.add('password', 'too short') 
    7171      end 
    72       if params[:user][:password] != params[:user][:retype_password] 
    73         @user.errors.add('retype_password', 'does not match new password') 
     72      if !visitor.is_admin? || params[:user][:retype_password] 
     73        if params[:user][:password] != params[:user][:retype_password] 
     74          @user.errors.add('retype_password', 'does not match new password') 
     75        end 
    7476      end 
    7577      unless visitor.is_admin? 
  • trunk/app/helpers/application_helper.rb

    r635 r637  
    479479       
    480480      # get list of notes in this scope 
     481      Node.logger.info "\n\n\n\n\n\n\n\n" 
    481482      notes = source.relation(method, :conditions=>["#{using} >= ? AND #{using} <= ?", start_date, end_date], :order=>"#{using} ASC", :or => options[:or]) || [] 
    482483       
  • trunk/app/models/node.rb

    r635 r637  
    149149  class << self 
    150150     
     151    # needed for compatibility with virtual classes 
     152    alias create_instance create 
     153    alias new_instance new 
     154    # == 
     155     
     156     
    151157    def inherited(child) 
    152158      super 
     
    166172    # FIXME: how to make sure all sub-classes of Node are loaded before this is called ? 
    167173    def classes_for_form(opts={}) 
     174      if klass = opts.delete(:class) 
     175        if klass = get_class(klass) 
     176          klass.classes_for_form(opts) 
     177        else 
     178          return ['', ''] # bad class 
     179        end 
     180      else 
     181        all_classes(opts).map{|a,b| [a[0..-1].sub(/^#{self.kpath}/,'').gsub(/./,'  ') + b.to_s, b.to_s] } # white spaces are insecable spaces (not ' ') 
     182      end 
     183    end 
     184     
     185    # FIXME: how to make sure all sub-classes of Node are loaded before this is called ? 
     186    def kpaths_for_form(opts={}) 
     187      all_classes(opts).map{|a,b| [a[1..-1].gsub(/./,'  ') + b.to_s, a.to_s] } # white spaces are insecable spaces (not ' ') 
     188    end 
     189     
     190    def all_classes(opts={}) 
    168191      virtual_classes = VirtualClass.find(:all, :conditions => ["site_id = ? AND create_group_id IN (?) AND kpath LIKE '#{self.kpath}%'", current_site[:id], visitor.group_ids]) 
    169192      classes = (virtual_classes.map{|r| [r.kpath, r.name]} + native_classes.to_a).sort{|a,b| a[0] <=> b[0]} 
    170       if opts[:without_kpath] 
    171         classes.reject! {|k,c| k =~ /^#{opts[:without_kpath]}/ } 
    172       end 
    173       classes.map{|a,b| [a[1..-1].gsub(/./,'  ') + b.to_s, b.to_s] } # white spaces are insecable spaces (not ' ') 
     193      if opts[:without] 
     194        reject_kpath =  opts[:without].split(',').map(&:strip).map {|name| Node.get_class(name) }.compact.map { |kla| kla.kpath }.join('|') 
     195        classes.reject! {|k,c| k =~ /^#{reject_kpath}/ } 
     196      end 
     197      classes 
    174198    end 
    175199     
     
    192216     
    193217    def get_class_from_kpath(kp) 
    194       @@native_node_classes[kp] || VirtualClass.find(:first, :conditions=>["site_id = ? AND kpath = ?",current_site[:id], kp]) 
     218      native_classes[kp] || VirtualClass.find(:first, :conditions=>["site_id = ? AND kpath = ?",current_site[:id], kp]) 
    195219    end 
    196220     
     
    293317       
    294318      node = if create_class != self 
    295         create_class.with_exclusive_scope(scope) { create_class.create(attributes) } 
    296       else 
    297         self.create(attributes) 
     319        create_class.with_exclusive_scope(scope) { create_class.create_instance(attributes) } 
     320      else 
     321        self.create_instance(attributes) 
    298322      end 
    299323      node.publish if publish 
  • trunk/app/models/relation.rb

    r634 r637  
    199199  end 
    200200   
     201  def source_unique 
     202    self[:source_unique] ? true : false 
     203  end 
     204   
     205  def target_unique 
     206    self[:target_unique] ? true : false 
     207  end 
     208   
    201209  private 
    202210    def valid_relation 
  • trunk/app/models/template_content.rb

    r587 r637  
    5757      if self[:klass] 
    5858        # this is a master template (found when choosing the template for rendering) 
    59         begin 
    60           klass = Module::const_get(self[:klass].to_sym) 
    61           raise NameError unless klass.ancestors.include?(Node) 
     59        if klass = Node.get_class(self[:klass]) 
    6260          self[:tkpath] = klass.kpath 
    63         rescue NameError 
     61        else 
    6462          errors.add('klass', 'invalid') 
    6563        end 
  • trunk/app/models/virtual_class.rb

    r635 r637  
    77  end 
    88   
     9  # FIXME: how to make sure all sub-classes of Node are loaded before this is called ? 
     10  def classes_for_form(opts={}) 
     11    all_classes(opts).map{|a,b| [a[0..-1].sub(/^#{self.kpath}/,'').gsub(/./,'  ') + b.to_s, b.to_s] } # white spaces are insecable spaces (not ' ') 
     12  end 
     13   
     14  def all_classes(opts={}) 
     15    classes = VirtualClass.find(:all, :conditions => ["site_id = ? AND create_group_id IN (?) AND kpath LIKE '#{self.kpath}%'", current_site[:id], visitor.group_ids]).map{|r| [r.kpath, r.name] }.sort{|a,b| a[0] <=> b[0] } 
     16    if opts[:without] 
     17      reject_kpath =  opts[:without].split(',').map(&:strip).map {|name| Node.get_class(name) }.compact.map { |kla| kla.kpath }.join('|') 
     18      classes.reject! {|k,c| k =~ /^#{reject_kpath}/ } 
     19    end 
     20    classes 
     21  end 
     22  
    923  # check inheritance chain through kpath 
    1024  def kpath_match?(kpath) 
     
    2034  end 
    2135   
    22   def new(*args) 
     36  def superclass=(klass) 
     37    if k = Node.get_class(klass) 
     38      @superclass = k 
     39    else 
     40      errors.add('superclass', 'invalid') 
     41    end 
     42  end 
     43   
     44  # new instances, not virtual classes 
     45  def new_instance(*args) 
    2346    obj = real_class.new(*args) 
    2447    obj[:vclass_id] = self[:id] 
     
    3962  end 
    4063   
    41   def create(*args) 
     64  # create instances, not virtual classes 
     65  def create_instance(*args) 
    4266    if @scope 
    4367      real_class.with_exclusive_scope(@scope) { 
    44         obj = self.new(*args) 
     68        obj = self.new_instance(*args) 
    4569        obj.save 
    4670        obj 
    4771      } 
    4872    else 
    49       obj = self.new(*args) 
     73      obj = self.new_instance(*args) 
    5074      obj.save 
    5175      obj 
     
    5579  private 
    5680    def valid_virtual_class 
    57       # validate real_class 
    58       # set kpath 
    59       # set site_id 
    60       # validate uniqueness of name (scope = site_id) 
    61       # validate create_group_id 
     81      if self[:name].blank? 
     82        errors.add('name', "can't be blank") 
     83        return false 
     84      end 
     85      @superclass ||= self.superclass 
     86      index = 0 
     87      kpath = nil 
     88      while index < self[:name].length 
     89        try_kpath = @superclass.kpath + self[:name][index..index].upcase 
     90        conditions = ["site_id = ? AND kpath = ?", current_site[:id], try_kpath] 
     91        unless new_record? 
     92          conditions[0] += " AND id <> ?" 
     93          conditions << self[:id] 
     94        end 
     95        unless VirtualClass.find(:first, :conditions=>conditions) 
     96          kpath = try_kpath 
     97          break 
     98        end 
     99        index += 1 
     100      end 
     101      errors.add('name', 'invalid (could not build unique kpath)') unless kpath 
     102      self[:kpath]      = kpath 
     103      self[:site_id]    = current_site[:id] 
     104      self[:real_class] = get_real_class(@superclass) 
     105 
     106      unless (secure(Group) { Group.find(self[:create_group_id]) } rescue nil) 
     107        errors.add('create_group_id', 'invalid group') 
     108      end 
     109      unless self[:real_class] 
     110        errors.add('superclass', 'invalid') 
     111      end 
     112      return errors.empty? 
     113    end 
     114     
     115    def get_real_class(klass) 
     116      klass.kind_of?(VirtualClass) ? get_real_class(klass.superclass) : klass.to_s 
    62117    end 
    63118end 
  • trunk/app/views/calendar/_large.rhtml

    r79 r637  
    11 
    22<h3 class='largecal_title'> 
    3   <span><%= link_to_remote( '<img src="/images/control_rewind.png"/>' ,      :update=>'largecal', :url=>{:controller=>'calendar', :action=>'show', :date=>(date << 1), :id=>source[:id], :size=>size, :find=>method, :rnd=>rnd } ) %></span> 
     3  <span><%= link_to_remote( _('img_prev_page') ,      :update=>'largecal', :url=>{:controller=>'calendar', :action=>'show', :date=>(date << 1), :id=>source[:id], :size=>size, :find=>method, :rnd=>rnd } ) %></span> 
    44  <span><%= link_to_remote(title, :update=>'largecal', :url=>{:controller=>'calendar', :action=>'show', :id=>source[:id], :size=>size, :find=>method, :rnd=>rnd} ) %></span> 
    5   <span><%= link_to_remote( '<img src="/images/control_fastforward.png"/>' , :update=>'largecal', :url=>{:controller=>'calendar', :action=>'show', :date=>(date >> 1), :id=>source[:id], :size=>size, :find=>method, :rnd=>rnd } ) %></span> 
     5  <span><%= link_to_remote( _('img_next_page') , :update=>'largecal', :url=>{:controller=>'calendar', :action=>'show', :date=>(date >> 1), :id=>source[:id], :size=>size, :find=>method, :rnd=>rnd } ) %></span> 
    66</h3> 
    77<table cellspacing="0" class="largecal"> 
  • trunk/app/views/calendar/_tiny.rhtml

    r599 r637  
    11<table cellspacing="0" class='tinycal'> 
    22  <tr class="head"><td class="button"> 
    3     <%= link_to_remote( '<img src="/images/control_rewind.png"/>' , :update=>'tinycal', :url=>{:controller=>'calendar', :action=>'show', :date=>(date << 1), :id=>source[:id], :size=>size, :find=>method, :rnd=>rnd } ) %> 
     3    <%= link_to_remote( _('img_prev_page') , :update=>'tinycal', :url=>{:controller=>'calendar', :action=>'show', :date=>(date << 1), :id=>source[:id], :size=>size, :find=>method, :rnd=>rnd } ) %> 
    44  </td> 
    55  <td class="title"><%= link_to_remote(title, :update=>'tinycal', :url=>{:controller=>'calendar', :action=>'show', :id=>source[:id], :size=>size, :find=>method, :rnd=>rnd }) %></td> 
    66  <td class="button"> 
    7     <%= link_to_remote( '<img src="/images/control_fastforward.png"/>' , :update=>'tinycal', :url=>{:controller=>'calendar', :action=>'show', :date=>(date >> 1), :id=>source[:id], :size=>size, :find=>method, :rnd=>rnd  } ) %> 
     7    <%= link_to_remote( _('img_next_page') , :update=>'tinycal', :url=>{:controller=>'calendar', :action=>'show', :date=>(date >> 1), :id=>source[:id], :size=>size, :find=>method, :rnd=>rnd  } ) %> 
    88  </td> 
    99  </tr> 
  • trunk/app/views/groups/index.rhtml

    r633 r637  
    22  <h3><%= _('manage groups') %></h3> 
    33  <table class="admin" cellspacing="0"> 
     4    <tr><th class='nav' colspan='3'> 
     5    <p class='next_page'><%= link_to _('img_next_page'), { :page => @group_pages.current.next } if @group_pages.current.next %></p> 
     6    <p class='prev_page'><%= link_to _('img_prev_page'), { :page => @group_pages.current.previous } if @group_pages.current.previous %></p></th></tr> 
    47    <%= render :partial=>'groups/li',  :collection=>@groups %> 
    58    <%= render :partial=>'groups/add', :locals=>{:users=>@users} %> 
    69  </table> 
    7   <%= link_to _("Previous page"), { :page => @group_pages.current.previous } if @group_pages.current.previous %> 
    8   <%= link_to _("Next page"), { :page => @group_pages.current.next } if @group_pages.current.next %> 
    910</div> 
    1011 
  • trunk/app/views/relations/_add.erb

    r633 r637  
    11<tr id='add_relation' class='btn_add'> 
    2   <td class='add'><%= link_to_function _('btn_relation_add'), "['add_relation', 'add_relation_form'].each(Element.toggle); $('relation_source_role').focus();" %></td><td colspan='6' class='add_relation'></td> 
     2  <td class='add'><%= link_to_function _('btn_relation_add'), "['add_relation', 'add_relation_form'].each(Element.toggle); $('relation_source_role').focus();" %></td><td colspan='7' class='add_relation'></td> 
    33</tr> 
    44<tr id='add_relation_form' style='display:none;'> 
  • trunk/app/views/relations/_form.erb

    r633 r637  
    66  end %> 
    77</td> 
    8 <td class="add" colspan="6"> 
     8<td class="add" colspan="8"> 
    99  <div id='relation_errors' class='errors'><%= error_messages_for('relation') %></div> 
    1010  <% unless @relation.new_record? %> 
     
    2323      <td class="target" ><%= text_field('relation', 'target_role', :size=>18 ) %></td> 
    2424    </tr> 
     25    <tr><td class="label" ><%= _('type') %></td>    
     26      <td class="source" ><%= radio_button("relation", "source_unique", true) %> <%= _('relation_img') %> 
     27                          <%= radio_button("relation", "source_unique", false) %> <%= _('relations_img') %></td>  
     28      <td class="target" ><%= radio_button("relation", "target_unique", true) %> <%= _('relation_img') %> 
     29                          <%= radio_button("relation", "target_unique", false) %> <%= _('relations_img') %></td> 
     30    </tr> 
    2531    <tr><td class="label"><%= _('kpath') %></td>    
    26       <td class="source"><%= text_field('relation', 'source_kpath', :size=>18 ) %></td> 
    27       <td class="target"><%= text_field('relation', 'target_kpath', :size=>18 ) %></td> 
     32      <td class="source"><%= select('relation', 'source_kpath', Node.kpaths_for_form ) %></td> 
     33      <td class="target"><%= select('relation', 'target_kpath', Node.kpaths_for_form ) %></td> 
    2834    </tr> 
    2935    <tr><td colspan='3'><p class='btn_validate'><input type='submit' value='<%= _('validate') %>'/></p></td></tr> 
  • trunk/app/views/relations/_li.erb

    r635 r637  
    11<tr id='relation<%= li[:id] %>'> 
    2   <td class="icon"><%= link_to_remote(_('relation_img'),  
     2  <td class="source"><%= link_to_remote((li.source_unique? ? _('relation_img') : _('relations_img')),  
    33          :update =>"relation#{li[:id]}",  
    44          :url    => edit_relation_path(li), 
    55          :method => :get) %></td> 
    6   <td class="source"><%= Node.get_class_from_kpath(li.source_kpath).to_s %></td>         
     6  <td class="source"><%= Node.get_class_from_kpath(li.source_kpath).to_s %></td>     
    77  <td class="source_role" ><%= li.source_role %></td> 
    88  <td class="source_icon" ><%= li.source_icon %></td> 
    99  <td class="target_icon" ><%= li.target_icon %></td> 
    10   <td class="target_role" ><%= li.target_role %></td> 
     10  <td class="target_role" ><%= li.target_role %></td>   
    1111  <td class="target"><%= Node.get_class_from_kpath(li.target_kpath).to_s %></td> 
     12  <td class="target" ><%= link_to_remote((li.target_unique? ? _('relation_img') : _('relations_img')),  
     13          :update =>"relation#{li[:id]}",  
     14          :url    => edit_relation_path(li), 
     15          :method => :get) %></td> 
    1216</tr> 
  • trunk/app/views/relations/index.erb

    r633 r637  
    33   
    44  <table id='relation_list' class='admin' cellspacing="0"> 
     5    <tr><th class='nav' colspan='9'> 
     6    <p class='next_page'><%= link_to _('img_next_page'), { :page => @relation_pages.current.next } if @relation_pages.current.next %></p> 
     7    <p class='prev_page'><%= link_to _('img_prev_page'), { :page => @relation_pages.current.previous } if @relation_pages.current.previous %></p></th></tr> 
    58    <%= render :partial=>'relations/li',  :collection=>@relations %> 
    69    <%= render :partial=>'relations/add' %> 
    7   </table>   
    8   <%= link_to _("Previous page"), { :page => @relation_pages.current.previous } if @relation_pages.current.previous %> 
    9   <%= link_to _("Next page"), { :page => @relation_pages.current.next } if @relation_pages.current.next %> 
    10 </div> 
    11  
     10  </table> 
     11  <pre> 
     12    </pre> 
    1213<div id='right'> 
    1314</div> 
  • trunk/app/views/templates/document_create_tabs/_template.rhtml

    r635 r637  
    1515 
    1616<label for='node_c_klass'><%= _('class scope') %></label> 
    17 <%= f.select('c_klass', Node.classes_for_form ) %><br/> 
     17<%= select('node', 'c_klass', Node.classes_for_form ) %><br/> 
    1818 
    1919<label   for='node_v_summary'><%= _('summary') %></label> 
  • trunk/app/views/templates/edit_tabs/_template.rhtml

    r634 r637  
    66 
    77<label for='node_c_klass'><%= _('class scope') %></label> 
    8 <%= f.select('c_klass', Node.classes_for_form ) %><br/> 
     8<%= select('node', 'c_klass', Node.classes_for_form ) %><br/> 
  • trunk/app/views/users/index.rhtml

    r633 r637  
    33   
    44  <table id='user_list' class='admin' cellspacing="0"> 
     5    <tr><th class='nav' colspan='5'> 
     6    <p class='next_page'><%= link_to _('img_next_page'), { :page => @user_pages.current.next } if @user_pages.current.next %></p> 
     7    <p class='prev_page'><%= link_to _('img_prev_page'), { :page => @user_pages.current.previous } if @user_pages.current.previous %></p></th></tr> 
    58    <%= render :partial=>'users/li',  :collection=>@users %> 
    69    <%= render :partial=>'users/add', :locals=>{:groups=>@groups} %> 
    710  </table>   
    8   <%= link_to _("Previous page"), { :page => @user_pages.current.previous } if @user_pages.current.previous %> 
    9   <%= link_to _("Next page"), { :page => @user_pages.current.next } if @user_pages.current.next %> 
    1011</div> 
    1112 
  • trunk/app/views/virtual_classes/_form.erb

    r635 r637  
    1616    <tr><td class='label'><%= _("name")%>      </td><td><%= text_field('virtual_class', 'name',        :size=>15 ) %></td></tr> 
    1717    <tr><td class='label'><%= _("icon")%>      </td><td><%= text_field('virtual_class', 'icon',        :size=>15 ) %></td></tr> 
    18     <tr><td class='label'><%= _("superclass")%></td><td><%= select('virtual_class', 'superclass',  Node.classes_for_form(:without_kpath => (@virtual_class.new_record? ? nil : @virtual_class.kpath)), :selected => @virtual_class.superclass.to_s ) %></td></tr> 
     18    <tr><td class='label'><%= _("superclass")%></td><td><%= select('virtual_class', 'superclass',  Node.classes_for_form(:without => (@virtual_class.new_record? ? nil : @virtual_class.to_s)), :selected => @virtual_class.superclass.to_s ) %></td></tr> 
     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> 
    1920    <tr><td class='label'><%= _("attributes")%></td><td><%= text_field('virtual_class', 'allowed_attributes',  :size=>15 ) %></td></tr> 
    2021    <tr><td colspan='2'><p class='btn_validate'><input type='submit' value='<%= _('validate') %>'/></p></td></tr> 
  • trunk/app/views/virtual_classes/index.erb

    r635 r637  
    33   
    44  <table id='virtual_class_list' class='admin' cellspacing="0"> 
     5    <tr><th class='nav' colspan='6'> 
     6    <p class='next_page'><%= link_to _('img_next_page'), { :page => @virtual_class_pages.current.next } if @virtual_class_pages.current.next %></p> 
     7    <p class='prev_page'><%= link_to _('img_prev_page'), { :page => @virtual_class_pages.current.previous } if @virtual_class_pages.current.previous %></p></th></tr> 
    58    <%= render :partial=>'virtual_classes/li',  :collection=>@virtual_classes %> 
    69    <%= render :partial=>'virtual_classes/add' %> 
    7   </table>   
    8   <%= link_to _("Previous page"), { :page => @virtual_class_pages.current.previous } if @virtual_class_pages.current.previous %> 
    9   <%= link_to _("Next page"), { :page => @virtual_class_pages.current.next } if @virtual_class_pages.current.next %> 
     10  </table> 
    1011</div> 
    1112 
  • trunk/config/deploy.rb

    r597 r637  
    216216desc "Database dump" 
    217217task :db_dump, :roles => :db do 
    218   run "cd #{deploy_to} && mysqldump #{db_name} -u root -p > #{db_name}.sql" do |channel, stream, data| 
     218  run "mysqldump #{db_name} -u root -p > #{deploy_to}/#{db_name}.sql" do |channel, stream, data| 
    219219    if data =~ /^Enter password:\s*/m 
    220220      logger.info "#{channel[:host]} asked for password" 
     
    223223    puts data 
    224224  end 
    225   run "cd #{deploy_to} && tar czf #{db_name}.sql.tar.gz #{db_name}.sql" 
    226   run "cd #{deploy_to} && rm #{db_name}.sql" 
     225  run "tar czf #{deploy_to}/#{db_name}.sql.tar.gz #{deploy_to}/#{db_name}.sql" 
     226  run "rm #{deploy_to}/#{db_name}.sql" 
    227227end 
    228228 
     
    250250  # key track of the current svn revision for app 
    251251   
    252   run "#{in_deploy} svn info > zena_version.txt" 
    253   run "cd #{deploy_to} && tar czf #{db_name}_data.tar.gz #{db_name}.sql.tar.gz data current/zena_version.txt" 
     252  run "#{in_deploy} svn info > #{deploy_to}/current/zena_version.txt" 
     253  run "#{in_deploy} rake zena:full_backup RAILS_ENV='production'" 
     254  run "cd #{deploy_to} && tar czf #{db_name}_data.tar.gz #{db_name}.sql.tar.gz all_data.tar.gz current/zena_version.txt" 
    254255  get_backup 
    255256end 
  • trunk/db/init/base/skins/default/Project.html

    r585 r637  
    55  </r:with> 
    66  <r:with part='body/container/context'> 
    7     <div id='small_calendar' do='calendar'/> 
     7    <div id='small_calendar' do='calendar' find='notes' or='added_notes'/> 
    88    <r:hot> 
    99      <div class='header'> 
  • trunk/db/init/base/skins/default/layout.html

    r635 r637  
    7979              <li do='add' before='self'/> 
    8080              <li class='inline_form' do='form'> 
    81                 <p class='node_klass'>  <input type='select' name='klass' options='Page,Section,Skin,Project'/></p> 
     81                <p class='node_klass'>  <input type='select' name='klass' root_class='Page' without='Document'/></p> 
    8282                <p class='node_v_title'><input type='text' name='v_title' value=''/></p> 
    8383                <p class='btn_validate'><input type="submit" value='validate' tset_value='validate'/></p> 
  • trunk/db/init/base/skins/default/notes.html

    r635 r637  
    1 <div id='notes' do='notes_all' limit='10' order='log_at DESC'> 
     1<div id='notes' do='notes' or='added_notes' limit='10' order='log_at DESC'> 
    22  <ul class='note_list'> 
    33    <li do='add' after='self'/> 
     
    55      <form> 
    66        <p class='node_v_title'><input type='text' name='v_title' size='25'/></p> 
    7         <p class='node_klass'>  <input type='select' name='klass' options='Post,Letter'/></p> 
     7        <p class='node_klass'>  <input type='select' name='klass' root_class='Note' selected='Post'/></p> 
    88        <p class='node_log_at'> <input type='date_box' name='log_at'/></p> 
    99        <p class='validate'>    <input type="submit" value='validate' do='void' tset_value='validate'/></p> 
  • trunk/db/schema.rb

    r635 r637  
    7979    t.column "ext",          :string,  :limit => 20 
    8080    t.column "size",         :integer 
    81     t.column "format",       :string,  :limit => 20 
    8281    t.column "width",        :integer 
    8382    t.column "height",       :integer 
     
    9493  add_index "dyn_attributes", ["owner_id"], :name => "index_dyn_attributes_on_owner_id" 
    9594  add_index "dyn_attributes", ["owner_table"], :name => "index_dyn_attributes_on_owner_table" 
    96  
    97   create_table "form_lines", :force => true do |t| 
    98     t.column "seizure_id", :integer 
    99     t.column "key",        :string 
    100     t.column "value",      :string 
    101   end 
    102  
    103   create_table "form_seizures", :force => true do |t| 
    104     t.column "user_id",    :integer,  :default => 0, :null => false 
    105     t.column "created_at", :datetime 
    106     t.column "updated_at", :datetime 
    107     t.column "form_id",    :integer 
    108   end 
    10995 
    11096  create_table "groups", :force => true do |t| 
     
    148134    t.column "alias",        :string,   :limit => 400 
    149135    t.column "fullpath",     :text 
    150     t.column "dgroup_id",    :integer 
    151136    t.column "custom_base",  :boolean,                 :default => false 
    152137    t.column "basepath",     :text 
     
    205190  end 
    206191 
     192  create_table "tmp", :id => false, :force => true do |t| 
     193    t.column "a", :string, :limit => 50 
     194    t.column "b", :string, :limit => 50 
     195  end 
     196 
    207197  create_table "users", :force => true do |t| 
    208     t.column "created_at",    :datetime 
    209     t.column "updated_at",    :datetime 
    210     t.column "login",         :string,   :limit => 20 
    211     t.column "password",      :string,   :limit => 40 
    212     t.column "lang",          :string,   :limit => 10, :default => "", :null => false 
    213     t.column "password_salt", :string,   :limit => 40 
    214     t.column "first_name",    :string,   :limit => 60 
    215     t.column "name",          :string,   :limit => 60 
    216     t.column "email",         :string,   :limit => 60 
    217     t.column "time_zone",     :string 
     198    t.column "created_at", :datetime 
     199    t.column "updated_at", :datetime 
     200    t.column "login",      :string,   :limit => 20 
     201    t.column "password",   :string,   :limit => 40 
     202    t.column "lang",       :string,   :limit => 10, :default => "", :null => false 
     203    t.column "first_name", :string,   :limit => 60 
     204    t.column "name",       :string,   :limit => 60 
     205    t.column "email",      :string,   :limit => 60 
     206    t.column "time_zone",  :string 
    218207  end 
    219208 
     
    230219    t.column "summary",      :text,                                    :null => false 
    231220    t.column "text",         :text,                                    :null => false 
    232     t.column "status",       :integer,                 :default => 30, :null => false 
    233     t.column "number",       :integer,                 :default => 1,  :null => false 
     221    t.column "status",       :integer,                 :default => 30 
     222    t.column "number",       :integer,                 :default => 1 
    234223    t.column "content_id",   :integer 
    235224    t.column "site_id",      :integer 
  • trunk/lib/gettext_strings.rb

    r635 r637  
    2323    # admin icons 
    2424    N_('relation_img') 
     25    N_('relations_img') 
    2526    N_('btn_relation_add') 
    2627    N_('virtual_class_img') 
     
    3435    N_('img_private')        # icon 
    3536    N_('img_custom_inherit') # icon 
     37    N_('img_user')          # edit users (admin) 
    3638    N_('img_user_admin')    # edit users (admin) 
    3739    N_('img_user_su')       # edit users (admin) 
     
    4042    N_('img_group_pub')     # edit users (admin) 
    4143    N_('img_group_site')    # edit users (admin) 
     44     
     45    N_('img_prev_page')     # admin lists 
     46    N_('img_next_page')     # admin lists 
    4247     
    4348    N_('admin')             # user status 
  • trunk/lib/parser/lib/parser.rb

    r617 r637  
    127127  def render(context={}) 
    128128    return '' if context["no_#{@method}".to_sym] 
    129     @context = context 
     129    if @name 
     130      path = (context[:path] || []) + [@name] 
     131      @context = context.merge(:path => path) 
     132    else 
     133      @context = context 
     134    end 
    130135    @result  = "" 
    131136    return @result unless before_render 
  • trunk/lib/parser/lib/rules/code_syntax.rb

    r634 r637  
    102102  def step 
    103103    if ztag = scan(/\A<\/?r:[^>]+>/)   
    104       ztag =~ /<(\/?)r:([^> ]+?)([^>]*?)(\/?)>/ 
     104      ztag =~ /<(\/?)r:([^> ]+)([^>]*?)(\/?)>/ 
    105105      start_group :tag, "<#{$1}r:" 
    106106      start_group :ztag, $2 
  • trunk/lib/parser/lib/rules/zena.rb

    r632 r637  
    422422      when 'select' 
    423423        return "<span class='parser_error'>select without name</span>"   unless   name = @params[:name] 
    424         klasses = @params[:options] || "Page,Note" 
    425         "<%= select('node', #{name.inspect}, #{klasses.split(',').map(&:strip).inspect}) %>" 
     424        if klass = @params[:root_class] 
     425          opts = {} 
     426          opts[:selected] = @params[:selected] if @params[:selected] 
     427          opts[:without]  = @params[:without]  if @params[:without] 
     428          "<%= select('node', #{name.inspect}, Node.classes_for_form(:class => #{klass.inspect}#{params_to_erb(opts)})) %>" 
     429        else 
     430          klasses = @params[:options] || "Page,Note" 
     431          "<%= select('node', #{name.inspect}, #{klasses.split(',').map(&:strip).inspect}) %>" 
     432        end 
    426433      when 'date_box' 
    427434        return "<span class='parser_error'>date_box without name</span>"   unless   name = @params[:name] 
    428435        "<%= date_box 'node', #{name.inspect}, :size=>15#{@context[:in_add] ? ", :value=>''" : ''} %>" 
    429436      when 'submit' 
    430         return nil # let render_html_tag do the job... 
     437        @html_tag = 'input' 
     438        @html_tag_params[:type] = 'submit' 
     439        render_html_tag(nil) 
    431440      else 
    432441        out make_input(@html_tag_params.merge(@params)) 
     
    951960      from   = 'project' 
    952961      date   = 'main_date' 
    953       find   = (@params[:find  ] || 'news'   ).to_sym 
    954       size   = (@params[:size  ] || 'tiny'    ).to_sym 
    955       using  = (@params[:using ] || 'event_at').gsub(/[^a-z_]/,'').to_sym # SQL injection security 
    956       "<div id='#{size}cal'><%= calendar(:node=>#{node}, :from=>#{from.inspect}, :date=>#{date}, :find=>#{find.inspect}, :size=>#{size.inspect}, :using=>#{using.inspect}) %></div>" 
     962      opts   = @params 
     963      opts[:find]   = (@params[:find  ] || 'news'   ).to_sym 
     964      opts[:size]   = (@params[:size  ] || 'tiny'    ).to_sym 
     965      opts[:using]  = (@params[:using ] || 'event_at').gsub(/[^a-z_]/,'').to_sym # SQL injection security 
     966      "<div id='#{opts[:size]}cal'><%= calendar(:node=>#{node}, :from=>#{from.inspect}, :date=>#{date}#{params_to_erb(opts)}) %></div>" 
    957967    end 
    958968     
     
    12181228     
    12191229    def unique_name 
    1220       "#{@options[:included_history][0].split('::')[0]}/#{((@context[:name] || 'list').split('/')[-1]).gsub(/[^\w\/]/,'_')}" 
     1230      "#{@options[:included_history][0].split('::')[0]}/#{((@context[:path] || ['list'])[-1]).gsub(/[^\w\/]/,'_')}" 
    12211231    end 
    12221232        
  • trunk/lib/parser/test/zafu.yml

    r623 r637  
    104104named_parts: 
    105105  src: "named_parts: <r:void><r:void name='lala'>lala</r:void> <r:test name='start'>start from here to <r:hello name='sub'>sub</r:hello></r:test></r:void> ok." 
    106   res: "named_parts: lala [test {= :name=>'start'}]start from here to [hello {= :name=>'sub'}]sub[/hello][/test] ok." 
     106  res: "named_parts: lala [test {= :name=>'start'} {> :path=>'start'}]start from here to [hello {= :name=>'sub'}]sub[/hello][/test] ok." 
    107107 
    108108include_part: 
  • trunk/lib/tasks/zena.rake

    r633 r637  
    147147  end 
    148148   
     149  desc "Create a backup of all data for a site" 
     150  task :backup_site do 
     151    unless host = ENV['HOST'] 
     152      puts "Please set HOST to the hostname for the site to backup. Aborting." 
     153    else 
     154      path = File.join(SITES_ROOT,ENV['HOST']) 
     155      unless File.exists?(path) 
     156        puts "Site does not exist in '#{SITES_ROOT}'" 
     157      else 
     158        folders = ['data'].map {|f| File.join(SITES_ROOT,f) } 
     159        cmd = "tar czf #{path}_data.tar.gz #{folders.join(' ')}" 
     160        puts cmd 
     161        puts `#{cmd}` 
     162      end 
     163    end