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

revision 16 by dpavlin, Mon Oct 6 17:09:17 2008 UTC revision 49 by dpavlin, Tue Oct 28 19:10:16 2008 UTC
# Line 9  use XML::Simple; Line 9  use XML::Simple;
9  use Data::Dump qw/dump/;  use Data::Dump qw/dump/;
10  use JSON;  use JSON;
11  use CGI;  use CGI;
12    use File::Slurp;
13    
14  my $debug = 0;  my $debug = $ENV{'DEBUG'} || 0;
15    
16  my $max_items = 500;  my $config_path = $0;
17    $config_path =~ s/.cgi/.js/;
18    
19  my $repository_dir = '/srv/svn';  my $hostname = `hostname -s`;
20  my $svnweb = 'https://svn-strix.carnet.hr/private/svnweb/index.cgi/%s/revision?rev=%d';  chomp($hostname);
21  my $strip_branch = s!^/(branches/)?[^/]+/!/!;  $hostname .= '.js';
22    $config_path = $hostname if -e $hostname;
23  # my local config for development  
24  $repository_dir = '/home/dpavlin/private/svn';  my $config = from_json( read_file( $config_path ) );
25  $svnweb = 'http://localhost/svnweb/index.cgi/%s/revision?rev=%d';  my $repository_dir = $config->{repository_dir} || die "no repository_dir in $config_path";
26  $strip_branch = s!!!;  my $svnweb = $config->{svnweb} || die "no svnweb in $config_path";
27    die "no js URLs to Exhibit API and/or plugins" unless $config->{js};
28    
29    my $limit = 1000;
30    
31  # for older JSON  # for older JSON
32  #sub encode_json { objToJson( @_ ) }  #sub encode_json { objToJson( @_ ) }
33    
34  sub path_strip {  sub path_strip {
35          my $path = shift;          my $path = shift;
36          $path =~ $strip_branch;  #       $path =~ $strip_branch;
37          return $path;          return $path;
38  }  }
39    
# Line 38  closedir($dir); Line 43  closedir($dir);
43    
44  our $q = CGI->new;  our $q = CGI->new;
45  my $repository = $q->param('repository');  my $repository = $q->param('repository');
46  $repository = (grep { m/^\Q$repository\E$/ } @repositories )[0];  $repository = (grep { m/^\Q$repository\E$/ } @repositories )[0] if $repository;
47    
48    warn "q = ",dump( $q );
49    warn "# limit: ", $q->param('limit');
50    
51  sub select_repository {  sub select_repository {
52          $q->start_form( -name => 'current_repository', -id => 'current_repository' ),          my $onChange = qq{document.getElementById('current_repository').submit();};
53          "Select repository: ",          # we want to activete javascript magic refresh after we hit submit for the first time, and not always
54          $q->popup_menu( -name => 'repository', -values => [ @repositories ], -onChange => qq{document.getElementById('current_repository').submit();} ),          $onChange = '' unless $q->param('did_submit');
55          $q->submit,          my $first_letter = substr($repositories[0],0,1);
56          $q->end_form;          return (
57                    $q->start_form( -name => 'current_repository', -id => 'current_repository', -method => 'post' ),
58                    "From repository ",
59                    $q->param('did_submit') ?
60                            $q->popup_menu( -name => 'repository', -values => [ @repositories ], -onChange => $onChange ) :
61                            "<table><tr><th>$first_letter</th><td>" . join( '', map {
62                                    my $delimiter = '';
63                                    if ( substr($_,0,1) ne $first_letter ) {
64                                            $first_letter = substr($_,0,1);
65                                            $delimiter = "</td></tr>\n<tr><th>$first_letter</th><td>";
66                                    }
67                                    $delimiter . $q->radio_group( -name => 'repository', -values => [ $_ ] )
68                            } @repositories ) . "<td></tr></table>",
69                            #$q->radio_group( -name => 'repository', -values => [ map { "$_, " } @repositories ], -onChange => $onChange ), # , -linebreak => 'true' ),
70                    " show ",
71                    $q->popup_menu( -name => 'limit', -values => [ qw/100 500 1000 5000 10000/ ], -onChange => $onChange ),
72                    " revisions and ",
73                    $q->checkbox(-name=>'path', -checked=>1, -value=>'ON', -label=>'path modifications', -onChange => $onChange ),
74                    " ",
75                    $q->submit(-value=>'in Exhibit'),
76                    $q->hidden(-name=>'did_submit', -value=>1),
77                    $q->end_form
78            );
79  }  }
80    
81  if ( ! $repository ) {  if ( ! $repository ) {
# Line 60  if ( ! $repository ) { Line 90  if ( ! $repository ) {
90    
91             <link rel="exhibit/data"             <link rel="exhibit/data"
92      type="application/json"      type="application/json"
93      href="?repository=$repository&json=1" />      href="|, $q->url( -query => 1 ), qq|&json=1" />
   
 <script  
         src="http://static.simile.mit.edu/exhibit/api-2.0/exhibit-api.js"  
         type="text/javascript"></script>  
94    
95  <script  |, join("\n", map { qq|<script src="$_" type="text/javascript"></script>| } @{ $config->{js} } ), qq|
         src="http://static.simile.mit.edu/exhibit/extensions-2.0/time/time-extension.js"></script>  
96    
97  </head>  </head>
98  <body>  <body>
# Line 82  if ( ! $repository ) { Line 107  if ( ! $repository ) {
107                    
108              <div ex:role="facet" ex:expression=".author" ex:facetLabel="Author"              <div ex:role="facet" ex:expression=".author" ex:facetLabel="Author"
109                  ex:sortMode="count"></div>                  ex:sortMode="count"></div>
110        |, $q->param('path') ?
111    qq|
112              <div ex:role="facet" ex:expression=".action" ex:facetLabel="Action"              <div ex:role="facet" ex:expression=".action" ex:facetLabel="Action"
113                  ex:sortMode="count" ex:scroll="false"></div>                  ex:sortMode="count" ex:scroll="false"></div>
114                    | : '',
115    qq|
116              <div ex:role="facet" ex:expression=".revision" ex:facetClass="NumericRange"              <div ex:role="facet" ex:expression=".revision" ex:facetClass="NumericRange"
117                  ex:interval="10" ex:scroll="true"></div>                  ex:interval="20" ex:scroll="true"></div>
118                    |, $q->param('path') ?
119    qq|
120              <div ex:role="facet" ex:expression=".path" ex:facetLabel="Path by Count"              <div ex:role="facet" ex:expression=".path" ex:facetLabel="Path by Count"
121                  ex:sortMode="count"></div>                  ex:sortMode="count"></div>
122                    | : '',
123    qq|
124          </td>          </td>
125          <td>          <td>
126                    
# Line 106  if ( ! $repository ) { Line 135  if ( ! $repository ) {
135                  ex:colorKey=".author"                  ex:colorKey=".author"
136                  ex:topBandUnit="week" ex:topBandPixelsPerUnit="200"                  ex:topBandUnit="week" ex:topBandPixelsPerUnit="200"
137                  ex:bottomBandUnit="month" ex:bottomBandPixelsPerUnit="25"                  ex:bottomBandUnit="month" ex:bottomBandPixelsPerUnit="25"
138                  ex:timelineHeight="650" />                  ex:timelineHeight="550" />
139                            
140              <div ex:role="view" ex:viewClass="Tabular"              <div ex:role="view" ex:viewClass="Tabular"
141                  ex:columns=".revision, .author, .date, .path, .action, .copyfrom-path, .copyfrom-rev, .msg"                  ex:columns=".revision, .author, .date, .PATH, .action, .copyfrom-path, .copyfrom-rev, .msg"
142                  />                  />
143          </td>          </td>
144    
# Line 136  my $json = { Line 165  my $json = {
165    
166  my $log;  my $log;
167  {  {
168          open( my $log_fh, '-|', "svn log --xml --stop-on-copy -v file://$repository_dir/$repository" ) || die "can't read svn log: $!";          my $cmd = "svn log --xml --stop-on-copy -v --limit " . ( $q->param('limit') || $limit ) . " file://$repository_dir/$repository";
169            warn "cmd: $cmd\n";
170            open( my $log_fh, '-|', $cmd) || die "can't read svn log: $!";
171          local $/ = undef;          local $/ = undef;
172          $log = <$log_fh>;          $log = <$log_fh>;
173          close( $log_fh );          close( $log_fh );
# Line 167  foreach my $e (@{$xml->{'logentry'}}) { Line 198  foreach my $e (@{$xml->{'logentry'}}) {
198    
199                  push @{ $json->{items} }, $item;                  push @{ $json->{items} }, $item;
200    
201                  $max_items--;                  last if ! $q->param('path');
                 # we skip all other items in commits with more than 10 files as they are too chatty  
                 last if $#{ $e->{'paths'}->{'path'} } > 10;  
 #               last; # FIXME record just single item for each commit!  
                 # we also break out when $max_items is reached to keep browser (somewhat) alive  
                 last if ! $max_items;  
202          }          }
203    
         last if ! $max_items;  
204  }  }
205    
206  print qq|Content-type: application/json\n\r\n\r|, encode_json( $json );  print qq|Content-type: application/json\n\r\n\r|, encode_json( $json );

Legend:
Removed from v.16  
changed lines
  Added in v.49

  ViewVC Help
Powered by ViewVC 1.1.26