Changeset 134

Show
Ignore:
Timestamp:
09/29/06 21:05:11 (2 years ago)
Author:
ahorn
Message:

corex branch: 1) simplify Radiant tag system and eliminate nested &tag blocks 2) exclude archive pages 3) replace archiver tests with generic virtual page tests.

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • branches/corex/radiant/app/models/file_not_found_page.rb

    r126 r134  
    1010  } 
    1111   
    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 
    1514  end 
    1615    
  • branches/corex/radiant/app/models/page.rb

    r132 r134  
    11require_dependency 'annotatable' 
     2require_dependency 'tag_helper' 
    23 
    34class Page < ActiveRecord::Base 
     
    3031  include Annotatable 
    3132  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  
    3936  attr_accessor :request, :response, :ptype 
    4037   
     
    161158    end 
    162159 
    163     def define_tags(&block) 
    164       @additional_tag_definition_blocks << block 
    165     end 
    166      
    167     # def define_child_tags(&block) 
    168     #   @additional_child_tag_definition_blocks << block 
    169     # end 
    170      
    171160    def display_name(string = nil) 
    172161      if string 
     
    232221      unless @context and @parser 
    233222        @context = PageContext.new(self) 
    234         self.class.additional_tag_definition_blocks.each { |block| instance_eval &block } 
     223        define_tags(@context) 
    235224        @parser = Radius::Parser.new(@context, :tag_prefix => 'r') 
    236225      end 
  • branches/corex/radiant/test/fixtures/pages.yml

    r132 r134  
    102102  parent_id: 10 
    103103  published_at: 2006-01-30 08:41:07  
    104 archive
     104page_with_virtual_children
    105105  id: 12 
    106   title: Archive 
     106  title: Page With Virtual Children 
    107107  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  
     112first_virtual_page: 
    114113  id: 41 
    115   title: %Y Archive 
    116   slug: year 
    117   type: ArchiveYearIndexPage 
     114  title: First Virtual Page 
     115  slug: first-virtual-page 
    118116  status_id: 101 
    119117  parent_id: 12 
    120118  virtual: true 
    121119  published_at: 2006-02-05 08:44:07  
    122 month_index
     120second_virtual_page
    123121  id: 42 
    124   title: %B %Y Archive 
    125   slug: month 
    126   type: ArchiveMonthIndexPage 
     122  title: Second Virtual Page 
     123  slug: second-virtual-page 
    127124  status_id: 101 
    128125  parent_id: 12 
    129126  virtual: true 
    130127  published_at: 2006-02-05 08:44:07  
    131 day_index
     128third_virtual_page
    132129  id: 43 
    133   title: %B %d, %Y Archive 
    134   slug: day 
    135   type: ArchiveDayIndexPage 
     130  title: Third Virtual Page 
     131  slug: third-virtual-page 
    136132  status_id: 101 
    137133  parent_id: 12 
     
    233229news: 
    234230  id: 30 
    235   title: News Archives 
     231  title: News 
    236232  breadcrumb: news 
    237233  slug: news 
  • branches/corex/radiant/test/helpers/page_test_helper.rb

    r126 r134  
    77end 
    88 
     9class VirtualPage < Page 
     10  description 'Virtual page.' 
     11   
     12  def virtual? 
     13    true 
     14  end 
     15end 
     16 
    917class TestPage < Page 
    1018  description 'this is just a test page' 
    1119   
    12   define_tags do 
    13     tag 'test1' do 
    14       'Hello world!' 
    15     end 
     20  define_tag 'test1' do 
     21    'Hello world!' 
    1622  end 
    1723   
    18   define_tags do 
    19     tag 'test2' do 
    20       'Another test.' 
    21     end 
     24  define_tag 'test2' do 
     25    'Another test.' 
    2226  end 
    2327   
  • branches/corex/radiant/test/unit/page_context_test.rb

    r126 r134  
    7272  end 
    7373  def test_tag_children_each_does_not_list_virtual_pages 
    74     setup_for_page(:archive
     74    setup_for_page(:page_with_virtual_children
    7575    assert_parse_output 'article article-2 article-3 article-4 article-5 ', '<r:children:each><r:slug /> </r:children:each>' 
    7676    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>' 
     
    7878   
    7979  def test_tag_children_each_header 
    80     setup_for_page(:archive
     80    setup_for_page(:page_with_virtual_children
    8181    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>' 
    8282  end 
    8383  def test_tag_children_each_header_with_name_attribute 
    84     setup_for_page(:archive
     84    setup_for_page(:page_with_virtual_children
    8585    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>}   
    8686  end 
    8787  def test_tag_children_each_header_with_restart_attribute 
    88     setup_for_page(:archive
     88    setup_for_page(:page_with_virtual_children
    8989    assert_parse_output( 
    9090      '[2000] (May) article (Jun) article-2 article-3 (Aug) article-4 [2001] (Aug) article-5 ', 
     
    220220   
    221221  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/"> 
    223223               <r:normal><a href="<r:url />"><r:title /></a></r:normal> 
    224224               <r:here><strong><r:title /></strong></r:here> 
     
    226226               <r:between> | </r:between> 
    227227             </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>} 
    229229    assert_parse_output expected, tags 
    230230  end 
    231231  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/"> 
    233233               <r:normal><r:title /></r:normal> 
    234234             </r:navigation>} 
    235     expected = %{Home Archives Radius Docs} 
     235    expected = %{Home Virtual Pages Radius Docs} 
    236236    assert_parse_output expected, tags 
    237237  end 
    238238  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/"> 
    240240               <r:normal><r:title /></r:normal> 
    241241               <r:selected><strong><r:title/></strong></r:selected> 
    242242             </r:navigation>} 
    243     expected = %{<strong>Home</strong> Archives <strong>Radius</strong> Docs} 
     243    expected = %{<strong>Home</strong> Virtual Pages <strong>Radius</strong> Docs} 
    244244    assert_parse_output expected, tags 
    245245  end 
     
    251251  end 
    252252  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"> 
    254254               <r:normal><r:title /></r:normal> 
    255255               <r:here><strong><r:title /></strong></r:here> 
    256256             </r:navigation>} 
    257     expected = %{Home Archives <strong>Radius</strong> Docs} 
     257    expected = %{Home Virtual Pages <strong>Radius</strong> Docs} 
    258258    assert_parse_output expected, tags 
    259259  end 
  • branches/corex/radiant/test/unit/page_test.rb

    r126 r134  
    144144    assert_equal expected, found  
    145145  end 
    146   def test_find_by_url_3 
    147     @page = pages(:homepage) 
    148     assert_equal pages(:article), @page.find_by_url('/archive/2000/05/01/article/') 
    149   end 
    150146  def test_find_by_url__when_virtual 
    151147    @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/') 
    153149    assert_equal nil, found 
    154150  end 
     
    279275   
    280276  def test_before_save 
    281     @page = create_test_page(:type => ArchiveMonthIndexPage) 
     277    @page = create_test_page(:type => VirtualPage) 
    282278    assert_equal true, @page.virtual? 
    283279    assert_equal true, @page.virtual