Added fragment caching for svn diffs.
git-svn-id: http://redmine.rubyforge.org/svn/trunk@499 e93f8b46-1217-0410-a6f0-8f06a7374b81
This commit is contained in:
parent
7eda64e464
commit
0759212a44
|
@ -17,6 +17,7 @@
|
||||||
|
|
||||||
require 'SVG/Graph/Bar'
|
require 'SVG/Graph/Bar'
|
||||||
require 'SVG/Graph/BarHorizontal'
|
require 'SVG/Graph/BarHorizontal'
|
||||||
|
require 'digest/sha1'
|
||||||
|
|
||||||
class RepositoriesController < ApplicationController
|
class RepositoriesController < ApplicationController
|
||||||
layout 'base'
|
layout 'base'
|
||||||
|
@ -73,11 +74,15 @@ class RepositoriesController < ApplicationController
|
||||||
end
|
end
|
||||||
|
|
||||||
def diff
|
def diff
|
||||||
@rev_to = params[:rev_to] || (@rev-1)
|
@rev_to = (params[:rev_to] && params[:rev_to].to_i > 0) ? params[:rev_to].to_i : (@rev - 1)
|
||||||
type = params[:type] || 'inline'
|
@diff_type = ('sbs' == params[:type]) ? 'sbs' : 'inline'
|
||||||
@diff = @repository.scm.diff(params[:path], @rev, @rev_to, type)
|
|
||||||
|
@cache_key = "repositories/diff/#{@repository.id}/" + Digest::MD5.hexdigest("#{@path}-#{@rev}-#{@rev_to}-#{@diff_type}")
|
||||||
|
unless read_fragment(@cache_key)
|
||||||
|
@diff = @repository.scm.diff(@path, @rev, @rev_to, type)
|
||||||
show_error and return unless @diff
|
show_error and return unless @diff
|
||||||
end
|
end
|
||||||
|
end
|
||||||
|
|
||||||
def stats
|
def stats
|
||||||
end
|
end
|
||||||
|
|
|
@ -8,21 +8,22 @@
|
||||||
<% end %>
|
<% end %>
|
||||||
<% end %>
|
<% end %>
|
||||||
<p><label><%= l(:label_view_diff) %></label>
|
<p><label><%= l(:label_view_diff) %></label>
|
||||||
<%= select_tag 'type', options_for_select([[l(:label_diff_inline), "inline"], [l(:label_diff_side_by_side), "sbs"]], params[:type]), :onchange => "if (this.value != '') {this.form.submit()}" %>
|
<%= select_tag 'type', options_for_select([[l(:label_diff_inline), "inline"], [l(:label_diff_side_by_side), "sbs"]], params[:type]), :onchange => "if (this.value != '') {this.form.submit()}" %></p>
|
||||||
<%= submit_tag l(:button_apply) %></p>
|
|
||||||
<% end %>
|
<% end %>
|
||||||
|
|
||||||
|
<% cache(@cache_key) do %>
|
||||||
<% @diff.each do |table_file| %>
|
<% @diff.each do |table_file| %>
|
||||||
<% if params[:type] == 'sbs' %>
|
<% if @diff_type == 'sbs' %>
|
||||||
<table class="list">
|
<table class="list">
|
||||||
<thead>
|
<thead>
|
||||||
<tr>
|
<tr>
|
||||||
<th colspan="4" class="list-filename">
|
<th colspan="4" class="list-filename">
|
||||||
<%= l(:label_attachment) %>: <%= table_file.file_name %>
|
<%= table_file.file_name %>
|
||||||
</th>
|
</th>
|
||||||
</tr>
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
<th colspan="2"><%= l(:label_revision) %> <%= @rev %></th>
|
<th colspan="2">@<%= @rev %></th>
|
||||||
<th colspan="2"><%= l(:label_revision) %> <%= @rev_to %></th>
|
<th colspan="2">@<%= @rev_to %></th>
|
||||||
</tr>
|
</tr>
|
||||||
</thead>
|
</thead>
|
||||||
<tbody>
|
<tbody>
|
||||||
|
@ -50,7 +51,7 @@
|
||||||
<thead>
|
<thead>
|
||||||
<tr>
|
<tr>
|
||||||
<th colspan="3" class="list-filename">
|
<th colspan="3" class="list-filename">
|
||||||
<%= l(:label_attachment) %>: <%= table_file.file_name %>
|
<%= table_file.file_name %>
|
||||||
</th>
|
</th>
|
||||||
</tr>
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
|
@ -83,6 +84,7 @@
|
||||||
</table>
|
</table>
|
||||||
<% end %>
|
<% end %>
|
||||||
<% end %>
|
<% end %>
|
||||||
|
<% end %>
|
||||||
|
|
||||||
<% content_for :header_tags do %>
|
<% content_for :header_tags do %>
|
||||||
<%= stylesheet_link_tag "scm" %>
|
<%= stylesheet_link_tag "scm" %>
|
||||||
|
|
Loading…
Reference in New Issue