@@ -17,6 +17,7 | |||||
17 |
|
17 | |||
18 | require 'SVG/Graph/Bar' |
|
18 | require 'SVG/Graph/Bar' | |
19 | require 'SVG/Graph/BarHorizontal' |
|
19 | require 'SVG/Graph/BarHorizontal' | |
|
20 | require 'digest/sha1' | |||
20 |
|
21 | |||
21 | class RepositoriesController < ApplicationController |
|
22 | class RepositoriesController < ApplicationController | |
22 | layout 'base' |
|
23 | layout 'base' | |
@@ -73,10 +74,14 class RepositoriesController < ApplicationController | |||||
73 | end |
|
74 | end | |
74 |
|
75 | |||
75 | def diff |
|
76 | def diff | |
76 | @rev_to = params[:rev_to] || (@rev-1) |
|
77 | @rev_to = (params[:rev_to] && params[:rev_to].to_i > 0) ? params[:rev_to].to_i : (@rev - 1) | |
77 |
type = params[:type] |
|
78 | @diff_type = ('sbs' == params[:type]) ? 'sbs' : 'inline' | |
78 | @diff = @repository.scm.diff(params[:path], @rev, @rev_to, type) |
|
79 | ||
79 | show_error and return unless @diff |
|
80 | @cache_key = "repositories/diff/#{@repository.id}/" + Digest::MD5.hexdigest("#{@path}-#{@rev}-#{@rev_to}-#{@diff_type}") | |
|
81 | unless read_fragment(@cache_key) | |||
|
82 | @diff = @repository.scm.diff(@path, @rev, @rev_to, type) | |||
|
83 | show_error and return unless @diff | |||
|
84 | end | |||
80 | end |
|
85 | end | |
81 |
|
86 | |||
82 | def stats |
|
87 | def stats |
@@ -8,21 +8,22 | |||||
8 | <% end %> |
|
8 | <% end %> | |
9 | <% end %> |
|
9 | <% end %> | |
10 | <p><label><%= l(:label_view_diff) %></label> |
|
10 | <p><label><%= l(:label_view_diff) %></label> | |
11 | <%= 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()}" %> |
|
11 | <%= 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> | |
12 | <%= submit_tag l(:button_apply) %></p> |
|
|||
13 | <% end %> |
|
12 | <% end %> | |
|
13 | ||||
|
14 | <% cache(@cache_key) do %> | |||
14 | <% @diff.each do |table_file| %> |
|
15 | <% @diff.each do |table_file| %> | |
15 |
<% if |
|
16 | <% if @diff_type == 'sbs' %> | |
16 | <table class="list"> |
|
17 | <table class="list"> | |
17 | <thead> |
|
18 | <thead> | |
18 | <tr> |
|
19 | <tr> | |
19 | <th colspan="4" class="list-filename"> |
|
20 | <th colspan="4" class="list-filename"> | |
20 |
|
|
21 | <%= table_file.file_name %> | |
21 | </th> |
|
22 | </th> | |
22 | </tr> |
|
23 | </tr> | |
23 | <tr> |
|
24 | <tr> | |
24 |
<th colspan="2"> |
|
25 | <th colspan="2">@<%= @rev %></th> | |
25 |
<th colspan="2"> |
|
26 | <th colspan="2">@<%= @rev_to %></th> | |
26 | </tr> |
|
27 | </tr> | |
27 | </thead> |
|
28 | </thead> | |
28 | <tbody> |
|
29 | <tbody> | |
@@ -50,7 +51,7 | |||||
50 | <thead> |
|
51 | <thead> | |
51 | <tr> |
|
52 | <tr> | |
52 | <th colspan="3" class="list-filename"> |
|
53 | <th colspan="3" class="list-filename"> | |
53 |
|
|
54 | <%= table_file.file_name %> | |
54 | </th> |
|
55 | </th> | |
55 | </tr> |
|
56 | </tr> | |
56 | <tr> |
|
57 | <tr> | |
@@ -83,6 +84,7 | |||||
83 | </table> |
|
84 | </table> | |
84 | <% end %> |
|
85 | <% end %> | |
85 | <% end %> |
|
86 | <% end %> | |
|
87 | <% end %> | |||
86 |
|
88 | |||
87 | <% content_for :header_tags do %> |
|
89 | <% content_for :header_tags do %> | |
88 | <%= stylesheet_link_tag "scm" %> |
|
90 | <%= stylesheet_link_tag "scm" %> |
General Comments 0
You need to be logged in to leave comments.
Login now