From e6c853e642170f1c4ee20cd3190bf20ee7be5f7d Mon Sep 17 00:00:00 2001 From: Arpit Jalan Date: Wed, 17 Sep 2014 00:57:43 +0530 Subject: [PATCH] show parent and child category in oneboxes --- lib/onebox/engine/discourse_local_onebox.rb | 6 ++++++ lib/onebox/templates/discourse_topic_onebox.handlebars | 2 +- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/lib/onebox/engine/discourse_local_onebox.rb b/lib/onebox/engine/discourse_local_onebox.rb index c1976de6091..6c4bda5fc57 100644 --- a/lib/onebox/engine/discourse_local_onebox.rb +++ b/lib/onebox/engine/discourse_local_onebox.rb @@ -58,9 +58,14 @@ module Onebox end category_name = '' + parent_category_name = '' category = topic.category if category && !category.uncategorized? category_name = "#{category.name}" + if !category.parent_category_id.nil? + parent_category = Category.find_by(id: category.parent_category_id) + parent_category_name = "#{parent_category.name}" + end end quote = post.excerpt(SiteSetting.post_onebox_maxlength) @@ -73,6 +78,7 @@ module Onebox posters: posters, quote: quote, category_name: category_name, + parent_category_name: parent_category_name, topic: topic.id @template = 'topic' diff --git a/lib/onebox/templates/discourse_topic_onebox.handlebars b/lib/onebox/templates/discourse_topic_onebox.handlebars index df209a0d798..2446ec6a9a2 100644 --- a/lib/onebox/templates/discourse_topic_onebox.handlebars +++ b/lib/onebox/templates/discourse_topic_onebox.handlebars @@ -2,7 +2,7 @@
{{{avatar}}} - {{title}} {{{category_name}}} + {{title}} {{{parent_category_name}}} {{{category_name}}}
{{{quote}}}