Changeset 1061
- Timestamp:
- 2008-06-15 00:51:32 (7 months ago)
- Files:
-
- trunk/README (modified) (1 diff)
- trunk/app/controllers/application.rb (modified) (2 diffs)
- trunk/app/controllers/comments_controller.rb (modified) (5 diffs)
- trunk/app/helpers/application_helper.rb (modified) (1 diff)
- trunk/app/models/comment.rb (modified) (1 diff)
- trunk/app/models/node.rb (modified) (4 diffs)
- trunk/app/models/site.rb (modified) (3 diffs)
- trunk/app/views/comments/_bin.rhtml (modified) (1 diff)
- trunk/app/views/comments/_li.rhtml (modified) (2 diffs)
- trunk/app/views/comments/_list.rhtml (modified) (1 diff)
- trunk/app/views/comments/index.rhtml (modified) (1 diff)
- trunk/app/views/comments/publish.rjs (modified) (1 diff)
- trunk/app/views/comments/remove.rjs (modified) (1 diff)
- trunk/app/views/nodes/create.rjs (modified) (1 diff)
- trunk/app/views/sites/_form.erb (modified) (2 diffs)
- trunk/app/views/virtual_classes/_li.erb (modified) (1 diff)
- trunk/config/environment.rb (modified) (1 diff)
- trunk/config/routes.rb (modified) (2 diffs)
- trunk/db/migrate/000_zena/038_create_site_attributes.rb (added)
- trunk/db/schema.rb (modified) (1 diff)
- trunk/lib/core_ext/patcher.rb (added)
- trunk/lib/parser/lib/rules/zena.rb (modified) (15 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) (5 diffs)
- trunk/po/fr/zena.po (modified) (5 diffs)
- trunk/po/zena.pot (modified) (5 diffs)
- trunk/public/stylesheets/comment.css (modified) (1 diff)
- trunk/public/stylesheets/popup.css (modified) (3 diffs)
- trunk/public/stylesheets/zena.css (modified) (1 diff)
- trunk/test/functional/comments_controller_test.rb (modified) (1 diff)
- trunk/test/helpers/zena_parser/ajax.yml (modified) (1 diff)
- trunk/test/helpers/zena_parser/basic.yml (modified) (5 diffs)
- trunk/test/helpers/zena_parser_test.rb (modified) (1 diff)
- trunk/test/sites/zena/nodes.yml (modified) (1 diff)
- trunk/test/unit/comment_test.rb (modified) (3 diffs)
- trunk/test/unit/dyn_attributes_test.rb (modified) (1 diff)
- trunk/test/unit/node_test.rb (modified) (3 diffs)
- trunk/test/unit/site_test.rb (modified) (1 diff)
- trunk/test/zena_test.rb (modified) (1 diff)
- trunk/vendor/plugins/dyn_attributes/lib/dyn_attributes.rb (modified) (4 diffs)
- trunk/vendor/plugins/zena_captcha (added)
- trunk/vendor/plugins/zena_captcha/MIT-LICENSE (added)
- trunk/vendor/plugins/zena_captcha/README (added)
- trunk/vendor/plugins/zena_captcha/init.rb (added)
- trunk/vendor/plugins/zena_captcha/lib (added)
- trunk/vendor/plugins/zena_captcha/lib/zena_captcha.rb (added)
- trunk/vendor/plugins/zena_captcha/patch (added)
- trunk/vendor/plugins/zena_captcha/patch/application.rb (added)
- trunk/vendor/plugins/zena_captcha/patch/application_helper.rb (added)
- trunk/vendor/plugins/zena_captcha/patch/site.rb (added)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
trunk/README
r1045 r1061 99 99 rake mongrel mongrel_cluster rmagick tzinfo RedCloth syntax gettext mongrel_upload_progress uuidtools daemons ruby-debug 100 100 101 gem install --source http://www.loonsoft.com/recaptcha/pkg/ recaptcha 102 101 103 === Advised tools 102 104 monit (debian package to monitor your mongrel processes) trunk/app/controllers/application.rb
r1050 r1061 734 734 def error_messages_for(obj, opts={}) 735 735 return '' if obj.errors.empty? 736 res = ["< ulclass='#{opts[:class] || 'errors'}'>"]736 res = ["<table class='#{opts[:class] || 'errors'}'>"] 737 737 obj.errors.each do |er,msg| 738 res << "< li><b>#{er}</b> #{_(msg)}</li>"739 end 740 res << '</ ul>'738 res << "<tr><td><b>#{er}</b></td><td>#{_(msg)}</td></tr>" 739 end 740 res << '</table>' 741 741 res.join("\n") 742 742 end … … 815 815 adate.strftime(format) 816 816 end 817 818 # Read the parameters and add errors to the object if it is considered spam. Save it otherwize. 819 def save_if_not_spam(obj, params) 820 # do nothing (overwritten by plugins like zena_captcha) 821 obj.save 822 end 823 end 817 824 818 end 825 load_patches_from_plugins trunk/app/controllers/comments_controller.rb
r1060 r1061 1 1 # FIXME: rewrite ! 2 2 class CommentsController < ApplicationController 3 before_filter :find_comment, :except => [:create, :index ]3 before_filter :find_comment, :except => [:create, :index, :empty_bin] 4 4 before_filter :find_node_and_discussion, :only => [:create] 5 5 before_filter :check_is_admin, :only=>[:index, :empty_bin] 6 helper_method :bin_content 6 helper_method :bin_content, :bin_content_size 7 layout :admin_layout 7 8 8 9 # TODO: test … … 22 23 @discussion.save if @discussion.new_record? && @node.can_comment? 23 24 24 @comment = secure!(Comment) { Comment.create(filter_attributes(params[:comment])) } 25 @comment = secure!(Comment) { Comment.new(filter_attributes(params[:comment])) } 26 27 save_if_not_spam(@comment, params) 25 28 26 29 respond_to do |format| … … 66 69 @node = secure(Node) { Node.find(@discussion[:node_id]) } 67 70 if @node && visitor.is_admin? || @node.can_drive? 71 Node.logger.error "\n\nremoving...\n\n" 68 72 @comment.remove 69 73 else … … 88 92 def index 89 93 @node = visitor.contact 90 @comment_pages, @comments = 91 paginate :comments, :order => 'status ASC, created_at DESC', :conditions=>"status > #{Zena::Status[:rem]}", :per_page => 20 92 render :layout=>admin_layout 94 secure!(Node) do 95 @comment_pages, @comments = paginate :comments, 96 :select => "comments.*", 97 :order => 'status ASC, comments.created_at DESC', 98 :join => 'INNER JOIN (discussions, nodes) on nodes.id = discussions.node_id and comments.discussion_id = discussions.id', 99 :conditions=>"status > #{Zena::Status[:rem]} AND (#{secure_scope('nodes')})", 100 :per_page => 20 101 end 93 102 end 94 103 … … 115 124 116 125 def bin_content 117 @bin_content ||= Comment.find(:all, :conditions=>['status <= ?', Zena::Status[:rem]]) 126 @bin_content ||= secure(Comment) { Comment.find(:all, :conditions=>['status <= ?', Zena::Status[:rem]]) } 127 end 128 129 def bin_content_size 130 secure(Comment) { Comment.count(:all, :conditions=>['status <= ?', Zena::Status[:rem]]) } 118 131 end 119 132 trunk/app/helpers/application_helper.rb
r1057 r1061 1280 1280 end 1281 1281 end 1282 =begin 1283 1284 # Methods added to this helper will be available to all templates in the application. 1285 module ApplicationHelper 1286 include Zena::Acts::SecureScope 1287 include Zena::Acts::Secure::InstanceMethods 1288 include ZenaGlobals 1289 uses_strips :base, :admin, :calendar 1290 1291 # Overwrite error_messages_for to include translation 1292 def error_messages_for(object_name, options = {}) 1293 options = options.symbolize_keys 1294 object = instance_variable_get("@#{object_name}") 1295 if object && !object.errors.empty? 1296 content_tag("div", 1297 content_tag("ul", object.errors.full_messages.collect { |msg| content_tag("li", t(msg)) }), 1298 "id" => options[:id] || "errorExplanation", "class" => options[:class] || "errorExplanation" 1299 ) 1300 else 1301 "" 1302 end 1303 end 1304 1305 1306 1307 end 1308 1309 =end 1282 load_patches_from_plugins trunk/app/models/comment.rb
r1060 r1061 87 87 errors.add('base', 'you cannot comment here') unless visitor.commentator? && discussion && discussion.open? 88 88 else 89 if !is_author? 89 if discussion.node.can_drive? 90 # OK 91 # can edit/delete comments 92 # TODO: should be restricted to 'delete' or 'erase text'... 93 elsif is_author? 94 errors.add('base', 'discussion closed, comment cannot be updated') if !can_write? 95 else 90 96 errors.add('base', 'you do not have the rights to do this') 91 else92 errors.add('base', 'discussion closed, comment cannot be updated') if !can_write?93 97 end 94 98 end 95 errors.add('text', "can't be blank") unless self[:text] && self[:text] != '' 96 errors.add('title', "can't be blank") unless self[:title] && self[:title] != '' 99 errors.add('text', "can't be blank") if self[:text].blank? 97 100 errors.add('discussion', 'invalid') unless discussion 98 101 errors.add('ip', "can't be blank") unless self[:ip] || !visitor.is_anon? trunk/app/models/node.rb
r1060 r1061 151 151 before_create :node_before_create 152 152 after_save :spread_project_and_section 153 after_create :node_after_create 153 154 attr_protected :site_id, :zip, :id, :section_id, :project_id, :publish_from, :max_status 154 155 attr_protected :c_version_id, :c_node_id # TODO: test … … 1036 1037 1037 1038 # Find the discussion for the current context (v_status and v_lang). This automatically creates a new #Discussion if there is 1038 # no closed or open discussion for the current lang and any of the following conditions are met: 1039 # - there already exists an +outside+, +open+ discussion for another language 1040 # - the virtual_class field auto_create_discussion is true 1041 # - the user has drive access to the node 1039 # no closed or open discussion for the current lang and Node#can_auto_create_discussion? is true 1042 1040 def discussion 1043 1041 return @discussion if defined?(@discussion) … … 1052 1050 end 1053 1051 1052 # Automatically create a discussion if any of the following conditions are met: 1053 # - there already exists an +outside+, +open+ discussion for another language 1054 # - the node is not published (creates an internal discussion) 1055 # - the user has drive access to the node 1054 1056 def can_auto_create_discussion? 1055 1057 can_drive? || 1056 1058 (v_status != Zena::Status[:pub]) || 1057 1059 Discussion.find(:first, :conditions=>[ "node_id = ? AND inside = ? AND open = ?", 1058 self[:id], false, true ]) || 1059 (vclass.auto_create_discussion) 1060 end 1061 1062 # Comments for the current context. Returns [] when none found. 1060 self[:id], false, true ]) 1061 end 1062 1063 # Comments for the current context. Returns nil when there is no discussion. 1063 1064 def comments 1064 1065 if discussion 1065 discussion.comments(:with_prop=>can_drive?) 1066 res = discussion.comments(:with_prop=>can_drive?) 1067 res == [] ? nil : res 1066 1068 else 1067 []1069 nil 1068 1070 end 1069 1071 end … … 1246 1248 end 1247 1249 1250 # Create an 'outside' discussion if the virtual class has auto_create_discussion set 1251 def node_after_create 1252 if vclass.auto_create_discussion 1253 Discussion.create(:node_id=>self[:id], :lang=>v_lang, :inside => false) 1254 end 1255 end 1256 1248 1257 # Called after a node is 'unpublished' 1249 1258 def after_unpublish trunk/app/models/site.rb
r1008 r1061 19 19 validate :valid_site 20 20 validates_uniqueness_of :host 21 attr_accessible :name, :languages, :default_lang, :authentication, :monolingual, :allow_private, :http_auth, :auto_publish, :redit_time 21 # we are using 'attr_protected' instead of attr_accessible because we have dynamic attributes 22 attr_protected *(column_names.map{|e| e.to_sym} - [:name, :languages, :default_lang, :authentication, :monolingual, :allow_private, :http_auth, :auto_publish, :redit_time]) 22 23 has_many :groups, :order => "name" 23 24 has_many :nodes 24 25 has_many :participations, :dependent => :destroy 25 26 has_many :users, :through => :participations 27 uses_dynamic_attributes :table_name => 'site_attributes' 28 29 @@attributes_for_form = { 30 :bool => [:authentication, :monolingual, :allow_private, :http_auth, :auto_publish], 31 :text => [:name, :languages, :default_lang], 32 } 26 33 27 34 class << self … … 152 159 site 153 160 end 161 162 # List of attributes that can be configured in the admin form 163 def attributes_for_form 164 @@attributes_for_form 165 end 154 166 end 155 167 … … 310 322 end 311 323 end 324 325 load_patches_from_plugins trunk/app/views/comments/_bin.rhtml
r512 r1061 1 <% if bin_content .size == 0 %>1 <% if bin_content_size == 0 %> 2 2 <img src='/images/bin_empty.gif'/> 3 3 <% else %> 4 <img src='/images/bin_full.gif'/><span><%= bin_content .size %></span> <%= link_to_remote(_('btn_bomb'), :url=>{:controller=>'comments', :action=>'empty_bin'}, :confirm=>_('Are you sure you want to permanently remove the content of this rubbish bin ?')) %>4 <img src='/images/bin_full.gif'/><span><%= bin_content_size %></span> <%= link_to_remote(_('btn_bomb'), :url => empty_bin_comments_path, :confirm=>_('Are you sure you want to permanently remove the content of this rubbish bin ?'), :method => :delete ) %> 5 5 <% end %> trunk/app/views/comments/_li.rhtml
r1060 r1061 1 <% puts li.inspect %>2 1 <li id='comment<%= li[:id] %>' <%= "class='c40' " if li[:status] < Zena::Status[:pub] %>><div class='header'> 3 <span class='reply'><% if li.can_write? -%>4 <%= link_to_remote(_('edit'), :url=>{:controller=>'comments', :action=>'edit', :id=>li[:id] }) %>5 <% elsif @node && @node.can_comment? -%>6 <%= link_to_remote(_('reply'), :url=>{:controller=>'comments', :action=>'reply_to', :id=>li[:id] }) %>7 <% end -%>8 </span>9 2 <span class='actions'> 10 <%= link_to_remote(_('btn_remove'), :url =>{:controller=>'comments', :action=>'remove', :id=>li[:id], :bin=>@admin }) if @admin || (@node.can_drive? && li[:status] < Zena::Status[:pub]) %>11 <%= link_to_remote(_('btn_publish'), :url=> {:controller=>'comments', :action=>'publish', :id=>li[:id], :bin=>@admin }) if (@admin || @node.can_drive?) &&li[:status] < Zena::Status[:pub] %>3 <%= link_to_remote(_('btn_remove'), :url => remove_comment_path(:id=>li[:id], :bin=>@admin), :method => :put) %> 4 <%= link_to_remote(_('btn_publish'), :url=> publish_comment_path(:id=>li[:id], :bin=>@admin), :method => :put) if li[:status] < Zena::Status[:pub] %> 12 5 </span> 13 6 <span class='date'><%= long_date(li.created_at) + " " + short_time(li.created_at) %></span> … … 17 10 <div class='body'> 18 11 <div class='zazen'><%= zazen(li.text) %></div> 19 <ul class='sub' id='replies_to<%= li[:id] %>'><%= render(:partial=>'comments/li', :collection=>li.replies(:with_prop=>@node.can_publish?)) unless @admin %></ul>20 12 </div> 21 13 </li> trunk/app/views/comments/_list.rhtml
r692 r1061 2 2 if @comments || node.discussion %> 3 3 <div class='comments' id='comments'> 4 <div id='comment_errors'></div> 4 5 <ul><%= render :partial=>'comments/li', :collection => @comments || node.comments %> 5 6 <% if node.can_comment? -%> trunk/app/views/comments/index.rhtml
r796 r1061 1 1 <h3><%= _('manage comments') %></h3> 2 <div id='comment_errors'></div> 2 3 3 4 <ul class='comments' id='comments_list'> trunk/app/views/comments/publish.rjs
r1060 r1061 1 page.visual_effect :highlight, "comment#{@comment[:id]}", :duration => 1.0 2 page.replace "comment#{@comment[:id]}", :partial=>'comments/li', :locals=>{:li=>@comment} 1 if @comment.errors.empty? 2 page.visual_effect :highlight, "comment#{@comment[:id]}", :duration => 1.0 3 page.replace "comment#{@comment[:id]}", :partial=>'comments/li', :collection => [@comment] 4 page.replace_html "comment_errors", :inline=>"" 5 else 6 page.replace_html "comment_errors", :inline=>error_messages_for(@comment) 7 end trunk/app/views/comments/remove.rjs
r484 r1061 1 page.visual_effect :highlight, "comment#{@comment[:id]}", :duration => 0.3 2 page.visual_effect :fade, "comment#{@comment[:id]}", :duration => 0.5 3 if params[:bin] 4 page.replace_html 'bin', :partial=>'comments/bin' 1 if @comment.errors.empty? 2 page.visual_effect :fade, "comment#{@comment[:id]}", :duration => 0.2 3 if params[:bin] 4 page.replace_html 'bin', :partial=>'comments/bin' 5 end 6 page.replace_html "comment_errors", :inline=>"" 7 else 8 page.replace_html "comment_errors", :inline=>error_messages_for(@comment) 5 9 end trunk/app/views/nodes/create.rjs
r857 r1061 5 5 ref = params[:reference] || "#{dom_id_from_template_url}_add" 6 6 page.insert_html pos.to_sym, ref, :file => fullpath_from_template_url + ".erb" 7 @node = @node.parent.new_child(:class => @node.class)8 page.replace "#{dom_id_from_template_url}_form", :file => fullpath_from_template_url + "_form.erb"9 7 if params[:done] 10 page << params[:done] 8 page << params[:done].gsub("NODE_ID", @node.zip).gsub("PARENT_ID", @node.parent_zip) 11 9 else 12 10 page.toggle "#{dom_id_from_template_url}_form", "#{dom_id_from_template_url}_add" 13 11 end 12 13 @node = @node.parent.new_child(:class => @node.class) 14 page.replace "#{dom_id_from_template_url}_form", :file => fullpath_from_template_url + "_form.erb" 14 15 end trunk/app/views/sites/_form.erb
r957 r1061 15 15 <table cellspacing='0' class='edit_site'> 16 16 <tr><td class='label'><%= _('host') %></td><td><%= @site[:host] %></td></tr> 17 <% [:name, :languages, :default_lang].each do |sym| -%>18 <tr><td class='label'><%= _(sym.to_s ) %></td><td><%= text_field('site', sym, :size=>15) %></td></tr>17 <% Site.attributes_for_form[:text].each do |sym| -%> 18 <tr><td class='label'><%= _(sym.to_s.sub(/\Ad_/,'').sub('_',' ')) %></td><td><%= text_field('site', sym, :size=>nil) %></td></tr> 19 19 <% end -%> 20 20 <tr><td class='label'><%= _('redit_time') %></td><td><%= text_field('site', :redit_time, :size=>15, :value => @site.redit_time) %></td></tr> … … 22 22 <tr><td class='label'><%= _('site group') %></td><td><%= @site.site_group.name %></td></tr> 23 23 <tr><td class='label'><%= _('options') %></td><td> 24 <% [:authentication, :monolingual, :allow_private, :http_auth, :auto_publish].each do |sym| -%>24 <% Site.attributes_for_form[:bool].each do |sym| -%> 25 25 <input type='hidden' name='site[<%= sym %>]' value=''/><input type='checkbox' name='site[<%= sym %>]' value='1'<%= @site[sym] ? " checked='checked'" : '' %>/> <%= _(sym.to_s) %> 26 26 <% end -%> trunk/app/views/virtual_classes/_li.erb
r1060 r1061 6 6 <td><%= li.name %></td> 7 7 <td class="adm_icon" ><%= li.icon ? "<img src='#{li.icon}'/>" : "" %></td> 8 <td class="auto_create_discussion" ><%= li.auto_create_discussion ? _(' yes') : _('no')%></td>8 <td class="auto_create_discussion" ><%= li.auto_create_discussion ? _('auto discussion') : '' %></td> 9 9 <td class="create_group"><%= li.create_group.name %></td> 10 10 <td class="superclass" ><%= li.superclass %></td> trunk/config/environment.rb
r964 r1061 72 72 require File.join(File.dirname(__FILE__), '../lib/core_ext/fixnum') 73 73 require File.join(File.dirname(__FILE__), '../lib/core_ext/dir') 74 require File.join(File.dirname(__FILE__), '../lib/core_ext/patcher') 74 75 ZazenParser = Parser.parser_with_rules(Zazen::Rules, Zazen::Tags) 75 76 ZafuParser = Parser.parser_with_rules(Zafu::Rules, Zena::Rules, Zafu::Tags, Zena::Tags) trunk/config/routes.rb
r1057 r1061 51 51 map.resources :sites, 52 52 :member => { :clear_cache => :post} 53 map.resources :comments 53 map.resources :comments, 54 :collection => { :empty_bin => :delete }, 55 :member => { :remove => :put, 56 :publish => :put, 57 :reply_to => :post, 58 } 54 59 map.resources :data_entries, :member => { :zafu => :get } 55 60 … … 93 98 94 99 # temporary routes... 95 map.connect 'comments/:action/:id', :controller => 'comments'96 100 map.connect 'discussions/:action/:id', :controller => 'discussions' 97 101 map.connect 'z/link/:action/:id', :controller => 'link' trunk/db/schema.rb
r1060 r1061 212 212 end 213 213 214 create_table "site_attributes", :force => true do |t| 215 t.column "owner_id", :integer 216 t.column "key", :string 217 t.column "value", :text 218 end 219 220 add_index "site_attributes", ["owner_id"], :name => "index_site_attributes_on_owner_id" 221 214 222 create_table "sites", :force => true do |t| 215 223 t.column "host", :string trunk/lib/parser/lib/rules/zena.rb
r1059 r1061 819 819 hidden_fields['done'] = "$('#{dom_id_from_template_url}_#{add_block.params[:focus] || 'v_title'}').focus();" 820 820 elsif params[:done] 821 hidden_fields['done'] = params[:done].inspect821 hidden_fields['done'] = CGI.escape(params[:done]) 822 822 end 823 823 end … … 834 834 hidden_fields.each do |k,v| 835 835 next if set_fields.include?(k) 836 form << "<input type='hidden' name='#{k}' value=\"#{v}\"/>\n" 836 v = "\"#{v}\"" unless v.kind_of?(String) && ['"', "'"].include?(v[0..0]) 837 form << "<input type='hidden' name='#{k}' value=#{v}/>\n" 837 838 end 838 839 form << "</div>" … … 1050 1051 end 1051 1052 #dom_id = "#{@context[:dom_id]}.\#{#{node_id}}" 1052 dom_id = "#{@context[:erb_dom_id]}.#{erb_node_id}"1053 erb_dom_id = "#{@context[:erb_dom_id]}.#{erb_node_id}" 1053 1054 if node_kind_of?(Node) 1054 1055 out "<% if #{node}[:link_id] -%>" 1055 out "<a class='#{@params[:class] || 'unlink'}' href='/nodes/#{erb_node_id}/links/<%= #{node}[:link_id] %>?remove=#{ dom_id}' onclick=\"new Ajax.Request('/nodes/#{erb_node_id}/links/<%= #{node}[:link_id] %>?remove=#{dom_id}', {asynchronous:true, evalScripts:true, method:'delete'}); return false;\">"1056 out "<a class='#{@params[:class] || 'unlink'}' href='/nodes/#{erb_node_id}/links/<%= #{node}[:link_id] %>?remove=#{erb_dom_id}' onclick=\"new Ajax.Request('/nodes/#{erb_node_id}/links/<%= #{node}[:link_id] %>?remove=#{erb_dom_id}', {asynchronous:true, evalScripts:true, method:'delete'}); return false;\">" 1056 1057 if !@blocks.empty? 1057 1058 out expand_with … … 1060 1061 end 1061 1062 out "</a><% end -%>" 1062 elsif node_kind_of?(DataEntry) 1063 elsif node_kind_of?(DataEntry) 1064 dom_id = "#{@context[:dom_id]}.\#{#{node_id}}" 1063 1065 out "<%= link_to_remote(#{text.inspect}, {:url => \"/data_entries/\#{#{node}[:id]}?remove=#{dom_id}\", :method => :delete}, :class=>#{(@params[:class] || 'unlink').inspect}) %>" 1064 1066 end … … 1153 1155 out "<% #{var}_dom_ids = [] -%>" 1154 1156 end 1155 1156 if join = @params[:join] 1157 @params[:alt_class] ||= @html_tag_params.delete(:alt_class) 1158 1159 if @params[:alt_class] || @params[:join] 1160 join = @params[:join] || '' 1157 1161 join = join.gsub(/<([^%])/, '<\1').gsub(/([^%])>/, '\1>') 1158 1162 out "<% #{list}.each_index do |#{var}_index| -%>" 1159 1163 out "<%= #{var}=#{list}[#{var}_index]; #{var}_index > 0 ? #{join.inspect} : '' %>" 1164 1165 if alt_class = @params[:alt_class] 1166 if html_class = @html_tag_params.delete(:class) 1167 html_append = " class='<%= #{var}_index % 2 != 0 ? #{alt_class.inspect} : #{html_class.inspect} %>'" 1168 else 1169 html_append = "<%= #{var}_index % 2 != 0 ? ' class=#{alt_class.inspect}' : '' %>" 1170 end 1171 else 1172 html_append = nil 1173 end 1160 1174 else 1161 1175 out "<% #{list}.each do |#{var}| -%>" 1176 html_append = nil 1162 1177 end 1163 1178 … … 1176 1191 1177 1192 if @context[:template_url] || @params[:draggable] == 'true' || descendant('unlink') 1178 # ajax, set id 1193 # ajax, set id, class 1179 1194 id_hash = {:id=> "#{erb_dom_id}.#{erb_node_id(var)}"} 1180 1195 if @html_tag … … 1187 1202 res = expand_with(:node=>var) 1188 1203 end 1189 out render_html_tag(res )1204 out render_html_tag(res, html_append) 1190 1205 out "<% end -%>" 1191 1206 … … 1198 1213 if @html_tag 1199 1214 @html_tag_params.merge!(id_hash) 1200 out render_html_tag(expand_with(:dom_id => dom_id) ) # dom_id is needed by 'unlink'1215 out render_html_tag(expand_with(:dom_id => dom_id), html_append) # dom_id is needed by 'unlink' 1201 1216 else 1202 1217 out add_params(expand_with, id_hash) … … 1903 1918 form_block = descendant('form') || each_block 1904 1919 if list_finder 1905 out "<% if (#{list_var} = #{list_finder}) || (#{node}. can_write?&& #{list_var}=[]) -%>"1920 out "<% if (#{list_var} = #{list_finder}) || (#{node}.#{node_kind_of?(Comment) ? "can_comment?" : "can_write?"} && #{list_var}=[]) -%>" 1906 1921 end 1907 1922 … … 1939 1954 if list_finder 1940 1955 if descendant('add') || descendant('add_document') 1941 out "<% if (#{list_var} = #{list_finder}) || (#{node}. can_write?&& #{list_var}=[]) -%>"1956 out "<% if (#{list_var} = #{list_finder}) || (#{node}.#{node_kind_of?(Comment) ? "can_comment?" : "can_write?"} && #{list_var}=[]) -%>" 1942 1957 elsif list_finder != 'nil' 1943 1958 out "<% if #{list_var} = #{list_finder} -%>" … … 2011 2026 k = $2.to_sym 2012 2027 end 2013 if [:kind_of, :klass, :status, :lang, :can, :node, :in ].include?(k)2028 if [:kind_of, :klass, :status, :lang, :can, :node, :in, :visitor, :has].include?(k) 2014 2029 tests << [k, v] 2015 2030 elsif k == :test … … 2041 2056 when 'drive', 'publish' 2042 2057 "#{node}.can_drive?" 2058 else 2059 nil 2060 end 2061 when :has 2062 case value 2063 when 'discussion' 2064 "#{node}.discussion" 2065 else 2066 nil 2043 2067 end 2044 2068 when :test … … 2105 2129 'false' 2106 2130 end 2131 when :visitor 2132 if value == 'anon' 2133 "visitor.is_anon?" 2134 else 2135 nil 2136 end 2107 2137 else 2108 2138 nil … … 2114 2144 # Block visibility of descendance with 'do_list'. 2115 2145 def public_descendants 2116 if ['do_list'].include?(@method) 2117 {} 2118 else 2119 super 2120 end 2146 all = super 2147 if @method == 'each' 2148 # do not propagate 'form' up 2149 all.delete('form') 2150 end 2151 all 2121 2152 end 2122 2153 … … 2418 2449 value = attribute ? "<%= #{node_attribute(attribute)} %>" : "" 2419 2450 end 2420 "<textarea name='#{name}'>#{value}</textarea>" 2451 input_id = @context[:template_url] ? " id='#{(dom_id_from_template_url + '_' + attribute.to_s)}#{erb_node_id}'" : '' 2452 "<textarea name='#{name}'#{input_id}>#{value}</textarea>" 2421 2453 end 2422 2454 trunk/po/en/zena.po
r1057 r1061 2 2 msgstr "" 3 3 "Project-Id-Version: 0.9.0\n" 4 "POT-Creation-Date: 2008-06- 09 20:09-0000\n"4 "POT-Creation-Date: 2008-06-12 15:07-0000\n" 5 5 "PO-Revision-Date: 2007-07-07 14:13+0100\n" 6 6 "Last-Translator: Gaspard Bucher <gaspard@teti.ch>\n" … … 134 134 msgstr "%A, %B %d %Y" 135 135 136 #: app/helpers/application_helper.rb:136 lib/parser/lib/rules/zena.rb:13 46136 #: app/helpers/application_helper.rb:136 lib/parser/lib/rules/zena.rb:1359 137 137 msgid "long_date" 138 138 msgstr "%Y-%m-%d" … … 494 494 msgstr "" 495 495 496 #: app/models/data_entry.rb:35 app/models/node.rb:62 0496 #: app/models/data_entry.rb:35 app/models/node.rb:621 497 497 #: app/views/data_entries/_li.html.erb:2 498 498 msgid "datetime" … … 1454 1454 1455 1455 #: app/views/virtual_classes/_li.erb:8 1456 msgid "yes" 1457 msgstr "" 1458 1459 #: app/views/virtual_classes/_li.erb:8 1460 msgid "no" 1461 msgstr "" 1456 #, fuzzy 1457 msgid "auto discussion" 1458 msgstr "<img src='/images/comments_add.png' alt='add a discussion'/>" 1462 1459 1463 1460 #: lib/gettext_strings.rb:5 … … 1818 1815 msgstr "<img src='/images/add.png' alt='add'/>" 1819 1816 1820 #: lib/parser/lib/rules/zena.rb:1 3961817 #: lib/parser/lib/rules/zena.rb:1409 1821 1818 msgid "riding zena" 1822 1819 msgstr "" 1823 1820 1824 #: lib/parser/lib/rules/zena.rb:1 3981821 #: lib/parser/lib/rules/zena.rb:1411 1825 1822 msgid "in peace with zena" 1826 1823 msgstr "" 1827 1824 1828 #: lib/parser/lib/rules/zena.rb:14 001825 #: lib/parser/lib/rules/zena.rb:1413 1829 1826 msgid "a zen garden" 1830 1827 msgstr "" 1831 1828 1832 #: lib/parser/lib/rules/zena.rb:14 021829 #: lib/parser/lib/rules/zena.rb:1415 1833 1830 msgid "made with zena" 1834 1831 msgstr "" 1835 1832 1836 #: lib/parser/lib/rules/zena.rb:14 181833 #: lib/parser/lib/rules/zena.rb:1431 1837 1834 msgid "%{skin}, design by %{name}" 1838 1835 msgstr "" trunk/po/fr/zena.po
r1057 r1061 2 2 msgstr "" 3 3 "Project-Id-Version: 0.9.0\n" 4 "POT-Creation-Date: 2008-06- 09 20:09-0000\n"4 "POT-Creation-Date: 2008-06-12 15:07-0000\n" 5 5 "PO-Revision-Date: 2007-07-07 14:13+0100\n" 6 6 "Last-Translator: Gaspard Bucher <gaspard@teti.ch>\n" … … 135 135 msgstr "%A, %d %B %Y" 136 136 137 #: app/helpers/application_helper.rb:136 lib/parser/lib/rules/zena.rb:13 46137 #: app/helpers/application_helper.rb:136 lib/parser/lib/rules/zena.rb:1359 138 138 msgid "long_date" 139 139 msgstr "%d.%m.%Y" … … 515 515 msgstr "objet" 516 516 517 #: app/models/data_entry.rb:35 app/models/node.rb:62 0517 #: app/models/data_entry.rb:35 app/models/node.rb:621 518 518 #: app/views/data_entries/_li.html.erb:2 519 519 msgid "datetime" … … 1527 1527 1528 1528 #: app/views/virtual_classes/_li.erb:8 1529 msgid "yes" 1530 msgstr "" 1531 1532 #: app/views/virtual_classes/_li.erb:8 1533 #, fuzzy 1534 msgid "no" 1535 msgstr "objet" 1529 #, fuzzy 1530 msgid "auto discussion" 1531 msgstr "discussion" 1536 1532 1537 1533 #: lib/gettext_strings.rb:5 … … 1890 1886 msgstr "<img src='/images/add.png' alt='ajouter'/>" 1891 1887 1892 #: lib/parser/lib/rules/zena.rb:1 3961888 #: lib/parser/lib/rules/zena.rb:1409 1893 1889 msgid "riding zena" 1894 1890 msgstr "en balade avec zena" 1895 1891 1896 #: lib/parser/lib/rules/zena.rb:1 3981892 #: lib/parser/lib/rules/zena.rb:1411 1897 1893 msgid "in peace with zena" 1898 1894 msgstr "paisible avec zena" 1899 1895 1900 #: lib/parser/lib/rules/zena.rb:14 001896 #: lib/parser/lib/rules/zena.rb:1413 1901 1897 msgid "a zen garden" 1902 1898 msgstr "un jardin zen" 1903 1899 1904 #: lib/parser/lib/rules/zena.rb:14 021900 #: lib/parser/lib/rules/zena.rb:1415 1905 1901 msgid "made with zena" 1906 1902 msgstr "conçu avec zena" 1907 1903 1908 #: lib/parser/lib/rules/zena.rb:14 181904 #: lib/parser/lib/rules/zena.rb:1431 1909 1905 msgid "%{skin}, design by %{name}" 1910 1906 msgstr "%{skin}, conception %{name}" 1907 1908 #, fuzzy 1909 #~ msgid "no" 1910 #~ msgstr "objet" 1911 1911 1912 1912 #, fuzzy trunk/po/zena.pot
r1057 r1061 8 8 msgstr "" 9 9 "Project-Id-Version: 0.9.0\n" 10 "POT-Creation-Date: 2008-06- 09 20:09-0000\n"10 "POT-Creation-Date: 2008-06-12 15:07-0000\n" 11 11 "PO-Revision-Date: 2007-05-13 19:08-0000\n" 12 12 "Last-Translator: FULL NAME <EMAIL@ADDRESS>\n" … … 135 135 msgstr "" 136 136 137 #: app/helpers/application_helper.rb:136 lib/parser/lib/rules/zena.rb:13 46137 #: app/helpers/application_helper.rb:136 lib/parser/lib/rules/zena.rb:1359 138 138 msgid "long_date" 139 139 msgstr "" … … 494 494 msgstr "" 495 495 496 #: app/models/data_entry.rb:35 app/models/node.rb:62 0496 #: app/models/data_entry.rb:35 app/models/node.rb:621 497 497 #: app/views/data_entries/_li.html.erb:2 498 498 msgid "datetime" … … 1431 1431 1432 1432 #: app/views/virtual_classes/_li.erb:8 1433 msgid "yes" 1434 msgstr "" 1435 1436 #: app/views/virtual_classes/_li.erb:8 1437 msgid "no" 1433 msgid "auto discussion" 1438 1434 msgstr "" 1439 1435 … … 1790 1786 msgstr "" 1791 1787 1792 #: lib/parser/lib/rules/zena.rb:1 3961788 #: lib/parser/lib/rules/zena.rb:1409 1793 1789 msgid "riding zena" 1794 1790 msgstr "" 1795 1791 1796 #: lib/parser/lib/rules/zena.rb:1 3981792 #: lib/parser/lib/rules/zena.rb:1411 1797 1793 msgid "in peace with zena" 1798 1794 msgstr "" 1799 1795 1800 #: lib/parser/lib/rules/zena.rb:14 001796 #: lib/parser/lib/rules/zena.rb:1413 1801 1797 msgid "a zen garden" 1802 1798 msgstr "" 1803 1799 1804 #: lib/parser/lib/rules/zena.rb:14 021800 #: lib/parser/lib/rules/zena.rb:1415 1805 1801 msgid "made with zena" 1806 1802 msgstr "" 1807 1803 1808 #: lib/parser/lib/rules/zena.rb:14 181804 #: lib/parser/lib/rules/zena.rb:1431 1809 1805 msgid "%{skin}, design by %{name}" 1810 1806 msgstr "" trunk/public/stylesheets/comment.css
r1060 r1061 40 40 .comments .btn_x a { display:block; } 41 41 .comments .btn_add a { visibility:visible;} 42 .comments .actions { position:absolute; right:-20px;}42 .comments .actions { position:absolute; left:-23px;} 43 43 .comments .actions a { display:block;} trunk/public/stylesheets/popup.css
r1048 r1061 16 16 17 17 /* search box */ 18 #search { z-index:999; z-index:999;position:absolute; top:1px; right:1px; padding-right:1px; font-size:0.8em; display:table;}18 #search { z-index:999; position:absolute; top:1px; right:1px; padding-right:1px; font-size:0.8em; display:table;} 19 19 20 20 /* messages and ajax-loader */ … … 39 39 .tab { padding:0; } 40 40 .tab form { } 41 .tab .validate { position:absolute; right:0; margin:0 2px; background:none; padding:3px; }41 .tab .validate { position:absolute; right:0; margin:0 2px; background:none; padding:3px; z-index:888;} 42 42 .tab .validate div { float:right; margin-left:4px; } 43 43 .tab .validate input { font-size:0.9em; padding:0;} …
