Changeset 134
- Timestamp:
- 09/29/06 21:05:11 (2 years ago)
- Files:
-
- branches/corex/radiant/app/models/archive_day_index_page.rb (deleted)
- branches/corex/radiant/app/models/archive_finder.rb (deleted)
- branches/corex/radiant/app/models/archive_month_index_page.rb (deleted)
- branches/corex/radiant/app/models/archive_page.rb (deleted)
- branches/corex/radiant/app/models/archive_year_index_page.rb (deleted)
- branches/corex/radiant/app/models/file_not_found_page.rb (modified) (1 diff)
- branches/corex/radiant/app/models/page.rb (modified) (4 diffs)
- branches/corex/radiant/app/models/tag_helper.rb (added)
- branches/corex/radiant/lib/archive_index_tags_and_methods.rb (deleted)
- branches/corex/radiant/test/fixtures/pages.yml (modified) (2 diffs)
- branches/corex/radiant/test/helpers/archive_index_test_helper.rb (deleted)
- branches/corex/radiant/test/helpers/page_test_helper.rb (modified) (1 diff)
- branches/corex/radiant/test/unit/archive_day_index_page_test.rb (deleted)
- branches/corex/radiant/test/unit/archive_month_index_page_test.rb (deleted)
- branches/corex/radiant/test/unit/archive_page_test.rb (deleted)
- branches/corex/radiant/test/unit/archive_year_index_page_test.rb (deleted)
- branches/corex/radiant/test/unit/page_context_test.rb (modified) (5 diffs)
- branches/corex/radiant/test/unit/page_test.rb (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
branches/corex/radiant/app/models/file_not_found_page.rb
r126 r134 10 10 } 11 11 12 define_tags do 13 url = request.request_uri if request 14 tag("attempted_url") { url } 12 define_tag("attempted_url") do 13 request.request_uri 15 14 end 16 15 branches/corex/radiant/app/models/page.rb
r132 r134 1 1 require_dependency 'annotatable' 2 require_dependency 'tag_helper' 2 3 3 4 class Page < ActiveRecord::Base … … 30 31 include Annotatable 31 32 annotate :description 32 33 include InheritableClassAttributes 34 cattr_inheritable_reader :additional_tag_definition_blocks 35 @additional_tag_definition_blocks = [] 36 cattr_inheritable_reader :additional_child_tag_definition_blocks 37 @additional_child_tag_definition_blocks = [] 38 33 34 include TagHelper 35 39 36 attr_accessor :request, :response, :ptype 40 37 … … 161 158 end 162 159 163 def define_tags(&block)164 @additional_tag_definition_blocks << block165 end166 167 # def define_child_tags(&block)168 # @additional_child_tag_definition_blocks << block169 # end170 171 160 def display_name(string = nil) 172 161 if string … … 232 221 unless @context and @parser 233 222 @context = PageContext.new(self) 234 self.class.additional_tag_definition_blocks.each { |block| instance_eval &block }223 define_tags(@context) 235 224 @parser = Radius::Parser.new(@context, :tag_prefix => 'r') 236 225 end branches/corex/radiant/test/fixtures/pages.yml
r132 r134 102 102 parent_id: 10 103 103 published_at: 2006-01-30 08:41:07 104 archive:104 page_with_virtual_children: 105 105 id: 12 106 title: Archive106 title: Page With Virtual Children 107 107 breadcrumb: Parent 108 slug: archive 109 type: ArchivePage 110 status_id: 100 111 parent_id: 1 112 published_at: 2006-01-30 08:41:07 113 year_index: 108 slug: page-with-virtual-children 109 status_id: 100 110 parent_id: 1 111 published_at: 2006-01-30 08:41:07 112 first_virtual_page: 114 113 id: 41 115 title: %Y Archive 116 slug: year 117 type: ArchiveYearIndexPage 114 title: First Virtual Page 115 slug: first-virtual-page 118 116 status_id: 101 119 117 parent_id: 12 120 118 virtual: true 121 119 published_at: 2006-02-05 08:44:07 122 month_index:120 second_virtual_page: 123 121 id: 42 124 title: %B %Y Archive 125 slug: month 126 type: ArchiveMonthIndexPage 122 title: Second Virtual Page 123 slug: second-virtual-page 127 124 status_id: 101 128 125 parent_id: 12 129 126 virtual: true 130 127 published_at: 2006-02-05 08:44:07 131 day_index:128 third_virtual_page: 132 129 id: 43 133 title: %B %d, %Y Archive 134 slug: day 135 type: ArchiveDayIndexPage 130 title: Third Virtual Page 131 slug: third-virtual-page 136 132 status_id: 101 137 133 parent_id: 12 … … 233 229 news: 234 230 id: 30 235 title: News Archives231 title: News 236 232 breadcrumb: news 237 233 slug: news branches/corex/radiant/test/helpers/page_test_helper.rb
r126 r134 7 7 end 8 8 9 class VirtualPage < Page 10 description 'Virtual page.' 11 12 def virtual? 13 true 14 end 15 end 16 9 17 class TestPage < Page 10 18 description 'this is just a test page' 11 19 12 define_tags do 13 tag 'test1' do 14 'Hello world!' 15 end 20 define_tag 'test1' do 21 'Hello world!' 16 22 end 17 23 18 define_tags do 19 tag 'test2' do 20 'Another test.' 21 end 24 define_tag 'test2' do 25 'Another test.' 22 26 end 23 27 branches/corex/radiant/test/unit/page_context_test.rb
r126 r134 72 72 end 73 73 def test_tag_children_each_does_not_list_virtual_pages 74 setup_for_page(: archive)74 setup_for_page(:page_with_virtual_children) 75 75 assert_parse_output 'article article-2 article-3 article-4 article-5 ', '<r:children:each><r:slug /> </r:children:each>' 76 76 assert_parse_output_match /^(draft |)article article-2 article-3 article-4 article-5( draft|) $/, '<r:children:each status="all"><r:slug /> </r:children:each>' … … 78 78 79 79 def test_tag_children_each_header 80 setup_for_page(: archive)80 setup_for_page(:page_with_virtual_children) 81 81 assert_parse_output '[May/00] article [Jun/00] article-2 article-3 [Aug/00] article-4 [Aug/01] article-5 ', '<r:children:each><r:header>[<r:date format="%b/%y" />] </r:header><r:slug /> </r:children:each>' 82 82 end 83 83 def test_tag_children_each_header_with_name_attribute 84 setup_for_page(: archive)84 setup_for_page(:page_with_virtual_children) 85 85 assert_parse_output '[2000] (May) article (Jun) article-2 article-3 (Aug) article-4 [2001] article-5 ', %{<r:children:each><r:header name="year">[<r:date format='%Y' />] </r:header><r:header name="month">(<r:date format="%b" />) </r:header><r:slug /> </r:children:each>} 86 86 end 87 87 def test_tag_children_each_header_with_restart_attribute 88 setup_for_page(: archive)88 setup_for_page(:page_with_virtual_children) 89 89 assert_parse_output( 90 90 '[2000] (May) article (Jun) article-2 article-3 (Aug) article-4 [2001] (Aug) article-5 ', … … 220 220 221 221 def test_tag_navigation_1 222 tags = %{<r:navigation urls="Home: Boy: /; Archives: /archive/; Radius: /radius/; Docs: /documentation/">222 tags = %{<r:navigation urls="Home: Boy: /; Virtual Pages: /page-with-virtual-children/; Radius: /radius/; Docs: /documentation/"> 223 223 <r:normal><a href="<r:url />"><r:title /></a></r:normal> 224 224 <r:here><strong><r:title /></strong></r:here> … … 226 226 <r:between> | </r:between> 227 227 </r:navigation>} 228 expected = %{<strong><a href="/">Home: Boy</a></strong> | <a href="/ archive/">Archives</a> | <strong>Radius</strong> | <a href="/documentation/">Docs</a>}228 expected = %{<strong><a href="/">Home: Boy</a></strong> | <a href="/page-with-virtual-children/">Virtual Pages</a> | <strong>Radius</strong> | <a href="/documentation/">Docs</a>} 229 229 assert_parse_output expected, tags 230 230 end 231 231 def test_tag_navigation_2 232 tags = %{<r:navigation urls="Home: /; Archives: /archive/; Radius: /radius/; Docs: /documentation/">232 tags = %{<r:navigation urls="Home: /; Virtual Pages: /page-with-virtual-children/; Radius: /radius/; Docs: /documentation/"> 233 233 <r:normal><r:title /></r:normal> 234 234 </r:navigation>} 235 expected = %{Home Archives Radius Docs}235 expected = %{Home Virtual Pages Radius Docs} 236 236 assert_parse_output expected, tags 237 237 end 238 238 def test_tag_navigation_3 239 tags = %{<r:navigation urls="Home: /; Archives: /archive/; Radius: /radius/; Docs: /documentation/">239 tags = %{<r:navigation urls="Home: /; Virtual Pages: /page-with-virtual-children/; Radius: /radius/; Docs: /documentation/"> 240 240 <r:normal><r:title /></r:normal> 241 241 <r:selected><strong><r:title/></strong></r:selected> 242 242 </r:navigation>} 243 expected = %{<strong>Home</strong> Archives <strong>Radius</strong> Docs}243 expected = %{<strong>Home</strong> Virtual Pages <strong>Radius</strong> Docs} 244 244 assert_parse_output expected, tags 245 245 end … … 251 251 end 252 252 def test_tag_navigation_with_urls_without_slashes 253 tags = %{<r:navigation urls="Home: ; Archives: /archive; Radius: /radius; Docs: /documentation">253 tags = %{<r:navigation urls="Home: ; Virtual Pages: /page-with-virtual-pages; Radius: /radius; Docs: /documentation"> 254 254 <r:normal><r:title /></r:normal> 255 255 <r:here><strong><r:title /></strong></r:here> 256 256 </r:navigation>} 257 expected = %{Home Archives <strong>Radius</strong> Docs}257 expected = %{Home Virtual Pages <strong>Radius</strong> Docs} 258 258 assert_parse_output expected, tags 259 259 end branches/corex/radiant/test/unit/page_test.rb
r126 r134 144 144 assert_equal expected, found 145 145 end 146 def test_find_by_url_3147 @page = pages(:homepage)148 assert_equal pages(:article), @page.find_by_url('/archive/2000/05/01/article/')149 end150 146 def test_find_by_url__when_virtual 151 147 @page = pages(:homepage) 152 found = @page.find_by_url('/ archive/2006/02/05/month/')148 found = @page.find_by_url('/page_with_virtual_children/first_virtual_page/') 153 149 assert_equal nil, found 154 150 end … … 279 275 280 276 def test_before_save 281 @page = create_test_page(:type => ArchiveMonthIndexPage)277 @page = create_test_page(:type => VirtualPage) 282 278 assert_equal true, @page.virtual? 283 279 assert_equal true, @page.virtual
