You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@thrift.apache.org by jo...@apache.org on 2014/03/18 04:32:16 UTC

svn commit: r1578731 - in /thrift/cms-site/trunk/lib: path.pm view.pm

Author: joes
Date: Tue Mar 18 03:32:15 2014
New Revision: 1578731

URL: http://svn.apache.org/r1578731
Log:
docs

Modified:
    thrift/cms-site/trunk/lib/path.pm
    thrift/cms-site/trunk/lib/view.pm

Modified: thrift/cms-site/trunk/lib/path.pm
URL: http://svn.apache.org/viewvc/thrift/cms-site/trunk/lib/path.pm?rev=1578731&r1=1578730&r2=1578731&view=diff
==============================================================================
--- thrift/cms-site/trunk/lib/path.pm (original)
+++ thrift/cms-site/trunk/lib/path.pm Tue Mar 18 03:32:15 2014
@@ -8,7 +8,7 @@ our @patterns = (
         conf     => $conf,
         template => 'default.html',
         view     => 'single_narrative',
-        dir      => "/docs",
+        dir      => "/docs/",
     }],
     [qr/\.md(?:text)?$/, single_narrative => {conf => $conf, template => 'default.html'}],
 );

Modified: thrift/cms-site/trunk/lib/view.pm
URL: http://svn.apache.org/viewvc/thrift/cms-site/trunk/lib/view.pm?rev=1578731&r1=1578730&r2=1578731&view=diff
==============================================================================
--- thrift/cms-site/trunk/lib/view.pm (original)
+++ thrift/cms-site/trunk/lib/view.pm Tue Mar 18 03:32:15 2014
@@ -4,14 +4,25 @@ use ASF::Util qw/read_text_file parse_fi
 
 sub dir_wrapper {
     my %args = @_;
+    # must end w/ trailing slash if passed as a 'dir' arg
     my $dir = delete $args{dir} || (parse_filename $args{path})[1];
     my @d;
     opendir my $dh, "content$dir" or die "Can't opendir content$dir: $!";
     for (grep $_ ne "." && $_ ne "..", readdir $dh) {
         my $f = -d $_ ? (glob "$_/index.*")[0] : $_;
-        my %a;
-        read_text_file "content/$dir/$f", \%a;
-        push @d, [ "$dir/$_", $a{headers}->{title} // $_ ];
+        my $file = "$dir$f";
+        my ($filename) = parse_filename $f;
+        my $a;
+        for my $p (@path::patterns) {
+            my ($re, $method, $args) = @$p;
+            next unless $file =~ $re;
+            my $s = view->can($method) or die "Can't locate method: $method\n";
+            my ($content, $ext, $vars) = $s->(%args, path => $file);
+            $file = "$dir$filename.$ext";
+            $a = $vars;
+            last;
+        }
+        push @d, [ $file, $a->{headers}->{title} // $_ ];
     }
     return view->can($args{view})->(dir => [sort {lc $a->[1] cmp lc $b->[1]} @d], %args);
 }