Changeset 484
- Timestamp:
- 2007-05-06 13:32:14 (2 years ago)
- Files:
-
- trunk/app/controllers/comment_controller.rb (deleted)
- trunk/app/controllers/comments_controller.rb (added)
- trunk/app/helpers/application_helper.rb (modified) (4 diffs)
- trunk/app/models/skin.rb (modified) (1 diff)
- trunk/app/models/tag.rb (modified) (3 diffs)
- trunk/app/models/template_version.rb (modified) (2 diffs)
- trunk/app/models/version.rb (modified) (2 diffs)
- trunk/app/views/comment (deleted)
- trunk/app/views/comments (added)
- trunk/app/views/comments/_add.rhtml (added)
- trunk/app/views/comments/_bin.rhtml (added)
- trunk/app/views/comments/_form.rhtml (added)
- trunk/app/views/comments/_li.rhtml (added)
- trunk/app/views/comments/_li_simple.rhtml (added)
- trunk/app/views/comments/_list.rhtml (added)
- trunk/app/views/comments/create.rjs (added)
- trunk/app/views/comments/edit.rjs (added)
- trunk/app/views/comments/empty_bin.rjs (added)
- trunk/app/views/comments/list.rhtml (added)
- trunk/app/views/comments/publish.rjs (added)
- trunk/app/views/comments/remove.rjs (added)
- trunk/app/views/comments/reply_to.rjs (added)
- trunk/app/views/comments/update.rjs (added)
- trunk/config/routes.rb (modified) (2 diffs)
- trunk/lib/parser/test/testhelp.rb (modified) (1 diff)
- trunk/lib/tasks/zena.rake (modified) (1 diff)
- trunk/test/helpers/application_helper_test.rb (added)
- trunk/test/helpers/basic.yml (modified) (5 diffs)
- trunk/test/helpers/test_all.rb (deleted)
- trunk/test/helpers/zazen_test.rb (added)
- trunk/test/helpers/zena_parser_test.rb (added)
- trunk/test/unit/h_application_test.rb (deleted)
- trunk/test/unit/h_zazen_test.rb (deleted)
- trunk/test/unit/page_test.rb (modified) (1 diff)
- trunk/test/unit/skin_test.rb (modified) (1 diff)
- trunk/test/unit/tag_test.rb (modified) (4 diffs)
- trunk/test/unit/template_version_test.rb (modified) (1 diff)
- trunk/test/unit/text_document_content_test.rb (modified) (1 diff)
- trunk/test/unit/trans_key_test.rb (modified) (1 diff)
- trunk/test/unit/trans_value_test.rb (modified) (1 diff)
- trunk/test/unit/user_test.rb (modified) (1 diff)
- trunk/test/unit/version_test.rb (modified) (1 diff)
- trunk/vendor/bricks/20070122-172926.txt (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
trunk/app/helpers/application_helper.rb
r481 r484 356 356 # the format is used as the image class. Example : 357 357 # img_tag(@node, :mode=>'pv') => <img src='/sites/test.host/data/jpg/20/bird_pv.jpg' height='80' width='80' alt='bird' class='pv'/> 358 def img_tag(obj, opt s={})358 def img_tag(obj, options={}) 359 359 return "" unless obj.kind_of?(Document) 360 mode = opts[:mode] 360 opts = options.dup 361 362 mode = opts.delete(:mode) 363 klass = opts.delete(:class) 364 alt = opts.delete(:alt) 365 img_id = opts.delete(:id) 366 361 367 content = obj.v_content 362 ext = content [:ext]368 ext = content.ext 363 369 opts = opts.merge(:format => ext) 364 365 alt = opts[:alt]366 img_id = opts[:id]367 370 368 371 src = width = height = img_class = nil … … 373 376 src = zen_path(obj, opts.merge(:mode => (mode == 'full' ? nil : mode))) 374 377 375 img_class = opts[:class]|| mode378 img_class = klass || mode 376 379 if mode == 'full' 377 380 # full size (format = nil) … … 387 390 alt ||= "#{content.ext} document" 388 391 389 img_class = opts[:class]|| 'doc'392 img_class = klass || 'doc' 390 393 unless File.exist?("#{RAILS_ROOT}/public/images/ext/#{ext}.png") 391 394 ext = 'other' … … 452 455 def show_comments(opts={}) 453 456 node = opts[:node] || @node 454 render_to_string(:partial=>'comment /list', :locals=>{:node=>node})457 render_to_string(:partial=>'comments/list', :locals=>{:node=>node}) 455 458 end 456 459 trunk/app/models/skin.rb
r455 r484 4 4 before_save :need_skin_name_update 5 5 after_save :update_skin_name 6 7 def template_url_for_name(template_name, helper)8 raise Exception.new('helper should not be nil!') unless (helper || ENV["RAILS_ENV"] == "test")9 if template_name == 'any'10 template = self11 zafu_url = "/#{self[:name]}/any"12 else13 template = secure(Template) { Template.find(:first, :conditions=>["parent_id = ? AND name = ?", self[:id], template_name])}14 zafu_url = "/#{self[:name]}/#{template_name}"15 end16 tmpl_name = "#{template_name}_#{visitor.lang}"17 tmpl_dir = "/templates/compiled/#{self[:name]}"18 FileUtils::mkpath("#{RAILS_ROOT}/app/views#{tmpl_dir}")19 # render for the current lang20 res = ZafuParser.new_with_url(zafu_url, :helper=>helper).render21 File.open("#{RAILS_ROOT}/app/views#{tmpl_dir}/#{tmpl_name}.rhtml", "wb") { |f| f.syswrite(res) }22 return "#{tmpl_dir}/#{tmpl_name}"23 rescue ActiveRecord::RecordNotFound24 nil25 end26 27 def template_for_path(path)28 asset_for_path(path, Template)29 end30 31 32 def asset_for_path(path, klass=Node)33 current = self34 if path == 'any'35 return current36 else37 path = path.split('/')38 while path != []39 template_name = path.shift40 current = secure(klass) { klass.find(:first, :conditions=>["parent_id = ? AND name = ?", current[:id], template_name])}41 end42 current43 end44 rescue ActiveRecord::RecordNotFound45 nil46 end47 6 48 7 private trunk/app/models/tag.rb
r375 r484 8 8 def pages(opts={}) 9 9 return super if opts[:in] 10 options = opts.merge(:conditions=>"kpath NOT LIKE 'NPD%'", :or=>["parent_id = ?", self[:id]])11 @pages ||=tag_for(options)10 options = opts.merge(:conditions=>"kpath LIKE 'NP%' AND kpath NOT LIKE 'NPD%'", :or=>["parent_id = ?", self[:id]]) 11 tag_for(options) 12 12 end 13 13 14 14 def documents(opts={}) 15 15 return super if opts[:in] 16 options = opts.merge(:conditions=>"kpath LIKE 'NP D%'", :or=>["parent_id = ?", self[:id]])17 @documents ||=tag_for(options)16 options = opts.merge(:conditions=>"kpath LIKE 'NP%' AND kpath LIKE 'NPD%'", :or=>["parent_id = ?", self[:id]]) 17 tag_for(options) 18 18 end 19 19 … … 23 23 return super if opts[:in] 24 24 options = opts.merge(:conditions=>"kpath LIKE 'NPD%' AND NOT LIKE 'NPDI%'", :or=>["parent_id = ?", self[:id]]) 25 @doconly ||=tag_for(options)25 tag_for(options) 26 26 end 27 27 … … 31 31 return super if opts[:in] 32 32 options = opts.merge(:conditions=>"kpath LIKE 'NPDI%'", :or=>["parent_id = ?", self[:id]]) 33 @images ||=tag_for(options)33 tag_for(options) 34 34 end 35 35 end trunk/app/models/template_version.rb
r471 r484 9 9 validates_presence_of :content 10 10 11 # Return the content for the version. Can it's 'own' content or the same as the version this one was copied from.11 # TODO: test 12 12 def content 13 13 return @content if @content … … 24 24 end 25 25 26 # TODO: test 26 27 def redaction_content 27 28 content 28 29 end 29 30 31 # TODO: test 30 32 def content_class 31 33 TemplateContent trunk/app/models/version.rb
r481 r484 26 26 class Version < ActiveRecord::Base 27 27 belongs_to :node 28 belongs_to :user , :foreign_key=>'user_id' # FIXME: can we remove this28 belongs_to :user 29 29 before_validation :version_before_validation 30 30 validates_presence_of :node … … 129 129 # Set version number and site_id before validation tests. 130 130 def version_before_validation 131 return false unless node 131 unless node 132 errors.add('base', 'node missing') 133 return false 134 end 132 135 self[:site_id] = node[:site_id] 133 136 trunk/config/routes.rb
r480 r484 30 30 :link => :any } 31 31 32 nodes.resources :discussions 32 # nodes.resources :discussions do |discussions| 33 # discussions.resources :comments, 34 # :name_prefix => nil, 35 # :member => { :reply_to => :post } 36 # end 33 37 end 34 38 35 39 map.resources :documents, :member => { :crop_form => :get, :file_form => :get } 36 37 40 # map.resources :trans_phrases do |phrases| 38 41 # phrases.resources :trans_values … … 78 81 79 82 # temporary routes... 83 map.connect 'comments/:action/:id', :controller => 'comments' 80 84 map.connect 'z/trans/:action', :controller => 'trans' 81 85 map.connect 'z/calendar/:action', :controller => 'calendar' trunk/lib/parser/test/testhelp.rb
r340 r484 14 14 strings = {} 15 15 test_methods = [] 16 YAML::load_documents( File.open( "#{file}.yml") ) do |doc|16 YAML::load_documents( File.open( File.join(File.dirname(__FILE__), "#{file}.yml") ) ) do |doc| 17 17 doc.each do |elem| 18 18 test_methods << elem[0] trunk/lib/tasks/zena.rake
r462 r484 175 175 rdoc.options << '--line-numbers' << '--inline-source' 176 176 end 177 Rake::Task['zena:rdoc'].comment = "Create the rdoc documentation" 178 179 Rake::TestTask.new(:test => "db:test:prepare") do |t| 180 t.libs << "test" 181 t.pattern = ['test/helpers/**/*_test.rb','test/unit/**/*_test.rb', 'lib/parser/test/*_test.rb'] 182 t.verbose = true 183 end 184 Rake::Task['zena:test'].comment = "Run the tests in test/helpers and test/unit" 177 185 end 178 186 187 namespace :test do 188 189 Rake::TestTask.new(:helpers => "db:test:prepare") do |t| 190 t.libs << "test" 191 t.pattern = 'test/helpers/**/*_test.rb' 192 t.verbose = true 193 end 194 Rake::Task['test:helpers'].comment = "Run the tests in test/helpers" 195 end 196 trunk/test/helpers/basic.yml
r483 r484 166 166 src: "<h1 class='title' do='title' status='true' actions='all'>dummy</h1>" 167 167 tem: "<h1 class='title'><div class='s<%= @node.version.status %>'><%= show_title(:node=>@node) + node_actions(:node=>@node, :actions=>\"all\")%></div></h1>" 168 res: "/<h1 class='title'><div class='s50'><span id='v_title22.1'>status title</span><span class='actions'><a.* \/nodes\/22\/versions\/1\/edit.*\/images\/page_edit.png'.*/><\/a>.*<\/span><\/div><\/h1>/"168 res: "/<h1 class='title'><div class='s50'><span id='v_title22.1'>status title</span><span class='actions'><a.*/nodes/22/versions/1/edit.*/images/page_edit.png'.*/></a>.*</span></div></h1>/" 169 169 170 170 show_c_width: … … 190 190 src: "<div id='path' do='show_path'><ul><li><a href='#'>first</a></li> / <li><a href='#'>second</a></li> / <li><a href='#' class='current'>here</a></li></ul></div>" 191 191 tem: "<div id='path'><%= show_path(:node=>@node) %></div>" 192 res: "/<div id='path'><ul class='path'><li>.*zena.*<li>.*oo \/page18.html.*<li><.*\/projects\/cleanWater.*cleanWater<\/a>.*\/oo\/projects\/cleanWater\/page22.html.*class='current'>status<\/a>/"192 res: "/<div id='path'><ul class='path'><li>.*zena.*<li>.*oo/page18.html.*<li><.*/projects/cleanWater.*cleanWater</a>.*/oo/projects/cleanWater/page22.html.*class='current'>status</a>/" 193 193 194 194 uses_calendar: … … 268 268 edit_not_each: 269 269 src: "<li class='blah'>this is a post <z:edit>edit post</z:edit></li>" 270 tem: "/<li class='blah'>this is a post < \/li>/"270 tem: "/<li class='blah'>this is a post </li>/" 271 271 272 272 edit_each_no_form: … … 278 278 node: 'wiki' 279 279 src: "<z:children><z:each><li do='show' attr='name'>blah</li>\n</z:each><z:add><li>add new</li></z:add><z:form><li><form>this is the form</form></li></z:form></z:children>" 280 res: "/<li>bird.*<li>flower.*<li.* toggle.*Node_add.*Node_form.*<li .*Node_form.*style.*none.*Ajax.Request.*input type='hidden' name='template_url' value='/each/add/with/root_Node'/"280 res: "/<li>bird.*<li>flower.*<li.*list_add.*list_form.*toggle.*<li .*list_form.*style.*none.*Ajax.Request.*input type='hidden' name='template_url' value='/each/add/with/form/list'/" 281 281 282 282 each_edit_with_form: … … 284 284 node: 'wiki' 285 285 src: "<z:children><z:each><li><z:show attr='name'>blah</z:show> <z:edit>edit</z:edit></li>\n</z:each><z:form><li><form>this is the form</form></li></z:form></z:children>" 286 res: "/<li id=' _each_edit_with_root_Node20'>bird <a href='#' onclick=\"new Ajax.Request\('\/z\/zafu\/ajax_edit\/20\?template_url=%2Feach%2Fedit%2Fwith%2Froot_Node'.*flower <a href=\"#\" onclick=\"new Ajax.Request\('\/z\/zafu\/ajax_edit\/21\?template_url=%2Feach%2Fedit%2Fwith%2Froot_Node.*edit</a></li>\n/"286 res: "/<li id='/each/edit/with/form/list30'>bird <a href=\"#\" onclick=\"new Ajax.Request\('/nodes/30/edit\?template_url=%2Feach%2Fedit%2Fwith%2Fform%2Flist/" 287 287 288 288 set_attribute: 289 289 src: "<div class='machin' do='void' set_class='node[id]'/><z:void set_class='s[v_status]i[id]'/>" 290 res: "<div class='node22' /><div class='s50i22'></div>"290 res: "<div class='node22'></div><div class='s50i22'></div>" 291 291 292 292 set_attribute_with_inner: trunk/test/unit/page_test.rb
r455 r484 1 1 require File.dirname(__FILE__) + '/../test_helper' 2 require 'document' # this is needed to load the document model.3 require 'tag'4 require 'project'5 require 'tracker'6 require 'contact'7 2 8 3 class PageTest < ZenaTestUnit 9 4 10 5 def test_select_classes 11 assert_equal ["Page", "Project", "Section", "Tag", "Tracker"], Page.select_classes 6 # preload models 7 Project 8 Skin 9 Tag 10 Tracker 11 assert_equal ["Page", "Project", "Section", "Skin", "Tag", "Tracker"], Page.select_classes 12 12 end 13 13 trunk/test/unit/skin_test.rb
r455 r484 3 3 class SkinTest < ZenaTestUnit 4 4 5 def test_template_url_for_name6 without_files('app/views/templates/compiled') do7 skin = secure(Skin) { Skin.find_by_name('wiki')}8 assert_kind_of Skin, skin9 path = File.join(RAILS_ROOT, 'app', 'views', 'templates', 'compiled', 'wiki', 'any_en.rhtml')10 assert !File.exist?(path), "File does not exist"11 assert_equal "/templates/compiled/wiki/any_en", skin.template_url_for_name('any', nil)12 assert File.exist?(path), "File exists"13 path = File.join(RAILS_ROOT, 'app', 'views', 'templates', 'compiled', 'wiki', 'layout_en.rhtml')14 assert !File.exist?(path), "File does not exist"15 assert_equal "/templates/compiled/wiki/layout_en", skin.template_url_for_name('layout', nil)16 assert File.exist?(path), "File exists"17 assert_equal nil, skin.template_url_for_name('bad', nil)18 end19 end20 21 def test_template_for_path22 skin = secure(Skin) { Skin.find_by_name('wiki')}23 assert_kind_of Skin, skin24 tmpl = skin.template_for_path('any')25 assert_equal tmpl, skin26 tmpl = skin.template_for_path('layout')27 assert_equal nodes_id(:layout), tmpl[:id]28 tmpl = skin.template_for_path('bad')29 assert_nil tmpl30 end31 32 5 def test_name_change 33 6 login(:lion) 34 7 skin = secure(Node) { nodes(:wiki_skin) } 35 tmpt = secure(Node) { nodes(:layout) } 8 tmpt = secure(Node) { nodes(:wiki_node) } 9 assert_kind_of Template, tmpt 36 10 assert_equal 'wiki', skin.name 37 11 assert_equal 'wiki', tmpt.c_skin_name 38 12 skin.name = 'fun' 39 13 assert skin.save, "Can save skin." 40 tmpt = secure(Node) { nodes(: layout)} # reload14 tmpt = secure(Node) { nodes(:wiki_node) } # reload 41 15 assert_equal 'fun', tmpt.c_skin_name 42 16 assert_equal 'fun', secure(Node) { nodes(:wiki_page_changes) }.c_skin_name trunk/test/unit/tag_test.rb
r352 r484 1 1 require File.dirname(__FILE__) + '/../test_helper' 2 2 3 class CollectorTest < ZenaTestUnit3 class TagTest < ZenaTestUnit 4 4 5 5 def test_pages … … 7 7 tag = secure(Node) { nodes(:art) } 8 8 pages = tag.pages 9 assert_equal 2, pages.size9 assert_equal 1, pages.size 10 10 assert_equal 'cleanWater', pages[0].name 11 11 child = secure(Page) { Page.create(:parent_id=>tag[:id], :name=>'a_child') } … … 13 13 tag = secure(Node) { nodes(:art) } 14 14 pages = tag.pages 15 assert_equal 3, pages.size16 assert_equal 'a_child', pages[ 0].name15 assert_equal 2, pages.size 16 assert_equal 'a_child', pages[1].name 17 17 end 18 18 … … 23 23 assert doc.save, "Can save" 24 24 tag = secure(Node) { nodes(:art) } 25 assert_equal 2, tag.pages.size25 assert_equal 1, tag.pages.size 26 26 assert_equal 1, tag.documents.size 27 27 assert_equal 'water', tag.documents[0].name trunk/test/unit/template_version_test.rb
r455 r484 1 1 require File.dirname(__FILE__) + '/../test_helper' 2 2 3 class TemplateVersionTest < Test::Unit::TestCase 4 fixtures :template_versions 5 6 # Replace this with your real tests. 3 class TemplateVersionTest < ZenaTestUnit 7 4 def test_truth 8 5 assert true trunk/test/unit/text_document_content_test.rb
r266 r484 1 1 require File.dirname(__FILE__) + '/../test_helper' 2 2 3 class TextDocumentContentTest < Test::Unit::TestCase 4 fixtures :text_document_contents 3 class TextDocumentContentTest < ZenaTestUnit 5 4 6 # Replace this with your real tests.7 5 def test_truth 8 6 assert true trunk/test/unit/trans_key_test.rb
r133 r484 9 9 assert_equal 'lundi', key['fr'] 10 10 assert_equal 'lundi', TransPhrase['Monday']['fr'] 11 end12 13 def test_create_new_key14 assert_nil TransPhrase.find_by_key('yoba')15 key = TransPhrase['yoba']16 assert_not_nil TransPhrase.find_by_key('yoba')17 11 end 18 12 trunk/test/unit/trans_value_test.rb
r66 r484 1 1 require File.dirname(__FILE__) + '/../test_helper' 2 2 3 class TransValueTest < Test::Unit::TestCase 4 3 class TransValueTest < ZenaTestUnit 5 4 def test_nothing 6 5 assert true, 'nothing to test' trunk/test/unit/user_test.rb
r455 r484 1 1 require File.dirname(__FILE__) + '/../test_helper' 2 ApplicationController # need to load to test caching 2 3 3 class UserTest < ZenaTestUnit 4 4 trunk/test/unit/version_test.rb
r472 r484 96 96 node = secure(Node) { Node.new(:parent_id=>1, :name=>'bob') } 97 97 assert node.save 98 vers = Version.new98 vers = secure(Version) { Version.new } 99 99 assert !vers.save 100 assert_equal "can't be blank", vers.errors[:node] 101 assert_equal "can't be blank", vers.errors[:user] 100 assert_equal "node missing", vers.errors[:base] 102 101 end 103 102 trunk/vendor/bricks/20070122-172926.txt
r251 r484 71 71 copy;app/views/comment/_li.rhtml;app/views/comment/_li.rhtml 72 72 copy;app/views/comment/_li_simple.rhtml;app/views/comment/_li_simple.rhtml 73 copy;app/views/comment /_list.rhtml;app/views/comment/_list.rhtml73 copy;app/views/comments/_list.rhtml;app/views/comments/_list.rhtml 74 74 copy;app/views/comment/create.rjs;app/views/comment/create.rjs 75 75 copy;app/views/comment/edit.rjs;app/views/comment/edit.rjs
