Author: wave
Date: Tue May 15 23:53:32 2012
New Revision: 1338953
URL: http://svn.apache.org/viewvc?rev=1338953&view=rev
Log:
Change view.pm to find the deepest ssi.mdtext that follows the parallel path
within the templates directory.
Modified:
incubator/ooo/ooo-site/trunk/lib/view.pm
Modified: incubator/ooo/ooo-site/trunk/lib/view.pm
URL:
http://svn.apache.org/viewvc/incubator/ooo/ooo-site/trunk/lib/view.pm?rev=1338953&r1=1338952&r2=1338953&view=diff
==============================================================================
--- incubator/ooo/ooo-site/trunk/lib/view.pm (original)
+++ incubator/ooo/ooo-site/trunk/lib/view.pm Tue May 15 23:53:32 2012
@@ -41,26 +41,12 @@ sub single_narrative {
read_text_file $f, $args{$1};
}
}
- # default navbars and mdtext from templates/ssi.mdtext.
- my $templates_folder = "templates";
- if (-d $templates_folder) {
- for my $f (grep -f, "$templates_folder/ssi.mdtext") {
- $f =~ m!/([^/]+)\.mdtext$! or die "Bad filename: $f\n";
- $args{$1} = {};
- read_text_file $f, $args{$1};
- }
- }
- # folder specific overrides
- $templates_folder = templatesfolder($args{path});
- $args{templates_folder} = $templates_folder;
- if (-d $templates_folder) {
- for my $f (grep -f, "$templates_folder/ssi.mdtext") {
- $f =~ m!/([^/]+)\.mdtext$! or die "Bad filename: $f\n";
- $args{$1} = {};
- read_text_file $f, $args{$1};
- }
- }
-
+
+ # get ssi information from templates/**/ssi.mdtext where ** matches the
content path.
+ my $ssi_header_file = ssiheaderfile($args{path});
+ $args{ssi} = {};
+ read_text_file $ssi_header_file, $args{ssi};
+
$args{content} = sort_tables($args{content});
my $style_path = $file;
@@ -100,25 +86,11 @@ sub html_page {
read_text_file $f, $args{$1};
}
}
- # default navbars and mdtext from templates/ssi.mdtext.
- my $templates_folder = "templates";
- if (-d $templates_folder) {
- for my $f (grep -f, "$templates_folder/ssi.mdtext") {
- $f =~ m!/([^/]+)\.mdtext$! or die "Bad filename: $f\n";
- $args{$1} = {};
- read_text_file $f, $args{$1};
- }
- }
- # folder specific overrides
- $templates_folder = templatesfolder($args{path});
- $args{templates_folder} = $templates_folder;
- if (-d $templates_folder) {
- for my $f (grep -f, "$templates_folder/ssi.mdtext") {
- $f =~ m!/([^/]+)\.mdtext$! or die "Bad filename: $f\n";
- $args{$1} = {};
- read_text_file $f, $args{$1};
- }
- }
+
+ # get ssi information from templates/**/ssi.mdtext where ** matches the
content path.
+ my $ssi_header_file = ssiheaderfile($args{path});
+ $args{ssi} = {};
+ read_text_file $ssi_header_file, $args{ssi};
if ($args{content} =~
m!<head.*?>(.*?)</head>(?:.*?<body(.*?)>)?(.*?)(?:</body>|\Z)!si) {
@args{qw/header bodytag content/} = ($1, $2, $3);
@@ -191,6 +163,22 @@ sub templatesfolder {
return $relpath;
}
+sub ssiheaderfile {
+ my @path = split m!/!, shift;
+ pop @path;
+ my $ssipath = "templates/ssi.mdtext";
+ my $relpath = "templates/";
+
+# get the deepest
+ for (@path) {
+ $relpath .= "$_/";
+ if (-e "$relpath/ssi.mdtext") {
+ $ssipath = "$relpath/ssi.mdtext";
+ }
+ }
+ return $ssipath;
+}
+
1;
=head1 LICENSE