Extracted categories menu to a helper, and got rid of hrefs

This commit is contained in:
Alexey Verkhovsky 2005-04-07 03:24:02 +00:00
parent 1df5f3f764
commit a74b3f8934
5 changed files with 18 additions and 32 deletions

View file

@ -120,7 +120,7 @@ class WikiController < ApplicationController
@page.unlock
redirect_show
end
def edit
if @page.nil?
redirect_to :action => 'index'
@ -294,13 +294,6 @@ class WikiController < ApplicationController
@pages_in_category = PageSet.new(@web).by_name
@set_name = 'the web'
end
@category_links = @categories.map { |c|
if @category == c
%{<span class="selected">#{c}</span>}
else
%{<a href="?category=#{c}">#{c}</a>}
end
}
end
def parse_rss_params

View file

@ -50,4 +50,19 @@ module ApplicationHelper
web.make_link(page_name, text, options.merge(:base_url => base_url))
end
# Creates a menu of categories
def categories_menu
if @categories.empty?
''
else
"<div id=\"categories\">\n" +
'<strong>Categories</strong>:' +
'[' + link_to_unless_current('Any', :web => @web.address, :action => @action_name) + "]\n" +
@categories.map { |c|
link_to_unless_current(c, :web => @web.address, :action => @action_name, :category => c)
}.join(', ') + "\n" +
'</div>'
end
end
end

View file

@ -1,12 +1,6 @@
<% @title = "All Pages" %>
<% unless @categories.empty? %>
<div id="categories">
<strong>Categories</strong>:
[<a href=".">Any</a>]
<%= @category_links.join(', ') %>
</div>
<% end %>
<%= categories_menu unless @categories.empty? %>
<div id="allPages" style="float: left; width: 280px; margin-right: 30px">
<% unless @pages_that_are_orphaned.empty? && @page_names_that_are_wanted.empty? %>

View file

@ -1,12 +1,6 @@
<% @title = "Recently Revised" %>
<% unless @categories.empty? %>
<div id="categories">
<strong>Categories</strong>:
[<a href=".">Any</a>]
<%= @category_links.join(', ') %>
</div>
<% end %>
<%= categories_menu %>
<% unless @pages_by_revision.empty? %>
<% revision_date = @pages_by_revision.first.revised_on %>