mirror of
https://github.com/redmine/redmine.git
synced 2026-02-25 16:11:25 +01:00
Show PDF attachments and repo entries instead of downloading them (#22483).
Patch by Gregor Schmidt (user:schmidt). git-svn-id: https://svn.redmine.org/redmine/trunk@24460 e93f8b46-1217-0410-a6f0-8f06a7374b81
This commit is contained in:
@@ -2443,6 +2443,8 @@ img {
|
||||
box-shadow: 0 1px 2px rgba(var(--oc-gray-9-rgb), 0.05);
|
||||
}
|
||||
|
||||
.pdf-full-view-link { margin: 0 0 0.5em; }
|
||||
|
||||
/* tablesort */
|
||||
th[role=columnheader]:not(.no-sort) {
|
||||
cursor: pointer;
|
||||
|
||||
@@ -102,6 +102,34 @@ table.filecontent tr:target td.line-code { background-color:var(--oc-blue-0); }
|
||||
|
||||
img.filecontent, video.filecontent { max-inline-size: 100%; }
|
||||
|
||||
.filecontent.pdf {
|
||||
inline-size: 100%;
|
||||
max-block-size: 80vh;
|
||||
overflow: hidden;
|
||||
position: relative;
|
||||
}
|
||||
|
||||
.filecontent.pdf::before {
|
||||
content: " ";
|
||||
display: block;
|
||||
inline-size: 100%;
|
||||
padding-block-end: 100%;
|
||||
}
|
||||
|
||||
.filecontent.pdf object,
|
||||
.filecontent.pdf p {
|
||||
position: absolute;
|
||||
inset-block-start: 0;
|
||||
inset-inline-start: 0;
|
||||
inset-inline-end: 0;
|
||||
}
|
||||
|
||||
.filecontent.pdf object {
|
||||
border: none;
|
||||
inline-size: 100%;
|
||||
block-size: 100%;
|
||||
}
|
||||
|
||||
.previous-filename {
|
||||
font-weight: normal;
|
||||
}
|
||||
|
||||
@@ -61,6 +61,8 @@ class AttachmentsController < ApplicationController
|
||||
render :action => 'file'
|
||||
elsif @attachment.is_image?
|
||||
render :action => 'image'
|
||||
elsif @attachment.is_pdf?
|
||||
render :action => 'pdf'
|
||||
else
|
||||
render :action => 'other'
|
||||
end
|
||||
|
||||
@@ -10,6 +10,8 @@
|
||||
|
||||
<% if Redmine::MimeType.is_type?('image', @path) %>
|
||||
<%= render :partial => 'common/image', :locals => {:path => @raw_url, :alt => @path} %>
|
||||
<% elsif Redmine::MimeType.of(@path) == 'application/pdf' %>
|
||||
<%= render :partial => 'common/pdf', :locals => {:path => @raw_url} %>
|
||||
<% elsif Redmine::MimeType.of(@path) == 'text/x-textile' %>
|
||||
<%= render :partial => 'common/markup', :locals => {:markup_text_formatting => 'textile', :markup_text => @content} %>
|
||||
<% elsif Redmine::MimeType.of(@path) == 'text/markdown' %>
|
||||
|
||||
@@ -726,6 +726,7 @@ en:
|
||||
label_no_preview: No preview available
|
||||
label_no_preview_alternative_html: No preview available. %{link} the file instead.
|
||||
label_no_preview_download: Download
|
||||
label_open_in_full_view: Open in full view
|
||||
label_change_status: Change status
|
||||
label_history: History
|
||||
label_attachment: File
|
||||
|
||||
@@ -239,6 +239,17 @@ class AttachmentsControllerTest < Redmine::ControllerTest
|
||||
assert_select 'img.filecontent', :src => attachments(:attachments_010).filename
|
||||
end
|
||||
|
||||
def test_show_pdf
|
||||
@request.session[:user_id] = 2
|
||||
get(:show, :params => {:id => 23})
|
||||
assert_response :success
|
||||
assert_equal 'text/html', @response.media_type
|
||||
|
||||
path = download_named_attachment_path(attachments(:attachments_023), attachments(:attachments_023).filename)
|
||||
assert_select ".filecontent.pdf object[data='#{path}']"
|
||||
assert_select '.nodata', :text => 'No preview available'
|
||||
end
|
||||
|
||||
def test_show_other_with_no_preview
|
||||
@request.session[:user_id] = 2
|
||||
get(:show, :params => {:id => 6})
|
||||
|
||||
Reference in New Issue
Block a user