From 96b64df4d46627fbcaf3c40612750405ca058333 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?R=C3=A9gis=20Hanol?= Date: Tue, 21 Jan 2020 22:27:21 +0100 Subject: [PATCH] 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. --- app/helpers/topics_helper.rb | 8 ++++---- app/views/topics/show.html.erb | 22 ++++++++++------------ 2 files changed, 14 insertions(+), 16 deletions(-) diff --git a/app/helpers/topics_helper.rb b/app/helpers/topics_helper.rb index 48306aee5bb..4f4a56b6e7c 100644 --- a/app/helpers/topics_helper.rb +++ b/app/helpers/topics_helper.rb @@ -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) diff --git a/app/views/topics/show.html.erb b/app/views/topics/show.html.erb index 5315bddaf67..c5187769bef 100644 --- a/app/views/topics/show.html.erb +++ b/app/views/topics/show.html.erb @@ -3,18 +3,16 @@ <%= render_topic_title(@topic_view.topic) %> - <% @breadcrumbs = categories_breadcrumb(@topic_view.topic) - if @breadcrumbs.present? %> -