You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@trafficserver.apache.org by am...@apache.org on 2011/03/07 05:08:58 UTC
svn commit: r1078671 - in /trafficserver/site/branches/ats-cms:
content/docs/trunk/admin/order.txt content/styles/ts.css lib/view.pm
templates/single_narrative.html
Author: amc
Date: Mon Mar 7 04:08:58 2011
New Revision: 1078671
URL: http://svn.apache.org/viewvc?rev=1078671&view=rev
Log:
First pass navigation bar
Added:
trafficserver/site/branches/ats-cms/content/docs/trunk/admin/order.txt
Modified:
trafficserver/site/branches/ats-cms/content/styles/ts.css
trafficserver/site/branches/ats-cms/lib/view.pm
trafficserver/site/branches/ats-cms/templates/single_narrative.html
Added: trafficserver/site/branches/ats-cms/content/docs/trunk/admin/order.txt
URL: http://svn.apache.org/viewvc/trafficserver/site/branches/ats-cms/content/docs/trunk/admin/order.txt?rev=1078671&view=auto
==============================================================================
--- trafficserver/site/branches/ats-cms/content/docs/trunk/admin/order.txt (added)
+++ trafficserver/site/branches/ats-cms/content/docs/trunk/admin/order.txt Mon Mar 7 04:08:58 2011
@@ -0,0 +1,15 @@
+cluster-howto
+configuration-files
+configuring-cache
+configuring-traffic-server
+event-logging-formats
+explicit-proxy-caching
+getting-started
+hierachical-caching
+http-proxy-caching
+monitoring-traffic
+reverse-proxy-http-redirects
+security-options
+traffic-line-commands
+traffic-server-error-messages
+faqs
Modified: trafficserver/site/branches/ats-cms/content/styles/ts.css
URL: http://svn.apache.org/viewvc/trafficserver/site/branches/ats-cms/content/styles/ts.css?rev=1078671&r1=1078670&r2=1078671&view=diff
==============================================================================
--- trafficserver/site/branches/ats-cms/content/styles/ts.css (original)
+++ trafficserver/site/branches/ats-cms/content/styles/ts.css Mon Mar 7 04:08:58 2011
@@ -114,4 +114,11 @@ span.title {
div.codehilite {
margin-left:2ex;
-}
\ No newline at end of file
+}
+
+div.nav {
+ background:black;
+ color:white;
+ -moz-border-radius: 5px;
+ -webkit-border-radius: 5px;
+}
Modified: trafficserver/site/branches/ats-cms/lib/view.pm
URL: http://svn.apache.org/viewvc/trafficserver/site/branches/ats-cms/lib/view.pm?rev=1078671&r1=1078670&r2=1078671&view=diff
==============================================================================
--- trafficserver/site/branches/ats-cms/lib/view.pm (original)
+++ trafficserver/site/branches/ats-cms/lib/view.pm Mon Mar 7 04:08:58 2011
@@ -14,6 +14,12 @@ use Dotiac::DTL::Addon::markup;
use ASF::Util qw/read_text_file shuffle/;
use File::Temp qw/tempfile/;
use LWP::Simple;
+use File::Spec;
+
+use constant ORDER_FILE => 'order.txt';
+# When we find this file during a directory ascent,
+# we've found the top documentation directory.
+use constant TOP_MARKER_FILE => 'STATUS';
push @Dotiac::DTL::TEMPLATE_DIRS, "templates";
@@ -30,6 +36,7 @@ sub single_narrative {
my $template = $args{template};
$args{path} =~ s/\.mdtext$/\.html/;
$args{breadcrumbs} = breadcrumbs($args{path});
+ $args{nav} = nav($file);
read_text_file $file, \%args;
@@ -178,6 +185,120 @@ sub breadcrumbs {
return join " » ", @rv;
}
+# Args
+# - Path to prospective order file.
+# - Local stem.
+# - Array ref to update with ordering if stem matched.
+# Return the index of the stem if found, -1 if not.
+sub order_probe {
+ my ($path, $stem, $order_ref) = @_;
+ $path = File::Spec->catfile($path, ORDER_FILE);
+ my $idx = -1; # return, default to fail.
+ if (open my $fh, '<', $path) {
+ local $/; # Grab the entire file
+ my @order = split(/\s+/, <$fh>);
+ my $n = scalar @order;
+ $idx = 0;
+ ++$idx while $idx < $n and $order[$idx] ne $stem;
+ if ($idx < $n) {
+ @$order_ref = @order;
+ } else {
+ $idx = -1;
+ }
+ close $fh;
+ }
+ return $idx;
+}
+
+# Args
+# - Base directory.
+# - Target stem.
+# - Language tag.
+# Return
+# A relative path to the target.
+sub targetfinder {
+ my ($path, $prefix, $stem, $lang) = @_;
+ my $file;
+ my $pattern;
+ my @candidates;
+ my $abs = File::Spec->catdir($path, $stem);
+ if (-d $abs) { # Target is a directory, look inside.
+ $pattern = File::Spec->catfile($abs, '*.' . $lang . '.*');
+ if ($prefix) {
+ $prefix = File::Spec->catdir($prefix, $stem);
+ } else {
+ $prefix = $stem;
+ }
+ } else { # look in the base directory.
+ $pattern = File::Spec->catfile($path, $stem . '.' . $lang . '.*');
+ }
+ @candidates = glob($pattern);
+
+ if (scalar @candidates) {
+ $file = (File::Spec->splitpath($candidates[0]))[2];
+ $file =~ s/[.][^.]*$/.html/;
+ } else {
+ warn "Could not find file for target '$stem', language '$lang', in '$path'\n";
+ $file = 'index.en.html';
+ }
+ $file = File::Spec->catfile($prefix, $file) if $prefix;
+ return $file;
+}
+
+# Return a hash that contains navigation bar data.
+# Structural assumptions -
+# The actual file being processed is in a directory that corresponds
+# to the content, with multiple files for different languages.
+# Therefore the orderinging file is one level up and orders the
+# content directories.
+sub nav {
+ my $path = shift;
+ my %nav; # Hash to return.
+ my ($vol, $dirs, $src) = File::Spec->splitpath($path);
+ $dirs =~ s!/+$!!; # So freaking annoying! Why do I have to do this?
+ my @dirs = File::Spec->splitdir($dirs);
+ # Language tag should be the second dotted element.
+ my $lang = $src;
+ $lang =~ s/^[^.]+[.]//;
+ $lang =~ s/[.].*$//;
+ my $stem = $src;
+ $stem =~ s/[.].*$//;
+
+ # Find the ordering file. We check the current directory
+ # first. If that doesn't work, use the containing directory name
+ # and check the next directory up.
+ my @order;
+ my $idx = order_probe($dirs, $stem, \@order);
+ my $prefix; # Relative path from source file directory to base directory.
+ if ($idx < 0) {
+ # That didn't work. Try popping up a directory.
+ $stem = pop @dirs; # Use directory name as stem.
+ $dirs = File::Spec->catdir(@dirs);
+ $idx = order_probe($dirs, $stem, \@order);
+ $prefix = '..';
+ }
+
+ if ($idx >= 0) {
+ $nav{display} = 1; # make it visible.
+ # Look for the top directory.
+ my $top_prefix = $prefix;
+ while (@dirs) {
+ pop @dirs;
+ my $pdir = File::Spec->catfile(@dirs);
+ my $top_mark = File::Spec->catfile($pdir, TOP_MARKER_FILE);
+ last if (-r $top_mark);
+ $top_prefix = File::Spec->catdir('..', $top_prefix);
+ }
+ $nav{top_url} = File::Spec->catfile($top_prefix, 'index.' . $lang . '.html');
+ if ($idx > 0) {
+ $nav{prev_url} = targetfinder($dirs,$prefix,$order[$idx-1],$lang);
+ }
+ if ($idx < scalar(@order) - 1) {
+ $nav{next_url} = targetfinder($dirs,$prefix,$order[$idx+1],$lang);
+ }
+ }
+ return \%nav;
+}
=head1 LICENSE
Modified: trafficserver/site/branches/ats-cms/templates/single_narrative.html
URL: http://svn.apache.org/viewvc/trafficserver/site/branches/ats-cms/templates/single_narrative.html?rev=1078671&r1=1078670&r2=1078671&view=diff
==============================================================================
--- trafficserver/site/branches/ats-cms/templates/single_narrative.html (original)
+++ trafficserver/site/branches/ats-cms/templates/single_narrative.html Mon Mar 7 04:08:58 2011
@@ -9,9 +9,9 @@
{% endif %}
<link rel="stylesheet" href="/styles/pygments_style.css" />
<link rel="stylesheet" href="/styles/ts.css" />
- <!-- Needed for amc debugging.
+ <!-- Needed for amc debugging. -->
<link rel="stylesheet" href="../../../../styles/ts.css" />
- -->
+ <!-- -->
{% if headers.base %}<base href="{{ headers.base }}" />{% endif %}
<title>{{ headers.title }}</title>
{% if headers.notice %}<!-- {{ headers.notice }} -->{% endif %}
@@ -22,10 +22,19 @@
<a href="http://trafficserver.apache.org/"><img class="logo" alt="Apache Traffic Server" src="http://trafficserver.apache.org/images/trans_logo_350x69.png" /></a>
<span class="title">{{ headers.title }}</span>
</div>
+ {% if nav.display %}
+ <div class="nav">
+ {% if nav.top_url %}<span class="nav"><a href="{{nav.top_url}}">Top</a></span>{% endif %}
+ {% if nav.next_url %}<span class="nav"><a href="{{nav.next_url}}">Next</a></span>{% endif %}
+ {% if nav.prev_url %}<span class="nav"><a href="{{nav.prev_url}}">Back</a></span>{% endif %}
+ </div>
+ {% endif %}
- <div id="content">
+ <div class="main">
+ <div id="content">
{{ content|markdown }}
- </div>
+ </div>
+ </div><!-- main -->
<div id="footer">
Copyright © 2010