diff --git a/app/assets/javascripts/discourse/routes/full-page-search.js.es6 b/app/assets/javascripts/discourse/routes/full-page-search.js.es6 index 3cda47e9a..dc895f430 100644 --- a/app/assets/javascripts/discourse/routes/full-page-search.js.es6 +++ b/app/assets/javascripts/discourse/routes/full-page-search.js.es6 @@ -1,4 +1,5 @@ import { translateResults, getSearchKey, isValidSearchTerm } from "discourse/lib/search"; +import Composer from 'discourse/models/composer'; export default Discourse.Route.extend({ queryParams: { q: {}, context_id: {}, context: {}, skip_context: {} }, @@ -39,6 +40,17 @@ export default Discourse.Route.extend({ didTransition() { this.controllerFor("full-page-search")._showFooter(); return true; + }, + + createTopic(searchTerm) { + let category; + if (searchTerm.indexOf("category:")) { + const match = searchTerm.match(/category:(\S*)/); + if (match && match[1]) { + category = match[1]; + } + } + this.container.lookup('controller:composer').open({action: Composer.CREATE_TOPIC, draftKey: Composer.CREATE_TOPIC, topicCategory: category}); } } diff --git a/app/assets/javascripts/discourse/templates/full-page-search.hbs b/app/assets/javascripts/discourse/templates/full-page-search.hbs index 344c28985..e216f7ab3 100644 --- a/app/assets/javascripts/discourse/templates/full-page-search.hbs +++ b/app/assets/javascripts/discourse/templates/full-page-search.hbs @@ -1,6 +1,11 @@