mirror of
https://github.com/discourse/discourse.git
synced 2025-03-28 15:25:36 +08:00
FEATURE: show tags in crawler view of tags page for static site
Previously tags page would have an empty page in crawler view
This commit is contained in:
parent
c3a38d2304
commit
b510006ca8
@ -27,13 +27,6 @@ class TagsController < ::ApplicationController
|
||||
@description_meta = I18n.t("tags.title")
|
||||
@title = @description_meta
|
||||
|
||||
respond_to do |format|
|
||||
|
||||
format.html do
|
||||
render :index
|
||||
end
|
||||
|
||||
format.json do
|
||||
show_all_tags = guardian.can_admin_tags? && guardian.is_admin?
|
||||
|
||||
if SiteSetting.tags_listed_by_group
|
||||
@ -44,10 +37,8 @@ class TagsController < ::ApplicationController
|
||||
{ id: tag_group.id, name: tag_group.name, tags: self.class.tag_counts_json(tag_group.tags) }
|
||||
end
|
||||
|
||||
render json: {
|
||||
tags: self.class.tag_counts_json(ungrouped_tags),
|
||||
extras: { tag_groups: grouped_tag_counts }
|
||||
}
|
||||
@tags = self.class.tag_counts_json(ungrouped_tags)
|
||||
@extras = { tag_groups: grouped_tag_counts }
|
||||
else
|
||||
tags = show_all_tags ? Tag.all : Tag.where("tags.topic_count > 0")
|
||||
unrestricted_tags = DiscourseTagging.filter_visible(tags, guardian)
|
||||
@ -60,11 +51,21 @@ class TagsController < ::ApplicationController
|
||||
{ id: c.id, tags: self.class.tag_counts_json(c.tags) }
|
||||
end
|
||||
|
||||
render json: {
|
||||
tags: self.class.tag_counts_json(unrestricted_tags),
|
||||
extras: { categories: category_tag_counts }
|
||||
}
|
||||
@tags = self.class.tag_counts_json(unrestricted_tags)
|
||||
@extras = { categories: category_tag_counts }
|
||||
end
|
||||
|
||||
respond_to do |format|
|
||||
|
||||
format.html do
|
||||
render :index
|
||||
end
|
||||
|
||||
format.json do
|
||||
render json: {
|
||||
tags: @tags,
|
||||
extras: @extras
|
||||
}
|
||||
end
|
||||
end
|
||||
end
|
||||
|
6
app/views/tags/_tag.html.erb
Normal file
6
app/views/tags/_tag.html.erb
Normal file
@ -0,0 +1,6 @@
|
||||
<div class="tag-box">
|
||||
<a href="<%= Discourse.base_url %>/tags/<%= tag[:id] %>" class="discourse-tag simple"><%= tag[:text] %></a>
|
||||
<% if tag[:count] && tag[:count] > 0 %>
|
||||
<span class="tag-count">x <%= tag[:count] %></span>
|
||||
<% end %>
|
||||
</div>
|
@ -1,3 +1,45 @@
|
||||
<% content_for :head do %>
|
||||
<%= raw crawlable_meta_data(title: @title, description: @description_meta) %>
|
||||
<% end %>
|
||||
|
||||
<div class="tag-crawler">
|
||||
|
||||
<% if @extras[:categories] %>
|
||||
<% @extras[:categories].each do |category| %>
|
||||
<div class="tag-list">
|
||||
<% if category[:name] %>
|
||||
<h3><%= category[:name] %></h3>
|
||||
<% end %>
|
||||
<% category[:tags].each do |tag| %>
|
||||
<%= render "tag", tag: tag %>
|
||||
<% end %>
|
||||
</div>
|
||||
<div class="clearfix"></div>
|
||||
<% end %>
|
||||
<% end %>
|
||||
|
||||
<% if @extras[:tag_groups] %>
|
||||
<% @extras[:tag_groups].each do |tag_group| %>
|
||||
<div class="tag-list">
|
||||
<% if tag_group[:name] %>
|
||||
<h3><%= tag_group[:name] %></h3>
|
||||
<% end %>
|
||||
<% tag_group[:tags].each do |tag| %>
|
||||
<%= render "tag", tag: tag %>
|
||||
<% end %>
|
||||
</div>
|
||||
<div class="clearfix"></div>
|
||||
<% end %>
|
||||
<% end %>
|
||||
|
||||
<% if @tags.present? %>
|
||||
<div class="tag-list">
|
||||
<h3><%= t 'js.tagging.other_tags' %></h3>
|
||||
<% @tags.each do |tag| %>
|
||||
<%= render "tag", tag: tag %>
|
||||
<% end %>
|
||||
</div>
|
||||
<div class="clearfix"></div>
|
||||
<% end %>
|
||||
|
||||
</div>
|
||||
|
Loading…
x
Reference in New Issue
Block a user