--- svn/svn2js.cgi 2008/10/05 18:45:10 14 +++ svn/svn2js.cgi 2008/10/06 09:41:28 15 @@ -13,8 +13,18 @@ my $max_items = 500; -my $repository = 'file:///home/dpavlin/.svk/strix4/'; -my $svnweb = 'http://localhost/svnweb/svk/index.cgi/strix4/revision?rev='; +my $repository = 'file:///srv/svn/strix/'; +my $svnweb = 'https://svn-strix.carnet.hr/private/svnweb/index.cgi/strix/revision?rev='; + +# for older JSON +sub encode_json { objToJson( @_ ) } + +sub path_strip { + my $path = shift; +# $path =~ s!^/[^/]+/[^/]+/!/!; + $path =~ s!^/(branches/)?[^/]+/!/!; + return $path; +} my $json = { properties => { @@ -43,19 +53,19 @@ foreach my $e (@{$xml->{'logentry'}}) { foreach my $p (@{$e->{'paths'}->{'path'}}) { - my $label = $e->{'revision'} . ' - ' . $p->{'content'}; + my $path = delete( $p->{'content'} ); + my $label = $e->{'revision'} . ' - ' . path_strip( $path ); my $item = { type => 'Item', id => $label, label => $label, uri => $svnweb . $e->{'revision'}, - path => delete( $p->{'content'} ), + path_full => $path, + path => path_strip( $path ), }; - $item->{$_} = $p->{$_} foreach keys %$p; - $item->{$_} = $e->{$_} foreach grep { ! /^(paths)$/ } keys %$e; - - $item->{'path'} =~ s!^/[^/]+/[^/]+/!/!; + $item->{$_} = $p->{$_} foreach grep { ! defined $item->{$_} } keys %$p; + $item->{$_} = $e->{$_} foreach grep { ! defined $item->{$_} && ! /^(paths)$/ } keys %$e; warn dump( $item ) if $debug;