Redmine 4.1.1
This commit is contained in:
parent
33e7b881a5
commit
3d976f1b3b
1593 changed files with 36180 additions and 19489 deletions
|
@ -1,5 +1,7 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
# Redmine - project management software
|
||||
# Copyright (C) 2006-2017 Jean-Philippe Lang
|
||||
# Copyright (C) 2006-2019 Jean-Philippe Lang
|
||||
#
|
||||
# This program is free software; you can redistribute it and/or
|
||||
# modify it under the terms of the GNU General Public License
|
||||
|
@ -32,6 +34,14 @@ class AttachmentsController < ApplicationController
|
|||
def show
|
||||
respond_to do |format|
|
||||
format.html {
|
||||
if @attachment.container.respond_to?(:attachments)
|
||||
@attachments = @attachment.container.attachments.to_a
|
||||
if index = @attachments.index(@attachment)
|
||||
@paginator = Redmine::Pagination::Paginator.new(
|
||||
@attachments.size, 1, index+1
|
||||
)
|
||||
end
|
||||
end
|
||||
if @attachment.is_diff?
|
||||
@diff = File.read(@attachment.diskfile, :mode => "rb")
|
||||
@diff_type = params[:type] || User.current.pref[:diff_type] || 'inline'
|
||||
|
@ -71,10 +81,11 @@ class AttachmentsController < ApplicationController
|
|||
def thumbnail
|
||||
if @attachment.thumbnailable? && tbnail = @attachment.thumbnail(:size => params[:size])
|
||||
if stale?(:etag => tbnail, :template => false)
|
||||
send_file tbnail,
|
||||
send_file(
|
||||
tbnail,
|
||||
:filename => filename_for_content_disposition(@attachment.filename),
|
||||
:type => detect_content_type(@attachment),
|
||||
:disposition => 'inline'
|
||||
:type => detect_content_type(@attachment, true),
|
||||
:disposition => 'inline')
|
||||
end
|
||||
else
|
||||
# No thumbnail for the attachment or thumbnail could not be created
|
||||
|
@ -156,8 +167,10 @@ class AttachmentsController < ApplicationController
|
|||
|
||||
# Returns the menu item that should be selected when viewing an attachment
|
||||
def current_menu_item
|
||||
if @attachment
|
||||
case @attachment.container
|
||||
container = @attachment.try(:container) || @container
|
||||
|
||||
if container
|
||||
case container
|
||||
when WikiPage
|
||||
:wiki
|
||||
when Message
|
||||
|
@ -165,7 +178,7 @@ class AttachmentsController < ApplicationController
|
|||
when Project, Version
|
||||
:files
|
||||
else
|
||||
@attachment.container.class.name.pluralize.downcase.to_sym
|
||||
container.class.name.pluralize.downcase.to_sym
|
||||
end
|
||||
end
|
||||
end
|
||||
|
@ -224,12 +237,20 @@ class AttachmentsController < ApplicationController
|
|||
@attachment.deletable? ? true : deny_access
|
||||
end
|
||||
|
||||
def detect_content_type(attachment)
|
||||
def detect_content_type(attachment, is_thumb = false)
|
||||
content_type = attachment.content_type
|
||||
if content_type.blank? || content_type == "application/octet-stream"
|
||||
content_type = Redmine::MimeType.of(attachment.filename)
|
||||
content_type =
|
||||
Redmine::MimeType.of(attachment.filename).presence ||
|
||||
"application/octet-stream"
|
||||
end
|
||||
content_type.to_s
|
||||
|
||||
if is_thumb && content_type == "application/pdf"
|
||||
# PDF previews are stored in PNG format
|
||||
content_type = "image/png"
|
||||
end
|
||||
|
||||
content_type
|
||||
end
|
||||
|
||||
def disposition(attachment)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue