Changeset 826
- Timestamp:
- 04/19/08 11:36:07 (4 months ago)
- Files:
-
- trunk/radiant/CHANGELOG (modified) (1 diff)
- trunk/radiant/app/controllers/admin/page_controller.rb (modified) (1 diff)
- trunk/radiant/app/models/standard_tags.rb (modified) (1 diff)
- trunk/radiant/db/migrate/018_add_description_and_keywords_to_pages.rb (added)
- trunk/radiant/db/schema.rb (modified) (2 diffs)
- trunk/radiant/spec/models/standard_tags_spec.rb (modified) (1 diff)
- trunk/radiant/spec/scenarios/home_page_scenario.rb (modified) (1 diff)
- trunk/radiant/spec/scenarios/pages_scenario.rb (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
trunk/radiant/CHANGELOG
r823 r826 2 2 3 3 === SVN 4 * Add <r:meta /> tag and appropriate fields to pages table. [Sean Cribbs] 4 5 * Move admin-related javascripts to admin/. [BjÞrn Arild MÊland] 5 6 * Add if_self and if_ancestor_or_self tags. [Marty Haught, Sean Cribbs] trunk/radiant/app/controllers/admin/page_controller.rb
r576 r826 92 92 @meta << {:field => "slug", :type => "text_field", :args => [{:class => 'textbox', :maxlength => 100}]} 93 93 @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}]} 94 96 end 95 97 trunk/radiant/app/models/standard_tags.rb
r815 r826 647 647 end 648 648 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 <meta /> 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 649 707 private 650 708 trunk/radiant/db/schema.rb
r813 r826 10 10 # It's strongly recommended to check this file into your version control system. 11 11 12 ActiveRecord::Schema.define(:version => 1 7) do12 ActiveRecord::Schema.define(:version => 18) do 13 13 14 14 create_table "config", :force => true do |t| … … 58 58 t.boolean "virtual", :default => false, :null => false 59 59 t.integer "lock_version", :default => 0 60 t.string "description" 61 t.string "keywords" 60 62 end 61 63 trunk/radiant/spec/models/standard_tags_spec.rb
r825 r826 555 555 end 556 556 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 & harmonious biscuits" /><meta rel="keywords" content="sweet & 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 & harmonious biscuitssweet & 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 & 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 & 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 & 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 & harmonious biscuits") 613 end 614 end 615 end 616 557 617 private 558 618 trunk/radiant/spec/scenarios/home_page_scenario.rb
r672 r826 2 2 3 3 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 5 7 create_page_part "body", :content => "Hello world!" 6 8 create_page_part "sidebar", :content => "<r:title /> sidebar." trunk/radiant/spec/scenarios/pages_scenario.rb
r672 r826 22 22 end 23 23 create_page "Childless" 24 create_page "Assorted" do24 create_page "Assorted", :keywords => "sweet & harmonious biscuits", :description => "sweet & harmonious biscuits" do 25 25 breadcrumbs = %w(f e d c b a j i h g) 26 26 %w(a b c d e f g h i j).each_with_index do |name, i|
