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/21 23:14:48 UTC

svn commit: r1341207 - in /sling/site: tools/conversion/convert_cwiki_markup.pl trunk/lib/view.pm trunk/readme.txt

Author: fmeschbe
Date: Mon May 21 21:14:47 2012
New Revision: 1341207

URL: http://svn.apache.org/viewvc?rev=1341207&view=rev
Log:
SLING-2002 Improvements:
  - Local paths in the sitemap must be absolute
  - Consoldite support for referenced pages of the
    form refs.pagename.... with properties path being
    the site link, headers the page headers, and content
    the page content
  - convert {excerpt-include} to link with excerpt
    header using Django template using refs....
  - resolve pagename of refs.pagename... using File::Find
    (first matching file is found; page names in the site
    should thus be unique)
  - add more info to readme.txt

Modified:
    sling/site/tools/conversion/convert_cwiki_markup.pl
    sling/site/trunk/lib/view.pm
    sling/site/trunk/readme.txt

Modified: sling/site/tools/conversion/convert_cwiki_markup.pl
URL: http://svn.apache.org/viewvc/sling/site/tools/conversion/convert_cwiki_markup.pl?rev=1341207&r1=1341206&r2=1341207&view=diff
==============================================================================
--- sling/site/tools/conversion/convert_cwiki_markup.pl (original)
+++ sling/site/tools/conversion/convert_cwiki_markup.pl Mon May 21 21:14:47 2012
@@ -73,7 +73,6 @@ while(my $line = <INP>) {
             $excerptHidden = 0;
         } else {
             $excerpt .= " $line";
-            print STDOUT ": $line";
         }
         next if ($excerptHidden);
    } elsif($line =~ s/^{excerpt}//) {
@@ -230,6 +229,16 @@ foreach my $line (@contents) {
        $line = "///Footnotes Go Here///\n";
    }
 
+   # referenced excerpts -- assume child nodes
+   if($line =~ /\{excerpt-include:[^}]*\}/) {
+      # {excerpt-include:Authentication - AuthenticationHandler|nopanel=true}
+      my $label = $line;
+      $label =~ s/.*{excerpt-include:([^}|]*).*/$1/;
+      $label = convertURL($label);
+      $label =~ s/\.html//;
+      $line =~s /\{excerpt-include:[^}]*\}/[{{ refs.$label.headers.excerpt }}]({{ refs.$label.path }})/;
+   }
+   
    print OUT $line;
 }
 

Modified: sling/site/trunk/lib/view.pm
URL: http://svn.apache.org/viewvc/sling/site/trunk/lib/view.pm?rev=1341207&r1=1341206&r2=1341207&view=diff
==============================================================================
--- sling/site/trunk/lib/view.pm (original)
+++ sling/site/trunk/lib/view.pm Mon May 21 21:14:47 2012
@@ -15,6 +15,7 @@ use ASF::Util qw/read_text_file shuffle/
 use File::Temp qw/tempfile/;
 use LWP::Simple;
 use SVN::Client;
+use File::Find;
 
 push @Dotiac::DTL::TEMPLATE_DIRS, "templates";
 
@@ -35,13 +36,34 @@ sub single_narrative {
 
     read_text_file $file, \%args;
 
+    $args{refs} = {};
+
+    # ensure loading child pages
     my $page_path = $file;
     $page_path =~ s/\.[^.]+$//;
     if (-d $page_path) {
+        $args{children} = {};
         for my $f (grep -f, glob "$page_path/*.mdtext") {
             $f =~ m!/([^/]+)\.mdtext$! or die "Bad filename: $f\n";
-            $args{$1} = {};
-            read_text_file $f, $args{$1};
+            $args{children}->{$1} = read_ref_page_data($f);
+            $args{refs}->{$1} = $args{children}->{$1};
+        }
+    }
+
+    # ensure loading pages referenced with ref.XXX.*    
+    while( $args{content} =~ /refs\.([^.]+)\./g ) {
+        my $label = $1;
+        if(!$args{refs}->{$label}) {
+            my $refPagePath;
+            find(sub {
+                if(!$refPagePath && $_ eq "$label.mdtext") {
+                    $refPagePath = $File::Find::name;
+                }
+            }, "content");
+            
+            if($refPagePath) {
+                $args{refs}->{$label} = read_ref_page_data($refPagePath);
+            }
         }
     }
 
@@ -233,6 +255,19 @@ sub fetch_doap_url_list {
 
 1;
 
+
+# Reads data of a referenced page
+sub read_ref_page_data {
+    my $file = shift;
+    my $out = {};
+    
+    read_text_file $file, $out;
+    $out->{path} = "$file";
+    $out->{path} =~ s/content(\/.*)\.mdtext/$1.html/;
+    
+    return $out;
+}
+
 sub breadcrumbs {
     my @path = split m!/!, shift;
     pop @path;

Modified: sling/site/trunk/readme.txt
URL: http://svn.apache.org/viewvc/sling/site/trunk/readme.txt?rev=1341207&r1=1341206&r2=1341207&view=diff
==============================================================================
--- sling/site/trunk/readme.txt (original)
+++ sling/site/trunk/readme.txt Mon May 21 21:14:47 2012
@@ -16,11 +16,38 @@ Notes on pages:
   * Metadata from child pages can be referred to in the
     content with the Django variable reference notation
     using the child page name (without extension) as
-    its container; e.g.:
-          {{ childpage.headers.excerpt }}
-          {{ childpage.headers.title }}
+    its container; e.g. for the child page named
+    "childpag":
+          {{ children.childpage.headers.excerpt }}
+          {{ children.childpage.headers.title }}
 
   * Content Pages can contain Django templates of the
     form {{...}} and {%...%}. If so, the page content
     is evaluated as a Django template before running
     it through the page template.
+
+  * Any page in the site can be referenced with refs.pagename
+    returning properties:
+       .path - the absolute path of the page on the site
+       .headers - page headers (e.g. .title, .excerpt)
+       .content - the raw page content
+    All pages in the children namespace are also available in
+    the refs namespace
+    
+
+Some usefull hints:
+
+  * Printing title of another page "handler":
+       {{ refs.handler.headers.title }}
+
+  * Printing excerpt of another page "handler":
+       {{ refs.handler.headers.excerpt }}
+  
+  * Linking to another page "handler":
+       ({{ refs.handler.path }})
+       
+  * Printing title as a link to another page "handler":
+       [{{ refs.handler.headers.title }}]({{ refs.handler.path }})
+       
+  * Printing excerpt as a link to another page "handler":
+       [{{ refs.handler.headers.excerpt }}]({{ refs.handler.path }})
\ No newline at end of file