blob: f80e891a55854db2b6ee3a029207ea361f329b7f (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
|
# frozen_string_literal: true
module SnippetsActions
extend ActiveSupport::Concern
def edit
end
def raw
disposition = params[:inline] == 'false' ? 'attachment' : 'inline'
workhorse_set_content_type!
send_data(
convert_line_endings(blob.data),
type: 'text/plain; charset=utf-8',
disposition: disposition,
filename: Snippet.sanitized_file_name(blob.name)
)
end
def js_request?
request.format.js?
end
private
def convert_line_endings(content)
params[:line_ending] == 'raw' ? content : content.gsub(/\r\n/, "\n")
end
def check_repository_error
repository_error = snippet.errors.delete(:repository)
flash.now[:alert] = repository_error if repository_error
recaptcha_check_with_fallback(repository_error.nil?) { render :edit }
end
end
|