/[simile]/svn/index.cgi
This is repository of my old source code which isn't updated any more. Go to git.rot13.org for current projects!
ViewVC logotype

Contents of /svn/index.cgi

Parent Directory Parent Directory | Revision Log Revision Log


Revision 30 - (show annotations)
Mon Oct 20 19:41:49 2008 UTC (15 years, 6 months ago) by dpavlin
File size: 5610 byte(s)
real subversion revision limit (selectable now) as well
as option to count all or just one path from each commit
(which might come in handy when dealing with huge repositories)
1 #!/usr/bin/perl -w
2
3 # svn2js.pl
4 #
5 # 10/05/08 16:15:38 CEST Dobrica Pavlinusic <dpavlin@rot13.org>
6
7 use strict;
8 use XML::Simple;
9 use Data::Dump qw/dump/;
10 use JSON;
11 use CGI;
12
13 my $debug = $ENV{'DEBUG'} || 0;
14
15 my $limit = 1000;
16
17 my $repository_dir = '/srv/svn';
18 my $svnweb = 'https://svn-strix.carnet.hr/private/svnweb/index.cgi/%s/revision?rev=%d';
19
20 # my local config for development
21 $repository_dir = '/home/dpavlin/private/svn';
22 $svnweb = 'http://localhost/svnweb/index.cgi/%s/revision?rev=%d';
23 # my local svk mirrors
24 $repository_dir = '/home/dpavlin/.svk';
25 $svnweb = 'http://localhost/svnweb/svk/index.cgi/%s/revision?rev=%d';
26
27 # for older JSON
28 #sub encode_json { objToJson( @_ ) }
29
30 sub path_strip {
31 my $path = shift;
32 # $path =~ $strip_branch;
33 return $path;
34 }
35
36 opendir(my $dir, $repository_dir) || die "can't open $repository_dir: $!";
37 my @repositories = sort grep { -f "$repository_dir/$_/format" } readdir($dir);
38 closedir($dir);
39
40 our $q = CGI->new;
41 my $repository = $q->param('repository');
42 $repository = (grep { m/^\Q$repository\E$/ } @repositories )[0] if $repository;
43
44 warn "q = ",dump( $q );
45 warn "# limit: ", $q->param('limit');
46
47 sub select_repository {
48 my $onChange = qq{document.getElementById('current_repository').submit();};
49 return (
50 $q->start_form( -name => 'current_repository', -id => 'current_repository', -method => 'post' ),
51 "From repository ",
52 $q->popup_menu( -name => 'repository', -values => [ @repositories ], -onChange => $onChange ),
53 " show ",
54 $q->popup_menu( -name => 'limit', -values => [ qw/100 500 1000 5000 10000/ ], -onChange => $onChange ),
55 " revisions with ",
56 $q->checkbox(-name=>'path', -checked=>1, -value=>'ON', -label=>'path modifications', -onChange => $onChange ),
57 $q->submit,
58 $q->end_form
59 );
60 }
61
62 if ( ! $repository ) {
63 print $q->header,$q->start_html("Select repository"), select_repository;
64 exit;
65 } elsif ( ! $q->param('json') ) {
66 $repository ||= 'Select repository';
67 print $q->header, qq|
68 <html>
69 <head>
70 <title>$repository -- Exhibit SVN exhibit facet browsing</title>
71
72 <link rel="exhibit/data"
73 type="application/json"
74 href="|, $q->url( -query => 1 ), qq|&json=1" />
75
76 <!--
77 <script
78 src="http://static.simile.mit.edu/exhibit/api-2.0/exhibit-api.js"
79 type="text/javascript"></script>
80
81 <script
82 src="http://static.simile.mit.edu/exhibit/extensions-2.0/time/time-extension.js"></script>
83 -->
84
85 <script
86 src="../exhibit/api/exhibit-api.js"
87 type="text/javascript"></script>
88 <script
89 src="..//exhibit/extensions/time/time-extension.js"></script>
90
91
92 </head>
93 <body>
94 <div style="float: right">
95 <a href="http://stud05.technikum-wien.at/~tw05n126/exhibit/log/log.html">based on</a>,
96 <a href="http://simile.mit.edu/exhibit/">exhibit</a></div>
97 |, select_repository, qq|
98 <table width="100%" style="font-size: 0.8em">
99 <tr valign="top">
100 <td rowspan="2" width="25%">
101 <div ex:role="facet" ex:facetClass="TextSearch" ex:facetLabel="Search"></div>
102
103 <div ex:role="facet" ex:expression=".author" ex:facetLabel="Author"
104 ex:sortMode="count"></div>
105 |, $q->param('path') ?
106 qq|
107 <div ex:role="facet" ex:expression=".action" ex:facetLabel="Action"
108 ex:sortMode="count" ex:scroll="false"></div>
109 | : '',
110 qq|
111 <div ex:role="facet" ex:expression=".revision" ex:facetClass="NumericRange"
112 ex:interval="20" ex:scroll="true"></div>
113 |, $q->param('path') ?
114 qq|
115 <div ex:role="facet" ex:expression=".path" ex:facetLabel="Path by Count"
116 ex:sortMode="count"></div>
117 | : '',
118 qq|
119 </td>
120 <td>
121
122 <div ex:role="facet" ex:expression=".path" ex:facetLabel="Path by Name"
123 ex:sortMode="value"></div>
124 </td>
125 </tr>
126 <tr valign="top">
127 <td ex:role="viewPanel">
128
129 <div ex:role="view" ex:viewClass="Timeline" ex:start=".date"
130 ex:colorKey=".author"
131 ex:topBandUnit="week" ex:topBandPixelsPerUnit="200"
132 ex:bottomBandUnit="month" ex:bottomBandPixelsPerUnit="25"
133 ex:timelineHeight="550" />
134
135 <div ex:role="view" ex:viewClass="Tabular"
136 ex:columns=".revision, .author, .date, .PATH, .action, .copyfrom-path, .copyfrom-rev, .msg"
137 />
138 </td>
139
140 </tr>
141 </table>
142
143 </body>
144 </html>
145 |;
146 exit;
147 }
148
149 my $json = {
150 properties => {
151 revision => {
152 valueType => "number",
153 },
154 'google-code-svn-link' => {
155 valueType => "url"
156 }
157 },
158 items => [],
159 };
160
161 my $log;
162 {
163 my $cmd = "svn log --xml --stop-on-copy -v --limit " . ( $q->param('limit') || $limit ) . " file://$repository_dir/$repository";
164 warn "cmd: $cmd\n";
165 open( my $log_fh, '-|', $cmd) || die "can't read svn log: $!";
166 local $/ = undef;
167 $log = <$log_fh>;
168 close( $log_fh );
169 }
170
171 my $xml = XMLin($log, ForceArray => [ 'logentry', 'path' ]);
172
173 warn dump( $xml ) if $debug;
174
175 foreach my $e (@{$xml->{'logentry'}}) {
176
177 foreach my $p (@{$e->{'paths'}->{'path'}}) {
178 my $path = delete( $p->{'content'} );
179 my $label = $e->{'revision'} . ' - ' . path_strip( $path );
180 my $item = {
181 type => 'Item',
182 id => $label,
183 label => $label,
184 uri => sprintf($svnweb, $repository, $e->{'revision'}),
185 path_full => $path,
186 path => path_strip( $path ),
187 };
188
189 $item->{$_} = $p->{$_} foreach grep { ! defined $item->{$_} } keys %$p;
190 $item->{$_} = $e->{$_} foreach grep { ! defined $item->{$_} && ! /^(paths)$/ } keys %$e;
191
192 warn dump( $item ) if $debug;
193
194 push @{ $json->{items} }, $item;
195
196 last if ! $q->param('path');
197 }
198
199 }
200
201 print qq|Content-type: application/json\n\r\n\r|, encode_json( $json );
202

Properties

Name Value
svn:executable *

  ViewVC Help
Powered by ViewVC 1.1.26