/[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 36 by dpavlin, Sat Oct 25 15:38:03 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    my $config = from_json( read_file( $config_path ) );
19    my $repository_dir = $config->{repository_dir} || die "no repository_dir in $config_path";
20    my $svnweb = $config->{svnweb} || die "no svnweb in $config_path";
21    
22  my $repository_dir = '/srv/svn';  my $limit = 1000;
 my $svnweb = 'https://svn-strix.carnet.hr/private/svnweb/index.cgi/%s/revision?rev=%d';  
 my $strip_branch = s!^/(branches/)?[^/]+/!/!;  
   
 # my local config for development  
 $repository_dir = '/home/dpavlin/private/svn';  
 $svnweb = 'http://localhost/svnweb/index.cgi/%s/revision?rev=%d';  
 $strip_branch = s!!!;  
23    
24  # for older JSON  # for older JSON
25  #sub encode_json { objToJson( @_ ) }  #sub encode_json { objToJson( @_ ) }
26    
27  sub path_strip {  sub path_strip {
28          my $path = shift;          my $path = shift;
29          $path =~ $strip_branch;  #       $path =~ $strip_branch;
30          return $path;          return $path;
31  }  }
32    
# Line 38  closedir($dir); Line 36  closedir($dir);
36    
37  our $q = CGI->new;  our $q = CGI->new;
38  my $repository = $q->param('repository');  my $repository = $q->param('repository');
39  $repository = (grep { m/^\Q$repository\E$/ } @repositories )[0];  $repository = (grep { m/^\Q$repository\E$/ } @repositories )[0] if $repository;
40    
41    warn "q = ",dump( $q );
42    warn "# limit: ", $q->param('limit');
43    
44  sub select_repository {  sub select_repository {
45          $q->start_form( -name => 'current_repository', -id => 'current_repository' ),          my $onChange = qq{document.getElementById('current_repository').submit();};
46          "Select repository: ",          return (
47          $q->popup_menu( -name => 'repository', -values => [ @repositories ], -onChange => qq{document.getElementById('current_repository').submit();} ),                  $q->start_form( -name => 'current_repository', -id => 'current_repository', -method => 'post' ),
48          $q->submit,                  "From repository ",
49          $q->end_form;                  $q->popup_menu( -name => 'repository', -values => [ @repositories ], -onChange => $onChange ),
50                    " show ",
51                    $q->popup_menu( -name => 'limit', -values => [ qw/100 500 1000 5000 10000/ ], -onChange => $onChange ),
52                    " revisions with ",
53                    $q->checkbox(-name=>'path', -checked=>1, -value=>'ON', -label=>'path modifications', -onChange => $onChange ),
54                    $q->submit,
55                    $q->end_form
56            );
57  }  }
58    
59  if ( ! $repository ) {  if ( ! $repository ) {
# Line 60  if ( ! $repository ) { Line 68  if ( ! $repository ) {
68    
69             <link rel="exhibit/data"             <link rel="exhibit/data"
70      type="application/json"      type="application/json"
71      href="?repository=$repository&json=1" />      href="|, $q->url( -query => 1 ), qq|&json=1" />
72    
73    <!--
74  <script  <script
75          src="http://static.simile.mit.edu/exhibit/api-2.0/exhibit-api.js"          src="http://static.simile.mit.edu/exhibit/api-2.0/exhibit-api.js"
76          type="text/javascript"></script>          type="text/javascript"></script>
77    
78  <script  <script
79          src="http://static.simile.mit.edu/exhibit/extensions-2.0/time/time-extension.js"></script>          src="http://static.simile.mit.edu/exhibit/extensions-2.0/time/time-extension.js"></script>
80    -->
81    
82    <script
83            src="../exhibit/api/exhibit-api.js"
84            type="text/javascript"></script>
85    <script
86            src="..//exhibit/extensions/time/time-extension.js"></script>
87    
88    
89  </head>  </head>
90  <body>  <body>
# Line 82  if ( ! $repository ) { Line 99  if ( ! $repository ) {
99                    
100              <div ex:role="facet" ex:expression=".author" ex:facetLabel="Author"              <div ex:role="facet" ex:expression=".author" ex:facetLabel="Author"
101                  ex:sortMode="count"></div>                  ex:sortMode="count"></div>
102        |, $q->param('path') ?
103    qq|
104              <div ex:role="facet" ex:expression=".action" ex:facetLabel="Action"              <div ex:role="facet" ex:expression=".action" ex:facetLabel="Action"
105                  ex:sortMode="count" ex:scroll="false"></div>                  ex:sortMode="count" ex:scroll="false"></div>
106                    | : '',
107    qq|
108              <div ex:role="facet" ex:expression=".revision" ex:facetClass="NumericRange"              <div ex:role="facet" ex:expression=".revision" ex:facetClass="NumericRange"
109                  ex:interval="10" ex:scroll="true"></div>                  ex:interval="20" ex:scroll="true"></div>
110                    |, $q->param('path') ?
111    qq|
112              <div ex:role="facet" ex:expression=".path" ex:facetLabel="Path by Count"              <div ex:role="facet" ex:expression=".path" ex:facetLabel="Path by Count"
113                  ex:sortMode="count"></div>                  ex:sortMode="count"></div>
114                    | : '',
115    qq|
116          </td>          </td>
117          <td>          <td>
118                    
# Line 106  if ( ! $repository ) { Line 127  if ( ! $repository ) {
127                  ex:colorKey=".author"                  ex:colorKey=".author"
128                  ex:topBandUnit="week" ex:topBandPixelsPerUnit="200"                  ex:topBandUnit="week" ex:topBandPixelsPerUnit="200"
129                  ex:bottomBandUnit="month" ex:bottomBandPixelsPerUnit="25"                  ex:bottomBandUnit="month" ex:bottomBandPixelsPerUnit="25"
130                  ex:timelineHeight="650" />                  ex:timelineHeight="550" />
131                            
132              <div ex:role="view" ex:viewClass="Tabular"              <div ex:role="view" ex:viewClass="Tabular"
133                  ex:columns=".revision, .author, .date, .path, .action, .copyfrom-path, .copyfrom-rev, .msg"                  ex:columns=".revision, .author, .date, .PATH, .action, .copyfrom-path, .copyfrom-rev, .msg"
134                  />                  />
135          </td>          </td>
136    
# Line 136  my $json = { Line 157  my $json = {
157    
158  my $log;  my $log;
159  {  {
160          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";
161            warn "cmd: $cmd\n";
162            open( my $log_fh, '-|', $cmd) || die "can't read svn log: $!";
163          local $/ = undef;          local $/ = undef;
164          $log = <$log_fh>;          $log = <$log_fh>;
165          close( $log_fh );          close( $log_fh );
# Line 167  foreach my $e (@{$xml->{'logentry'}}) { Line 190  foreach my $e (@{$xml->{'logentry'}}) {
190    
191                  push @{ $json->{items} }, $item;                  push @{ $json->{items} }, $item;
192    
193                  $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;  
194          }          }
195    
         last if ! $max_items;  
196  }  }
197    
198  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.36

  ViewVC Help
Powered by ViewVC 1.1.26