From b5927b82376ba0982b29d634bd8d4834fcbf740b Mon Sep 17 00:00:00 2001 From: Vijay Dev Date: Sat, 31 Dec 2011 22:55:25 +0530 Subject: [PATCH] DRY up guides index page Use the list of guides available in documents.yaml to fill in the menu in the index page instead of duplicating the list again. Also, remove WIP guides from the menu. --- railties/guides/rails_guides/helpers.rb | 12 +++++- railties/guides/source/documents.yaml | 2 +- railties/guides/source/layout.html.erb | 55 +++++-------------------- 3 files changed, 21 insertions(+), 48 deletions(-) diff --git a/railties/guides/rails_guides/helpers.rb b/railties/guides/rails_guides/helpers.rb index 45ad9b9588..e6ef656474 100644 --- a/railties/guides/rails_guides/helpers.rb +++ b/railties/guides/rails_guides/helpers.rb @@ -11,15 +11,23 @@ module RailsGuides result << content_tag(:dd, capture(&block)) result end - + def documents_by_section @documents_by_section ||= YAML.load_file(File.expand_path('../../source/documents.yaml', __FILE__)) end - + def documents_flat documents_by_section.map {|section| section['documents']}.flatten end + def finished_documents(documents) + documents.reject { |document| document['work_in_progress'] } + end + + def docs_for_menu(position) + position == 'L' ? documents_by_section.to(3) : documents_by_section.from(4) + end + def author(name, nick, image = 'credits_pic_blank.gif', &block) image = "images/#{image}" diff --git a/railties/guides/source/documents.yaml b/railties/guides/source/documents.yaml index dccfefb4fb..58713a08a8 100644 --- a/railties/guides/source/documents.yaml +++ b/railties/guides/source/documents.yaml @@ -84,7 +84,7 @@ url: configuring.html description: This guide covers the basic configuration settings for a Rails application. - - name: Rails Command Line Tools and Rake tasks + name: Rails Command Line Tools and Rake Tasks url: command_line.html description: This guide covers the command line tools and rake tasks provided by Rails. - diff --git a/railties/guides/source/layout.html.erb b/railties/guides/source/layout.html.erb index e69936b43a..84427b380c 100644 --- a/railties/guides/source/layout.html.erb +++ b/railties/guides/source/layout.html.erb @@ -44,51 +44,16 @@
  • Guides Index
  • Contribute