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/16 00:41:30 UTC

svn commit: r1244790 - /openejb/site/trunk/lib/view.pm

Author: dblevins
Date: Wed Feb 15 23:41:30 2012
New Revision: 1244790

URL: http://svn.apache.org/viewvc?rev=1244790&view=rev
Log:
Improved sitemap.xml generation to finally be recursive and therefor include the examples

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=1244790&r1=1244789&r2=1244790&view=diff
==============================================================================
--- openejb/site/trunk/lib/view.pm (original)
+++ openejb/site/trunk/lib/view.pm Wed Feb 15 23:41:30 2012
@@ -185,37 +185,23 @@ sub sitemapxml {
 
     my $dir = $template;
     $dir =~ s!/[^/]+$!!;
-    opendir my $dh, $dir or die "Can't opendir $dir: $!\n";
-    my %data;
-    for (map "$dir/$_", grep $_ ne "." && $_ ne ".." && $_ ne ".svn", readdir $dh) {
-        if (-f and /\.md(text)?$/) {
-            my $file = $_;
-            $file =~ s/^content//;
-            no warnings 'once';
-            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->(path => $file, %$args);
-                $file =~ s/\.mdtext$/.$ext/;
-                $data{$file} = $vars;
-                last;
-            }
-        }
-    }
+
+    my %data = listdir($dir);
 
     my $content .= '<?xml version="1.0" encoding="utf-8"?>' . "\n";
     $content .= '<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">' . "\n";
 
     for (sort keys %data) {
         my $link = $_;
-        $link =~ s,.*/,,;
+        $link =~ s,^//,,;
 
         $content .= "    <url>\n";
         $content .= "        <loc>http://tomee.apache.org/$link</loc>\n";
 
         if ($link =~ m/tomcat/) {
             $content .= "        <priority>0.8</priority>\n";
+        } elsif ($link =~ m/example/) {
+            $content .= "        <priority>0.9</priority>\n";
         }
 
         $content .= "    </url>\n";
@@ -228,6 +214,38 @@ sub sitemapxml {
     return ($content, 'xml', \%args);
 }
 
+sub listdir() {
+    my $dir = shift;
+    my %data;
+
+    opendir my $dh, $dir or die "Can't opendir $dir: $!\n";
+    for (map "$dir/$_", grep $_ ne "." && $_ ne ".." && $_ ne ".svn", readdir $dh) {
+        if (-f and /\.md(text)?$/) {
+            my $file = $_;
+            $file =~ s/^content//;
+            no warnings 'once';
+            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->(path => $file, %$args);
+                $file =~ s/\.md(text)?$/.$ext/;
+
+                print "LISTING $file\n";
+                $data{$file} = $vars;
+                last;
+            }
+        }
+
+        if (-d) {
+            my %subdir = listdir($_);
+            %data = (%subdir, %data);
+        }
+    }
+
+    return %data;
+}
+
 
 sub _breadcrumbs {
     my $path        = shift;