Changeset 826

Show
Ignore:
Timestamp:
04/19/08 11:36:07 (4 months ago)
Author:
seancribbs
Message:

Add <r:meta /> tag and appropriate fields to pages table.

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/radiant/CHANGELOG

    r823 r826  
    22 
    33=== SVN 
     4* Add <r:meta /> tag and appropriate fields to pages table. [Sean Cribbs] 
    45* Move admin-related javascripts to admin/. [BjÞrn Arild MÊland] 
    56* Add if_self and if_ancestor_or_self tags. [Marty Haught, Sean Cribbs] 
  • trunk/radiant/app/controllers/admin/page_controller.rb

    r576 r826  
    9292      @meta << {:field => "slug", :type => "text_field", :args => [{:class => 'textbox', :maxlength => 100}]} 
    9393      @meta << {:field => "breadcrumb", :type => "text_field", :args => [{:class => 'textbox', :maxlength => 160}]} 
     94      @meta << {:field => "description", :type => "text_field", :args => [{:class => 'textbox', :maxlength => 200}]} 
     95      @meta << {:field => "keywords", :type => "text_field", :args => [{:class => 'textbox', :maxlength => 200}]} 
    9496    end 
    9597     
  • trunk/radiant/app/models/standard_tags.rb

    r815 r826  
    647647  end 
    648648   
     649  desc %{ 
     650    The namespace for 'meta' attributes.  If used as a singleton tag, both the description 
     651    and keywords fields will be output as &lt;meta /&gt; tags unless the attribute 'tag' is set to 'false'. 
     652     
     653    *Usage*: 
     654     
     655    <pre><code> <r:meta [tag="false"] />  
     656     <r:meta> 
     657       <r:description [tag="false"] /> 
     658       <r:keywords [tag="false"] /> 
     659     </r:meta> 
     660    </code></pre> 
     661  } 
     662  tag 'meta' do |tag| 
     663    if tag.double? 
     664      tag.expand 
     665    else 
     666      tag.render('description', tag.attr) + 
     667      tag.render('keywords', tag.attr) 
     668    end 
     669  end 
     670   
     671  desc %{ 
     672    Emits the page description field in a meta tag, unless attribute 
     673    'tag' is set to 'false'. 
     674     
     675    *Usage*: 
     676     
     677    <pre><code> <r:meta:description [tag="false"] /> </code></pre> 
     678  } 
     679  tag 'meta:description' do |tag| 
     680    show_tag = tag.attr['tag'] != 'false' || false 
     681    description = CGI.escapeHTML(tag.locals.page.description) 
     682    if show_tag 
     683      "<meta name=\"description\" content=\"#{description}\" />" 
     684    else 
     685      description 
     686    end 
     687  end 
     688 
     689  desc %{ 
     690    Emits the page keywords field in a meta tag, unless attribute 
     691    'tag' is set to 'false'. 
     692     
     693    *Usage*: 
     694     
     695    <pre><code> <r:meta:keywords [tag="false"] /> </code></pre> 
     696  }   
     697  tag 'meta:keywords' do |tag| 
     698    show_tag = tag.attr['tag'] != 'false' || false 
     699    keywords = CGI.escapeHTML(tag.locals.page.keywords) 
     700    if show_tag 
     701      "<meta name=\"keywords\" content=\"#{keywords}\" />" 
     702    else 
     703      keywords 
     704    end     
     705  end 
     706   
    649707  private 
    650708   
  • trunk/radiant/db/schema.rb

    r813 r826  
    1010# It's strongly recommended to check this file into your version control system. 
    1111 
    12 ActiveRecord::Schema.define(:version => 17) do 
     12ActiveRecord::Schema.define(:version => 18) do 
    1313 
    1414  create_table "config", :force => true do |t| 
     
    5858    t.boolean  "virtual",                      :default => false, :null => false 
    5959    t.integer  "lock_version",                 :default => 0 
     60    t.string   "description" 
     61    t.string   "keywords" 
    6062  end 
    6163 
  • trunk/radiant/spec/models/standard_tags_spec.rb

    r825 r826  
    555555  end 
    556556 
     557  describe "<r:meta>" do 
     558    it "should render <meta> tags for the description and keywords" do 
     559      page(:home).should render('<r:meta/>').as(%{<meta rel="description" content="The homepage" /><meta rel="keywords" content="Home, Page" />}) 
     560    end 
     561     
     562    it "should render <meta> tags with escaped values for the description and keywords" do 
     563      page.should render('<r:meta/ >').as(%{<meta rel="description" content="sweet &amp; harmonious biscuits" /><meta rel="keywords" content="sweet &amp; harmonious biscuits" />}) 
     564    end 
     565 
     566    describe "with 'tag' attribute set to 'false'" do 
     567      it "should render the contents of the description and keywords" do 
     568        page(:home).should render('<r:meta tag="false" />').as(%{The homepageHome, Page}) 
     569      end 
     570       
     571      it "should escape the contents of the description and keywords" do 
     572        page.should render('<r:meta tag="false" />').as("sweet &amp; harmonious biscuitssweet &amp; harmonious biscuits") 
     573      end 
     574    end 
     575  end 
     576   
     577  describe "<r:meta:description>" do 
     578    it "should render a <meta> tag for the description" do 
     579      page(:home).should render('<r:meta:description/>').as(%{<meta rel="description" content="The homepage" />}) 
     580    end 
     581     
     582    it "should render a <meta> tag with escaped value for the description" do 
     583      page.should render('<r:meta/ >').as(%{<meta rel="description" content="sweet &amp; harmonious biscuits" />}) 
     584    end 
     585 
     586    describe "with 'tag' attribute set to 'false'" do 
     587      it "should render the contents of the description" do 
     588        page(:home).should render('<r:meta:description tag="false" />').as(%{The homepage}) 
     589      end 
     590       
     591      it "should escape the contents of the description" do 
     592        page.should render('<r:meta:description tag="false" />').as("sweet &amp; harmonious biscuits") 
     593      end 
     594    end 
     595  end 
     596   
     597  describe "<r:meta:keywords>" do 
     598    it "should render a <meta> tag for the keywords" do 
     599      page(:home).should render('<r:meta:keywords/>').as(%{<meta rel="keywords" content="Home, Page" />}) 
     600    end 
     601     
     602    it "should render a <meta> tag with escaped value for the keywords" do 
     603      page.should render('<r:meta/ >').as(%{<meta rel="keywords" content="sweet &amp; harmonious biscuits" />}) 
     604    end 
     605 
     606    describe "with 'tag' attribute set to 'false'" do 
     607      it "should render the contents of the keywords" do 
     608        page(:home).should render('<r:meta:keywords tag="false" />').as(%{Home, Page}) 
     609      end 
     610       
     611      it "should escape the contents of the keywords" do 
     612        page.should render('<r:meta:keywords tag="false" />').as("sweet &amp; harmonious biscuits") 
     613      end 
     614    end 
     615  end 
     616   
    557617  private 
    558618 
  • trunk/radiant/spec/scenarios/home_page_scenario.rb

    r672 r826  
    22   
    33  def load 
    4     create_page "Home", :slug => "/", :parent_id => nil do 
     4    create_page "Home", :slug => "/", :parent_id => nil,  
     5                        :description => "The homepage",  
     6                        :keywords => "home, page" do 
    57      create_page_part "body", :content => "Hello world!" 
    68      create_page_part "sidebar", :content => "<r:title /> sidebar." 
  • trunk/radiant/spec/scenarios/pages_scenario.rb

    r672 r826  
    2222    end 
    2323    create_page "Childless" 
    24     create_page "Assorted" do 
     24    create_page "Assorted", :keywords => "sweet & harmonious biscuits", :description => "sweet & harmonious biscuits" do 
    2525      breadcrumbs = %w(f e d c b a j i h g) 
    2626      %w(a b c d e f g h i j).each_with_index do |name, i|