From 55e6accb9cbb2129b66a578edcb472415751ce1f Mon Sep 17 00:00:00 2001 From: Faizaan Gagan Date: Mon, 12 Oct 2020 20:31:33 +0530 Subject: [PATCH] FEATURE: Markdown support for product description (#21) --- .../discourse_subscriptions/products_controller.rb | 2 +- .../discourse/templates/components/product-list.hbs | 2 +- assets/javascripts/discourse/templates/s/show.hbs | 2 +- spec/requests/products_controller_spec.rb | 6 +++--- 4 files changed, 6 insertions(+), 6 deletions(-) diff --git a/app/controllers/discourse_subscriptions/products_controller.rb b/app/controllers/discourse_subscriptions/products_controller.rb index 930a3cc..1032ba2 100644 --- a/app/controllers/discourse_subscriptions/products_controller.rb +++ b/app/controllers/discourse_subscriptions/products_controller.rb @@ -46,7 +46,7 @@ module DiscourseSubscriptions { id: product[:id], name: product[:name], - description: product[:metadata][:description], + description: PrettyText.cook(product[:metadata][:description]), subscribed: current_user_products.include?(product[:id]) } end diff --git a/assets/javascripts/discourse/templates/components/product-list.hbs b/assets/javascripts/discourse/templates/components/product-list.hbs index 0734a78..1102445 100644 --- a/assets/javascripts/discourse/templates/components/product-list.hbs +++ b/assets/javascripts/discourse/templates/components/product-list.hbs @@ -6,7 +6,7 @@

{{product.name}}

- {{product.description}} + {{html-safe product.description}}

{{#if isLoggedIn}} diff --git a/assets/javascripts/discourse/templates/s/show.hbs b/assets/javascripts/discourse/templates/s/show.hbs index fa214ed..17ddaa8 100644 --- a/assets/javascripts/discourse/templates/s/show.hbs +++ b/assets/javascripts/discourse/templates/s/show.hbs @@ -8,7 +8,7 @@

- {{model.product.description}} + {{html-safe model.product.description}}

diff --git a/spec/requests/products_controller_spec.rb b/spec/requests/products_controller_spec.rb index be290f0..5921843 100644 --- a/spec/requests/products_controller_spec.rb +++ b/spec/requests/products_controller_spec.rb @@ -32,7 +32,7 @@ module DiscourseSubscriptions expect(response.parsed_body).to eq([{ "id" => "prodct_23456", "name" => "Very Special Product", - "description" => "Many people listened to my phone call with the Ukrainian President while it was being made", + "description" => PrettyText.cook("Many people listened to my phone call with the Ukrainian President while it was being made"), "subscribed" => false }]) end @@ -54,7 +54,7 @@ module DiscourseSubscriptions expect(response.parsed_body).to eq([{ "id" => "prodct_23456", "name" => "Very Special Product", - "description" => "Many people listened to my phone call with the Ukrainian President while it was being made", + "description" => PrettyText.cook("Many people listened to my phone call with the Ukrainian President while it was being made"), "subscribed" => false }]) end @@ -86,7 +86,7 @@ module DiscourseSubscriptions expect(response.parsed_body).to eq( "id" => "prodct_23456", "name" => "Very Special Product", - "description" => "Many people listened to my phone call with the Ukrainian President while it was being made", + "description" => PrettyText.cook("Many people listened to my phone call with the Ukrainian President while it was being made"), "subscribed" => false ) end