You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@sling.apache.org by fm...@apache.org on 2012/05/20 00:10:01 UTC
svn commit: r1340578 - /sling/site/trunk/lib/view.pm
Author: fmeschbe
Date: Sat May 19 22:10:01 2012
New Revision: 1340578
URL: http://svn.apache.org/viewvc?rev=1340578&view=rev
Log:
SLING-2002 Fix breadcrumb and use SVN client to extract last modification information from SVN to be used in the template
Modified:
sling/site/trunk/lib/view.pm
Modified: sling/site/trunk/lib/view.pm
URL: http://svn.apache.org/viewvc/sling/site/trunk/lib/view.pm?rev=1340578&r1=1340577&r2=1340578&view=diff
==============================================================================
--- sling/site/trunk/lib/view.pm (original)
+++ sling/site/trunk/lib/view.pm Sat May 19 22:10:01 2012
@@ -14,6 +14,7 @@ use Dotiac::DTL::Addon::markup;
use ASF::Util qw/read_text_file shuffle/;
use File::Temp qw/tempfile/;
use LWP::Simple;
+use SVN::Client;
push @Dotiac::DTL::TEMPLATE_DIRS, "templates";
@@ -30,6 +31,7 @@ sub single_narrative {
my $template = $args{template};
$args{path} =~ s/\.mdtext$/\.html/;
$args{breadcrumbs} = breadcrumbs($args{path});
+ $args{svninfo} = svninfo($file);
read_text_file $file, \%args;
@@ -172,15 +174,47 @@ sub breadcrumbs {
pop @path;
my @rv;
my $relpath = "";
+ my $ext;
+ my $sep = "/";
for (@path) {
- $relpath .= "$_/";
- $_ ||= "Home";
- push @rv, qq(<a href="$relpath">\u$_</a>);
+ $relpath .= "$sep$_";
+ if ($_) {
+ $ext = ".html";
+ $sep = "/";
+ s/-/ /g;
+ s/(\w+)/\u\L$1/g;
+ } else {
+ $_ = "Home";
+ $ext = "";
+ $sep = "";
+ }
+ push @rv, qq(<a href="$relpath$ext">$_</a>);
}
return join " » ", @rv;
}
+# Returns information on the last change to the file
+# as a reference to a has with three properties
+# - rev The SVN Revision
+# - date The last modification date (seconds since the epoch)
+# - author of the revision
+sub svninfo {
+ my $source = $_[0];
+ my %info;
+ my $receiver = sub {
+ my $svninfo = $_[1];
+ $info{rev} = $svninfo->last_changed_rev;
+ $info{date} = $svninfo->last_changed_date / 1000000;
+ $info{author} = $svninfo->last_changed_author;
+ };
+
+ my $ctx = SVN::Client->new;
+ $ctx->info($source, undef, undef, $receiver, 0);
+ return \%info;
+}
+
+
=head1 LICENSE
Licensed to the Apache Software Foundation (ASF) under one