attachment: add a new feature to switch "side by side" and "inline" for patches (#9612)

git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/trunk@7860 e93f8b46-1217-0410-a6f0-8f06a7374b81
This commit is contained in:
Toshi MARUYAMA 2011-11-20 06:13:26 +00:00
parent 700c6de3db
commit 245b534c83
2 changed files with 11 additions and 2 deletions

View File

@ -27,6 +27,8 @@ class AttachmentsController < ApplicationController
format.html {
if @attachment.is_diff?
@diff = File.new(@attachment.diskfile, "rb").read
@diff_type = params[:type] || User.current.pref[:diff_type] || 'inline'
@diff_type = 'inline' unless %w(inline sbs).include?(@diff_type)
render :action => 'diff'
elsif @attachment.is_text? && @attachment.filesize <= Setting.file_max_size_displayed.to_i.kilobyte
@content = File.new(@attachment.diskfile, "rb").read

View File

@ -5,9 +5,16 @@
<span class="author"><%= link_to_user(@attachment.author) %>, <%= format_time(@attachment.created_on) %></span></p>
<p><%= link_to_attachment @attachment, :text => l(:button_download), :download => true -%>
<span class="size">(<%= number_to_human_size @attachment.filesize %>)</span></p>
</div>
&nbsp;
<p>
<% form_tag({}, :method => 'get') do %>
<label><%= l(:label_view_diff) %></label>
<%= select_tag 'type',
options_for_select(
[[l(:label_diff_inline), "inline"], [l(:label_diff_side_by_side), "sbs"]], @diff_type),
:onchange => "if (this.value != '') {this.form.submit()}" %>
<% end %>
</p>
<%= render :partial => 'common/diff', :locals => {:diff => @diff, :diff_type => @diff_type} %>
<% html_title @attachment.filename %>