You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@tomee.apache.org by db...@apache.org on 2012/02/15 02:06:53 UTC
svn commit: r1244297 - /openejb/site/trunk/lib/view.pm
Author: dblevins
Date: Wed Feb 15 01:06:53 2012
New Revision: 1244297
URL: http://svn.apache.org/viewvc?rev=1244297&view=rev
Log:
Fixed breadcrumb links
Added ability to resolve relative links in {include:some/file.mdtext} usage
Modified:
openejb/site/trunk/lib/view.pm
Modified: openejb/site/trunk/lib/view.pm
URL: http://svn.apache.org/viewvc/openejb/site/trunk/lib/view.pm?rev=1244297&r1=1244296&r2=1244297&view=diff
==============================================================================
--- openejb/site/trunk/lib/view.pm (original)
+++ openejb/site/trunk/lib/view.pm Wed Feb 15 01:06:53 2012
@@ -90,6 +90,15 @@ sub basic {
read_text_file("content/$include", \%a);
my $text = $a{content};
$args{headers}{title} = $a{headers}{title} unless $args{headers}{title};
+
+ # If the file to be included is in a child directory, resolve all the links
+ # in the included content to be relative to this document
+ if ($include =~ m,/,) {
+ my $ipath = $include;
+ $ipath =~ s,/[^/]*$,,;
+ $text =~ s,(\[[^[]+])\(([^/][^)]+)\),$1($ipath/$2),g;
+ }
+
$args{content} =~ s/{include:$include}/$text/g;
}
@@ -224,8 +233,11 @@ sub _breadcrumbs {
my $path = shift;
my $base = shift;
+ my $index = "$base/index.html";
+ $index =~ s,/+,/,g;
+
my @breadcrumbs = (
- qq|<a href="$base/index.html">Home</a>|,
+ qq|<a href="$index">Home</a>|,
);
my @path_components = split( m!/!, $path );
pop @path_components;
@@ -235,6 +247,7 @@ sub _breadcrumbs {
for (@path_components) {
$relpath .= "$_/";
+ $relpath =~ s,/+,/,g;
next unless $_;
my @names = split("-", $_);
@@ -243,7 +256,6 @@ sub _breadcrumbs {
$name .= ucfirst($n) . " ";
}
$name =~ s/ *$//;
-
push @breadcrumbs, qq(<a href="$relpath">\u$name</a>);
}
return join " » ", @breadcrumbs;