From 60ebd101d0fa3ddbfab86a676b81efba589f8393 Mon Sep 17 00:00:00 2001 From: Douwe Maan Date: Thu, 13 Apr 2017 11:47:28 -0500 Subject: Use blob viewers for snippets --- app/controllers/snippets_controller.rb | 13 +++++++++++++ 1 file changed, 13 insertions(+) (limited to 'app/controllers/snippets_controller.rb') diff --git a/app/controllers/snippets_controller.rb b/app/controllers/snippets_controller.rb index 056910fad67..906833505d1 100644 --- a/app/controllers/snippets_controller.rb +++ b/app/controllers/snippets_controller.rb @@ -3,6 +3,7 @@ class SnippetsController < ApplicationController include SpammableActions include SnippetsActions include MarkdownPreview + include RendersBlob before_action :snippet, only: [:show, :edit, :destroy, :update, :raw, :download] @@ -60,6 +61,18 @@ class SnippetsController < ApplicationController end def show + blob = @snippet.blob + override_max_blob_size(blob) + + respond_to do |format| + format.html do + render 'show' + end + + format.json do + render_blob_json(blob) + end + end end def destroy -- cgit v1.2.1 From 2b3fc5e624bd0c8b9e1c68bf2b3741d8898cf0b0 Mon Sep 17 00:00:00 2001 From: Douwe Maan Date: Sun, 30 Apr 2017 12:15:20 -0500 Subject: Add download button to project snippets --- app/controllers/snippets_controller.rb | 14 +++----------- 1 file changed, 3 insertions(+), 11 deletions(-) (limited to 'app/controllers/snippets_controller.rb') diff --git a/app/controllers/snippets_controller.rb b/app/controllers/snippets_controller.rb index 906833505d1..7fbfa6c2ee4 100644 --- a/app/controllers/snippets_controller.rb +++ b/app/controllers/snippets_controller.rb @@ -5,10 +5,10 @@ class SnippetsController < ApplicationController include MarkdownPreview include RendersBlob - before_action :snippet, only: [:show, :edit, :destroy, :update, :raw, :download] + before_action :snippet, only: [:show, :edit, :destroy, :update, :raw] # Allow read snippet - before_action :authorize_read_snippet!, only: [:show, :raw, :download] + before_action :authorize_read_snippet!, only: [:show, :raw] # Allow modify snippet before_action :authorize_update_snippet!, only: [:edit, :update] @@ -16,7 +16,7 @@ class SnippetsController < ApplicationController # Allow destroy snippet before_action :authorize_admin_snippet!, only: [:destroy] - skip_before_action :authenticate_user!, only: [:index, :show, :raw, :download] + skip_before_action :authenticate_user!, only: [:index, :show, :raw] layout 'snippets' respond_to :html @@ -83,14 +83,6 @@ class SnippetsController < ApplicationController redirect_to snippets_path end - def download - send_data( - convert_line_endings(@snippet.content), - type: 'text/plain; charset=utf-8', - filename: @snippet.sanitized_file_name - ) - end - def preview_markdown render_markdown_preview(params[:text], skip_project_check: true) end -- cgit v1.2.1 From 8c3a03c1b9bf5c80571c9dc07ba258fa10dd61c8 Mon Sep 17 00:00:00 2001 From: Jarka Kadlecova Date: Thu, 27 Apr 2017 12:41:26 +0200 Subject: Display comments for personal snippets --- app/controllers/snippets_controller.rb | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'app/controllers/snippets_controller.rb') diff --git a/app/controllers/snippets_controller.rb b/app/controllers/snippets_controller.rb index 906833505d1..e338db8353b 100644 --- a/app/controllers/snippets_controller.rb +++ b/app/controllers/snippets_controller.rb @@ -1,4 +1,5 @@ class SnippetsController < ApplicationController + include RendersNotes include ToggleAwardEmoji include SpammableActions include SnippetsActions @@ -64,6 +65,11 @@ class SnippetsController < ApplicationController blob = @snippet.blob override_max_blob_size(blob) + @noteable = @snippet + + @discussions = @snippet.discussions + @notes = prepare_notes_for_rendering(@discussions.flat_map(&:notes)) + respond_to do |format| format.html do render 'show' -- cgit v1.2.1