Revision 14
- Date:
- 2008/10/05 18:45:10
- Files:
-
- /svn
- /svn/svn.html (Diff) (Checkout)
- /svn/svn2js.cgi (Diff) (Checkout)
Legend:
- Added
- Removed
- Modified
-
svn/svn.html
1 <html> 2 <head> 3 <title>SVN facet browsing exhibit</title> 4 5 <!-- 6 <link rel="exhibit/data" 7 type="application/rdf+xml" 8 href="log.xml" /> 9 10 <link rel="exhibit/data" type="application/jsonp" 11 href="http://spreadsheets.google.com/feeds/list/o07573463909577017953.6839049389601542536/od6/public/basic?alt=json-in-script" 12 ex:converter="googleSpreadsheets" /> 13 14 <link rel="exhibit/data" 15 type="application/json" 16 href="log.json" /> 17 <link rel="exhibit/data" 18 type="application/json" 19 href="svn.js" /> 20 --> 21 <link rel="exhibit/data" 22 type="application/json" 23 href="svn2js.cgi" /> 24 25 <script 26 src="http://static.simile.mit.edu/exhibit/api-2.0/exhibit-api.js" 27 type="text/javascript"></script> 28 29 30 <script 31 src="http://static.simile.mit.edu/exhibit/extensions-2.0/time/time-extension.js"></script> 32 33 34 </head> 35 <body> 36 <div style="float: right"> 37 <a href="http://stud05.technikum-wien.at/~tw05n126/exhibit/log/log.html">based on</a>, 38 <a href="http://simile.mit.edu/exhibit/">exhibit</a></div> 39 <h1 style="font-size: 0.8em">Exhibit SVN History</h1> 40 <table width="100%" style="font-size: 0.8em"> 41 <tr valign="top"> 42 <td rowspan="2" width="25%"> 43 <div ex:role="facet" ex:facetClass="TextSearch" ex:facetLabel="Search"></div> 44 45 <div ex:role="facet" ex:expression=".author" ex:facetLabel="Author" 46 ex:sortMode="count"></div> 47 48 <div ex:role="facet" ex:expression=".action" ex:facetLabel="Action" 49 ex:sortMode="count" ex:scroll="false"></div> 50 51 <div ex:role="facet" ex:expression=".revision" ex:facetClass="NumericRange" 52 ex:interval="10" ex:scroll="true"></div> 53 54 <div ex:role="facet" ex:expression=".path" ex:facetLabel="Path by Count" 55 ex:sortMode="count"></div> 56 57 </td> 58 <td> 59 60 <div ex:role="facet" ex:expression=".path" ex:facetLabel="Path by Name" 61 ex:sortMode="value"></div> 62 </td> 63 </tr> 64 <tr valign="top"> 65 <td ex:role="viewPanel"> 66 67 <div ex:role="view" ex:viewClass="Timeline" ex:start=".date" 68 ex:colorKey=".author" 69 ex:topBandUnit="week" ex:topBandPixelsPerUnit="200" 70 ex:bottomBandUnit="month" ex:bottomBandPixelsPerUnit="25" 71 ex:timelineHeight="650" /> 72 73 <div ex:role="view" ex:viewClass="Tabular" 74 ex:columns=".revision, .author, .date, .path, .action, .copyfrom-path, .copyfrom-rev, .msg" 75 /> 76 </td> 77 78 </tr> 79 </table> 80 81 </body> 82 </html> 83 84 -
svn/svn2js.cgi
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 12 my $debug = 0; 13 14 my $max_items = 500; 15 16 my $repository = 'file:///home/dpavlin/.svk/strix4/'; 17 my $svnweb = 'http://localhost/svnweb/svk/index.cgi/strix4/revision?rev='; 18 19 my $json = { 20 properties => { 21 revision => { 22 valueType => "number", 23 }, 24 'google-code-svn-link' => { 25 valueType => "url" 26 } 27 }, 28 items => [], 29 }; 30 31 my $log; 32 { 33 open( my $log_fh, '-|', "svn log --xml --stop-on-copy -v $repository" ) || die "can't read svn log: $!"; 34 local $/ = undef; 35 $log = <$log_fh>; 36 close( $log_fh ); 37 } 38 39 my $xml = XMLin($log, ForceArray => [ 'logentry', 'path' ]); 40 41 warn dump( $xml ) if $debug; 42 43 foreach my $e (@{$xml->{'logentry'}}) { 44 45 foreach my $p (@{$e->{'paths'}->{'path'}}) { 46 my $label = $e->{'revision'} . ' - ' . $p->{'content'}; 47 my $item = { 48 type => 'Item', 49 id => $label, 50 label => $label, 51 uri => $svnweb . $e->{'revision'}, 52 path => delete( $p->{'content'} ), 53 }; 54 55 $item->{$_} = $p->{$_} foreach keys %$p; 56 $item->{$_} = $e->{$_} foreach grep { ! /^(paths)$/ } keys %$e; 57 58 $item->{'path'} =~ s!^/[^/]+/[^/]+/!/!; 59 60 warn dump( $item ) if $debug; 61 62 push @{ $json->{items} }, $item; 63 64 $max_items--; 65 # we skip all other items in commits with more than 10 files as they are too chatty 66 last if $#{ $e->{'paths'}->{'path'} } > 10; 67 # last; # FIXME record just single item for each commit! 68 # we also break out when $max_items is reached to keep browser (somewhat) alive 69 last if ! $max_items; 70 } 71 72 last if ! $max_items; 73 } 74 75 print qq|Content-type: application/json\n\r\n\r|, encode_json( $json ); 76