From 28ac5fb17c81a8b1cb2d685738f13e76c024bf85 Mon Sep 17 00:00:00 2001 From: Guo Xiang Tan Date: Fri, 29 Jan 2016 22:59:15 +0800 Subject: [PATCH] FEATURE: DiscourseEvent hook for server side markdown context. --- lib/pretty_text.rb | 3 +-- spec/components/post_creator_spec.rb | 1 + 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/pretty_text.rb b/lib/pretty_text.rb index 22abb167342..eb9f079d779 100644 --- a/lib/pretty_text.rb +++ b/lib/pretty_text.rb @@ -218,8 +218,7 @@ module PrettyText context.eval('opts["categoryHashtagLookup"] = function(c){return helpers.category_hashtag_lookup(c);}') context.eval('opts["lookupAvatar"] = function(p){return Discourse.Utilities.avatarImg({size: "tiny", avatarTemplate: helpers.avatar_template(p)});}') context.eval('opts["getTopicInfo"] = function(i){return helpers.get_topic_info(i)};') - # TODO: @tgxworld this broke the build - # DiscourseEvent.trigger(:markdown_context, context) + DiscourseEvent.trigger(:markdown_context, context) baked = context.eval('Discourse.Markdown.markdownConverter(opts).makeHtml(raw)') end diff --git a/spec/components/post_creator_spec.rb b/spec/components/post_creator_spec.rb index 01006058e1b..b0bd19c9022 100644 --- a/spec/components/post_creator_spec.rb +++ b/spec/components/post_creator_spec.rb @@ -78,6 +78,7 @@ describe PostCreator do DiscourseEvent.expects(:trigger).with(:after_validate_topic, anything, anything).once DiscourseEvent.expects(:trigger).with(:before_create_topic, anything, anything).once DiscourseEvent.expects(:trigger).with(:after_trigger_post_process, anything).once + DiscourseEvent.expects(:trigger).with(:markdown_context, anything).at_least_once creator.create end