Changeset 806
- Timestamp:
- 04/18/08 15:46:58 (3 months ago)
- Files:
-
- trunk/radiant/app/models/standard_tags.rb (modified) (3 diffs)
- trunk/radiant/public/javascripts/admin.js (modified) (1 diff)
- trunk/radiant/spec/models/standard_tags_spec.rb (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
trunk/radiant/app/models/standard_tags.rb
r782 r806 438 438 end 439 439 end 440 441 desc %{ 442 Inside this tag all page related tags refer to the page found at the @url@ attribute. 440 441 desc %{ 442 Inside this tag all page related tags refer to the page found at the @url@ attribute. 443 @url@s may be relative or absolute paths. 443 444 444 445 *Usage:* … … 446 447 } 447 448 tag 'find' do |tag| 448 if url = tag.attr['url'] 449 if found = Page.find_by_url(tag.attr['url']) 450 unless FileNotFoundPage === found 451 tag.locals.page = found 452 tag.expand 453 end 454 end 455 else 456 raise TagError.new("`find' tag must contain `url' attribute") 449 url = tag.attr['url'] 450 raise TagError.new("`find' tag must contain `url' attribute") unless url 451 452 found = Page.find_by_url(absolute_path_for(tag.locals.page.url, url)) 453 if page_found?(found) 454 tag.locals.page = found 455 tag.expand 457 456 end 458 457 end … … 691 690 File.join(request.relative_url_root, url) 692 691 end 692 693 def absolute_path_for(base_path, new_path) 694 if new_path.first == '/' 695 new_path 696 else 697 File.expand_path(File.join(base_path, new_path)) 698 end 699 end 700 701 def page_found?(page) 702 page && !(FileNotFoundPage === page) 703 end 693 704 end trunk/radiant/public/javascripts/admin.js
r759 r806 60 60 $('publication-date').hide().select('select').invoke('disable'); 61 61 }) 62 }); 63 64 when('notice', function(notice) { 65 new Effect.Fade(notice, {delay: 3}) 62 66 }); 63 67 }); trunk/radiant/spec/models/standard_tags_spec.rb
r782 r806 343 343 page.should render(%{<r:find url="/parent/"><r:children:each><r:slug /> </r:children:each></r:find>}).as('child child-2 child-3 ') 344 344 end 345 specify '<r:find> with relative url' do 346 page(:great_grandchild).should render(%{<r:find url="../../../child-2"><r:title/></r:find>}).as("Child 2") 347 end 345 348 346 349 specify '<r:escape_html>' do
