Show something on categories page when js is disabled

This commit is contained in:
Neil Lalonde 2013-04-26 13:10:41 -04:00
parent b82e408351
commit 6063f81946
2 changed files with 18 additions and 2 deletions

View file

@ -4,11 +4,15 @@ class CategoriesController < ApplicationController
before_filter :ensure_logged_in, except: [:index, :show]
before_filter :fetch_category, only: [:show, :update, :destroy]
skip_before_filter :check_xhr, only: [:index]
def index
list = CategoryList.new(current_user)
@list = CategoryList.new(current_user)
discourse_expires_in 1.minute
render_serialized(list, CategoryListSerializer)
respond_to do |format|
format.html { render }
format.json { render_serialized(@list, CategoryListSerializer) }
end
end
def show

View file

@ -0,0 +1,12 @@
<% @list.categories.each do |c| %>
<div class="category">
<h2><a href="/category/<%= c.slug.blank? ? c.id : c.slug %>"><%= c.name %></a></h2>
<div class="topic-list">
<% c.topics.limit(6).each do |t| %>
<a href="<%= t.relative_url %>"><%= t.title %></a> <span title='<%= t 'posts' %>'>(<%= t.posts_count %>)</span><br/>
<% end %>
</div>
</div>
<% end %>
<p><%= t 'powered_by_html' %></p>