directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From pamarce...@apache.org
Subject svn commit: r1327583 - in /directory/sandbox/pamarcelot/trunks/directory-website: cgi-bin/ content/ content/test.mdtext lib/ lib/path.pm lib/view.pm templates/ templates/page.html
Date Wed, 18 Apr 2012 17:05:01 GMT
Author: pamarcelot
Date: Wed Apr 18 17:05:00 2012
New Revision: 1327583

URL: http://svn.apache.org/viewvc?rev=1327583&view=rev
Log:
Added basic content (a single markdown page).

Added:
    directory/sandbox/pamarcelot/trunks/directory-website/cgi-bin/
    directory/sandbox/pamarcelot/trunks/directory-website/content/
    directory/sandbox/pamarcelot/trunks/directory-website/content/test.mdtext
    directory/sandbox/pamarcelot/trunks/directory-website/lib/
    directory/sandbox/pamarcelot/trunks/directory-website/lib/path.pm
    directory/sandbox/pamarcelot/trunks/directory-website/lib/view.pm
    directory/sandbox/pamarcelot/trunks/directory-website/templates/
    directory/sandbox/pamarcelot/trunks/directory-website/templates/page.html

Added: directory/sandbox/pamarcelot/trunks/directory-website/content/test.mdtext
URL: http://svn.apache.org/viewvc/directory/sandbox/pamarcelot/trunks/directory-website/content/test.mdtext?rev=1327583&view=auto
==============================================================================
--- directory/sandbox/pamarcelot/trunks/directory-website/content/test.mdtext (added)
+++ directory/sandbox/pamarcelot/trunks/directory-website/content/test.mdtext Wed Apr 18 17:05:00
2012
@@ -0,0 +1,5 @@
+Title: Welcome to Apache Directory
+
+This is the content in **Markdown**.
+
+<div style="border: 1px black solid;">And this is an HTML div.</div>
\ No newline at end of file

Added: directory/sandbox/pamarcelot/trunks/directory-website/lib/path.pm
URL: http://svn.apache.org/viewvc/directory/sandbox/pamarcelot/trunks/directory-website/lib/path.pm?rev=1327583&view=auto
==============================================================================
--- directory/sandbox/pamarcelot/trunks/directory-website/lib/path.pm (added)
+++ directory/sandbox/pamarcelot/trunks/directory-website/lib/path.pm Wed Apr 18 17:05:00
2012
@@ -0,0 +1,31 @@
+package path;
+
+# All our pages use the same view function
+our @patterns = (
+    [qr!^/.*\.html$!,   normal_page => {} ],
+    [qr!^/.*\.mdtext$!, normal_page => { template=>"page.html" } ],
+);
+
+# for specifying interdependencies between files
+our %dependencies = ();
+
+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: directory/sandbox/pamarcelot/trunks/directory-website/lib/view.pm
URL: http://svn.apache.org/viewvc/directory/sandbox/pamarcelot/trunks/directory-website/lib/view.pm?rev=1327583&view=auto
==============================================================================
--- directory/sandbox/pamarcelot/trunks/directory-website/lib/view.pm (added)
+++ directory/sandbox/pamarcelot/trunks/directory-website/lib/view.pm Wed Apr 18 17:05:00
2012
@@ -0,0 +1,96 @@
+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/;
+
+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}";
+    $args{path} =~ s/\.mdtext$/\.html/;
+
+    my $template = $file;
+    if($args{template}) {
+       $template = $args{template};
+    }
+
+    read_text_file $file, \%args;
+    $args{breadcrumbs} = breadcrumbs($args{path}, $args{headers});
+
+    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;
+}
+
+# Generates cwiki-style breadcrumbs
+sub breadcrumbs {
+    my ($fullpath, $headerref) = @_;
+    my @titles = split m!/!, $fullpath;
+    my @paths = split m!/!, $fullpath;
+
+    if($paths[scalar@paths-1] =~ /^index/) { 
+      pop @titles; 
+      pop @paths; 
+    } else {
+      if($headerref && $headerref->{title}) {
+         $titles[scalar@titles-1] = $headerref->{title};
+      }
+    }
+    $titles[0] = "Home";
+
+    my @rv;
+    my $relpath = "/";
+    for(my $i=0; $i<scalar @paths; $i++) {
+        my $title = $titles[$i];
+        $relpath .= $paths[$i];
+        push @rv, qq(<a href="$relpath">\u$title</a>);
+        unless($relpath eq "/") { $relpath .= "/"; }
+    }
+    return join "&nbsp;&raquo&nbsp;", @rv;
+}
+
+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: directory/sandbox/pamarcelot/trunks/directory-website/templates/page.html
URL: http://svn.apache.org/viewvc/directory/sandbox/pamarcelot/trunks/directory-website/templates/page.html?rev=1327583&view=auto
==============================================================================
--- directory/sandbox/pamarcelot/trunks/directory-website/templates/page.html (added)
+++ directory/sandbox/pamarcelot/trunks/directory-website/templates/page.html Wed Apr 18 17:05:00
2012
@@ -0,0 +1,26 @@
+<!DOCTYPE html>
+<!--
+
+    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.
+-->
+<html>
+	<head>
+		<title>{% block title %}{{ headers.title }}{% endblock %} &mdash; Apache Directory</title>
+	</head>
+	<body>
+		{% block content %}{{ content|markdown }}{% endblock %}
+	</body>
+</html>



Mime
View raw message