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.
This commit is contained in:
Vijay Dev 2011-12-31 22:55:25 +05:30
parent d3a2c0e183
commit b5927b8237
3 changed files with 21 additions and 48 deletions

View File

@ -11,15 +11,23 @@ module RailsGuides
result << content_tag(:dd, capture(&block)) result << content_tag(:dd, capture(&block))
result result
end end
def documents_by_section def documents_by_section
@documents_by_section ||= YAML.load_file(File.expand_path('../../source/documents.yaml', __FILE__)) @documents_by_section ||= YAML.load_file(File.expand_path('../../source/documents.yaml', __FILE__))
end end
def documents_flat def documents_flat
documents_by_section.map {|section| section['documents']}.flatten documents_by_section.map {|section| section['documents']}.flatten
end 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) def author(name, nick, image = 'credits_pic_blank.gif', &block)
image = "images/#{image}" image = "images/#{image}"

View File

@ -84,7 +84,7 @@
url: configuring.html url: configuring.html
description: This guide covers the basic configuration settings for a Rails application. 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 url: command_line.html
description: This guide covers the command line tools and rake tasks provided by Rails. description: This guide covers the command line tools and rake tasks provided by Rails.
- -

View File

@ -44,51 +44,16 @@
<li class="index"><a href="index.html" onclick="guideMenu(); return false;" id="guidesMenu">Guides Index</a> <li class="index"><a href="index.html" onclick="guideMenu(); return false;" id="guidesMenu">Guides Index</a>
<div id="guides" class="clearfix" style="display: none;"> <div id="guides" class="clearfix" style="display: none;">
<hr /> <hr />
<dl class="L"> <% ['L', 'R'].each do |position| %>
<dt>Start Here</dt> <dl class="<%= position %>">
<dd><a href="getting_started.html">Getting Started with Rails</a></dd> <% docs_for_menu(position).each do |section| %>
<dt>Models</dt> <dt><%= section['name'] %></dt>
<dd><a href="migrations.html">Rails Database Migrations</a></dd> <% finished_documents(section['documents']).each do |document| %>
<dd><a href="active_record_validations_callbacks.html">Active Record Validations and Callbacks</a></dd> <dd><a href="<%= document['url'] %>"><%= document['name'] %></a></dd>
<dd><a href="association_basics.html">Active Record Associations</a></dd> <% end %>
<dd><a href="active_record_querying.html">Active Record Query Interface</a></dd> <% end %>
<dt>Views</dt> </dl>
<dd><a href="layouts_and_rendering.html">Layouts and Rendering in Rails</a></dd> <% end %>
<dd><a href="form_helpers.html">Action View Form Helpers</a></dd>
<dt>Controllers</dt>
<dd><a href="action_controller_overview.html">Action Controller Overview</a></dd>
<dd><a href="routing.html">Rails Routing from the Outside In</a></dd>
</dl>
<dl class="R">
<dt>Digging Deeper</dt>
<dd><a href="active_support_core_extensions.html">Active Support Core Extensions</a></dd>
<dd><a href="i18n.html">Rails Internationalization API</a></dd>
<dd><a href="action_mailer_basics.html">Action Mailer Basics</a></dd>
<dd><a href="testing.html">Testing Rails Applications</a></dd>
<dd><a href="security.html">Securing Rails Applications</a></dd>
<dd><a href="debugging_rails_applications.html">Debugging Rails Applications</a></dd>
<dd><a href="performance_testing.html">Performance Testing Rails Applications</a></dd>
<dd><a href="configuring.html">Configuring Rails Applications</a></dd>
<dd><a href="command_line.html">Rails Command Line Tools and Rake Tasks</a></dd>
<dd><a href="caching_with_rails.html">Caching with Rails</a></dd>
<dd><a href="asset_pipeline.html">Asset Pipeline</a></dd>
<dt>Extending Rails</dt>
<dd><a href="plugins.html">The Basics of Creating Rails Plugins</a></dd>
<dd><a href="rails_on_rack.html">Rails on Rack</a></dd>
<dd><a href="generators.html">Creating and Customizing Rails Generators</a></dd>
<dt>Contributing to Ruby on Rails</dt>
<dd><a href="contributing_to_ruby_on_rails.html">Contributing to Ruby on Rails</a></dd>
<dd><a href="api_documentation_guidelines.html">API Documentation Guidelines</a></dd>
<dd><a href="ruby_on_rails_guides_guidelines.html">Ruby on Rails Guides Guidelines</a></dd>
<dt>Release Notes</dt>
<dd><a href="3_1_release_notes.html">Ruby on Rails 3.1 Release Notes</a></dd>
<dd><a href="3_0_release_notes.html">Ruby on Rails 3.0 Release Notes</a></dd>
<dd><a href="2_3_release_notes.html">Ruby on Rails 2.3 Release Notes</a></dd>
<dd><a href="2_2_release_notes.html">Ruby on Rails 2.2 Release Notes</a></dd>
</dl>
</div> </div>
</li> </li>
<li><a href="contributing_to_ruby_on_rails.html">Contribute</a></li> <li><a href="contributing_to_ruby_on_rails.html">Contribute</a></li>