From c1aded8b643e404c4a0b07579f68a37007e32daf Mon Sep 17 00:00:00 2001 From: Neil Lalonde Date: Tue, 3 May 2016 15:51:50 -0400 Subject: [PATCH] FIX: crawler view of tags index page --- app/controllers/tags_controller.rb | 14 +++++++++++--- app/views/tags/index.html.erb | 20 ++++++++++++++++++++ config/locales/server.en.yml | 1 + 3 files changed, 32 insertions(+), 3 deletions(-) create mode 100644 app/views/tags/index.html.erb diff --git a/app/controllers/tags_controller.rb b/app/controllers/tags_controller.rb index 0aecc1be9ef..6b25d361de8 100644 --- a/app/controllers/tags_controller.rb +++ b/app/controllers/tags_controller.rb @@ -7,14 +7,22 @@ class TagsController < ::ApplicationController before_filter :ensure_tags_enabled - skip_before_filter :check_xhr, only: [:tag_feed, :show] + skip_before_filter :check_xhr, only: [:tag_feed, :show, :index] before_filter :ensure_logged_in, only: [:notifications, :update_notifications, :update] before_filter :set_category_from_params, except: [:index, :update, :destroy, :tag_feed, :search, :notifications, :update_notifications] def index tag_counts = self.class.tags_by_count(guardian, limit: 300).count - tags = tag_counts.map {|t, c| { id: t, text: t, count: c } } - render json: { tags: tags } + @tags = tag_counts.map {|t, c| { id: t, text: t, count: c } } + + respond_to do |format| + format.html do + render :index + end + format.json do + render json: { tags: @tags } + end + end end Discourse.filters.each do |filter| diff --git a/app/views/tags/index.html.erb b/app/views/tags/index.html.erb new file mode 100644 index 00000000000..0ffd169cb51 --- /dev/null +++ b/app/views/tags/index.html.erb @@ -0,0 +1,20 @@ +<% if crawler_layout? %> + +<% content_for :title do %><%=t "tags.title" %><% end %> + +

<%=t "tags.title" %>

+ +
+ <% @tags.each do |tag| %> +
+ + + + <%= tag[:text] %> + + +
+ <% end %> +
+ +<% end %> diff --git a/config/locales/server.en.yml b/config/locales/server.en.yml index 2c054c63566..a054bc51635 100644 --- a/config/locales/server.en.yml +++ b/config/locales/server.en.yml @@ -3025,6 +3025,7 @@ en: user_exists: "Sorry, that user has already been invited. You may only invite a user to a topic once." tags: + title: "Tags" staff_tag_disallowed: "The tag \"%{tag}\" may only be applied by staff." staff_tag_remove_disallowed: "The tag \"%{tag}\" may only be removed by staff." rss_by_tag: "Topics tagged %{tag}"