/[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 47 by dpavlin, Mon Oct 27 20:34:27 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    die "no js URLs to Exhibit API and/or plugins" unless $config->{js};
22    
23  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!!!;  
24    
25  # for older JSON  # for older JSON
26  #sub encode_json { objToJson( @_ ) }  #sub encode_json { objToJson( @_ ) }
27    
28  sub path_strip {  sub path_strip {
29          my $path = shift;          my $path = shift;
30          $path =~ $strip_branch;  #       $path =~ $strip_branch;
31          return $path;          return $path;
32  }  }
33    
# Line 38  closedir($dir); Line 37  closedir($dir);
37    
38  our $q = CGI->new;  our $q = CGI->new;
39  my $repository = $q->param('repository');  my $repository = $q->param('repository');
40  $repository = (grep { m/^\Q$repository\E$/ } @repositories )[0];  $repository = (grep { m/^\Q$repository\E$/ } @repositories )[0] if $repository;
41    
42    warn "q = ",dump( $q );
43    warn "# limit: ", $q->param('limit');
44    
45  sub select_repository {  sub select_repository {
46          $q->start_form( -name => 'current_repository', -id => 'current_repository' ),          my $onChange = qq{document.getElementById('current_repository').submit();};
47          "Select repository: ",          # we want to activete javascript magic refresh after we hit submit for the first time, and not always
48          $q->popup_menu( -name => 'repository', -values => [ @repositories ], -onChange => qq{document.getElementById('current_repository').submit();} ),          $onChange = '' unless $q->param('did_submit');
49          $q->submit,          return (
50          $q->end_form;                  $q->start_form( -name => 'current_repository', -id => 'current_repository', -method => 'post' ),
51                    "From repository ",
52                    $q->param('did_submit') ?
53                            $q->popup_menu( -name => 'repository', -values => [ @repositories ], -onChange => $onChange ) :
54                            $q->radio_group( -name => 'repository', -values => [ @repositories ], -onChange => $onChange ), # , -linebreak => 'true' ),
55                    " show ",
56                    $q->popup_menu( -name => 'limit', -values => [ qw/100 500 1000 5000 10000/ ], -onChange => $onChange ),
57                    " revisions and ",
58                    $q->checkbox(-name=>'path', -checked=>1, -value=>'ON', -label=>'path modifications', -onChange => $onChange ),
59                    " ",
60                    $q->submit(-value=>'in Exhibit'),
61                    $q->hidden(-name=>'did_submit', -value=>1),
62                    $q->end_form
63            );
64  }  }
65    
66  if ( ! $repository ) {  if ( ! $repository ) {
# Line 60  if ( ! $repository ) { Line 75  if ( ! $repository ) {
75    
76             <link rel="exhibit/data"             <link rel="exhibit/data"
77      type="application/json"      type="application/json"
78      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>  
79    
80  <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>  
81    
82  </head>  </head>
83  <body>  <body>
# Line 82  if ( ! $repository ) { Line 92  if ( ! $repository ) {
92                    
93              <div ex:role="facet" ex:expression=".author" ex:facetLabel="Author"              <div ex:role="facet" ex:expression=".author" ex:facetLabel="Author"
94                  ex:sortMode="count"></div>                  ex:sortMode="count"></div>
95        |, $q->param('path') ?
96    qq|
97              <div ex:role="facet" ex:expression=".action" ex:facetLabel="Action"              <div ex:role="facet" ex:expression=".action" ex:facetLabel="Action"
98                  ex:sortMode="count" ex:scroll="false"></div>                  ex:sortMode="count" ex:scroll="false"></div>
99                    | : '',
100    qq|
101              <div ex:role="facet" ex:expression=".revision" ex:facetClass="NumericRange"              <div ex:role="facet" ex:expression=".revision" ex:facetClass="NumericRange"
102                  ex:interval="10" ex:scroll="true"></div>                  ex:interval="20" ex:scroll="true"></div>
103                    |, $q->param('path') ?
104    qq|
105              <div ex:role="facet" ex:expression=".path" ex:facetLabel="Path by Count"              <div ex:role="facet" ex:expression=".path" ex:facetLabel="Path by Count"
106                  ex:sortMode="count"></div>                  ex:sortMode="count"></div>
107                    | : '',
108    qq|
109          </td>          </td>
110          <td>          <td>
111                    
# Line 106  if ( ! $repository ) { Line 120  if ( ! $repository ) {
120                  ex:colorKey=".author"                  ex:colorKey=".author"
121                  ex:topBandUnit="week" ex:topBandPixelsPerUnit="200"                  ex:topBandUnit="week" ex:topBandPixelsPerUnit="200"
122                  ex:bottomBandUnit="month" ex:bottomBandPixelsPerUnit="25"                  ex:bottomBandUnit="month" ex:bottomBandPixelsPerUnit="25"
123                  ex:timelineHeight="650" />                  ex:timelineHeight="550" />
124                            
125              <div ex:role="view" ex:viewClass="Tabular"              <div ex:role="view" ex:viewClass="Tabular"
126                  ex:columns=".revision, .author, .date, .path, .action, .copyfrom-path, .copyfrom-rev, .msg"                  ex:columns=".revision, .author, .date, .PATH, .action, .copyfrom-path, .copyfrom-rev, .msg"
127                  />                  />
128          </td>          </td>
129    
# Line 136  my $json = { Line 150  my $json = {
150    
151  my $log;  my $log;
152  {  {
153          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";
154            warn "cmd: $cmd\n";
155            open( my $log_fh, '-|', $cmd) || die "can't read svn log: $!";
156          local $/ = undef;          local $/ = undef;
157          $log = <$log_fh>;          $log = <$log_fh>;
158          close( $log_fh );          close( $log_fh );
# Line 167  foreach my $e (@{$xml->{'logentry'}}) { Line 183  foreach my $e (@{$xml->{'logentry'}}) {
183    
184                  push @{ $json->{items} }, $item;                  push @{ $json->{items} }, $item;
185    
186                  $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;  
187          }          }
188    
         last if ! $max_items;  
189  }  }
190    
191  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.47

  ViewVC Help
Powered by ViewVC 1.1.26