/[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

Diff of /svn/index.cgi

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

svn/svn2js.cgi revision 14 by dpavlin, Sun Oct 5 18:45:10 2008 UTC svn/index.cgi revision 17 by dpavlin, Sun Oct 12 14:06:38 2008 UTC
# Line 8  use strict; Line 8  use strict;
8  use XML::Simple;  use XML::Simple;
9  use Data::Dump qw/dump/;  use Data::Dump qw/dump/;
10  use JSON;  use JSON;
11    use CGI;
12    
13  my $debug = 0;  my $debug = $ENV{'DEBUG'} || 0;
14    
15  my $max_items = 500;  my $max_items = 500;
16    
17  my $repository = 'file:///home/dpavlin/.svk/strix4/';  my $repository_dir = '/srv/svn';
18  my $svnweb = 'http://localhost/svnweb/svk/index.cgi/strix4/revision?rev=';  my $svnweb = 'https://svn-strix.carnet.hr/private/svnweb/index.cgi/%s/revision?rev=%d';
19    my $strip_branch = s!^/(branches/)?[^/]+/!/!;
20    
21    # my local config for development
22    $repository_dir = '/home/dpavlin/private/svn';
23    $svnweb = 'http://localhost/svnweb/index.cgi/%s/revision?rev=%d';
24    $strip_branch = s!!!;
25    
26    # for older JSON
27    #sub encode_json { objToJson( @_ ) }
28    
29    sub path_strip {
30            my $path = shift;
31            $path =~ $strip_branch;
32            return $path;
33    }
34    
35    opendir(my $dir, $repository_dir) || die "can't open $repository_dir: $!";
36    my @repositories = sort grep { -f "$repository_dir/$_/format" } readdir($dir);
37    closedir($dir);
38    
39    our $q = CGI->new;
40    my $repository = $q->param('repository');
41    $repository = (grep { m/^\Q$repository\E$/ } @repositories )[0];
42    
43    sub select_repository {
44            $q->start_form( -name => 'current_repository', -id => 'current_repository', -method => 'post' ),
45            "Select repository: ",
46            $q->popup_menu( -name => 'repository', -values => [ @repositories ], -onChange => qq{document.getElementById('current_repository').submit();} ),
47            $q->submit,
48            $q->end_form;
49    }
50    
51    if ( ! $repository ) {
52            print $q->header,$q->start_html("Select repository"), select_repository;
53            exit;
54    } elsif ( ! $q->param('json') ) {
55            $repository ||= 'Select repository';
56            print $q->header, qq|
57    <html>
58    <head>
59    <title>$repository -- Exhibit SVN exhibit facet browsing</title>
60    
61               <link rel="exhibit/data"
62        type="application/json"
63        href="?repository=$repository&json=1" />
64    
65    <script
66            src="http://static.simile.mit.edu/exhibit/api-2.0/exhibit-api.js"
67            type="text/javascript"></script>
68    
69    <script
70            src="http://static.simile.mit.edu/exhibit/extensions-2.0/time/time-extension.js"></script>
71    
72    </head>
73    <body>
74    <div style="float: right">
75    <a href="http://stud05.technikum-wien.at/~tw05n126/exhibit/log/log.html">based on</a>,
76    <a href="http://simile.mit.edu/exhibit/">exhibit</a></div>
77    |, select_repository, qq|
78    <table width="100%" style="font-size: 0.8em">
79        <tr valign="top">
80            <td rowspan="2" width="25%">
81              <div ex:role="facet" ex:facetClass="TextSearch" ex:facetLabel="Search"></div>
82            
83                <div ex:role="facet" ex:expression=".author" ex:facetLabel="Author"
84                    ex:sortMode="count"></div>
85        
86                <div ex:role="facet" ex:expression=".action" ex:facetLabel="Action"
87                    ex:sortMode="count" ex:scroll="false"></div>
88                    
89                <div ex:role="facet" ex:expression=".revision" ex:facetClass="NumericRange"
90                    ex:interval="10" ex:scroll="true"></div>
91                    
92                <div ex:role="facet" ex:expression=".path" ex:facetLabel="Path by Count"
93                    ex:sortMode="count"></div>
94                    
95            </td>
96            <td>
97            
98                <div ex:role="facet" ex:expression=".path" ex:facetLabel="Path by Name"
99                    ex:sortMode="value"></div>
100            </td>
101        </tr>
102        <tr valign="top">
103            <td ex:role="viewPanel">
104    
105                <div ex:role="view" ex:viewClass="Timeline" ex:start=".date"
106                    ex:colorKey=".author"
107                    ex:topBandUnit="week" ex:topBandPixelsPerUnit="200"
108                    ex:bottomBandUnit="month" ex:bottomBandPixelsPerUnit="25"
109                    ex:timelineHeight="650" />
110                
111                <div ex:role="view" ex:viewClass="Tabular"
112                    ex:columns=".revision, .author, .date, .path, .action, .copyfrom-path, .copyfrom-rev, .msg"
113                    />
114            </td>
115    
116        </tr>
117    </table>
118    
119    </body>
120    </html>
121            |;
122            exit;
123    }
124    
125  my $json = {  my $json = {
126          properties => {          properties => {
# Line 30  my $json = { Line 136  my $json = {
136    
137  my $log;  my $log;
138  {  {
139          open( my $log_fh, '-|', "svn log --xml --stop-on-copy -v $repository" ) || die "can't read svn log: $!";          open( my $log_fh, '-|', "svn log --xml --stop-on-copy -v file://$repository_dir/$repository" ) || die "can't read svn log: $!";
140          local $/ = undef;          local $/ = undef;
141          $log = <$log_fh>;          $log = <$log_fh>;
142          close( $log_fh );          close( $log_fh );
# Line 43  warn dump( $xml ) if $debug; Line 149  warn dump( $xml ) if $debug;
149  foreach my $e (@{$xml->{'logentry'}}) {  foreach my $e (@{$xml->{'logentry'}}) {
150    
151          foreach my $p (@{$e->{'paths'}->{'path'}}) {          foreach my $p (@{$e->{'paths'}->{'path'}}) {
152                  my $label = $e->{'revision'} . ' - ' . $p->{'content'};                  my $path = delete( $p->{'content'} );
153                    my $label = $e->{'revision'} . ' - ' . path_strip( $path );
154                  my $item = {                  my $item = {
155                          type => 'Item',                          type => 'Item',
156                          id => $label,                          id => $label,
157                          label => $label,                          label => $label,
158                          uri => $svnweb . $e->{'revision'},                          uri => sprintf($svnweb, $repository, $e->{'revision'}),
159                          path => delete( $p->{'content'} ),                          path_full => $path,
160                            path => path_strip( $path ),
161                  };                  };
162    
163                  $item->{$_} = $p->{$_} foreach keys %$p;                  $item->{$_} = $p->{$_} foreach grep { ! defined $item->{$_} } keys %$p;
164                  $item->{$_} = $e->{$_} foreach grep { ! /^(paths)$/ } keys %$e;                  $item->{$_} = $e->{$_} foreach grep { ! defined $item->{$_} && ! /^(paths)$/ } keys %$e;
   
                 $item->{'path'} =~ s!^/[^/]+/[^/]+/!/!;  
165    
166                  warn dump( $item ) if $debug;                  warn dump( $item ) if $debug;
167    

Legend:
Removed from v.14  
changed lines
  Added in v.17

  ViewVC Help
Powered by ViewVC 1.1.26