Author: ieugen
Date: Wed Apr 4 13:54:09 2012
New Revision: 1309389
URL: http://svn.apache.org/viewvc?rev=1309389&view=rev
Log:
Issue #JAMES-1374 - Migrate James web sites to Apache CMS
JAMES-1374
- initial import for James site with Apache CMS
- we can use svn-externals to put other svn versioned documentation files here
Added:
james/site-cms/
james/site-cms/branches/
james/site-cms/trunk/
james/site-cms/trunk/content/
james/site-cms/trunk/content/index.mdtext
james/site-cms/trunk/content/sitemap.html
james/site-cms/trunk/lib/
james/site-cms/trunk/lib/path.pm
james/site-cms/trunk/lib/view.pm
james/site-cms/trunk/templates/
james/site-cms/trunk/templates/single_narrative.html
james/site-cms/trunk/templates/skeleton.html
Added: james/site-cms/trunk/content/index.mdtext
URL:
http://svn.apache.org/viewvc/james/site-cms/trunk/content/index.mdtext?rev=1309389&view=auto
==============================================================================
--- james/site-cms/trunk/content/index.mdtext (added)
+++ james/site-cms/trunk/content/index.mdtext Wed Apr 4 13:54:09 2012
@@ -0,0 +1,6 @@
+# Welcome
+
+Welcome to the Apache CMS. Please see the following resources for further
help:
+
+ -
[http://www.apache.org/dev/cmsref.html](http://www.apache.org/dev/cmsref.html)
+ -
[http://wiki.apache.org/general/ApacheCms2010](http://wiki.apache.org/general/ApacheCms2010)
Added: james/site-cms/trunk/content/sitemap.html
URL:
http://svn.apache.org/viewvc/james/site-cms/trunk/content/sitemap.html?rev=1309389&view=auto
==============================================================================
--- james/site-cms/trunk/content/sitemap.html (added)
+++ james/site-cms/trunk/content/sitemap.html Wed Apr 4 13:54:09 2012
@@ -0,0 +1,2 @@
+{% include "single_narrative.html" %}
+
Added: james/site-cms/trunk/lib/path.pm
URL:
http://svn.apache.org/viewvc/james/site-cms/trunk/lib/path.pm?rev=1309389&view=auto
==============================================================================
--- james/site-cms/trunk/lib/path.pm (added)
+++ james/site-cms/trunk/lib/path.pm Wed Apr 4 13:54:09 2012
@@ -0,0 +1,39 @@
+package path;
+
+# taken from django's url.py
+
+our @patterns = (
+ [qr!\.mdtext$!, single_narrative => { template =>
"single_narrative.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: james/site-cms/trunk/lib/view.pm
URL:
http://svn.apache.org/viewvc/james/site-cms/trunk/lib/view.pm?rev=1309389&view=auto
==============================================================================
--- james/site-cms/trunk/lib/view.pm (added)
+++ james/site-cms/trunk/lib/view.pm Wed Apr 4 13:54:09 2012
@@ -0,0 +1,192 @@
+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 single_narrative {
+ my %args = @_;
+ my $file = "content$args{path}";
+ my $template = $args{template};
+ $args{path} =~ s/\.mdtext$/\.html/;
+ $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;
+}
+
+# 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.
+
+sub news_page {
+ my %args = @_;
+ my $template = "content$args{path}";
+ $args{breadcrumbs} = breadcrumbs($args{path});
+
+ my $page_path = $template;
+ $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};
+ }
+ }
+
+ for ((fetch_doap_url_list())[0..2]) {
+ push @{$args{projects}}, parse_doap($_);
+ }
+
+ return Dotiac::DTL::Template($template)->render(\%args), html => \%args;
+}
+
+sub sitemap {
+ my %args = @_;
+ my $template = "content$args{path}";
+ $args{breadcrumbs} .= breadcrumbs($args{path});
+ 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 /\.mdtext$/) {
+ 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 $content = "";
+
+ for (sort keys %data) {
+ $content .= "- [$data{$_}->{headers}->{title}]($_)\n";
+ for my $hdr (grep /^#/, split "\n", $data{$_}->{content}) {
+ $hdr =~ /^(#+)\s+([^#]+)?\s+\1\s+\{#([^}]+)\}$/ or next;
+ my $level = length $1;
+ $level *= 4;
+ $content .= " " x $level;
+ $content .= "- [$2]($_#$3)\n";
+ }
+ }
+ $args{content} = $content;
+ return Dotiac::DTL::Template($template)->render(\%args), html => \%args;
+}
+
+sub exports {
+ my %args = @_;
+ my $template = "content$args{path}";
+ $args{breadcrumbs} = breadcrumbs($args{path});
+
+ my $page_path = $template;
+ $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};
+ }
+ $args{table} = `xsltproc $page_path/eccnmatrix.xsl
$page_path/eccnmatrix.xml`;
+
+ }
+
+ return Dotiac::DTL::Template($template)->render(\%args), html => \%args;
+}
+
+sub parse_doap {
+ my $url = shift;
+ my $doap = get $url or die "Can't get $url: $!\n";
+ my ($fh, $filename) = tempfile("XXXXXX");
+ print $fh $doap;
+ close $fh;
+ my $result = eval `xsltproc lib/doap2perl.xsl $filename`;
+ unlink $filename;
+ return $result;
+}
+
+sub fetch_doap_url_list {
+ my $xml = get
"http://svn.apache.org/repos/asf/infrastructure/site-tools/trunk/projects/files.xml"
+ or die "Can't get doap file list: $!\n";
+ my ($fh, $filename) = tempfile("XXXXXX");
+ print $fh $xml;
+ close $fh;
+ chomp(my @urls = grep /^http/, `xsltproc lib/list2urls.xsl $filename`);
+ unlink $filename;
+ shuffle \@urls;
+ return @urls;
+}
+
+1;
+
+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;
+}
+
+
+=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: james/site-cms/trunk/templates/single_narrative.html
URL:
http://svn.apache.org/viewvc/james/site-cms/trunk/templates/single_narrative.html?rev=1309389&view=auto
==============================================================================
--- james/site-cms/trunk/templates/single_narrative.html (added)
+++ james/site-cms/trunk/templates/single_narrative.html Wed Apr 4 13:54:09
2012
@@ -0,0 +1 @@
+{% extends "skeleton.html" %}
Added: james/site-cms/trunk/templates/skeleton.html
URL:
http://svn.apache.org/viewvc/james/site-cms/trunk/templates/skeleton.html?rev=1309389&view=auto
==============================================================================
--- james/site-cms/trunk/templates/skeleton.html (added)
+++ james/site-cms/trunk/templates/skeleton.html Wed Apr 4 13:54:09 2012
@@ -0,0 +1,56 @@
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
+<html lang="en">
+ <head>
+ <title>{% block title %}{{ headers.title }}{% endblock %}</title>
+
+ <meta http-equiv="Content-Type" content="text/html;charset=UTF-8">
+ <meta property="og:image"
content="http://www.apache.org/images/asf_logo.gif" />
+
+ <link rel="stylesheet" type="text/css" media="screen"
href="http://www.apache.org/css/style.css">
+ <link rel="stylesheet" type="text/css" media="screen"
href="http://www.apache.org/css/code.css">
+
+ </style>
+
+ {% if headers.atom %}
+ <link rel="alternate" href="{{ headers.atom.url }}"
+ type="application/atom+xml" title="{{ headers.atom.title }}" />
+ {% endif %}
+
+ {% if headers.base %}<base href="{{ headers.base }}" />{% endif %}
+ {% if headers.notice %}<!-- {{ headers.notice }} -->{% endif %}
+ </head>
+
+ <body>
+ <div id="page" class="container_16">
+ <div id="header" class="grid_8">
+ <img src="http://www.apache.org/images/feather-small.gif" alt="The
Apache Software Foundation">
+ <h1>The Apache Software Foundation</h1>
+ <h2>{% block tagline %}{{ headers.title }}{% endblock %}</h2>
+ </div>
+ <div id="nav" class="grid_8">
+ <ul>
+ <!-- <li><a href="/" title="Welcome!">Home</a></li> -->
+ <li><a href="http://www.apache.org/foundation/" title="The
Foundation">Foundation</a></li>
+ <li><a href="http://projects.apache.org" title="The
Projects">Projects</a></li>
+ <li><a href="http://people.apache.org" title="The
People">People</a></li>
+ <li><a href="http://www.apache.org/foundation/getinvolved.html"
title="Get Involved">Get Involved</a></li>
+ <li><a href="http://www.apache.org/dyn/closer.cgi"
title="Download">Download</a></li>
+ <li><a href="http://www.apache.org/foundation/sponsorship.html"
title="Support Apache">Support Apache</a></li>
+ </ul>
+ <p>{{ breadcrumbs|safe }}</p>
+ <form name="search" id="search" action="http://www.google.com/search"
method="get">
+ <input value="*.apache.org" name="sitesearch" type="hidden"/>
+ <input type="text" name="q" id="query">
+ <input type="submit" id="submit" value="Search">
+ </form>
+ </div>
+ <div class="clear"></div>
+ {% block content %}<div id="content" class="grid_16"><div
class="section-content">{{ content|markdown }}</div></div>{% endblock %}
+ <div class="clear"></div>
+ </div>
+
+ <div id="copyright" class="container_16">
+ <p>Copyright © 2011 The Apache Software Foundation, Licensed under
the <a href="http://www.apache.org/licenses/LICENSE-2.0">Apache License,
Version 2.0</a>.<br/>Apache and the Apache feather logo are trademarks of The
Apache Software Foundation.</p>
+ </div>
+ </body>
+</html>
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]