summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorToon Claes <toon@gitlab.com>2018-10-10 09:32:17 +0200
committerToon Claes <toon@gitlab.com>2019-06-04 15:36:28 +0200
commitedd0f49f4e6425cc7c33ffc54e3aab1b766742bc (patch)
treedee3dac831defffbe18986a810d5ac90dd4c624a
parent8d370eabc2f2d1e40bd58f7289009a0c0aeb05e3 (diff)
downloadgitlab-ce-tc-org-mode-wiki.tar.gz
WIP attempt to build an org previewertc-org-mode-wiki
-rw-r--r--app/controllers/concerns/preview_orgmode.rb26
-rw-r--r--app/controllers/projects/wikis_controller.rb1
2 files changed, 27 insertions, 0 deletions
diff --git a/app/controllers/concerns/preview_orgmode.rb b/app/controllers/concerns/preview_orgmode.rb
new file mode 100644
index 00000000000..de7c22cf941
--- /dev/null
+++ b/app/controllers/concerns/preview_orgmode.rb
@@ -0,0 +1,26 @@
+# frozen_string_literal: true
+
+module PreviewOrgmode
+ extend ActiveSupport::Concern
+
+ def preview_orgmode
+ context = {
+ current_user: (current_user if defined?(current_user)),
+
+ # RelativeLinkFilter
+ project: project,
+ commit: @commit,
+ project_wiki: @project_wiki,
+ ref: @ref,
+ requested_path: @path
+ }
+
+ html = Gitlab::OtherMarkup.render('preview.org', params[:text], context)
+ html = Banzai.post_process(html, context)
+ html = Hamlit::RailsHelpers.preserve(html)
+
+ render json: {
+ body: html
+ }
+ end
+end
diff --git a/app/controllers/projects/wikis_controller.rb b/app/controllers/projects/wikis_controller.rb
index fa5bdbc7d49..2007bf6d175 100644
--- a/app/controllers/projects/wikis_controller.rb
+++ b/app/controllers/projects/wikis_controller.rb
@@ -2,6 +2,7 @@
class Projects::WikisController < Projects::ApplicationController
include PreviewMarkdown
+ include PreviewOrgmode
include SendsBlob
include Gitlab::Utils::StrongMemoize