summaryrefslogtreecommitdiff
path: root/app/controllers/projects/wikis_controller.rb
diff options
context:
space:
mode:
authorGabriel Mazetto <gabriel@gitlab.com>2016-03-30 15:04:58 -0300
committerGabriel Mazetto <gabriel@gitlab.com>2016-03-30 15:04:58 -0300
commitb69f8a62b2078fbd43413c670dea76871b74d0d5 (patch)
tree1f0888698071a83b6ed83c0909d1f19f3cf0fcb1 /app/controllers/projects/wikis_controller.rb
parent4a01b5e293ccb358d77ac1a25b92d14fd913a4d7 (diff)
downloadgitlab-ce-b69f8a62b2078fbd43413c670dea76871b74d0d5.tar.gz
Add specific markdown_preview route for Wikis
Diffstat (limited to 'app/controllers/projects/wikis_controller.rb')
-rw-r--r--app/controllers/projects/wikis_controller.rb14
1 files changed, 14 insertions, 0 deletions
diff --git a/app/controllers/projects/wikis_controller.rb b/app/controllers/projects/wikis_controller.rb
index 02ceb8f4334..9f3a4a69721 100644
--- a/app/controllers/projects/wikis_controller.rb
+++ b/app/controllers/projects/wikis_controller.rb
@@ -88,6 +88,20 @@ class Projects::WikisController < Projects::ApplicationController
)
end
+ def markdown_preview
+ text = params[:text]
+
+ ext = Gitlab::ReferenceExtractor.new(@project, current_user, current_user)
+ ext.analyze(text)
+
+ render json: {
+ body: view_context.markdown(text, pipeline: :wiki, project_wiki: @project_wiki),
+ references: {
+ users: ext.users.map(&:username)
+ }
+ }
+ end
+
def git_access
end