Skip to content

Commit

Permalink
Add show method to news controller.
Browse files Browse the repository at this point in the history
  • Loading branch information
seven1m committed May 13, 2009
1 parent b62d2b9 commit 6d9399d
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 8 deletions.
24 changes: 21 additions & 3 deletions app/controllers/news_controller.rb
Expand Up @@ -5,8 +5,8 @@ def index
respond_to do |format|
format.html do
unless Setting.get(:features, :news_page)
if news_url = Setting.get(:url, :news)
redirect_to news_url
if the_url = Setting.get(:url, :news)
redirect_to the_url
else
render :text => 'This feature is currently unavailable.'
end
Expand All @@ -25,6 +25,24 @@ def index
end
end

def show
if Setting.get(:features, :news_page)
respond_to do |format|
format.html
end
else
respond_to do |format|
format.html do
if the_url = Setting.get(:url, :news)
redirect_to the_url
else
render :text => 'This feature is currently unavailable.'
end
end
end
end
end

def new
if @logged_in.admin?(:manage_news) or Setting.get(:features, :news_by_users)
@news_item = NewsItem.new
Expand Down Expand Up @@ -91,4 +109,4 @@ def create
render :action => 'new'
end
end
end
end
8 changes: 4 additions & 4 deletions app/views/news/index.html.erb
Expand Up @@ -4,16 +4,16 @@
<% end %>
<% end %>

<h2>News</h2>
<h1>News</h1>

<% @news_items.each do |news_item| %>
<div class="news-item">
<h3>
<h2>
<%=h news_item.title %>
<% if @logged_in.can_edit?(news_item) %>
<%= link_to 'edit', edit_news_item_path(news_item), :class => 'discreet' %>
<% end %>
</h3>
</h2>
<p>
<%= white_list_with_removal news_item.body %>
</p>
Expand All @@ -22,4 +22,4 @@
<% unless @news_items.any? %>
<p><em>No news is available at this time.</em></p>
<% end %>
<% end %>
2 changes: 1 addition & 1 deletion app/views/shares/_subnav.erb
Expand Up @@ -4,6 +4,6 @@
<% if Setting.get(:features, :verses) %><%= link_to 'Verses', verses_path %><% end %>
<% if Setting.get(:features, :recipes) %><%= link_to 'Recipes', recipes_path %><% end %>
<% if Setting.get(:url, :news) or Setting.get(:features, :news_page) %>
<%= link_to 'News', Setting.get(:url, :news) %>
<%= link_to 'News', news_path %>
<% end %>
<% end %>

0 comments on commit 6d9399d

Please sign in to comment.