<p>Harald Welte has uploaded this change for <strong>review</strong>.</p><p><a href="https://gerrit.osmocom.org/9178">View Change</a></p><pre style="font-family: monospace,monospace; white-space: pre-wrap;">redmine: Change content-disposition of image attachments to 'inline'<br><br>Closes: OS#3264<br>Change-Id: Ib60a12fc4adc0ceebfed70ff14d5ae256868bb2b<br>---<br>M redmine/Dockerfile<br>A redmine/redmine-image-content-disposition.diff<br>2 files changed, 67 insertions(+), 0 deletions(-)<br><br></pre><pre style="font-family: monospace,monospace; white-space: pre-wrap;">git pull ssh://gerrit.osmocom.org:29418/docker-playground refs/changes/78/9178/1</pre><pre style="font-family: monospace,monospace; white-space: pre-wrap;"><span>diff --git a/redmine/Dockerfile b/redmine/Dockerfile</span><br><span>index 81976c6..1d8362d 100644</span><br><span>--- a/redmine/Dockerfile</span><br><span>+++ b/redmine/Dockerfile</span><br><span>@@ -12,3 +12,6 @@</span><br><span> </span><br><span> COPY    redmine-openid-hmac-digest.diff /tmp/</span><br><span> RUN    cd /usr/local/bundle/gems/ruby-openid-2.3.0 && patch -p0 < /tmp/redmine-openid-hmac-digest.diff</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+COPY      redmine-image-content-disposition.diff /tmp/</span><br><span style="color: hsl(120, 100%, 40%);">+RUN       patch -p1 < /tmp/redmine-image-content-disposition.diff</span><br><span>diff --git a/redmine/redmine-image-content-disposition.diff b/redmine/redmine-image-content-disposition.diff</span><br><span>new file mode 100644</span><br><span>index 0000000..50d83db</span><br><span>--- /dev/null</span><br><span>+++ b/redmine/redmine-image-content-disposition.diff</span><br><span>@@ -0,0 +1,64 @@</span><br><span style="color: hsl(120, 100%, 40%);">+From 6c94d485cb3e23559da8f0356a1052a620d7a2c2 Mon Sep 17 00:00:00 2001</span><br><span style="color: hsl(120, 100%, 40%);">+From: Harald Welte <laforge@gnumonks.org></span><br><span style="color: hsl(120, 100%, 40%);">+Date: Mon, 14 May 2018 23:16:51 +0200</span><br><span style="color: hsl(120, 100%, 40%);">+Subject: [PATCH] chagnge content-disposition of pdf/image/text/patch to</span><br><span style="color: hsl(120, 100%, 40%);">+ 'inline'</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+Related:  https://osmocom.org/issues/3264</span><br><span style="color: hsl(120, 100%, 40%);">+---</span><br><span style="color: hsl(120, 100%, 40%);">+ app/controllers/attachments_controller.rb | 9 ++++++++-</span><br><span style="color: hsl(120, 100%, 40%);">+ app/models/attachment.rb                  | 8 ++++++++</span><br><span style="color: hsl(120, 100%, 40%);">+ 2 files changed, 16 insertions(+), 1 deletion(-)</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+diff --git a/app/controllers/attachments_controller.rb b/app/controllers/attachments_controller.rb</span><br><span style="color: hsl(120, 100%, 40%);">+index c2b5fa9c8..f2a57c31d 100644</span><br><span style="color: hsl(120, 100%, 40%);">+--- a/app/controllers/attachments_controller.rb</span><br><span>++++ b/app/controllers/attachments_controller.rb</span><br><span style="color: hsl(120, 100%, 40%);">+@@ -57,7 +57,7 @@ class AttachmentsController < ApplicationController</span><br><span style="color: hsl(120, 100%, 40%);">+       # images are sent inline</span><br><span style="color: hsl(120, 100%, 40%);">+       send_file @attachment.diskfile, :filename => filename_for_content_disposition(@attachment.filename),</span><br><span style="color: hsl(120, 100%, 40%);">+                                       :type => detect_content_type(@attachment),</span><br><span style="color: hsl(120, 100%, 40%);">+-                                      :disposition => 'attachment'</span><br><span style="color: hsl(120, 100%, 40%);">++                                      :disposition => disposition(@attachment)</span><br><span style="color: hsl(120, 100%, 40%);">+     end</span><br><span style="color: hsl(120, 100%, 40%);">+   end</span><br><span style="color: hsl(120, 100%, 40%);">+ </span><br><span style="color: hsl(120, 100%, 40%);">+@@ -188,4 +188,12 @@ class AttachmentsController < ApplicationController</span><br><span style="color: hsl(120, 100%, 40%);">+     end</span><br><span style="color: hsl(120, 100%, 40%);">+     content_type.to_s</span><br><span style="color: hsl(120, 100%, 40%);">+   end</span><br><span style="color: hsl(120, 100%, 40%);">++</span><br><span style="color: hsl(120, 100%, 40%);">++  def disposition(attachment)</span><br><span style="color: hsl(120, 100%, 40%);">++    if attachment.is_pdf? || attachment.is_image? || attachment.is_diff? || attachment.is_text?</span><br><span style="color: hsl(120, 100%, 40%);">++      'inline'</span><br><span style="color: hsl(120, 100%, 40%);">++    else</span><br><span style="color: hsl(120, 100%, 40%);">++      'attachment'</span><br><span style="color: hsl(120, 100%, 40%);">++    end</span><br><span style="color: hsl(120, 100%, 40%);">++  end</span><br><span style="color: hsl(120, 100%, 40%);">+ end</span><br><span style="color: hsl(120, 100%, 40%);">+diff --git a/app/models/attachment.rb b/app/models/attachment.rb</span><br><span style="color: hsl(120, 100%, 40%);">+index 3d16f57cc..a2520b0d5 100644</span><br><span style="color: hsl(120, 100%, 40%);">+--- a/app/models/attachment.rb</span><br><span>++++ b/app/models/attachment.rb</span><br><span style="color: hsl(120, 100%, 40%);">+@@ -236,10 +236,18 @@ class Attachment < ActiveRecord::Base</span><br><span style="color: hsl(120, 100%, 40%);">+     Redmine::MimeType.is_type?('text', filename)</span><br><span style="color: hsl(120, 100%, 40%);">+   end</span><br><span style="color: hsl(120, 100%, 40%);">+ </span><br><span style="color: hsl(120, 100%, 40%);">++  def is_image?</span><br><span style="color: hsl(120, 100%, 40%);">++    Redmine::MimeType.is_type?('image', filename)</span><br><span style="color: hsl(120, 100%, 40%);">++  end</span><br><span style="color: hsl(120, 100%, 40%);">++</span><br><span style="color: hsl(120, 100%, 40%);">+   def is_diff?</span><br><span style="color: hsl(120, 100%, 40%);">+     self.filename =~ /\.(patch|diff)$/i</span><br><span style="color: hsl(120, 100%, 40%);">+   end</span><br><span style="color: hsl(120, 100%, 40%);">+ </span><br><span style="color: hsl(120, 100%, 40%);">++  def is_pdf?</span><br><span style="color: hsl(120, 100%, 40%);">++    Redmine::MimeType.of(filename) == "application/pdf"</span><br><span style="color: hsl(120, 100%, 40%);">++  end</span><br><span style="color: hsl(120, 100%, 40%);">++</span><br><span style="color: hsl(120, 100%, 40%);">+   # Returns true if the file is readable</span><br><span style="color: hsl(120, 100%, 40%);">+   def readable?</span><br><span style="color: hsl(120, 100%, 40%);">+     File.readable?(diskfile)</span><br><span style="color: hsl(120, 100%, 40%);">+-- </span><br><span style="color: hsl(120, 100%, 40%);">+2.17.0</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span></span><br></pre><p>To view, visit <a href="https://gerrit.osmocom.org/9178">change 9178</a>. To unsubscribe, or for help writing mail filters, visit <a href="https://gerrit.osmocom.org/settings">settings</a>.</p><div itemscope itemtype="http://schema.org/EmailMessage"><div itemscope itemprop="action" itemtype="http://schema.org/ViewAction"><link itemprop="url" href="https://gerrit.osmocom.org/9178"/><meta itemprop="name" content="View Change"/></div></div>

<div style="display:none"> Gerrit-Project: docker-playground </div>
<div style="display:none"> Gerrit-Branch: master </div>
<div style="display:none"> Gerrit-MessageType: newchange </div>
<div style="display:none"> Gerrit-Change-Id: Ib60a12fc4adc0ceebfed70ff14d5ae256868bb2b </div>
<div style="display:none"> Gerrit-Change-Number: 9178 </div>
<div style="display:none"> Gerrit-PatchSet: 1 </div>
<div style="display:none"> Gerrit-Owner: Harald Welte <laforge@gnumonks.org> </div>