Changeset 637
- Timestamp:
- 2007-06-18 16:54:11 (2 years ago)
- Files:
-
- trunk/TODO (modified) (1 diff)
- trunk/app/controllers/application.rb (modified) (2 diffs)
- trunk/app/controllers/relations_controller.rb (modified) (1 diff)
- trunk/app/controllers/users_controller.rb (modified) (1 diff)
- trunk/app/helpers/application_helper.rb (modified) (1 diff)
- trunk/app/models/node.rb (modified) (4 diffs)
- trunk/app/models/post.rb (deleted)
- trunk/app/models/relation.rb (modified) (1 diff)
- trunk/app/models/template_content.rb (modified) (1 diff)
- trunk/app/models/virtual_class.rb (modified) (4 diffs)
- trunk/app/views/calendar/_large.rhtml (modified) (1 diff)
- trunk/app/views/calendar/_tiny.rhtml (modified) (1 diff)
- trunk/app/views/groups/index.rhtml (modified) (1 diff)
- trunk/app/views/relations/_add.erb (modified) (1 diff)
- trunk/app/views/relations/_form.erb (modified) (2 diffs)
- trunk/app/views/relations/_li.erb (modified) (1 diff)
- trunk/app/views/relations/index.erb (modified) (1 diff)
- trunk/app/views/templates/document_create_tabs/_template.rhtml (modified) (1 diff)
- trunk/app/views/templates/edit_tabs/_template.rhtml (modified) (1 diff)
- trunk/app/views/users/index.rhtml (modified) (1 diff)
- trunk/app/views/virtual_classes/_form.erb (modified) (1 diff)
- trunk/app/views/virtual_classes/index.erb (modified) (1 diff)
- trunk/config/deploy.rb (modified) (3 diffs)
- trunk/db/init/base/skins/default/Project.html (modified) (1 diff)
- trunk/db/init/base/skins/default/layout.html (modified) (1 diff)
- trunk/db/init/base/skins/default/notes.html (modified) (2 diffs)
- trunk/db/schema.rb (modified) (5 diffs)
- trunk/lib/gettext_strings.rb (modified) (3 diffs)
- trunk/lib/parser/lib/parser.rb (modified) (1 diff)
- trunk/lib/parser/lib/rules/code_syntax.rb (modified) (1 diff)
- trunk/lib/parser/lib/rules/zena.rb (modified) (3 diffs)
- trunk/lib/parser/test/zafu.yml (modified) (1 diff)
- trunk/lib/tasks/zena.rake (modified) (2 diffs)
- trunk/locale/en/LC_MESSAGES/zena.mo (modified) (previous)
- trunk/locale/fr/LC_MESSAGES/zena.mo (modified) (previous)
- trunk/po/en/zena.po (modified) (20 diffs)
- trunk/po/fr/zena.po (modified) (18 diffs)
- trunk/po/zena.pot (modified) (16 diffs)
- trunk/public/images/collection.png (added)
- trunk/public/images/ext/doc.png (modified) (previous)
- trunk/public/images/ext/doc_tiny.png (modified) (previous)
- trunk/public/images/target.png (added)
- trunk/public/stylesheets/admin.css (modified) (4 diffs)
- trunk/test/fixtures/nodes.yml (modified) (2 diffs)
- trunk/test/functional/application_controller_test.rb (modified) (2 diffs)
- trunk/test/helpers/basic.yml (modified) (2 diffs)
- trunk/test/helpers/relations.yml (modified) (1 diff)
- trunk/test/helpers/zena_parser_test.rb (modified) (1 diff)
- trunk/test/unit/node_test.rb (modified) (1 diff)
- trunk/test/unit/virtual_class_test.rb (modified) (3 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
trunk/TODO
r633 r637 17 17 18 18 * 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) 19 21 * if mksite fails (password too short, etc): rollback ! 20 22 * What if a Note/Contact contains pages and one of these pages has 'custom_base' set ? trunk/app/controllers/application.rb
r619 r637 106 106 mode = opts[:mode] 107 107 format = opts[:format] || 'html' 108 klass = @node. class108 klass = @node.vclass 109 109 110 110 # possible classes for the master template : … … 362 362 params[:lang], 363 363 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 364 365 session[:lang], 365 (visitor.is_anon? ? nil : visitor.lang), # visitor.lang comes before http headers if logged in366 366 (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] }, 367 367 (visitor.is_anon? ? visitor.lang : nil), # anonymous user's lang comes last trunk/app/controllers/relations_controller.rb
r633 r637 10 10 @relation_pages, @relations = nil, nil 11 11 secure(Relation) do 12 @relation_pages, @relations = paginate :relations, :per_page => 20 12 @relation_pages, @relations = paginate :relations, :per_page => 20, :order => 'source_role' 13 13 end 14 14 respond_to do |format| trunk/app/controllers/users_controller.rb
r636 r637 70 70 @user.errors.add('password', 'too short') 71 71 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 74 76 end 75 77 unless visitor.is_admin? trunk/app/helpers/application_helper.rb
r635 r637 479 479 480 480 # get list of notes in this scope 481 Node.logger.info "\n\n\n\n\n\n\n\n" 481 482 notes = source.relation(method, :conditions=>["#{using} >= ? AND #{using} <= ?", start_date, end_date], :order=>"#{using} ASC", :or => options[:or]) || [] 482 483 trunk/app/models/node.rb
r635 r637 149 149 class << self 150 150 151 # needed for compatibility with virtual classes 152 alias create_instance create 153 alias new_instance new 154 # == 155 156 151 157 def inherited(child) 152 158 super … … 166 172 # FIXME: how to make sure all sub-classes of Node are loaded before this is called ? 167 173 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={}) 168 191 virtual_classes = VirtualClass.find(:all, :conditions => ["site_id = ? AND create_group_id IN (?) AND kpath LIKE '#{self.kpath}%'", current_site[:id], visitor.group_ids]) 169 192 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 174 198 end 175 199 … … 192 216 193 217 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]) 195 219 end 196 220 … … 293 317 294 318 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) 298 322 end 299 323 node.publish if publish trunk/app/models/relation.rb
r634 r637 199 199 end 200 200 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 201 209 private 202 210 def valid_relation trunk/app/models/template_content.rb
r587 r637 57 57 if self[:klass] 58 58 # 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]) 62 60 self[:tkpath] = klass.kpath 63 rescue NameError61 else 64 62 errors.add('klass', 'invalid') 65 63 end trunk/app/models/virtual_class.rb
r635 r637 7 7 end 8 8 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 9 23 # check inheritance chain through kpath 10 24 def kpath_match?(kpath) … … 20 34 end 21 35 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) 23 46 obj = real_class.new(*args) 24 47 obj[:vclass_id] = self[:id] … … 39 62 end 40 63 41 def create(*args) 64 # create instances, not virtual classes 65 def create_instance(*args) 42 66 if @scope 43 67 real_class.with_exclusive_scope(@scope) { 44 obj = self.new (*args)68 obj = self.new_instance(*args) 45 69 obj.save 46 70 obj 47 71 } 48 72 else 49 obj = self.new (*args)73 obj = self.new_instance(*args) 50 74 obj.save 51 75 obj … … 55 79 private 56 80 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 62 117 end 63 118 end trunk/app/views/calendar/_large.rhtml
r79 r637 1 1 2 2 <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> 4 4 <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> 6 6 </h3> 7 7 <table cellspacing="0" class="largecal"> trunk/app/views/calendar/_tiny.rhtml
r599 r637 1 1 <table cellspacing="0" class='tinycal'> 2 2 <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 } ) %> 4 4 </td> 5 5 <td class="title"><%= link_to_remote(title, :update=>'tinycal', :url=>{:controller=>'calendar', :action=>'show', :id=>source[:id], :size=>size, :find=>method, :rnd=>rnd }) %></td> 6 6 <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 } ) %> 8 8 </td> 9 9 </tr> trunk/app/views/groups/index.rhtml
r633 r637 2 2 <h3><%= _('manage groups') %></h3> 3 3 <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> 4 7 <%= render :partial=>'groups/li', :collection=>@groups %> 5 8 <%= render :partial=>'groups/add', :locals=>{:users=>@users} %> 6 9 </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 %>9 10 </div> 10 11 trunk/app/views/relations/_add.erb
r633 r637 1 1 <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> 3 3 </tr> 4 4 <tr id='add_relation_form' style='display:none;'> trunk/app/views/relations/_form.erb
r633 r637 6 6 end %> 7 7 </td> 8 <td class="add" colspan=" 6">8 <td class="add" colspan="8"> 9 9 <div id='relation_errors' class='errors'><%= error_messages_for('relation') %></div> 10 10 <% unless @relation.new_record? %> … … 23 23 <td class="target" ><%= text_field('relation', 'target_role', :size=>18 ) %></td> 24 24 </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> 25 31 <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> 28 34 </tr> 29 35 <tr><td colspan='3'><p class='btn_validate'><input type='submit' value='<%= _('validate') %>'/></p></td></tr> trunk/app/views/relations/_li.erb
r635 r637 1 1 <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')), 3 3 :update =>"relation#{li[:id]}", 4 4 :url => edit_relation_path(li), 5 5 :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> 7 7 <td class="source_role" ><%= li.source_role %></td> 8 8 <td class="source_icon" ><%= li.source_icon %></td> 9 9 <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> 11 11 <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> 12 16 </tr> trunk/app/views/relations/index.erb
r633 r637 3 3 4 4 <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> 5 8 <%= render :partial=>'relations/li', :collection=>@relations %> 6 9 <%= 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> 12 13 <div id='right'> 13 14 </div> trunk/app/views/templates/document_create_tabs/_template.rhtml
r635 r637 15 15 16 16 <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/> 18 18 19 19 <label for='node_v_summary'><%= _('summary') %></label> trunk/app/views/templates/edit_tabs/_template.rhtml
r634 r637 6 6 7 7 <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 3 3 4 4 <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> 5 8 <%= render :partial=>'users/li', :collection=>@users %> 6 9 <%= render :partial=>'users/add', :locals=>{:groups=>@groups} %> 7 10 </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 %>10 11 </div> 11 12 trunk/app/views/virtual_classes/_form.erb
r635 r637 16 16 <tr><td class='label'><%= _("name")%> </td><td><%= text_field('virtual_class', 'name', :size=>15 ) %></td></tr> 17 17 <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> 19 20 <tr><td class='label'><%= _("attributes")%></td><td><%= text_field('virtual_class', 'allowed_attributes', :size=>15 ) %></td></tr> 20 21 <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 3 3 4 4 <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> 5 8 <%= render :partial=>'virtual_classes/li', :collection=>@virtual_classes %> 6 9 <%= 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> 10 11 </div> 11 12 trunk/config/deploy.rb
r597 r637 216 216 desc "Database dump" 217 217 task :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| 219 219 if data =~ /^Enter password:\s*/m 220 220 logger.info "#{channel[:host]} asked for password" … … 223 223 puts data 224 224 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" 227 227 end 228 228 … … 250 250 # key track of the current svn revision for app 251 251 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" 254 255 get_backup 255 256 end trunk/db/init/base/skins/default/Project.html
r585 r637 5 5 </r:with> 6 6 <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'/> 8 8 <r:hot> 9 9 <div class='header'> trunk/db/init/base/skins/default/layout.html
r635 r637 79 79 <li do='add' before='self'/> 80 80 <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> 82 82 <p class='node_v_title'><input type='text' name='v_title' value=''/></p> 83 83 <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'> 2 2 <ul class='note_list'> 3 3 <li do='add' after='self'/> … … 5 5 <form> 6 6 <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> 8 8 <p class='node_log_at'> <input type='date_box' name='log_at'/></p> 9 9 <p class='validate'> <input type="submit" value='validate' do='void' tset_value='validate'/></p> trunk/db/schema.rb
r635 r637 79 79 t.column "ext", :string, :limit => 20 80 80 t.column "size", :integer 81 t.column "format", :string, :limit => 2082 81 t.column "width", :integer 83 82 t.column "height", :integer … … 94 93 add_index "dyn_attributes", ["owner_id"], :name => "index_dyn_attributes_on_owner_id" 95 94 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", :integer99 t.column "key", :string100 t.column "value", :string101 end102 103 create_table "form_seizures", :force => true do |t|104 t.column "user_id", :integer, :default => 0, :null => false105 t.column "created_at", :datetime106 t.column "updated_at", :datetime107 t.column "form_id", :integer108 end109 95 110 96 create_table "groups", :force => true do |t| … … 148 134 t.column "alias", :string, :limit => 400 149 135 t.column "fullpath", :text 150 t.column "dgroup_id", :integer151 136 t.column "custom_base", :boolean, :default => false 152 137 t.column "basepath", :text … … 205 190 end 206 191 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 207 197 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 218 207 end 219 208 … … 230 219 t.column "summary", :text, :null => false 231 220 t.column "text", :text, :null => false 232 t.column "status", :integer, :default => 30 , :null => false233 t.column "number", :integer, :default => 1 , :null => false221 t.column "status", :integer, :default => 30 222 t.column "number", :integer, :default => 1 234 223 t.column "content_id", :integer 235 224 t.column "site_id", :integer trunk/lib/gettext_strings.rb
r635 r637 23 23 # admin icons 24 24 N_('relation_img') 25 N_('relations_img') 25 26 N_('btn_relation_add') 26 27 N_('virtual_class_img') … … 34 35 N_('img_private') # icon 35 36 N_('img_custom_inherit') # icon 37 N_('img_user') # edit users (admin) 36 38 N_('img_user_admin') # edit users (admin) 37 39 N_('img_user_su') # edit users (admin) … … 40 42 N_('img_group_pub') # edit users (admin) 41 43 N_('img_group_site') # edit users (admin) 44 45 N_('img_prev_page') # admin lists 46 N_('img_next_page') # admin lists 42 47 43 48 N_('admin') # user status trunk/lib/parser/lib/parser.rb
r617 r637 127 127 def render(context={}) 128 128 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 130 135 @result = "" 131 136 return @result unless before_render trunk/lib/parser/lib/rules/code_syntax.rb
r634 r637 102 102 def step 103 103 if ztag = scan(/\A<\/?r:[^>]+>/) 104 ztag =~ /<(\/?)r:([^> ]+ ?)([^>]*?)(\/?)>/104 ztag =~ /<(\/?)r:([^> ]+)([^>]*?)(\/?)>/ 105 105 start_group :tag, "<#{$1}r:" 106 106 start_group :ztag, $2 trunk/lib/parser/lib/rules/zena.rb
r632 r637 422 422 when 'select' 423 423 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 426 433 when 'date_box' 427 434 return "<span class='parser_error'>date_box without name</span>" unless name = @params[:name] 428 435 "<%= date_box 'node', #{name.inspect}, :size=>15#{@context[:in_add] ? ", :value=>''" : ''} %>" 429 436 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) 431 440 else 432 441 out make_input(@html_tag_params.merge(@params)) … … 951 960 from = 'project' 952 961 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>" 957 967 end 958 968 … … 1218 1228 1219 1229 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\/]/,'_')}" 1221 1231 end 1222 1232 trunk/lib/parser/test/zafu.yml
r623 r637 104 104 named_parts: 105 105 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." 107 107 108 108 include_part: trunk/lib/tasks/zena.rake
r633 r637 147 147 end 148 148 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
