diff options
author | Filipa Lacerda <filipa@gitlab.com> | 2017-02-23 11:48:53 +0000 |
---|---|---|
committer | Filipa Lacerda <filipa@gitlab.com> | 2017-02-23 11:48:53 +0000 |
commit | 05c66406ca7e7f29b9b210fda9f31a60528917f1 (patch) | |
tree | 18d7f553a61fea3c6a9655be16a4842478990284 /app/controllers/snippets_controller.rb | |
parent | 0f36cfd7f58977becea9d3ecf410d3669440fbe9 (diff) | |
parent | f106ad513546c8d77b88a0a061a0b6a7e7ee26ed (diff) | |
download | gitlab-ce-26900-pipelines-tabs.tar.gz |
Merge branch 'master' into 26900-pipelines-tabs26900-pipelines-tabs
* master: (361 commits)
Code style improvements
remove require.context from network_bundle
remove require.context from graphs_bundle
remove require.context from filtered_search_bundle
Ignore two Rails CVEs in bundler:audit job
Remove Pages readme
Change Pages redirect
Add missing index.md to Pages docs
Added double newline after file upload markdown insert
Reorder main index items in Pages overview
remove html comments
remove <>
wrapping text - part 3
wrapping text - part 2 [ci skip]
fix link
wrap text - part 1 - [ci skip]
typo
fix spelling, add intermediate cert link
Improve `Gitlab::EeCompatCheck` by using the `git apply --3way` flag
remove link to unfinished video
...
Diffstat (limited to 'app/controllers/snippets_controller.rb')
-rw-r--r-- | app/controllers/snippets_controller.rb | 30 |
1 files changed, 11 insertions, 19 deletions
diff --git a/app/controllers/snippets_controller.rb b/app/controllers/snippets_controller.rb index b169d993688..2d26718873f 100644 --- a/app/controllers/snippets_controller.rb +++ b/app/controllers/snippets_controller.rb @@ -1,6 +1,7 @@ class SnippetsController < ApplicationController include ToggleAwardEmoji include SpammableActions + include SnippetsActions before_action :snippet, only: [:show, :edit, :destroy, :update, :raw, :download] @@ -22,7 +23,7 @@ class SnippetsController < ApplicationController if params[:username].present? @user = User.find_by(username: params[:username]) - render_404 and return unless @user + return render_404 unless @user @snippets = SnippetsFinder.new.execute(current_user, { filter: :by_user, @@ -41,19 +42,19 @@ class SnippetsController < ApplicationController end def create - create_params = snippet_params.merge(request: request) - @snippet = CreateSnippetService.new(nil, current_user, create_params).execute + create_params = snippet_params.merge(spammable_params) - respond_with @snippet.becomes(Snippet) - end + @snippet = CreateSnippetService.new(nil, current_user, create_params).execute - def edit + recaptcha_check_with_fallback { render :new } end def update - UpdateSnippetService.new(nil, current_user, @snippet, - snippet_params).execute - respond_with @snippet.becomes(Snippet) + update_params = snippet_params.merge(spammable_params) + + UpdateSnippetService.new(nil, current_user, @snippet, update_params).execute + + recaptcha_check_with_fallback { render :edit } end def show @@ -67,18 +68,9 @@ class SnippetsController < ApplicationController redirect_to snippets_path end - def raw - send_data( - @snippet.content, - type: 'text/plain; charset=utf-8', - disposition: 'inline', - filename: @snippet.sanitized_file_name - ) - end - def download send_data( - @snippet.content, + convert_line_endings(@snippet.content), type: 'text/plain; charset=utf-8', filename: @snippet.sanitized_file_name ) |