Changeset 599
- Timestamp:
- 2007-06-03 23:01:47 (2 years ago)
- Files:
-
- trunk/TODO (modified) (1 diff)
- trunk/app/controllers/application.rb (modified) (1 diff)
- trunk/app/controllers/nodes_controller.rb (modified) (1 diff)
- trunk/app/helpers/application_helper.rb (modified) (1 diff)
- trunk/app/models/contact.rb (modified) (2 diffs)
- trunk/app/models/contact_version.rb (modified) (1 diff)
- trunk/app/models/document.rb (modified) (2 diffs)
- trunk/app/models/document_version.rb (modified) (1 diff)
- trunk/app/models/image.rb (modified) (2 diffs)
- trunk/app/models/image_version.rb (modified) (1 diff)
- trunk/app/models/node.rb (modified) (3 diffs)
- trunk/app/models/template.rb (modified) (2 diffs)
- trunk/app/models/template_version.rb (modified) (2 diffs)
- trunk/app/models/text_document.rb (modified) (2 diffs)
- trunk/app/models/text_document_version.rb (modified) (1 diff)
- trunk/app/models/version.rb (modified) (3 diffs)
- trunk/app/views/calendar/_tiny.rhtml (modified) (1 diff)
- trunk/app/views/nodes/create.rjs (modified) (1 diff)
- trunk/db/init/base/help.yml (modified) (1 diff)
- trunk/db/init/base/skins/default/layout.html (modified) (1 diff)
- trunk/db/init/base/skins/default/notes.html (modified) (1 diff)
- trunk/db/schema.rb (modified) (2 diffs)
- trunk/lib/multiversion.rb (modified) (2 diffs)
- trunk/lib/parser/lib/rules/zafu.rb (modified) (5 diffs)
- trunk/lib/parser/lib/rules/zena.rb (modified) (10 diffs)
- trunk/lib/parser/test/parser_test.rb (modified) (2 diffs)
- trunk/lib/parser/test/zafu.yml (modified) (1 diff)
- trunk/lib/parser/test/zazen.yml (modified) (1 diff)
- trunk/lib/tasks/zena.rake (modified) (1 diff)
- trunk/public/stylesheets/calendars.css (modified) (1 diff)
- trunk/test/helpers/basic.yml (modified) (1 diff)
- trunk/test/helpers/zafu_ajax.yml (modified) (2 diffs)
- trunk/test/helpers/zena_parser_test.rb (modified) (2 diffs)
- trunk/test/unit/page_test.rb (modified) (1 diff)
- trunk/test/unit/site_test.rb (modified) (2 diffs)
- trunk/test/unit/template_test.rb (modified) (1 diff)
- trunk/test/unit/text_document_version_test.rb (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
trunk/TODO
r583 r599 9 9 * image 10 10 * template 11 12 ****** FIXME: visitor.lang should never be empty or bad. set 'lang' in participation ? 11 13 12 14 * if mksite fails (password too short, etc): rollback ! trunk/app/controllers/application.rb
r586 r599 234 234 raise Zena::AccessViolation.new("'template_url' contains illegal characters : #{template_url.inspect}") 235 235 end 236 236 237 237 template_url = template_url[1..-1].split('/') 238 path = "/#{template_url[0]}/#{template_url[1]}/#{ visitor.lang}/#{template_url[2..-1].join('/')}"238 path = "/#{template_url[0]}/#{template_url[1]}/#{session[:dev] ? 'dev' : lang}/#{template_url[2..-1].join('/')}" 239 239 240 240 "#{SITES_ROOT}/#{current_site.host}/zafu#{path}" trunk/app/controllers/nodes_controller.rb
r587 r599 46 46 :join => "INNER JOIN versions ON versions.node_id = nodes.id", 47 47 :conditions => match, 48 :order => "score DESC" } 48 :order => "score DESC", 49 :group => "nodes.id" } 49 50 elsif params[:id] 50 51 query = { trunk/app/helpers/application_helper.rb
r591 r599 471 471 472 472 # get list of notes in this scope 473 notes = source. send(method, :conditions=>["#{using} >= ? AND #{using} <= ?", start_date, end_date], :order=>"#{using} ASC") || []473 notes = source.relation(method, :conditions=>["#{using} >= ? AND #{using} <= ?", start_date, end_date], :order=>"#{using} ASC") || [] 474 474 475 475 # build event hash trunk/app/models/contact.rb
r561 r599 8 8 link :favorites, :class_name=>'Node' 9 9 link :collaborator_for, :class_name=>'Project', :as=>'collaborator' 10 11 # TODO: test 12 def self.version_class 13 ContactVersion 14 end 10 15 11 16 def user … … 21 26 end 22 27 23 private24 # TODO: test25 def version_class26 ContactVersion27 end28 28 end trunk/app/models/contact_version.rb
r569 r599 9 9 before_validation_on_create :contact_version_before_validation_on_create 10 10 11 def content_class11 def self.content_class 12 12 ContactContent 13 13 end trunk/app/models/document.rb
r576 r599 41 41 def parent_class 42 42 Node 43 end 44 45 def version_class 46 DocumentVersion 43 47 end 44 48 … … 101 105 private 102 106 103 # Set name from filename 104 def document_before_validation 105 content = version.content 106 if new_record? 107 if ! self[:name].blank? 108 # name set 109 base = self[:name] 110 elsif file = content.instance_variable_get(:@file) 111 # set with filename 112 base = file.original_filename 107 # Set name from filename 108 def document_before_validation 109 content = version.content 110 if new_record? 111 if ! self[:name].blank? 112 # name set 113 base = self[:name] 114 elsif file = content.instance_variable_get(:@file) 115 # set with filename 116 base = file.original_filename 117 else 118 # set with title 119 base = version.title 120 end 121 if base =~ /(.*)\.(\w+)$/ 122 self[:name] = $1 123 ext = $2 124 else 125 self[:name] = base 126 ext = nil 127 end 128 129 content[:name] = self[:name].sub(/\.*$/,'') # remove trailing dots 130 content.ext = ext 113 131 else 114 # set with title 115 base = version.title 116 end 117 if base =~ /(.*)\.(\w+)$/ 118 self[:name] = $1 119 ext = $2 120 else 121 self[:name] = base 122 ext = nil 123 end 124 125 content[:name] = self[:name].sub(/\.*$/,'') # remove trailing dots 126 content.ext = ext 127 else 128 # we cannot use 'old' here as this record is not secured when spreading inheritance 129 if self[:name] != self.class.find(self[:id])[:name] && self[:name] && self[:name] != '' 130 # FIXME: name is not important (just used to find file in case db crash: do not sync.) 131 # update all content names : 132 versions.each do |v| 133 if v[:id] == @version[:id] 134 v = @version # make sure modifications are made to our loaded version/content 135 else 136 v.node = self # preload so the relation to 'self' is kept 132 # we cannot use 'old' here as this record is not secured when spreading inheritance 133 if self[:name] != self.class.find(self[:id])[:name] && self[:name] && self[:name] != '' 134 # FIXME: name is not important (just used to find file in case db crash: do not sync.) 135 # update all content names : 136 versions.each do |v| 137 if v[:id] == @version[:id] 138 v = @version # make sure modifications are made to our loaded version/content 139 else 140 v.node = self # preload so the relation to 'self' is kept 141 end 142 content = v.content 143 content.name = self[:name].sub(/\.*$/,'') # remove trailing dots 144 content.save 137 145 end 138 content = v.content139 content.name = self[:name].sub(/\.*$/,'') # remove trailing dots140 content.save141 146 end 142 147 end 143 148 end 144 end145 146 # This is a callback from acts_as_multiversioned147 def version_class148 DocumentVersion149 end150 149 end trunk/app/models/document_version.rb
r375 r599 8 8 class DocumentVersion < Version 9 9 validates_presence_of :content 10 def content_class10 def self.content_class 11 11 DocumentContent 12 12 end trunk/app/models/image.rb
r582 r599 60 60 ImageBuilder.image_content_type?(content_type) 61 61 end 62 63 # This is a callback from acts_as_multiversioned 64 def version_class 65 ImageVersion 66 end 62 67 end 63 68 # Crop the image using the 'crop' hash with the top left corner position (:x, :y) and the width and height (:width, :heigt). Example: … … 86 91 version.filesize(format) 87 92 end 88 89 private90 # This is a callback from acts_as_multiversioned91 def version_class92 ImageVersion93 end94 93 end trunk/app/models/image_version.rb
r542 r599 9 9 before_create :set_image_text 10 10 11 def content_class11 def self.content_class 12 12 ImageContent 13 13 end trunk/app/models/node.rb
r598 r599 550 550 def relation(methods, opts={}) 551 551 res = nil 552 try_list = methods. split(',')552 try_list = methods.to_s.split(',') 553 553 plural = Zena::Acts::Linkable::plural_method?(try_list[0]) 554 554 if !plural … … 738 738 c = klass.new(opts) 739 739 c.parent_id = self[:id] 740 c.instance_variable_set(:@parent, self) 741 740 742 c.visitor = visitor 741 743 … … 795 797 def user_zip; self[:user_id]; end 796 798 797 # More reflection needed before implementation. 799 800 def klass=(new_class) 801 if new_class.kind_of?(String) 802 klass = Module.const_get(new_class) 803 else 804 klass = new_class 805 end 806 raise NameError if !klass.ancestors.include?(Node) || klass.version_class != self.class.content_class 807 808 809 810 rescue NameError 811 errors.add('klass', 'invalid') 812 end 798 813 799 814 # transform an Node into another Object. This is a two step operation : trunk/app/models/template.rb
r598 r599 5 5 def accept_content_type?(content_type) 6 6 content_type =~ /text\/(html|xml)/ 7 end 8 9 def version_class 10 TemplateVersion 7 11 end 8 12 end … … 43 47 end 44 48 45 def version_class46 TemplateVersion47 end48 49 end trunk/app/models/template_version.rb
r587 r599 8 8 class TemplateVersion < Version 9 9 validates_presence_of :content 10 11 12 # TODO: test 13 def self.content_class 14 TemplateContent 15 end 10 16 11 17 # TODO: test … … 29 35 end 30 36 31 # TODO: test32 def content_class33 TemplateContent34 end35 37 end trunk/app/models/text_document.rb
r588 r599 15 15 def accept_content_type?(content_type) 16 16 content_type =~ /^(text)/ 17 end 18 19 def version_class 20 TextDocumentVersion 17 21 end 18 22 end … … 56 60 content[:ext] ||= 'txt' 57 61 end 58 # This is a callback from acts_as_multiversioned59 def version_class60 TextDocumentVersion61 end62 62 end trunk/app/models/text_document_version.rb
r368 r599 3 3 =end 4 4 class TextDocumentVersion < DocumentVersion 5 def content_class5 def self.content_class 6 6 TextDocumentContent 7 7 end trunk/app/models/version.rb
r587 r599 43 43 before_create :set_number 44 44 uses_dynamic_attributes 45 46 class << self 47 # Some #Version sub-classes need to have more specific content than just 'text' and 'summary'. 48 # this content is stored in a delegate 'content' object found with the 'content_class' class method 49 def content_class 50 nil 51 end 52 end 45 53 46 54 def author … … 123 131 end 124 132 125 # Some #Version sub-classes need to have more specific content than just 'text' and 'summary'.126 # this content is stored in a delegate 'content' object found with the 'content_class' class method127 def content_class128 nil129 end130 131 133 def clone 132 134 obj = super … … 137 139 138 140 private 141 def content_class 142 self.class.content_class 143 end 144 139 145 def can_update_content 140 146 if @redaction_content && Version.find_all_by_content_id(self[:id]).size > 0 trunk/app/views/calendar/_tiny.rhtml
r585 r599 1 <table cellspacing="0" id="tinycal">1 <table cellspacing="0" class='tinycal'> 2 2 <tr class="head"><td class="button"> 3 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 } ) %> trunk/app/views/nodes/create.rjs
r471 r599 6 6 ref = params[:reference] || "#{params[:template_url]}_add" 7 7 page.insert_html pos.to_sym, ref, :file => fullpath_from_template_url + ".erb" 8 @node = Node.new8 @node = @node.parent.new_child(:class => @node.class) 9 9 page.replace "#{params[:template_url]}_form", :file => fullpath_from_template_url + "_form.erb" 10 10 page.toggle "#{params[:template_url]}_form", "#{params[:template_url]}_add" trunk/db/init/base/help.yml
r589 r599 1 1 class: Page 2 v_title: Skins (layout themes)2 v_title: Help 3 3 v_summary: | 4 4 |_. markup |_. result | trunk/db/init/base/skins/default/layout.html
r584 r599 77 77 <ol> 78 78 <li do='each' set_class='li_s[v_status]' do='link'/> 79 <r:add before='self' tag='li'/> 80 <r:form> 81 <li class='inline_form'> 82 <form> 83 <p class='hidden'> <input type='hidden' name='node[parent_id]' value='' do='void' set_value='[id]'/></p> 84 <p class='node_klass'> <r:input type='select' attr='klass' options='Page,Section,Skin,Project'/></p> 85 <p class='node_v_title'><input type='text' name='node[v_title]' value=''/></p> 86 <p class='btn_validate'><input type="submit" value='validate' do='void' tset_value='validate'/></p> 87 </form> 88 </li> 89 </r:form> 79 <li do='add' before='self'/> 80 <li class='inline_form' do='form'> 81 <p class='node_klass'> <input type='select' name='klass' options='Page,Section,Skin,Project'/></p> 82 <p class='node_v_title'><input type='text' name='v_title' value=''/></p> 83 <p class='btn_validate'><input type="submit" value='validate' tset_value='validate'/></p> 84 </li> 90 85 </ol> 91 86 </r:if> trunk/db/init/base/skins/default/notes.html
r584 r599 1 1 <div id='notes' do='notes_all' limit='10' order='log_at DESC'> 2 2 <ul class='note_list'> 3 < r:add after='self' tag='li'/>4 < r:form><li class='inline_form'><form>5 <p class='hidden'> <input type='hidden' name='node[parent_id]' value='' do='void' set_value='[id]'/></p>6 <p class='node_klass'> < r:input type='select' attr='klass' options='Post,Letter'/></p>7 <p class='node_log_at'> < r:input type='date_box' attr='log_at'/></p>8 <p class='node_v_title'><input type='text' name=' node[v_title]' do='void' set_value='[v_title]' size='25'/></p>3 <li do='add' after='self'/> 4 <li class='inline_form' do='form'> 5 <form> 6 <p class='node_klass'> <input type='select' name='klass' options='Post,Letter'/></p> 7 <p class='node_log_at'> <input type='date_box' name='log_at'/></p> 8 <p class='node_v_title'><input type='text' name='v_title' size='25'/></p> 9 9 <p class='validate'> <input type="submit" value='validate' do='void' tset_value='validate'/></p> 10 </form> </li>11 </ r:form>10 </form> 11 </li> 12 12 <li class='note' do='each'> 13 13 <div class='header'> trunk/db/schema.rb
r589 r599 157 157 t.column "public_group_id", :integer 158 158 t.column "site_group_id", :integer 159 t.column "trans_group_id", :integer 159 160 t.column "name", :string 160 161 t.column "authentication", :boolean … … 174 175 t.column "klass", :string 175 176 t.column "mode", :string 176 end177 178 create_table "tmp", :id => false, :force => true do |t|179 t.column "a", :string, :limit => 50180 t.column "b", :string, :limit => 50181 177 end 182 178 trunk/lib/multiversion.rb
r589 r599 566 566 567 567 def version_class 568 Version568 self.class.version_class 569 569 end 570 570 … … 587 587 # PUT YOUR CLASS METHODS HERE 588 588 589 # This is a callback from acts_as_multiversioned 590 def version_class 591 Version 592 end 593 589 594 # Find a node based on a version id 590 595 def version(version_id) trunk/lib/parser/lib/rules/zafu.rb
r592 r599 68 68 return text if @html_tag_done 69 69 if @html_tag 70 if text.blank? && ['meta' ].include?(@html_tag)70 if text.blank? && ['meta','input'].include?(@html_tag) 71 71 res = "<#{@html_tag}#{params_to_html(@html_tag_params || {})}#{append.join('')}/>" 72 72 else … … 109 109 end 110 110 111 res = "<#{@html_tag}#{params_to_html(@params)}" 112 @html_tag_done = true 113 inner = expand_with 114 if inner == '' 115 res + "/>" 116 else 117 res + ">#{inner}" 118 end 119 end 120 121 def r_form 122 res = "<#{@html_tag}#{params_to_html(@params)}" 123 @html_tag_done = true 124 inner = expand_with 125 if inner == '' 126 res + "/>" 127 else 128 res + ">#{inner}" 129 end 130 end 131 132 def r_input 133 res = "<#{@html_tag}#{params_to_html(@params)}" 134 @html_tag_done = true 135 inner = expand_with 136 if inner == '' 137 res + "/>" 138 else 139 res + ">#{inner}" 140 end 141 end 142 143 def r_textarea 111 144 res = "<#{@html_tag}#{params_to_html(@params)}" 112 145 @html_tag_done = true … … 127 160 @html_tag = @options[:html_tag] 128 161 @options.delete(:html_tag) 129 @html_tag_params = parse_params(@options [:html_tag_params])162 @html_tag_params = parse_params(@options.delete(:html_tag_params)) 130 163 @options.delete(:html_tag_params) 131 164 132 165 # end_tag 133 @end_tag = @html_tag || @options.delete(:end_do) || "r:#{@method}"166 @end_tag = @html_tag || @options.delete(:end_do) || @options.delete(:end_tag) || "r:#{@method}" 134 167 @end_tag_count = 1 135 168 … … 137 170 @space_before = @options[:space_before] 138 171 @options.delete(:space_before) 172 173 # form capture (input, textarea, form) 174 @options[:form] ||= true if @method == 'form' 139 175 140 176 # puts "[#{@space_before}(#{@method})#{@space_after}]" … … 267 303 # puts "HTML:[#{$&}]" # html 268 304 make(:asset) 305 elsif @options[:form] && @text =~ /\A<(input|textarea|form)([^>]*?)(\/?)>/ 306 eat $& 307 method = $1 == 'form' ? 'form_tag' : $1 # <form> ==> r_form_tag, <r:form> ==> r_form 308 opts.merge!(:method=>method, :params=>$2) 309 opts.merge!(:text=>'') if $3 != '' 310 opts.merge!(:end_tag=>'form') if method == 'form_tag' 311 make(:void, opts) 269 312 elsif @text =~ /\A[^>]*?>/ 270 313 # html tag trunk/lib/parser/lib/rules/zena.rb
r592 r599 72 72 # some 'id' information can be set during rendering and should merge into tag_params 73 73 @html_tag_params_bak = @html_tag_params 74 @html_tag_params = @html_tag_params.merge(@context [:html_tag_params]|| {})74 @html_tag_params = @html_tag_params.merge(@context.delete(:html_tag_params) || {}) 75 75 unless @context[:preflight] 76 76 if store = @params.delete(:store) … … 330 330 331 331 def r_edit 332 @pass[:edit] = self333 332 if @context[:preflight] 333 @pass[:edit] = self 334 334 # preprocessing 335 335 return "" … … 345 345 end 346 346 347 # FIXME: implement all inputs correctly !348 # change ALL inputs/textarea,form etc from within a z:form ?349 347 def r_input 348 return '' if @context[:preflight] 350 349 case @params[:type] 351 350 when 'select' 351 return "<span class='parser_error'>select without name</span>" unless name = @params[:name] 352 352 klasses = @params[:options] || "Page,Note" 353 "<%= select('node', '#{@params[:attr]}', #{klasses.split(',').map(&:strip).inspect}) %>"353 "<%= select('node', #{name.inspect}, #{klasses.split(',').map(&:strip).inspect}) %>" 354 354 when 'date_box' 355 "<%= date_box 'node', '#{@params[:attr]}', :size=>15 %>" 356 end 355 return "<span class='parser_error'>date_box without name</span>" unless name = @params[:name] 356 "<%= date_box 'node', #{name.inspect}, :size=>15#{@context[:in_add] ? ", :value=>''" : ''} %>" 357 else 358 @html_tag = 'input' 359 @html_tag_params.merge!(@params) 360 if name = @html_tag_params[:name] 361 if name =~ /\Anode\[(.*?)\]/ 362 name = $1 363 else 364 @html_tag_params[:name] = "node[#{name}]" 365 end 366 return '' if name == 'node[parent_id]' # set with 'r_form' 367 end 368 if @context[:in_add] 369 value = @html_tag_params[:value] ? '' : " value=''" 370 else 371 value = name ? " value='<%= #{node_attribute(name, :node=>'@node')} %>'" : '' 372 end 373 out render_html_tag(nil, value) 374 end 375 end 376 377 def r_form_tag 378 if @context[:preflight] 379 @pass[:form_tag] = self 380 # preprocessing 381 return "" 382 end 383 # replace <form> with constructed form 384 "#{@context[:form_tag]}#{expand_with(:form_tag => nil)}</form>" 357 385 end 358 386 … … 361 389 # FIXME: use <r:form href='self'> or <r:form action='...'> 362 390 def r_form 363 @pass[:form] = self364 391 if @context[:preflight] 392 @pass[:form] = self 365 393 # preprocessing 366 394 return "" 367 395 end 368 396 369 370 397 if template_url = @context[:template_url] 371 398 # ajax 372 # TODO: use remote_form_for :#{node_class.to_s.downcase}, :url ... and replace all input/select/...373 399 374 400 if @context[:in_add] 375 @html_tag_params.merge!(:id=>"#{template_url}_form") 376 form = "<p class='btn_x'><a href='#' onclick='[\"#{template_url}_add\", \"#{template_url}_form\"].each(Element.toggle);return false;'>#{_('btn_x')}</a></p>\n" 377 form << "<%= form_remote_tag(:url => #{node_class.to_s.downcase.pluralize}_path) %>\n" 378 else 379 # saved form 401 # inline form used to create new elements: set values to '' and 'parent_id' from context 402 @html_tag_params.merge!(:id=>"#{template_url}_form", :style=>"display:none;") 403 start = "<p class='btn_x'><a href='#' onclick='[\"#{template_url}_add\", \"#{template_url}_form\"].each(Element.toggle);return false;'>#{_('btn_x')}</a></p>\n" 404 form = "<%= form_remote_tag(:url => #{node_class.to_s.downcase.pluralize}_path) %>\n" 405 else 406 # saved form used to edit: set values and 'parent_id' from @node 380 407 @html_tag_params.merge!(:id=>"#{template_url}<%= @node.new_record? ? '_form' : @node[:zip] %>") 408 # new_record? = edit/create failed, rendering form with errors 409 # else = edit 410 start =<<-END_TXT 411 <% if @node.new_record? -%> 412 <p class='btn_x'><a href='#' onclick='[\"#{template_url}_add\", \"#{template_url}_form\"].each(Element.toggle);return false;'>#{_('btn_x')}</a></p> 413 <% else -%> 414 <p class='btn_x'><%= link_to_remote(#{_('btn_x').inspect}, :url => #{node_class.to_s.downcase}_path(#{node}[:zip]) + '?template_url=#{CGI.escape(template_url)}', :method => :get) %></a></p> 415 <% end -%> 416 END_TXT 381 417 form =<<-END_TXT 382 418 <% if @node.new_record? -%> 383 <p class='btn_x'><a href='#' onclick='[\"#{template_url}_add\", \"#{template_url}_form\"].each(Element.toggle);return false;'>#{_('btn_x')}</a></p> 384 <%= form_remote_tag(:url => #{node_class.to_s.downcase.pluralize}_path) %> 419 <%= form_remote_tag(:url => #{node_class.to_s.downcase.pluralize}_path) %> 385 420 <% else -%> 386 <p class='btn_x'><%= link_to_remote(#{_('btn_x').inspect}, :url => #{node_class.to_s.downcase}_path(#{node}[:zip]) + '?template_url=#{CGI.escape(template_url)}', :method => :get) %></a></p> 387 <%= form_remote_tag(:url => #{node_class.to_s.downcase}_path(#{node}[:zip]), :method => :put) %> 421 <%= form_remote_tag(:url => #{node_class.to_s.downcase}_path(#{node}[:zip]), :method => :put) %> 388 422 <% end -%> 389 423 END_TXT … … 391 425 form << "<div class='hidden'>" 392 426 form << "<input type='hidden' name='template_url' value='#{template_url}'/>\n" 427 form << "<input type='hidden' name='node[parent_id]' value='<%= #{@context[:in_add] ? '@node[:zip]' : node + '.parent_zip'} %>'/>\n" 393 428 394 if @params[:klass] 395 # FIXME: add the 'klass' attribute to node_class if no input for klass 429 if @params[:klass] && @context[:in_add] 396 430 form << "<input type='hidden' name='node[klass]' value='#{@params[:klass]}'/>\n" 397 431 end … … 410 444 form = "FORM WITHOUT AJAX TODO\n" 411 445 end 412 exp = expand_with 413 414 exp.gsub!(/<form[^>]*>/,form) 415 if @html_tag 416 out render_html_tag(exp) 417 elsif exp =~ /\A([^<]*)<(\w+)([^>]*)>(.*)<\/\2>(.*)/m 418 out $1 419 tag = $2 420 inner = $4 421 after = $5 422 if @html_tag_params 423 start_tag = add_params("<#{$2}#{$3}>", @html_tag_params) 424 else 425 start_tag = "<#{$2}#{$3}>" 426 end 427 out "#{start_tag}#{inner}</#{tag}>#{after}" 428 @html_tag_done = true 429 else 430 out exp 431 end 446 if @pass[:form_tag] 447 res = start + expand_with(:form_tag => form) 448 else 449 res = start + form + expand_with + '</form>' 450 end 451 out render_html_tag(res) 432 452 end 433 453 … … 463 483 # TODO: test 464 484 def r_add 465 @pass[:add] = self466 485 if @context[:preflight] 486 @pass[:add] = self 467 487 # preprocessing 468 488 return "" … … 493 513 end 494 514 495 form_opts = { :node=>"@#{node_class.to_s.downcase}", :html_tag_params=>{:id=>"#{prefix}_form", :style=>"display:none;"}, :no_form => false, :in_add => true } 515 516 # FIXME: :after, :before, :top, :bottom should move to 'r_form' during preflight 517 # :node => .. should be removed. 518 # just leave ':in_add' 519 520 form_opts = { :node=>"@#{node_class.to_s.downcase}", :no_form => false, :in_add => true } 496 521 497 522 [:after, :before, :top, :bottom].each do |sym| … … 869 894 # TODO: test 870 895 def r_calendar 871 from = 'project' .inspect896 from = 'project' 872 897 date = 'main_date' 873 find = (@params[:find ] || 'news' ).to_sym .inspect874 size = (@params[:size ] || 'tiny' ).to_sym .inspect875 using = (@params[:using ] || 'event_at').gsub(/[^a-z_]/,'').to_sym .inspect# SQL injection security876 "< %= calendar(:node=>#{node}, :from=>#{from}, :date=>#{date}, :find=>#{find}, :size=>#{size}, :using=>#{using}) %>"898 find = (@params[:find ] || 'news' ).to_sym 899 size = (@params[:size ] || 'tiny' ).to_sym 900 using = (@params[:using ] || 'event_at').gsub(/[^a-z_]/,'').to_sym # SQL injection security 901 "<div id='#{size}cal'><%= calendar(:node=>#{node}, :from=>#{from.inspect}, :date=>#{date}, :find=>#{find.inspect}, :size=>#{size.inspect}, :using=>#{using.inspect}) %></div>" 877 902 end 878 903 … … 1297 1322 end 1298 1323 end 1299 @html_tag = 'div' if !@html_tag && set_params != {} 1300 1301 @html_tag_params ||= {}1324 1325 @html_tag = 'div' if !@html_tag && (set_params != {} || @html_tag_params != {}) 1326 1302 1327 bak = @html_tag_params.dup 1303 1328 res_params = {} trunk/lib/parser/test/parser_test.rb
r591 r599 36 36 "nothing missing" 37 37 end 38 39 def r_textarea 40 res = "<#{@html_tag}#{params_to_html(@params)}" 41 @html_tag_done = true 42 inner = expand_with 43 if inner == '' 44 res + "/>" 45 else 46 res + ">#{inner}" 47 end 48 end 49 38 50 def r_test 39 51 self.inspect … … 44 56 testfile :zafu, :zafu_asset, :zafu_insight, :zazen 45 57 def test_single 46 do_test('zafu', ' ignore_do_empty')58 do_test('zafu', 'form') 47 59 end 48 60 trunk/lib/parser/test/zafu.yml
r591 r599 290 290 src: "<r:void class='test' tag='p'>blah</r:void>" 291 291 res: "<p class='test'>blah</p>" 292 293 static_form: 294 src: "<r:test><form action='hello'><p><input type='text' name='hoy' value='hili'/></p></form></r:test>" 295 res: "[test]<form action='hello'><p><input type='text' name='hoy' value='hili'/></p></form>[/test]" 296 297 form: 298 src: "<r:test><p do='form'><form action='hello'><p><input type='text' name='hoy' value='hili'/></p></form></p></r:test>" 299 res: "[test][form]<p>[form_tag {= :action=>'hello'}]<p>[input {= :name=>'hoy', :type=>'text', :value=>'hili'}/]</p>[/form_tag]</p>[/form][/test]" trunk/lib/parser/test/zazen.yml
r496 r599 6 6 src: "some @strange < code@" 7 7 res: "<p>some <code>strange < code</code></p>" 8 9 at_code_again: 10 src: "We changed the syntax from @zafu|<z:link/>@ to @zafu|<r:link/>@ to better reflect the fact that we want to *render* a link." 11 res: "/code class='zafu'.*/" 8 12 9 13 at_code_ruby: trunk/lib/tasks/zena.rake
r597 r599 116 116 # OR we could symlink /var/zena/current/... 117 117 ['calendar', 'images', 'javascripts', 'stylesheets'].each do |dir| 118 # FIXME: 'RAILS_ROOT' should be '/var/zena/current' and not '/var/zena/releases/20070632030330' !!! 118 119 FileUtils.ln_s("#{RAILS_ROOT}/public/#{dir}", "#{host_path}/public/#{dir}") 119 120 end trunk/public/stylesheets/calendars.css
r585 r599 1 1 /* small calendar */ 2 2 3 # small_calendar{ height: 9em; margin-bottom:0.8em; }4 #tinycal { font-size:0.7em; margin:auto; cursor:pointer; }5 #tinycal table { border: 1px solid #CAD4DA; background:#F5F8F9; }6 #tinycal td { text-align:center; color:#333; }7 #tinycal a { color:inherit; }8 #tinycal em { border-bottom:2px solid orange; }9 #tinycal .head td { font-weight:bold; padding: 2px; line-height:1.5; font-size:0.9em; color:#655; padding:2px; text-align:center; }10 #tinycal .head td.button a { border:0; text-decoration:none; color:#568BB9;}11 #tinycal .body td { height:1.8em; }12 #tinycal .body #tiny_today p { background:#CFD6DA; }13 #tinycal .body td.other, #tinycal .body td.other a { color:#ccc; }14 #tinycal .body td.sat, #tinycal .body td.sat a { color:#35950B; }15 #tinycal .body td.satother, #tinycal .body td.satother a { color:#C8DEC1; }16 #tinycal .body td.sun, #tinycal .body td.sun a { color:#35950B; }17 #tinycal .body td.sunother, #tinycal .body td.sunother a { color:#C8DEC1; }3 #tinycal { height: 9em; margin-bottom:0.8em; }
