Changesets can be listed by changeset number.
The Git repository is here.
- Revision:
- 453
- Log:
Properly handle "file not found" events for log files, rather than
just allowing an Application Error to be raised.
- Author:
- rool
- Date:
- Fri Sep 06 02:04:50 +0100 2013
- Size:
- 4008 Bytes
1 | require 'revision_parser' |
2 | |
3 | class RevisionsController < ApplicationController |
4 | |
5 | def list |
6 | # Use cvslog2web output directly for a list of recent changes. |
7 | |
8 | render :file => "#{CVSLOG2WEB_OUTPUT}/recent.html", :layout => 'default' |
9 | end |
10 | |
11 | def logs |
12 | # Use cvslog2web output directly for log details of a specific change. |
13 | # Links are based off an 'ident' parameter pulled in via a query string; |
14 | # we don't want people putting in "../" etc. to try and navigate around |
15 | # the server, so strip out ".", "\" and "/". |
16 | |
17 | log = "#{params[:ident]}" |
18 | log.gsub!(/\.html$/, '') |
19 | log.gsub!(/[\.\/\\]/, '') |
20 | |
21 | filename = "#{CVSLOG2WEB_OUTPUT}/#{log}.html" |
22 | |
23 | if File.file?(filename) |
24 | render :file => filename, :layout => 'default' |
25 | else |
26 | raise ActionController::RoutingError.new('Not Found') |
27 | end |
28 | end |
29 | |
30 | def revisions |
31 | # Create a revision parser for a CVSHistory RSS feed. Get a |
32 | # hash keyed by revision number (as a string), each entry |
33 | # containing an array of RevisionDetails objects. Sort the |
34 | # revision keys in reverse order of associated date (i.e. most |
35 | # recent first) and iterate through the resulting sorted list. |
36 | |
37 | parser = RevisionParser.new(get_parser_url()) |
38 | revisions = parser.fetch_and_parse(true) |
39 | sort_keys = revisions.keys.sort do |key_x, key_y| |
40 | revisions[key_y][0][:date] <=> revisions[key_x][0][:date] |
41 | end |
42 | |
43 | # Create an array of items in sorted order. |
44 | |
45 | @output = [] |
46 | |
47 | sort_keys.each do |revision| |
48 | |
49 | # For each revision we have an array of changed files. For the overall |
50 | # item details, choose (arbitrarily) the first one - 'item' should only |
51 | # be looked at in terms of the attributes it has which apply equally to |
52 | # all files in this revision. Make sure we note the key name that was |
53 | # used for this item within the item itself. |
54 | |
55 | item = revisions[revision][0] |
56 | item[:key] = revision |
57 | |
58 | @output.push(item) |
59 | end |
60 | |
61 | # Render the default layout to create the revision list. |
62 | |
63 | render :layout => 'default' |
64 | end |
65 | |
66 | def show |
67 | # The 'list' action creates links that create a parameter 'ident' in the |
68 | # @params hash. This is a key to a revision hash entry. Extract the relevant |
69 | # hash and pass it to the view. |
70 | |
71 | parser = RevisionParser.new(get_parser_url()) |
72 | revisions = parser.fetch_and_parse(true) |
73 | @output = revisions[@params[:ident]] |
74 | |
75 | # Sort the array of revised files by category of action then by path. |
76 | |
77 | @output.sort do |x,y| |
78 | x[:category] <=> y[:category] |
79 | end.sort do |x,y| |
80 | x[:path] <=> y[:path] |
81 | end |
82 | |
83 | # Create mappings between categories and Collaboa icons plus suffix text. |
84 | # |
85 | # TO DO: Move these icons to the shared pool and update Collaboa accordingly. |
86 | |
87 | @category_map = { |
88 | 'Addition' => { :image => '/tracker/images/chg-icon_A.png', :text => '(+)' }, |
89 | 'Removal' => { :image => '/tracker/images/chg-icon_D.png', :text => '(-)' }, |
90 | 'Commit' => { :image => '/tracker/images/chg-icon_M.png', :text => '' }, |
91 | :unknown => { :image => '/tracker/images/icon_file.gif', :text => '?' } |
92 | } |
93 | |
94 | render :layout => 'default' |
95 | end |
96 | |
97 | # Synthesised revisions: return the CVS History feed URL. |
98 | |
99 | def get_parser_url |
100 | |
101 | # For sites that hold a development service on usual port numbers, |
102 | # check to see if we're using the development HTTP port. If so, |
103 | # change to the development HTTPS port. Then check to see if we're |
104 | # on the development HTTPS port; if not, change to port 443 for a |
105 | # regular HTTPS service. |
106 | |
107 | port = request.env['SERVER_PORT'] |
108 | port = DEVEL_HTTPS_PORT if (port == DEVEL_HTTP_PORT) |
109 | port = 443 if (port != DEVEL_HTTPS_PORT) |
110 | |
111 | "https://#{request.host}:#{port}#{CVSLOG2WEB_PREFIX}" + |
112 | '?revsel1=na&revsel2=na&datesel1=na&datesel2=na&selop=in&opA=on&opM=on&opR=on&opT=on&limit=1&rss=1' |
113 | end |
114 | end |