Author: igalic
Date: Wed Aug 31 22:35:25 2011
New Revision: 1163850

URL: http://svn.apache.org/viewvc?rev=1163850&view=rev
Log:
indentation only

Modified:
    trafficserver/site/branches/ats-cms/lib/view.pm

Modified: trafficserver/site/branches/ats-cms/lib/view.pm
URL: 
http://svn.apache.org/viewvc/trafficserver/site/branches/ats-cms/lib/view.pm?rev=1163850&r1=1163849&r2=1163850&view=diff
==============================================================================
--- trafficserver/site/branches/ats-cms/lib/view.pm (original)
+++ trafficserver/site/branches/ats-cms/lib/view.pm Wed Aug 31 22:35:25 2011
@@ -58,12 +58,12 @@ sub single_narrative {
     $args{style} = $ENV{TS_STYLE} if $ENV{TS_STYLE};
 
     load_vars($chain, \%args);
-    read_text_file $file, \%args;
-       if ($args{headers}->{navigation}) {
-               nav_links($chain, \%args);
+read_text_file $file, \%args;
+    if ($args{headers}->{navigation}) {
+        nav_links($chain, \%args);
 }
 
-    return Dotiac::DTL::Template($template)->render(\%args), html => \%args;
+return Dotiac::DTL::Template($template)->render(\%args), html => \%args;
 }
 
 # Has the same behavior as the above for foo.page/bar.txt
@@ -173,7 +173,7 @@ sub fetch_doap_url_list {
     chomp(my @urls = grep /^http/, `xsltproc lib/list2urls.xsl $filename`);
     unlink $filename;
     shuffle \@urls;
-    return @urls;
+return @urls;
 }
 
 1;
@@ -208,12 +208,12 @@ sub load_stems {
     # Two things to count -- language based files and directories.
     my %stems;
     for (glob(File::Spec->catfile($dir, '*'))) {
-       my $name = (File::Spec->splitpath($_))[2];
-       if (-d $_) {
-           $stems{$name} = 1;
-       } elsif (my $stem = (split_content_name($name))[0]) {
-           $stems{$stem} = 1;
-       }
+        my $name = (File::Spec->splitpath($_))[2];
+        if (-d $_) {
+            $stems{$name} = 1;
+        } elsif (my $stem = (split_content_name($name))[0]) {
+            $stems{$stem} = 1;
+        }
     }
     return keys %stems;
 }
@@ -229,19 +229,19 @@ sub load_ordering {
     my $zret = FALSE;
     my $file= File::Spec->catfile($path, ORDER_FILE);
     if (open my $fh, '<', $file) {
-       local $/; # Grab the entire file
-       my @order = split(/\s+/, <$fh>);
-       # index is special - remove it if present and put it first.
-       @order = grep { ! /^index$/o } @order;
-       unshift(@order, 'index');
-       @$order_ref = @order; # copy over if we found stem.
-       close $fh;
-       $zret = TRUE;
+        local $/; # Grab the entire file
+        my @order = split(/\s+/, <$fh>);
+        # index is special - remove it if present and put it first.
+        @order = grep { ! /^index$/o } @order;
+        unshift(@order, 'index');
+        @$order_ref = @order; # copy over if we found stem.
+        close $fh;
+        $zret = TRUE;
     } elsif (1 == scalar(my @stems = load_stems($path))) {
-       # If there's only one stem, the order is implied and no explicit file
-       # is required.
-       @$order_ref = @stems;
-       $zret = TRUE;
+        # If there's only one stem, the order is implied and no explicit file
+        # is required.
+        @$order_ref = @stems;
+        $zret = TRUE;
     }
     return $zret;
 }
@@ -258,31 +258,31 @@ sub ascend {
     my ($stem, $lang, $ext) = split_content_name($src_file);
     my $rpath = '.'; # path relative to source content file.
     my @chain; # Ordered list of directory descriptors.
-    
+
     while (@dirs) {
         my @order;
-       my $path = File::Spec->catdir(@dirs);
-       # Stop when we can't load an ordering.
-       last unless load_ordering($path, \@order);
-       # Save data that will be useful later.
-       my %entry = (
-           order => \@order,
-           path => $path,
-           rpath => $rpath,
-           stem => $stem
-       );
-       my $var_path = File::Spec->catfile($path, VAR_FILE);
-       $entry{var_file} = $var_path if -r $var_path;
-       push(@chain, \%entry);
-       # Set up for next iteration
-       $rpath = File::Spec->catdir($rpath, '..');
-       $stem = pop @dirs;
-    }
-    
-    # Add lang to last element which is the content file.
-    $chain[0]->{lang} = $lang;
-    
-    return \@chain;    
+        my $path = File::Spec->catdir(@dirs);
+        # Stop when we can't load an ordering.
+        last unless load_ordering($path, \@order);
+    # Save data that will be useful later.
+    my %entry = (
+        order => \@order,
+    path => $path,
+    rpath => $rpath,
+    stem => $stem
+);
+my $var_path = File::Spec->catfile($path, VAR_FILE);
+$entry{var_file} = $var_path if -r $var_path;
+push(@chain, \%entry);
+    # Set up for next iteration
+    $rpath = File::Spec->catdir($rpath, '..');
+    $stem = pop @dirs;
+}
+
+# Add lang to last element which is the content file.
+$chain[0]->{lang} = $lang;
+
+return \@chain;    
 }
 
 # Return the index of target in an array, -1 if not found.
@@ -292,8 +292,8 @@ sub index_of {
     my ($target, $list) = @_;
     my $idx = 0;
     for my $item (@$list) {
-       return $idx if $item eq $target;
-       ++$idx;
+        return $idx if $item eq $target;
+        ++$idx;
     }
     return -1;
 }
@@ -308,7 +308,7 @@ sub probe_ordering {
     $path = File::Spec->catfile($path, ORDER_FILE);
     my $idx = -1; # return, default to fail.
     if (load_ordering($path, $order_ref)) {
-       $idx = index_of($stem, $order_ref);
+        $idx = index_of($stem, $order_ref);
     }
     warn "Order file '$path' does not contain stem '$stem'\n" if $idx < 0;
     return $idx;
@@ -323,7 +323,7 @@ sub load_vars {
     # Load the variables, starting at the top so that lower directories
     # override.
     for my $d (reverse @$chain) {
-       read_text_file $d->{var_file}, $args if exists $d->{var_file};
+        read_text_file $d->{var_file}, $args if exists $d->{var_file};
     }
     delete $args->{content}; # discard any content.
 }
@@ -336,14 +336,14 @@ sub probe_content {
     my ($dir, $stem, $lang) = @_;
     confess unless $stem and $lang;
     if (! -r File::Spec->catfile($dir, "$stem.$lang." . SUFFIX)) {
-       $lang = DEFAULT_LANG;
+        $lang = DEFAULT_LANG;
         if (! -r File::Spec->catfile($dir, "$stem.$lang." . SUFFIX)) {
-           $lang = undef;
-       }
+            $lang = undef;
+        }
     }
     return $lang ? "$stem.$lang.html" : undef;
 }
-       
+
 # Return relative path to the leftmost leaf.
 #  - Starting directory.
 #  - Initial stem.
@@ -354,21 +354,21 @@ sub left_leaf {
     my $zret = ''; # Relative path to target.
     # Content file for this stem?
     if (my $file = probe_content($dir, $stem, $lang)) {
-       $zret = File::Spec->catfile($rpath, $file);
+        $zret = File::Spec->catfile($rpath, $file);
     } elsif (-d (my $path = File::Spec->catdir($dir, $stem))) {
-       $rpath = File::Spec->catdir($rpath, $stem);
-       # Is there ordering data?
-       my @order;
-       if (load_ordering($path, \@order)) {
-           return left_leaf($path, $order[0], $lang, $rpath);
-       } else {
-           warn "Directory '$path' has no order file and is not a singleton 
stem.\n";
-       }
+        $rpath = File::Spec->catdir($rpath, $stem);
+        # Is there ordering data?
+        my @order;
+        if (load_ordering($path, \@order)) {
+        return left_leaf($path, $order[0], $lang, $rpath);
     } else {
-       warn "Failed to find target in language '$lang' or default '"
-           , DEFAULT_LANG, "' for stem '$stem' in directory $path\n";
+        warn "Directory '$path' has no order file and is not a singleton 
stem.\n";
     }
-    return $zret;
+} else {
+    warn "Failed to find target in language '$lang' or default '"
+    , DEFAULT_LANG, "' for stem '$stem' in directory $path\n";
+}
+return $zret;
 }
 
 # Return relative path to the rightmost leaf.
@@ -381,21 +381,21 @@ sub right_leaf {
     my $zret = ''; # Relative path to target.
     # Content file for this stem?
     if (my $file = probe_content($dir, $stem, $lang)) {
-       $zret = File::Spec->catfile($rpath, $file);
+        $zret = File::Spec->catfile($rpath, $file);
     } elsif (-d (my $path = File::Spec->catdir($dir, $stem))) {
-       $rpath = File::Spec->catdir($rpath, $stem);
-       # Is there ordering data?
-       my @order;
-       if (load_ordering($path, \@order)) {
-           return right_leaf($path, pop @order, $lang, $rpath);
-       } else {
-           warn "Directory '$dir' has no order file and is not a singleton 
stem.\n";
-       }
+        $rpath = File::Spec->catdir($rpath, $stem);
+        # Is there ordering data?
+        my @order;
+        if (load_ordering($path, \@order)) {
+        return right_leaf($path, pop @order, $lang, $rpath);
     } else {
-       warn "Failed to find target in language '$lang' or default '"
-           , DEFAULT_LANG, "' for stem '$stem' in directory $path\n";
+        warn "Directory '$dir' has no order file and is not a singleton 
stem.\n";
     }
-    return $zret;
+} else {
+    warn "Failed to find target in language '$lang' or default '",
+        DEFAULT_LANG, "' for stem '$stem' in directory $path\n";
+}
+return $zret;
 }
 
 # Args - Directory chain.
@@ -413,15 +413,15 @@ sub auto_nav {
 
     # Ascend the directory chain, watching for branch points left and right.   
 
     for my $entry (@$chain) {
-       my $order = $entry->{order};
-       my $idx = index_of($entry->{stem}, $order);
-       if (!$next_url && $idx < scalar(@$order) - 1 ) {
-           $next_url = left_leaf($entry->{path}, $order->[$idx+1], $lang, 
$entry->{rpath});
-       }
-       if (!$back_url && $idx > 0) {
-           $back_url = right_leaf($entry->{path}, $order->[$idx-1], $lang, 
$entry->{rpath});
-       }
-       last if $next_url and $back_url;
+        my $order = $entry->{order};
+        my $idx = index_of($entry->{stem}, $order);
+        if (!$next_url && $idx < scalar(@$order) - 1 ) {
+            $next_url = left_leaf($entry->{path}, $order->[$idx+1], $lang, 
$entry->{rpath});
+        }
+        if (!$back_url && $idx > 0) {
+            $back_url = right_leaf($entry->{path}, $order->[$idx-1], $lang, 
$entry->{rpath});
+        }
+        last if $next_url and $back_url;
     }
 
     my $top = $chain->[$#$chain];
@@ -430,7 +430,7 @@ sub auto_nav {
     push (@nav, { url => $next_url, text => 'Next' }) if $next_url;
     push (@nav, { url => $back_url, text => 'Back' }) if $back_url;
     push (@nav, { url => $top_url, text => 'Top' }) if $top_url;
-    
+
     return \@nav;
 }
 
@@ -440,11 +440,11 @@ sub parse_links {
     my @links; # Return: list of link items.
     my $need_fill = 0; # URLs to be named later found.
     for (split(/\s+/, $input)) {
-       if (/\[([^\]]+)\]\(([^)]+)/) {
-           my ($text, $url) = ($1, $2);
-           push (@links, { text => $text, url => $url });
-           $need_fill = 1 if $url eq '*';
-       }
+        if (/\[([^\]]+)\]\(([^)]+)/) {
+            my ($text, $url) = ($1, $2);
+            push (@links, { text => $text, url => $url });
+            $need_fill = 1 if $url eq '*';
+        }
     }
     return ( \@links , $need_fill );
 }
@@ -464,41 +464,41 @@ sub nav_links {
     my $explicit; # array ref of nav links from user data.
     my $fill = 0; # Need to fill generated links from navigation?
     if ($args->{headers}{navigation}) {
-       ($explicit, $fill) = parse_links($args->{headers}{navigation});
+        ($explicit, $fill) = parse_links($args->{headers}{navigation});
     }
     if ($explicit) {
-       # If user has marked nav links for fill from generated data,
-       # find those and fill in the generated values.
-       if ($fill) {
-           # Get the auto navs and then make a hash keyed by text.
-           my $auto_list = auto_nav($chain);
-           my %auto_map = map { $_->{text} => $_ } @$auto_list;
-           # Do the direct fills
-           for (@$explicit) {
-               if (exists $auto_map{$_->{text}} and $_->{url} eq '*') {
-                   my $tag = $_->{text};
-                   $_->{url} = $auto_map{$tag}->{url};
-                   $auto_map{$tag}->{used} = 1;
-               }
-           }
-           # Do it again and do the generic fill, if any.
-           # Need to do generic fill separately so we don't duplicate.
-           my @unused = grep {
-               not exists $auto_map{$_->{text}}{used}
-           } @$auto_list;
-
-           @$explicit = map {
-               $_->{text} eq '*' && $_->{url} eq '*' ? @unused : $_;
-           } @$explicit if @unused;
-
-           # Clean out any navs that were marked for substitution but
-           # didn't get matched.
-           @$explicit = grep { $_->{url} ne '*' } @$explicit;
-       }
-       $args->{nav} = $explicit if @$explicit;
+        # If user has marked nav links for fill from generated data,
+        # find those and fill in the generated values.
+        if ($fill) {
+            # Get the auto navs and then make a hash keyed by text.
+            my $auto_list = auto_nav($chain);
+            my %auto_map = map { $_->{text} => $_ } @$auto_list;
+            # Do the direct fills
+            for (@$explicit) {
+                if (exists $auto_map{$_->{text}} and $_->{url} eq '*') {
+                    my $tag = $_->{text};
+                    $_->{url} = $auto_map{$tag}->{url};
+                    $auto_map{$tag}->{used} = 1;
+                }
+            }
+            # Do it again and do the generic fill, if any.
+            # Need to do generic fill separately so we don't duplicate.
+            my @unused = grep {
+                not exists $auto_map{$_->{text}}{used}
+            } @$auto_list;
+
+            @$explicit = map {
+            $_->{text} eq '*' && $_->{url} eq '*' ? @unused : $_;
+            } @$explicit if @unused;
+
+            # Clean out any navs that were marked for substitution but
+            # didn't get matched.
+            @$explicit = grep { $_->{url} ne '*' } @$explicit;
+        }
+        $args->{nav} = $explicit if @$explicit;
     } else {
-       my $auto_navs = auto_nav($chain);
-       $args->{nav} = $auto_navs if @$auto_navs;
+        my $auto_navs = auto_nav($chain);
+        $args->{nav} = $auto_navs if @$auto_navs;
     }
 }
 
@@ -515,11 +515,11 @@ sub langs {
     my $lang = $1;
     my $pattern  = File::Spec->catfile($dirs, "$stem.*");
     for (glob($pattern)) {
-       if (m/[.]([^.]+)[.][^.]+$/) {
-           my $ol = $1; # other language.
-           next if $ol eq $lang; # don't include us.
-           push(@langs, { text=>$ol, url=>"$stem.$ol.$ext" } );
-       }
+        if (m/[.]([^.]+)[.][^.]+$/) {
+            my $ol = $1; # other language.
+            next if $ol eq $lang; # don't include us.
+            push(@langs, { text=>$ol, url=>"$stem.$ol.$ext" } );
+        }
     }
     # Django support is broken, empty arrays are true.
     return @langs ? \@langs : undef;


Reply via email to