Revision 15
- Date:
- 2008/10/06 09:41:28
- Files:
Legend:
- Added
- Removed
- Modified
-
svn/svn2js.cgi
13 13 14 14 my $max_items = 500; 15 15 16 my $repository = 'file:///home/dpavlin/.svk/strix4/'; 17 my $svnweb = 'http://localhost/svnweb/svk/index.cgi/strix4/revision?rev='; 16 my $repository = 'file:///srv/svn/strix/'; 17 my $svnweb = 'https://svn-strix.carnet.hr/private/svnweb/index.cgi/strix/revision?rev='; 18 18 19 # for older JSON 20 sub encode_json { objToJson( @_ ) } 21 22 sub path_strip { 23 my $path = shift; 24 # $path =~ s!^/[^/]+/[^/]+/!/!; 25 $path =~ s!^/(branches/)?[^/]+/!/!; 26 return $path; 27 } 28 19 29 my $json = { 20 30 properties => { 21 31 revision => { … … 43 53 foreach my $e (@{$xml->{'logentry'}}) { 44 54 45 55 foreach my $p (@{$e->{'paths'}->{'path'}}) { 46 my $label = $e->{'revision'} . ' - ' . $p->{'content'}; 56 my $path = delete( $p->{'content'} ); 57 my $label = $e->{'revision'} . ' - ' . path_strip( $path ); 47 58 my $item = { 48 59 type => 'Item', 49 60 id => $label, 50 61 label => $label, 51 62 uri => $svnweb . $e->{'revision'}, 52 path => delete( $p->{'content'} ), 63 path_full => $path, 64 path => path_strip( $path ), 53 65 }; 54 66 55 $item->{$_} = $p->{$_} foreach keys %$p; 56 $item->{$_} = $e->{$_} foreach grep { ! /^(paths)$/ } keys %$e; 67 $item->{$_} = $p->{$_} foreach grep { ! defined $item->{$_} } keys %$p; 68 $item->{$_} = $e->{$_} foreach grep { ! defined $item->{$_} && ! /^(paths)$/ } keys %$e; 57 69 58 $item->{'path'} =~ s!^/[^/]+/[^/]+/!/!; 59 60 70 warn dump( $item ) if $debug; 61 71 62 72 push @{ $json->{items} }, $item;