mirror of
https://github.com/discourse/discourse.git
synced 2025-03-21 22:36:43 +08:00
FIX: use schema.org's BreadcrumList
The data-vocabulary.org schema is being deprecated. We're now using the BreadcrumList data from the latest and greatest schema.org. FIX: categories_breadcrumb helper to support more than 2 levels of categories.
This commit is contained in:
parent
89bd7ba45f
commit
96b64df4d4
@ -9,13 +9,13 @@ module TopicsHelper
|
||||
|
||||
def categories_breadcrumb(topic)
|
||||
breadcrumb = []
|
||||
|
||||
category = topic.category
|
||||
|
||||
if category && !category.uncategorized?
|
||||
if (parent = category.parent_category)
|
||||
breadcrumb.push url: parent.url, name: parent.name
|
||||
breadcrumb.push(url: category.url, name: category.name)
|
||||
while category = category.parent_category
|
||||
breadcrumb.prepend(url: category.url, name: category.name)
|
||||
end
|
||||
breadcrumb.push url: category.url, name: category.name
|
||||
end
|
||||
|
||||
Plugin::Filter.apply(:topic_categories_breadcrumb, topic, breadcrumb)
|
||||
|
@ -3,18 +3,16 @@
|
||||
<%= render_topic_title(@topic_view.topic) %>
|
||||
</h1>
|
||||
|
||||
<% @breadcrumbs = categories_breadcrumb(@topic_view.topic)
|
||||
if @breadcrumbs.present? %>
|
||||
<div id='breadcrumbs'>
|
||||
<% @breadcrumbs.each_with_index do |c,i| %>
|
||||
<div id="breadcrumb-<%=i%>" itemscope itemtype="http://data-vocabulary.org/Breadcrumb"
|
||||
<%-if (i+1) < @breadcrumbs.length%>
|
||||
itemref="breadcrumb-<%=(i+1)%>"
|
||||
<%-end%>>
|
||||
<a href="<%=c[:url]%>" itemprop="url" class='badge-wrapper bullet'>
|
||||
<% @breadcrumbs = categories_breadcrumb(@topic_view.topic) %>
|
||||
<% if @breadcrumbs.present? %>
|
||||
<div id="breadcrumbs" itemscope itemtype="http://schema.org/BreadcrumbList">
|
||||
<% @breadcrumbs.each_with_index do |c, i| %>
|
||||
<div itemprop="itemListElement" itemscope itemtype="http://schema.org/ListItem">
|
||||
<a href="<%= Discourse.base_url %><%= c[:url] %>" class="badge-wrapper bullet" itemprop="item">
|
||||
<span class="badge-category-bg"></span>
|
||||
<span itemprop="title" class='category-title'><%=c[:name]%></span>
|
||||
<span class="category-title" itemprop="name"><%= c[:name] %></span>
|
||||
</a>
|
||||
<meta itemprop="position" content="<%= i + 1 %>" />
|
||||
</div>
|
||||
<% end %>
|
||||
</div>
|
||||
@ -26,7 +24,7 @@
|
||||
<div class='crawler-tags-list' itemscope itemtype='http://schema.org/DiscussionForumPosting'>
|
||||
<% @tags.each_with_index do |tag, i| %>
|
||||
<div itemprop='keywords'>
|
||||
<a href='<%= "#{Discourse.base_url}/tag/#{tag.name}" %>' rel="tag">
|
||||
<a href='<%= "#{Discourse.base_url}/tag/#{tag.name}" %>' rel="tag">
|
||||
<span itemprop='headline'><%= tag.name -%></span>
|
||||
</a>
|
||||
</div>
|
||||
@ -44,7 +42,7 @@
|
||||
<% if (u = post.user) %>
|
||||
<div class='crawler-post-meta'>
|
||||
<span class="creator" itemprop="author" itemscope itemtype="http://schema.org/Person">
|
||||
<a itemprop="url" href='<%= Discourse.base_uri %>/u/<%= u.username %>'><span itemprop='name'><%= u.username %></span></a>
|
||||
<a itemprop="url" href='<%= Discourse.base_url %>/u/<%= u.username %>'><span itemprop='name'><%= u.username %></span></a>
|
||||
<%= "(#{u.name})" if (SiteSetting.display_name_on_posts && SiteSetting.enable_names? && !u.name.blank?) %>
|
||||
<%
|
||||
post_custom_fields = @topic_view.post_custom_fields[post.id] || {}
|
||||
|
Loading…
x
Reference in New Issue
Block a user