Author: lewismc
Date: Sat Mar 16 22:43:12 2013
New Revision: 1457328
URL: http://svn.apache.org/r1457328
Log:
initial commit of some files to CMS site
Added:
gora/cms_site/branches/
gora/cms_site/trunk/
gora/cms_site/trunk/cgi-bin/
gora/cms_site/trunk/content/
gora/cms_site/trunk/lib/
gora/cms_site/trunk/lib/path.pm
gora/cms_site/trunk/lib/view.pm
gora/cms_site/trunk/templates/
Added: gora/cms_site/trunk/lib/path.pm
URL:
http://svn.apache.org/viewvc/gora/cms_site/trunk/lib/path.pm?rev=1457328&view=auto
==============================================================================
--- gora/cms_site/trunk/lib/path.pm (added)
+++ gora/cms_site/trunk/lib/path.pm Sat Mar 16 22:43:12 2013
@@ -0,0 +1,38 @@
+package path;
+
+# taken from django's url.py
+
+our @patterns = (
+ [qr!\.mdtext$!, normal_page => { template => "standard_markdown.html"
}],
+
+# [qr!/sitemap\.html$!, sitemap => { headers => { title => "Sitemap" }} ],
+
+) ;
+
+# for specifying interdependencies between files
+
+our %dependencies = (
+# "/sitemap.html" => [ grep s!^content!!, glob "content/*.mdtext" ],
+);
+
+1;
+
+=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.
+
Added: gora/cms_site/trunk/lib/view.pm
URL:
http://svn.apache.org/viewvc/gora/cms_site/trunk/lib/view.pm?rev=1457328&view=auto
==============================================================================
--- gora/cms_site/trunk/lib/view.pm (added)
+++ gora/cms_site/trunk/lib/view.pm Sat Mar 16 22:43:12 2013
@@ -0,0 +1,95 @@
+package view;
+
+# BUILD CONSTRAINT: all views must return $content, $extension.
+# additional return values (as seen below) are optional. However,
+# careful use of symlinks and dependency management in path.pm can
+# resolve most issues with this constraint.
+
+use strict;
+use warnings;
+use Dotiac::DTL qw/Template/;
+use Dotiac::DTL::Addon::markup;
+use ASF::Util qw/read_text_file shuffle/;
+use File::Temp qw/tempfile/;
+use LWP::Simple;
+
+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.
+
+sub normal_page {
+ my %args = @_;
+ my $file = "content$args{path}";
+ my $template = $args{template};
+
+ $args{path} =~ s/\.mdtext$/\.html/;
+ $args{base} = _base($args{path});
+ $args{breadcrumbs} = breadcrumbs($args{path});
+
+ read_text_file $file, \%args;
+
+ my $page_path = $file;
+ $page_path =~ s/\.[^.]+$/.page/;
+ if (-d $page_path) {
+ 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};
+ }
+ }
+
+ return Dotiac::DTL::Template($template)->render(\%args), html => \%args;
+}
+
+sub breadcrumbs {
+ my @path = split m!/!, shift;
+ pop @path;
+ my @rv;
+ my $relpath = "";
+ for (@path) {
+ $relpath .= "$_/";
+ $_ ||= "Home";
+ push @rv, qq(<a href="$relpath">\u$_</a>);
+ }
+ return join " » ", @rv;
+}
+
+sub _base {
+ my $path = shift;
+
+ my @path_components = split( m!/!, $path );
+ pop @path_components;
+ pop @path_components;
+
+ my $rel = "./";
+
+ for (@path_components) {
+ $rel .= "../";
+ }
+
+ return $rel;
+}
+
+=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.