diff options
author | haseeb <haseebeqx@yahoo.com> | 2018-02-06 19:03:18 +0530 |
---|---|---|
committer | haseeb <haseebeqx@yahoo.com> | 2018-02-28 18:48:26 +0530 |
commit | 27e8d38cea92d165a2e8400b25df23f408b4dca0 (patch) | |
tree | 0a16f63c8f380c92fb4185ca21ba8a264c572641 /app/controllers | |
parent | 56af0631c6c6d838301ac068f2e79b8f4de9fda7 (diff) | |
download | gitlab-ce-27e8d38cea92d165a2e8400b25df23f408b4dca0.tar.gz |
embedded snippets support
Diffstat (limited to 'app/controllers')
-rw-r--r-- | app/controllers/concerns/snippets_actions.rb | 4 | ||||
-rw-r--r-- | app/controllers/projects/snippets_controller.rb | 3 | ||||
-rw-r--r-- | app/controllers/snippets_controller.rb | 4 |
3 files changed, 11 insertions, 0 deletions
diff --git a/app/controllers/concerns/snippets_actions.rb b/app/controllers/concerns/snippets_actions.rb index 9095cc7f783..120614739aa 100644 --- a/app/controllers/concerns/snippets_actions.rb +++ b/app/controllers/concerns/snippets_actions.rb @@ -17,6 +17,10 @@ module SnippetsActions end # rubocop:enable Gitlab/ModuleWithInstanceVariables + def js_request? + request.format.js? + end + private def convert_line_endings(content) diff --git a/app/controllers/projects/snippets_controller.rb b/app/controllers/projects/snippets_controller.rb index 7c19aa7bb23..208a1d19862 100644 --- a/app/controllers/projects/snippets_controller.rb +++ b/app/controllers/projects/snippets_controller.rb @@ -5,6 +5,8 @@ class Projects::SnippetsController < Projects::ApplicationController include SnippetsActions include RendersBlob + skip_before_action :verify_authenticity_token, only: [:show], if: :js_request? + before_action :check_snippets_available! before_action :snippet, only: [:show, :edit, :destroy, :update, :raw, :toggle_award_emoji, :mark_as_spam] @@ -71,6 +73,7 @@ class Projects::SnippetsController < Projects::ApplicationController format.json do render_blob_json(blob) end + format.js { render 'shared/snippets/show'} end end diff --git a/app/controllers/snippets_controller.rb b/app/controllers/snippets_controller.rb index be2d3f638ff..3d51520ddf4 100644 --- a/app/controllers/snippets_controller.rb +++ b/app/controllers/snippets_controller.rb @@ -6,6 +6,8 @@ class SnippetsController < ApplicationController include RendersBlob include PreviewMarkdown + skip_before_action :verify_authenticity_token, only: [:show], if: :js_request? + before_action :snippet, only: [:show, :edit, :destroy, :update, :raw] # Allow read snippet @@ -77,6 +79,8 @@ class SnippetsController < ApplicationController format.json do render_blob_json(blob) end + + format.js { render 'shared/snippets/show' } end end |