Author: danhaywood
Date: Mon Nov 26 10:00:57 2012
New Revision: 1413532

URL: http://svn.apache.org/viewvc?rev=1413532&view=rev
Log:
working on isis documentation page

Added:
    isis/site/trunk/lib/OpenEJBSiteDotiacFilter.pm
Modified:
    isis/site/trunk/lib/path.pm
    isis/site/trunk/lib/view.pm

Added: isis/site/trunk/lib/OpenEJBSiteDotiacFilter.pm
URL: 
http://svn.apache.org/viewvc/isis/site/trunk/lib/OpenEJBSiteDotiacFilter.pm?rev=1413532&view=auto
==============================================================================
--- isis/site/trunk/lib/OpenEJBSiteDotiacFilter.pm (added)
+++ isis/site/trunk/lib/OpenEJBSiteDotiacFilter.pm Mon Nov 26 10:00:57 2012
@@ -0,0 +1,66 @@
+package OpenEJBSiteDotiacFilter;
+use strict;
+use warnings;
+use Text::Markdown qw( markdown );
+use Dotiac::DTL::Value;
+use Dotiac::DTL::Filter;
+
+sub import {
+    *Dotiac::DTL::Filter::markdown = \&markdown_filter;
+}
+
+sub markdown_filter {
+    my $value = shift;
+
+    # Use raw value rather than escape (by calling repr() rather than
+    # string()) so that we can embed html in our .mdtext documents.
+    my $raw  = $value->repr;
+
+    $raw =~ s,\(/\),<IMG class="emoticon" 
src="https://cwiki.apache.org/confluence/images/icons/emoticons/check.gif"; 
height="16" width="16" align="absmiddle" alt="" border="0">,g;
+    $raw =~ s,\(x\),<IMG class="emoticon" 
src="https://cwiki.apache.org/confluence/images/icons/emoticons/error.gif"; 
height="16" width="16" align="absmiddle" alt="" border="0">,g;
+
+
+    my $start = "{{{{{";
+    my $end = "}}}}}";
+
+    $raw =~ s,(^|\n){,$start,g;
+    $raw =~ s,(^|\n)},$end,g;
+
+    my $html = markdown($raw);
+
+    $html =~ s,$start([a-z0-9-]+),<div class="$1">,g;
+    $html =~ s,$end,</div>,g;
+
+    $html =~ s,<li><p>,<li>,g;
+    $html =~ s,</p></li>,</li>,g;
+
+
+    # Blindly mark return value as safe.
+    my $retval = Dotiac::DTL::Value->safe($html);
+
+    return $retval;
+}
+
+1;
+
+__END__
+
+=head1 LICENSE
+
+    Licensed to the Apache Software Foundation (ASF) under one or more
+    contributor license agreements.  See the NOTICE file distributed with
+    this work for additional information regarding copyright ownership.  The
+    ASF licenses this file to you under the Apache License, Version 2.0 (the
+    "License"); you may not use this file except in compliance with the
+    License.  You may obtain a copy of the License at
+    
+        http://www.apache.org/licenses/LICENSE-2.0
+    
+    Unless required by applicable law or agreed to in writing, software
+    distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+    WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.  See the
+    License for the specific language governing permissions and limitations
+    under the License.
+
+=cut
+

Modified: isis/site/trunk/lib/path.pm
URL: 
http://svn.apache.org/viewvc/isis/site/trunk/lib/path.pm?rev=1413532&r1=1413531&r2=1413532&view=diff
==============================================================================
--- isis/site/trunk/lib/path.pm (original)
+++ isis/site/trunk/lib/path.pm Mon Nov 26 10:00:57 2012
@@ -1,21 +1,29 @@
 package path;
-
-# taken from django's url.py
+use strict;
+use warnings;
+use ASF::Value;
+
+# The @patterns array is used to map filepaths to page treatments.  Each
+# element must be an arrayref with 3 elements of its own: a regex pattern for
+# selecting filepaths, the name of the subroutine from view.pm which will be
+# invoked to generate the page, and a hashref of named parameters which will
+# be passed to the view subroutine.
 
 our @patterns = (
 
        [qr!\index.md$!, single_narrative => { template => "index.html" }],
 
-       [qr!\.md$!, single_narrative => { template => "doc.html" }],
-       [qr!\documentation.md$!, basic => { template => "doc.html" }],
-       [qr!\.mdtext$!, single_narrative => { template => "doc.html" }],
-    
+       #[qr!\.md(text)?$!, single_narrative => { template => "doc.html" }],
+       [qr!\.md(text)?$!, basic => { template => "doc.html" }],
 #      [qr!\.mdtext$!, single_narrative => { template => 
"single_narrative.html" }],
        [qr!/sitemap\.html$!, sitemap => { headers => { title => "Sitemap" }} ],
 
 ) ;
 
-# for specifying interdependencies between files
+# The %dependecies hash is used when building pages that reference or depend
+# upon other pages -- e.g. a sitemap, which depends upon the pages that it
+# links to.  The keys for %dependencies are filepaths, and the values are
+# arrayrefs containing other filepaths.
 
 our %dependencies = (
     "/sitemap.html" => [ grep s!^content!!, glob "content/*.mdtext" ],

Modified: isis/site/trunk/lib/view.pm
URL: 
http://svn.apache.org/viewvc/isis/site/trunk/lib/view.pm?rev=1413532&r1=1413531&r2=1413532&view=diff
==============================================================================
--- isis/site/trunk/lib/view.pm (original)
+++ isis/site/trunk/lib/view.pm Mon Nov 26 10:00:57 2012
@@ -1,13 +1,55 @@
 package view;
 use base 'ASF::View'; # see 
https://svn.apache.org/repos/infra/websites/cms/build/lib/ASF/View.pm
 
+=head1 INTERFACE
+
+Each function within view.pm which will be used for page generation must
+implement a standard interface.
+
+    sub my_view {
+        my %args = @_;
+        ...
+        return ($content, $extension, @optional);
+    }
+
+First, each function must accept labeled parameters.  The only parameter which
+will always be present is "path"; see the documentation in path.pm for the
+"@patterns" array with regards to invocation with additional parameters.
+
+Second, each function must return a list with at least two elements: the first
+element must be the page content, and the second must be a file extention.
+Returning additional elements in the list (as some of the functions below do)
+is optional.
+
+    return ($content, 'html', \%args);
+
+The constraints imposed by this interface may cause difficulties, for example
+when you want to generate both "foo.html" and "foo.pdf".  However, it is
+usually possible to work around such issues with symlinks and dependency
+management in path.pm.
+
+=cut
+
 use strict;
 use warnings;
-#use Carp;
-#use Dotiac::DTL;
+use Carp;
+use Dotiac::DTL;
 use ASF::Util qw( read_text_file );
-#use OpenEJBSiteDotiacFilter;
-#use Data::Dumper;
+use OpenEJBSiteDotiacFilter;
+use Data::Dumper;
+
+BEGIN { push @Dotiac::DTL::TEMPLATE_DIRS, "templates"; }
+
+# This is most widely used view.  It takes a
+# 'template' argument and a 'path' argument.
+# Assuming the path ends in foo.mdtext, any files
+# like foo.page/bar.mdtext will be parsed and
+# passed to the template in the "bar" (hash)
+# variable.
+# Has the same behavior as the above for foo.page/bar.txt
+# files, parsing them into a bar variable for the template.
+# Otherwise presumes the template is the path.
+
 
 # A "basic" view, which takes 'template' and 'path' parameters.
 # borrowed from openejb
@@ -20,7 +62,7 @@ sub basic {
 
     read_text_file($filepath, \%args);
 
-    $args{path} =~ s/\.md$/\.html/;
+    $args{path} =~ s/\.md(text)?$/\.html/;
     $args{base} = _base($args{path});
     $args{breadcrumbs} = _breadcrumbs($args{path}, $args{base});
 


Reply via email to