Apache/OTL.pm
author Mahlon E. Smith <mahlon@martini.nu>
Fri, 24 Jul 2009 07:49:06 -0700
changeset 1 1ae1a79094fa
parent 0 868dae1581ff
child 3 1b5eb968d2c4
permissions -rwxr-xr-x
ModPerl2 update. This code was actually released (before it was in a repo) in February of 2005.
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
1
1ae1a79094fa ModPerl2 update. This code was actually released (before it was in a
Mahlon E. Smith <mahlon@martini.nu>
parents: 0
diff changeset
     1
#
1ae1a79094fa ModPerl2 update. This code was actually released (before it was in a
Mahlon E. Smith <mahlon@martini.nu>
parents: 0
diff changeset
     2
# VimOutliner (OTL) XHTML pretty printer for mod_perl2/apache2.
1ae1a79094fa ModPerl2 update. This code was actually released (before it was in a
Mahlon E. Smith <mahlon@martini.nu>
parents: 0
diff changeset
     3
#
1ae1a79094fa ModPerl2 update. This code was actually released (before it was in a
Mahlon E. Smith <mahlon@martini.nu>
parents: 0
diff changeset
     4
# Copyright (c) 2006, Mahlon E. Smith <mahlon@martini.nu>
1ae1a79094fa ModPerl2 update. This code was actually released (before it was in a
Mahlon E. Smith <mahlon@martini.nu>
parents: 0
diff changeset
     5
# All rights reserved.
1ae1a79094fa ModPerl2 update. This code was actually released (before it was in a
Mahlon E. Smith <mahlon@martini.nu>
parents: 0
diff changeset
     6
# Redistribution and use in source and binary forms, with or without
1ae1a79094fa ModPerl2 update. This code was actually released (before it was in a
Mahlon E. Smith <mahlon@martini.nu>
parents: 0
diff changeset
     7
# modification, are permitted provided that the following conditions are met:
1ae1a79094fa ModPerl2 update. This code was actually released (before it was in a
Mahlon E. Smith <mahlon@martini.nu>
parents: 0
diff changeset
     8
#
1ae1a79094fa ModPerl2 update. This code was actually released (before it was in a
Mahlon E. Smith <mahlon@martini.nu>
parents: 0
diff changeset
     9
#     * Redistributions of source code must retain the above copyright
1ae1a79094fa ModPerl2 update. This code was actually released (before it was in a
Mahlon E. Smith <mahlon@martini.nu>
parents: 0
diff changeset
    10
#       notice, this list of conditions and the following disclaimer.
1ae1a79094fa ModPerl2 update. This code was actually released (before it was in a
Mahlon E. Smith <mahlon@martini.nu>
parents: 0
diff changeset
    11
#     * Redistributions in binary form must reproduce the above copyright
1ae1a79094fa ModPerl2 update. This code was actually released (before it was in a
Mahlon E. Smith <mahlon@martini.nu>
parents: 0
diff changeset
    12
#       notice, this list of conditions and the following disclaimer in the
1ae1a79094fa ModPerl2 update. This code was actually released (before it was in a
Mahlon E. Smith <mahlon@martini.nu>
parents: 0
diff changeset
    13
#       documentation and/or other materials provided with the distribution.
1ae1a79094fa ModPerl2 update. This code was actually released (before it was in a
Mahlon E. Smith <mahlon@martini.nu>
parents: 0
diff changeset
    14
#     * Neither the name of Mahlon E. Smith nor the names of his
1ae1a79094fa ModPerl2 update. This code was actually released (before it was in a
Mahlon E. Smith <mahlon@martini.nu>
parents: 0
diff changeset
    15
#       contributors may be used to endorse or promote products derived
1ae1a79094fa ModPerl2 update. This code was actually released (before it was in a
Mahlon E. Smith <mahlon@martini.nu>
parents: 0
diff changeset
    16
#       from this software without specific prior written permission.
1ae1a79094fa ModPerl2 update. This code was actually released (before it was in a
Mahlon E. Smith <mahlon@martini.nu>
parents: 0
diff changeset
    17
#
1ae1a79094fa ModPerl2 update. This code was actually released (before it was in a
Mahlon E. Smith <mahlon@martini.nu>
parents: 0
diff changeset
    18
# THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND ANY
1ae1a79094fa ModPerl2 update. This code was actually released (before it was in a
Mahlon E. Smith <mahlon@martini.nu>
parents: 0
diff changeset
    19
# EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
1ae1a79094fa ModPerl2 update. This code was actually released (before it was in a
Mahlon E. Smith <mahlon@martini.nu>
parents: 0
diff changeset
    20
# WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
1ae1a79094fa ModPerl2 update. This code was actually released (before it was in a
Mahlon E. Smith <mahlon@martini.nu>
parents: 0
diff changeset
    21
# DISCLAIMED. IN NO EVENT SHALL THE REGENTS AND CONTRIBUTORS BE LIABLE FOR ANY
1ae1a79094fa ModPerl2 update. This code was actually released (before it was in a
Mahlon E. Smith <mahlon@martini.nu>
parents: 0
diff changeset
    22
# DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
1ae1a79094fa ModPerl2 update. This code was actually released (before it was in a
Mahlon E. Smith <mahlon@martini.nu>
parents: 0
diff changeset
    23
# (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
1ae1a79094fa ModPerl2 update. This code was actually released (before it was in a
Mahlon E. Smith <mahlon@martini.nu>
parents: 0
diff changeset
    24
# LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
1ae1a79094fa ModPerl2 update. This code was actually released (before it was in a
Mahlon E. Smith <mahlon@martini.nu>
parents: 0
diff changeset
    25
# ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
1ae1a79094fa ModPerl2 update. This code was actually released (before it was in a
Mahlon E. Smith <mahlon@martini.nu>
parents: 0
diff changeset
    26
# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
1ae1a79094fa ModPerl2 update. This code was actually released (before it was in a
Mahlon E. Smith <mahlon@martini.nu>
parents: 0
diff changeset
    27
# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
1ae1a79094fa ModPerl2 update. This code was actually released (before it was in a
Mahlon E. Smith <mahlon@martini.nu>
parents: 0
diff changeset
    28
#
0
868dae1581ff Initial commit and migration to Mercurial.
Mahlon E. Smith <mahlon@martini.nu>
parents:
diff changeset
    29
868dae1581ff Initial commit and migration to Mercurial.
Mahlon E. Smith <mahlon@martini.nu>
parents:
diff changeset
    30
package Apache::OTL;
868dae1581ff Initial commit and migration to Mercurial.
Mahlon E. Smith <mahlon@martini.nu>
parents:
diff changeset
    31
use strict;
1
1ae1a79094fa ModPerl2 update. This code was actually released (before it was in a
Mahlon E. Smith <mahlon@martini.nu>
parents: 0
diff changeset
    32
use warnings;
0
868dae1581ff Initial commit and migration to Mercurial.
Mahlon E. Smith <mahlon@martini.nu>
parents:
diff changeset
    33
use Apache2::Const qw/ DECLINED OK /;
1
1ae1a79094fa ModPerl2 update. This code was actually released (before it was in a
Mahlon E. Smith <mahlon@martini.nu>
parents: 0
diff changeset
    34
use Apache2::Request;
1ae1a79094fa ModPerl2 update. This code was actually released (before it was in a
Mahlon E. Smith <mahlon@martini.nu>
parents: 0
diff changeset
    35
use Apache2::RequestRec;
1ae1a79094fa ModPerl2 update. This code was actually released (before it was in a
Mahlon E. Smith <mahlon@martini.nu>
parents: 0
diff changeset
    36
use Apache2::RequestUtil;
1ae1a79094fa ModPerl2 update. This code was actually released (before it was in a
Mahlon E. Smith <mahlon@martini.nu>
parents: 0
diff changeset
    37
use Apache2::RequestIO;
1ae1a79094fa ModPerl2 update. This code was actually released (before it was in a
Mahlon E. Smith <mahlon@martini.nu>
parents: 0
diff changeset
    38
use Apache2::Log;
1ae1a79094fa ModPerl2 update. This code was actually released (before it was in a
Mahlon E. Smith <mahlon@martini.nu>
parents: 0
diff changeset
    39
use Time::HiRes 'gettimeofday';
0
868dae1581ff Initial commit and migration to Mercurial.
Mahlon E. Smith <mahlon@martini.nu>
parents:
diff changeset
    40
868dae1581ff Initial commit and migration to Mercurial.
Mahlon E. Smith <mahlon@martini.nu>
parents:
diff changeset
    41
sub handler
868dae1581ff Initial commit and migration to Mercurial.
Mahlon E. Smith <mahlon@martini.nu>
parents:
diff changeset
    42
{
1
1ae1a79094fa ModPerl2 update. This code was actually released (before it was in a
Mahlon E. Smith <mahlon@martini.nu>
parents: 0
diff changeset
    43
    my $VERSION = '0.5';
1ae1a79094fa ModPerl2 update. This code was actually released (before it was in a
Mahlon E. Smith <mahlon@martini.nu>
parents: 0
diff changeset
    44
    my $ID      = '$Id$';
1ae1a79094fa ModPerl2 update. This code was actually released (before it was in a
Mahlon E. Smith <mahlon@martini.nu>
parents: 0
diff changeset
    45
    my $r       = shift;
1ae1a79094fa ModPerl2 update. This code was actually released (before it was in a
Mahlon E. Smith <mahlon@martini.nu>
parents: 0
diff changeset
    46
    my $t0      = Time::HiRes::gettimeofday;
0
868dae1581ff Initial commit and migration to Mercurial.
Mahlon E. Smith <mahlon@martini.nu>
parents:
diff changeset
    47
    my (
868dae1581ff Initial commit and migration to Mercurial.
Mahlon E. Smith <mahlon@martini.nu>
parents:
diff changeset
    48
        $file,          # the absolute file path
868dae1581ff Initial commit and migration to Mercurial.
Mahlon E. Smith <mahlon@martini.nu>
parents:
diff changeset
    49
        $title,         # the file's title
868dae1581ff Initial commit and migration to Mercurial.
Mahlon E. Smith <mahlon@martini.nu>
parents:
diff changeset
    50
        $uri,           # the file uri
868dae1581ff Initial commit and migration to Mercurial.
Mahlon E. Smith <mahlon@martini.nu>
parents:
diff changeset
    51
        $data,          # file contents
868dae1581ff Initial commit and migration to Mercurial.
Mahlon E. Smith <mahlon@martini.nu>
parents:
diff changeset
    52
        @blocks,        # todo groupings
868dae1581ff Initial commit and migration to Mercurial.
Mahlon E. Smith <mahlon@martini.nu>
parents:
diff changeset
    53
        $mtime,         # last modification time of otl file
1
1ae1a79094fa ModPerl2 update. This code was actually released (before it was in a
Mahlon E. Smith <mahlon@martini.nu>
parents: 0
diff changeset
    54
        $get,           # get arguments (sorting, etc)
1ae1a79094fa ModPerl2 update. This code was actually released (before it was in a
Mahlon E. Smith <mahlon@martini.nu>
parents: 0
diff changeset
    55
        %opt,           # options from otl file
0
868dae1581ff Initial commit and migration to Mercurial.
Mahlon E. Smith <mahlon@martini.nu>
parents:
diff changeset
    56
    );
868dae1581ff Initial commit and migration to Mercurial.
Mahlon E. Smith <mahlon@martini.nu>
parents:
diff changeset
    57
1
1ae1a79094fa ModPerl2 update. This code was actually released (before it was in a
Mahlon E. Smith <mahlon@martini.nu>
parents: 0
diff changeset
    58
    # sanity checks
1ae1a79094fa ModPerl2 update. This code was actually released (before it was in a
Mahlon E. Smith <mahlon@martini.nu>
parents: 0
diff changeset
    59
    return DECLINED unless $r->method eq 'GET';
1ae1a79094fa ModPerl2 update. This code was actually released (before it was in a
Mahlon E. Smith <mahlon@martini.nu>
parents: 0
diff changeset
    60
1ae1a79094fa ModPerl2 update. This code was actually released (before it was in a
Mahlon E. Smith <mahlon@martini.nu>
parents: 0
diff changeset
    61
    ( $file, $uri ) = ( $r->filename, $r->uri );
0
868dae1581ff Initial commit and migration to Mercurial.
Mahlon E. Smith <mahlon@martini.nu>
parents:
diff changeset
    62
    return DECLINED unless -e $file;
868dae1581ff Initial commit and migration to Mercurial.
Mahlon E. Smith <mahlon@martini.nu>
parents:
diff changeset
    63
    $mtime = localtime( (stat(_))[9] );
868dae1581ff Initial commit and migration to Mercurial.
Mahlon E. Smith <mahlon@martini.nu>
parents:
diff changeset
    64
1
1ae1a79094fa ModPerl2 update. This code was actually released (before it was in a
Mahlon E. Smith <mahlon@martini.nu>
parents: 0
diff changeset
    65
    my $req = Apache2::Request->new($r);
1ae1a79094fa ModPerl2 update. This code was actually released (before it was in a
Mahlon E. Smith <mahlon@martini.nu>
parents: 0
diff changeset
    66
    $get = $req->param || {};
0
868dae1581ff Initial commit and migration to Mercurial.
Mahlon E. Smith <mahlon@martini.nu>
parents:
diff changeset
    67
1
1ae1a79094fa ModPerl2 update. This code was actually released (before it was in a
Mahlon E. Smith <mahlon@martini.nu>
parents: 0
diff changeset
    68
    my %re = (
1ae1a79094fa ModPerl2 update. This code was actually released (before it was in a
Mahlon E. Smith <mahlon@martini.nu>
parents: 0
diff changeset
    69
        title       => qr/(?:.+)?\/(.+).otl$/i,
1ae1a79094fa ModPerl2 update. This code was actually released (before it was in a
Mahlon E. Smith <mahlon@martini.nu>
parents: 0
diff changeset
    70
        percent     => qr/(\[.\]) (\d+)%/,
1ae1a79094fa ModPerl2 update. This code was actually released (before it was in a
Mahlon E. Smith <mahlon@martini.nu>
parents: 0
diff changeset
    71
        todo        => qr/(\[_\]) /,
1ae1a79094fa ModPerl2 update. This code was actually released (before it was in a
Mahlon E. Smith <mahlon@martini.nu>
parents: 0
diff changeset
    72
        done        => qr/(\[X\]) /,
1ae1a79094fa ModPerl2 update. This code was actually released (before it was in a
Mahlon E. Smith <mahlon@martini.nu>
parents: 0
diff changeset
    73
        comment     => qr/^(?:\t+)?:(.+)/,
1ae1a79094fa ModPerl2 update. This code was actually released (before it was in a
Mahlon E. Smith <mahlon@martini.nu>
parents: 0
diff changeset
    74
        time        => qr/(\d{2}:\d{2}:\d{2})/,
1ae1a79094fa ModPerl2 update. This code was actually released (before it was in a
Mahlon E. Smith <mahlon@martini.nu>
parents: 0
diff changeset
    75
        date        => qr/(\d{2,4}-\d{2}-\d{2})/,
1ae1a79094fa ModPerl2 update. This code was actually released (before it was in a
Mahlon E. Smith <mahlon@martini.nu>
parents: 0
diff changeset
    76
        subitem     => qr/^\t(?!\t)/,
1ae1a79094fa ModPerl2 update. This code was actually released (before it was in a
Mahlon E. Smith <mahlon@martini.nu>
parents: 0
diff changeset
    77
        remove_tabs => qr/^(?:\t+)?(.+)/,
1ae1a79094fa ModPerl2 update. This code was actually released (before it was in a
Mahlon E. Smith <mahlon@martini.nu>
parents: 0
diff changeset
    78
        linetext    => qr/^(?:\[.\] (?:\d+%)?)? (.+)/,
1ae1a79094fa ModPerl2 update. This code was actually released (before it was in a
Mahlon E. Smith <mahlon@martini.nu>
parents: 0
diff changeset
    79
1ae1a79094fa ModPerl2 update. This code was actually released (before it was in a
Mahlon E. Smith <mahlon@martini.nu>
parents: 0
diff changeset
    80
        comma_sep   => qr/(?:\s+)?\,(?:\s+)?/,
1ae1a79094fa ModPerl2 update. This code was actually released (before it was in a
Mahlon E. Smith <mahlon@martini.nu>
parents: 0
diff changeset
    81
        hideline    => qr/(?:\t+)?\#/,
0
868dae1581ff Initial commit and migration to Mercurial.
Mahlon E. Smith <mahlon@martini.nu>
parents:
diff changeset
    82
    );
868dae1581ff Initial commit and migration to Mercurial.
Mahlon E. Smith <mahlon@martini.nu>
parents:
diff changeset
    83
1
1ae1a79094fa ModPerl2 update. This code was actually released (before it was in a
Mahlon E. Smith <mahlon@martini.nu>
parents: 0
diff changeset
    84
    # snag file
1ae1a79094fa ModPerl2 update. This code was actually released (before it was in a
Mahlon E. Smith <mahlon@martini.nu>
parents: 0
diff changeset
    85
    open OTL, $file
1ae1a79094fa ModPerl2 update. This code was actually released (before it was in a
Mahlon E. Smith <mahlon@martini.nu>
parents: 0
diff changeset
    86
        or ( $r->log_error("Unable to read $file: $!") && return DECLINED );
0
868dae1581ff Initial commit and migration to Mercurial.
Mahlon E. Smith <mahlon@martini.nu>
parents:
diff changeset
    87
    do {
868dae1581ff Initial commit and migration to Mercurial.
Mahlon E. Smith <mahlon@martini.nu>
parents:
diff changeset
    88
        local $/ = undef;
868dae1581ff Initial commit and migration to Mercurial.
Mahlon E. Smith <mahlon@martini.nu>
parents:
diff changeset
    89
        $data = <OTL>;  # shlorp
868dae1581ff Initial commit and migration to Mercurial.
Mahlon E. Smith <mahlon@martini.nu>
parents:
diff changeset
    90
    };
868dae1581ff Initial commit and migration to Mercurial.
Mahlon E. Smith <mahlon@martini.nu>
parents:
diff changeset
    91
    close OTL;
868dae1581ff Initial commit and migration to Mercurial.
Mahlon E. Smith <mahlon@martini.nu>
parents:
diff changeset
    92
868dae1581ff Initial commit and migration to Mercurial.
Mahlon E. Smith <mahlon@martini.nu>
parents:
diff changeset
    93
    # just spit out the plain otl if requested.
1
1ae1a79094fa ModPerl2 update. This code was actually released (before it was in a
Mahlon E. Smith <mahlon@martini.nu>
parents: 0
diff changeset
    94
    if ( $get->{'show'} && $get->{show} eq 'source' ) {
0
868dae1581ff Initial commit and migration to Mercurial.
Mahlon E. Smith <mahlon@martini.nu>
parents:
diff changeset
    95
        $r->content_type('text/plain');
868dae1581ff Initial commit and migration to Mercurial.
Mahlon E. Smith <mahlon@martini.nu>
parents:
diff changeset
    96
        $r->print( $data );
868dae1581ff Initial commit and migration to Mercurial.
Mahlon E. Smith <mahlon@martini.nu>
parents:
diff changeset
    97
        return OK;
868dae1581ff Initial commit and migration to Mercurial.
Mahlon E. Smith <mahlon@martini.nu>
parents:
diff changeset
    98
    }           
868dae1581ff Initial commit and migration to Mercurial.
Mahlon E. Smith <mahlon@martini.nu>
parents:
diff changeset
    99
868dae1581ff Initial commit and migration to Mercurial.
Mahlon E. Smith <mahlon@martini.nu>
parents:
diff changeset
   100
    # divide each outline into groups
868dae1581ff Initial commit and migration to Mercurial.
Mahlon E. Smith <mahlon@martini.nu>
parents:
diff changeset
   101
    # skip blocks that start with a comment '#'
868dae1581ff Initial commit and migration to Mercurial.
Mahlon E. Smith <mahlon@martini.nu>
parents:
diff changeset
   102
    @blocks = grep { $_ !~ /^\#/ } split /\n\n+/, $data;
868dae1581ff Initial commit and migration to Mercurial.
Mahlon E. Smith <mahlon@martini.nu>
parents:
diff changeset
   103
868dae1581ff Initial commit and migration to Mercurial.
Mahlon E. Smith <mahlon@martini.nu>
parents:
diff changeset
   104
    # get optional settings and otl title
868dae1581ff Initial commit and migration to Mercurial.
Mahlon E. Smith <mahlon@martini.nu>
parents:
diff changeset
   105
    {
868dae1581ff Initial commit and migration to Mercurial.
Mahlon E. Smith <mahlon@martini.nu>
parents:
diff changeset
   106
        my $settings = shift @blocks;
868dae1581ff Initial commit and migration to Mercurial.
Mahlon E. Smith <mahlon@martini.nu>
parents:
diff changeset
   107
        if ($settings =~ $re{comment}) {
868dae1581ff Initial commit and migration to Mercurial.
Mahlon E. Smith <mahlon@martini.nu>
parents:
diff changeset
   108
            %opt = map { split /=/ } split /\s?:/, $settings;
868dae1581ff Initial commit and migration to Mercurial.
Mahlon E. Smith <mahlon@martini.nu>
parents:
diff changeset
   109
        }
868dae1581ff Initial commit and migration to Mercurial.
Mahlon E. Smith <mahlon@martini.nu>
parents:
diff changeset
   110
        
868dae1581ff Initial commit and migration to Mercurial.
Mahlon E. Smith <mahlon@martini.nu>
parents:
diff changeset
   111
        # if the first group wasn't a comment,
868dae1581ff Initial commit and migration to Mercurial.
Mahlon E. Smith <mahlon@martini.nu>
parents:
diff changeset
   112
        # we probably just aren't using a settings
868dae1581ff Initial commit and migration to Mercurial.
Mahlon E. Smith <mahlon@martini.nu>
parents:
diff changeset
   113
        # line.  push the group back into place.
868dae1581ff Initial commit and migration to Mercurial.
Mahlon E. Smith <mahlon@martini.nu>
parents:
diff changeset
   114
        else {
868dae1581ff Initial commit and migration to Mercurial.
Mahlon E. Smith <mahlon@martini.nu>
parents:
diff changeset
   115
            unshift @blocks, $settings;
868dae1581ff Initial commit and migration to Mercurial.
Mahlon E. Smith <mahlon@martini.nu>
parents:
diff changeset
   116
        }
868dae1581ff Initial commit and migration to Mercurial.
Mahlon E. Smith <mahlon@martini.nu>
parents:
diff changeset
   117
    }
868dae1581ff Initial commit and migration to Mercurial.
Mahlon E. Smith <mahlon@martini.nu>
parents:
diff changeset
   118
868dae1581ff Initial commit and migration to Mercurial.
Mahlon E. Smith <mahlon@martini.nu>
parents:
diff changeset
   119
    # GET args override settings
1
1ae1a79094fa ModPerl2 update. This code was actually released (before it was in a
Mahlon E. Smith <mahlon@martini.nu>
parents: 0
diff changeset
   120
    $opt{$_} = $get->{$_} foreach keys %$get;
0
868dae1581ff Initial commit and migration to Mercurial.
Mahlon E. Smith <mahlon@martini.nu>
parents:
diff changeset
   121
868dae1581ff Initial commit and migration to Mercurial.
Mahlon E. Smith <mahlon@martini.nu>
parents:
diff changeset
   122
    # set title (fallback to file uri)
868dae1581ff Initial commit and migration to Mercurial.
Mahlon E. Smith <mahlon@martini.nu>
parents:
diff changeset
   123
    $title =
868dae1581ff Initial commit and migration to Mercurial.
Mahlon E. Smith <mahlon@martini.nu>
parents:
diff changeset
   124
        $opt{title}
868dae1581ff Initial commit and migration to Mercurial.
Mahlon E. Smith <mahlon@martini.nu>
parents:
diff changeset
   125
      ? $opt{title}
868dae1581ff Initial commit and migration to Mercurial.
Mahlon E. Smith <mahlon@martini.nu>
parents:
diff changeset
   126
      : $1 if $uri =~ $re{title};
868dae1581ff Initial commit and migration to Mercurial.
Mahlon E. Smith <mahlon@martini.nu>
parents:
diff changeset
   127
1
1ae1a79094fa ModPerl2 update. This code was actually released (before it was in a
Mahlon E. Smith <mahlon@martini.nu>
parents: 0
diff changeset
   128
    # start html output
0
868dae1581ff Initial commit and migration to Mercurial.
Mahlon E. Smith <mahlon@martini.nu>
parents:
diff changeset
   129
    $r->content_type('text/html');
868dae1581ff Initial commit and migration to Mercurial.
Mahlon E. Smith <mahlon@martini.nu>
parents:
diff changeset
   130
    $r->print(<<EHTML);
1
1ae1a79094fa ModPerl2 update. This code was actually released (before it was in a
Mahlon E. Smith <mahlon@martini.nu>
parents: 0
diff changeset
   131
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
0
868dae1581ff Initial commit and migration to Mercurial.
Mahlon E. Smith <mahlon@martini.nu>
parents:
diff changeset
   132
<html>
868dae1581ff Initial commit and migration to Mercurial.
Mahlon E. Smith <mahlon@martini.nu>
parents:
diff changeset
   133
    <!--
868dae1581ff Initial commit and migration to Mercurial.
Mahlon E. Smith <mahlon@martini.nu>
parents:
diff changeset
   134
        generated by otl_handler $VERSION
1
1ae1a79094fa ModPerl2 update. This code was actually released (before it was in a
Mahlon E. Smith <mahlon@martini.nu>
parents: 0
diff changeset
   135
        Mahlon E. Smith <mahlon\@martini.nu>
1ae1a79094fa ModPerl2 update. This code was actually released (before it was in a
Mahlon E. Smith <mahlon@martini.nu>
parents: 0
diff changeset
   136
        http://www.martini.nu/
0
868dae1581ff Initial commit and migration to Mercurial.
Mahlon E. Smith <mahlon@martini.nu>
parents:
diff changeset
   137
1
1ae1a79094fa ModPerl2 update. This code was actually released (before it was in a
Mahlon E. Smith <mahlon@martini.nu>
parents: 0
diff changeset
   138
        Get VimOutliner at: http://www.vimoutliner.org/
0
868dae1581ff Initial commit and migration to Mercurial.
Mahlon E. Smith <mahlon@martini.nu>
parents:
diff changeset
   139
    -->
868dae1581ff Initial commit and migration to Mercurial.
Mahlon E. Smith <mahlon@martini.nu>
parents:
diff changeset
   140
    <head>
868dae1581ff Initial commit and migration to Mercurial.
Mahlon E. Smith <mahlon@martini.nu>
parents:
diff changeset
   141
        <title>$title</title>
868dae1581ff Initial commit and migration to Mercurial.
Mahlon E. Smith <mahlon@martini.nu>
parents:
diff changeset
   142
EHTML
868dae1581ff Initial commit and migration to Mercurial.
Mahlon E. Smith <mahlon@martini.nu>
parents:
diff changeset
   143
1
1ae1a79094fa ModPerl2 update. This code was actually released (before it was in a
Mahlon E. Smith <mahlon@martini.nu>
parents: 0
diff changeset
   144
    # optional styles
1ae1a79094fa ModPerl2 update. This code was actually released (before it was in a
Mahlon E. Smith <mahlon@martini.nu>
parents: 0
diff changeset
   145
    if ( $opt{style} ) {
1ae1a79094fa ModPerl2 update. This code was actually released (before it was in a
Mahlon E. Smith <mahlon@martini.nu>
parents: 0
diff changeset
   146
        foreach ( split /$re{'comma_sep'}/, $opt{style} ) {
1ae1a79094fa ModPerl2 update. This code was actually released (before it was in a
Mahlon E. Smith <mahlon@martini.nu>
parents: 0
diff changeset
   147
            my $media = $_ =~ /print/ ? 'print' : 'screen';
1ae1a79094fa ModPerl2 update. This code was actually released (before it was in a
Mahlon E. Smith <mahlon@martini.nu>
parents: 0
diff changeset
   148
            print qq{\t<link href="$_" rel="stylesheet" media="$media" type="text/css" />\n};
1ae1a79094fa ModPerl2 update. This code was actually released (before it was in a
Mahlon E. Smith <mahlon@martini.nu>
parents: 0
diff changeset
   149
        }
1ae1a79094fa ModPerl2 update. This code was actually released (before it was in a
Mahlon E. Smith <mahlon@martini.nu>
parents: 0
diff changeset
   150
    }
1ae1a79094fa ModPerl2 update. This code was actually released (before it was in a
Mahlon E. Smith <mahlon@martini.nu>
parents: 0
diff changeset
   151
1ae1a79094fa ModPerl2 update. This code was actually released (before it was in a
Mahlon E. Smith <mahlon@martini.nu>
parents: 0
diff changeset
   152
    # optional javascript
1ae1a79094fa ModPerl2 update. This code was actually released (before it was in a
Mahlon E. Smith <mahlon@martini.nu>
parents: 0
diff changeset
   153
    if ( $opt{js} ) {
1ae1a79094fa ModPerl2 update. This code was actually released (before it was in a
Mahlon E. Smith <mahlon@martini.nu>
parents: 0
diff changeset
   154
        $r->print( "\t<script type=\"text/javascript\" src=\"$_\"></script>\n" )
1ae1a79094fa ModPerl2 update. This code was actually released (before it was in a
Mahlon E. Smith <mahlon@martini.nu>
parents: 0
diff changeset
   155
            foreach split /$re{'comma_sep'}/, $opt{js};
1ae1a79094fa ModPerl2 update. This code was actually released (before it was in a
Mahlon E. Smith <mahlon@martini.nu>
parents: 0
diff changeset
   156
        $r->print( ' ' x 4, "</head>\n" );
1ae1a79094fa ModPerl2 update. This code was actually released (before it was in a
Mahlon E. Smith <mahlon@martini.nu>
parents: 0
diff changeset
   157
        $r->print( ' ' x 4, "<body>\n" );
0
868dae1581ff Initial commit and migration to Mercurial.
Mahlon E. Smith <mahlon@martini.nu>
parents:
diff changeset
   158
    } else {
868dae1581ff Initial commit and migration to Mercurial.
Mahlon E. Smith <mahlon@martini.nu>
parents:
diff changeset
   159
        $r->print(<<EHTML);
868dae1581ff Initial commit and migration to Mercurial.
Mahlon E. Smith <mahlon@martini.nu>
parents:
diff changeset
   160
    </head>
868dae1581ff Initial commit and migration to Mercurial.
Mahlon E. Smith <mahlon@martini.nu>
parents:
diff changeset
   161
    <body>
868dae1581ff Initial commit and migration to Mercurial.
Mahlon E. Smith <mahlon@martini.nu>
parents:
diff changeset
   162
EHTML
868dae1581ff Initial commit and migration to Mercurial.
Mahlon E. Smith <mahlon@martini.nu>
parents:
diff changeset
   163
    }
868dae1581ff Initial commit and migration to Mercurial.
Mahlon E. Smith <mahlon@martini.nu>
parents:
diff changeset
   164
1
1ae1a79094fa ModPerl2 update. This code was actually released (before it was in a
Mahlon E. Smith <mahlon@martini.nu>
parents: 0
diff changeset
   165
    # title, last modification times
0
868dae1581ff Initial commit and migration to Mercurial.
Mahlon E. Smith <mahlon@martini.nu>
parents:
diff changeset
   166
    $r->print("<div class=\"header\">$opt{title}</div>\n") if $opt{title};
868dae1581ff Initial commit and migration to Mercurial.
Mahlon E. Smith <mahlon@martini.nu>
parents:
diff changeset
   167
    $r->print("<div class=\"last_mod\">Last modified: $mtime</div>\n") if $opt{last_mod};
868dae1581ff Initial commit and migration to Mercurial.
Mahlon E. Smith <mahlon@martini.nu>
parents:
diff changeset
   168
    if ($opt{legend}) {
868dae1581ff Initial commit and migration to Mercurial.
Mahlon E. Smith <mahlon@martini.nu>
parents:
diff changeset
   169
        $r->print(<<EHTML);
868dae1581ff Initial commit and migration to Mercurial.
Mahlon E. Smith <mahlon@martini.nu>
parents:
diff changeset
   170
<div class="legend">
1
1ae1a79094fa ModPerl2 update. This code was actually released (before it was in a
Mahlon E. Smith <mahlon@martini.nu>
parents: 0
diff changeset
   171
<span class="done">Item completed</span><br />
1ae1a79094fa ModPerl2 update. This code was actually released (before it was in a
Mahlon E. Smith <mahlon@martini.nu>
parents: 0
diff changeset
   172
<span class="todo">Item is incomplete</span><br />
0
868dae1581ff Initial commit and migration to Mercurial.
Mahlon E. Smith <mahlon@martini.nu>
parents:
diff changeset
   173
</div>
868dae1581ff Initial commit and migration to Mercurial.
Mahlon E. Smith <mahlon@martini.nu>
parents:
diff changeset
   174
EHTML
868dae1581ff Initial commit and migration to Mercurial.
Mahlon E. Smith <mahlon@martini.nu>
parents:
diff changeset
   175
    }
1
1ae1a79094fa ModPerl2 update. This code was actually released (before it was in a
Mahlon E. Smith <mahlon@martini.nu>
parents: 0
diff changeset
   176
1ae1a79094fa ModPerl2 update. This code was actually released (before it was in a
Mahlon E. Smith <mahlon@martini.nu>
parents: 0
diff changeset
   177
    # sorter
0
868dae1581ff Initial commit and migration to Mercurial.
Mahlon E. Smith <mahlon@martini.nu>
parents:
diff changeset
   178
    if ($opt{sort}) {
868dae1581ff Initial commit and migration to Mercurial.
Mahlon E. Smith <mahlon@martini.nu>
parents:
diff changeset
   179
        my %sorts = (
868dae1581ff Initial commit and migration to Mercurial.
Mahlon E. Smith <mahlon@martini.nu>
parents:
diff changeset
   180
            alpha   => 'alphabetical',
868dae1581ff Initial commit and migration to Mercurial.
Mahlon E. Smith <mahlon@martini.nu>
parents:
diff changeset
   181
            percent => 'percentages',
868dae1581ff Initial commit and migration to Mercurial.
Mahlon E. Smith <mahlon@martini.nu>
parents:
diff changeset
   182
        );
868dae1581ff Initial commit and migration to Mercurial.
Mahlon E. Smith <mahlon@martini.nu>
parents:
diff changeset
   183
        $r->print("<div class=\"sort\">Sort: \n");
868dae1581ff Initial commit and migration to Mercurial.
Mahlon E. Smith <mahlon@martini.nu>
parents:
diff changeset
   184
        foreach (sort keys %sorts) {
868dae1581ff Initial commit and migration to Mercurial.
Mahlon E. Smith <mahlon@martini.nu>
parents:
diff changeset
   185
            if ($opt{sorttype} eq $_ && $opt{sortrev}) {
868dae1581ff Initial commit and migration to Mercurial.
Mahlon E. Smith <mahlon@martini.nu>
parents:
diff changeset
   186
                $r->print("<a href=\"$uri?sorttype=$_\">$sorts{$_}</a>&nbsp;");
868dae1581ff Initial commit and migration to Mercurial.
Mahlon E. Smith <mahlon@martini.nu>
parents:
diff changeset
   187
            } elsif ($opt{sorttype} eq $_ && ! $opt{sortrev}) {
868dae1581ff Initial commit and migration to Mercurial.
Mahlon E. Smith <mahlon@martini.nu>
parents:
diff changeset
   188
                $r->print("<a href=\"$uri?sorttype=$_&sortrev=1\">$sorts{$_}</a>&nbsp;");
868dae1581ff Initial commit and migration to Mercurial.
Mahlon E. Smith <mahlon@martini.nu>
parents:
diff changeset
   189
            } else {
868dae1581ff Initial commit and migration to Mercurial.
Mahlon E. Smith <mahlon@martini.nu>
parents:
diff changeset
   190
                $r->print("<a href=\"$uri?sorttype=$_\">$sorts{$_}</a>&nbsp;");
868dae1581ff Initial commit and migration to Mercurial.
Mahlon E. Smith <mahlon@martini.nu>
parents:
diff changeset
   191
            }
868dae1581ff Initial commit and migration to Mercurial.
Mahlon E. Smith <mahlon@martini.nu>
parents:
diff changeset
   192
        }
868dae1581ff Initial commit and migration to Mercurial.
Mahlon E. Smith <mahlon@martini.nu>
parents:
diff changeset
   193
        $r->print("</div>\n");
868dae1581ff Initial commit and migration to Mercurial.
Mahlon E. Smith <mahlon@martini.nu>
parents:
diff changeset
   194
    }
868dae1581ff Initial commit and migration to Mercurial.
Mahlon E. Smith <mahlon@martini.nu>
parents:
diff changeset
   195
868dae1581ff Initial commit and migration to Mercurial.
Mahlon E. Smith <mahlon@martini.nu>
parents:
diff changeset
   196
    foreach my $block ( sort { sorter(\%opt, \%re) } @blocks ) {
868dae1581ff Initial commit and migration to Mercurial.
Mahlon E. Smith <mahlon@martini.nu>
parents:
diff changeset
   197
        # separate outline items
1
1ae1a79094fa ModPerl2 update. This code was actually released (before it was in a
Mahlon E. Smith <mahlon@martini.nu>
parents: 0
diff changeset
   198
        my @lines = grep { $_ !~ /$re{'hideline'}/ } split /\n/, $block;
1ae1a79094fa ModPerl2 update. This code was actually released (before it was in a
Mahlon E. Smith <mahlon@martini.nu>
parents: 0
diff changeset
   199
        my $data  = [];
1ae1a79094fa ModPerl2 update. This code was actually released (before it was in a
Mahlon E. Smith <mahlon@martini.nu>
parents: 0
diff changeset
   200
1ae1a79094fa ModPerl2 update. This code was actually released (before it was in a
Mahlon E. Smith <mahlon@martini.nu>
parents: 0
diff changeset
   201
        # build structure and get item counts
1ae1a79094fa ModPerl2 update. This code was actually released (before it was in a
Mahlon E. Smith <mahlon@martini.nu>
parents: 0
diff changeset
   202
        my ( $subs, $comments, $subsubs ) = ( 0, 0, 0 );
1ae1a79094fa ModPerl2 update. This code was actually released (before it was in a
Mahlon E. Smith <mahlon@martini.nu>
parents: 0
diff changeset
   203
        foreach ( @lines ) {
1ae1a79094fa ModPerl2 update. This code was actually released (before it was in a
Mahlon E. Smith <mahlon@martini.nu>
parents: 0
diff changeset
   204
            if (/$re{comment}/) {
1ae1a79094fa ModPerl2 update. This code was actually released (before it was in a
Mahlon E. Smith <mahlon@martini.nu>
parents: 0
diff changeset
   205
                $comments++;
1ae1a79094fa ModPerl2 update. This code was actually released (before it was in a
Mahlon E. Smith <mahlon@martini.nu>
parents: 0
diff changeset
   206
            }
1ae1a79094fa ModPerl2 update. This code was actually released (before it was in a
Mahlon E. Smith <mahlon@martini.nu>
parents: 0
diff changeset
   207
            elsif (/$re{subitem}/) {
1ae1a79094fa ModPerl2 update. This code was actually released (before it was in a
Mahlon E. Smith <mahlon@martini.nu>
parents: 0
diff changeset
   208
                $subs++;
0
868dae1581ff Initial commit and migration to Mercurial.
Mahlon E. Smith <mahlon@martini.nu>
parents:
diff changeset
   209
            }
1
1ae1a79094fa ModPerl2 update. This code was actually released (before it was in a
Mahlon E. Smith <mahlon@martini.nu>
parents: 0
diff changeset
   210
1ae1a79094fa ModPerl2 update. This code was actually released (before it was in a
Mahlon E. Smith <mahlon@martini.nu>
parents: 0
diff changeset
   211
            my $level = 0;
1ae1a79094fa ModPerl2 update. This code was actually released (before it was in a
Mahlon E. Smith <mahlon@martini.nu>
parents: 0
diff changeset
   212
            $level = $1 =~ tr/\t/\t/ if /^(\t+)/;
1ae1a79094fa ModPerl2 update. This code was actually released (before it was in a
Mahlon E. Smith <mahlon@martini.nu>
parents: 0
diff changeset
   213
            $level++;
1ae1a79094fa ModPerl2 update. This code was actually released (before it was in a
Mahlon E. Smith <mahlon@martini.nu>
parents: 0
diff changeset
   214
1ae1a79094fa ModPerl2 update. This code was actually released (before it was in a
Mahlon E. Smith <mahlon@martini.nu>
parents: 0
diff changeset
   215
            s#$re{remove_tabs}#$1# unless $opt{'debug'};
1ae1a79094fa ModPerl2 update. This code was actually released (before it was in a
Mahlon E. Smith <mahlon@martini.nu>
parents: 0
diff changeset
   216
            push @$data, [ $level, $_ ];
0
868dae1581ff Initial commit and migration to Mercurial.
Mahlon E. Smith <mahlon@martini.nu>
parents:
diff changeset
   217
        }
1
1ae1a79094fa ModPerl2 update. This code was actually released (before it was in a
Mahlon E. Smith <mahlon@martini.nu>
parents: 0
diff changeset
   218
        $subsubs = ( scalar @lines - 1 ) - $subs - $comments;
0
868dae1581ff Initial commit and migration to Mercurial.
Mahlon E. Smith <mahlon@martini.nu>
parents:
diff changeset
   219
1
1ae1a79094fa ModPerl2 update. This code was actually released (before it was in a
Mahlon E. Smith <mahlon@martini.nu>
parents: 0
diff changeset
   220
        # begin parsing structure
1ae1a79094fa ModPerl2 update. This code was actually released (before it was in a
Mahlon E. Smith <mahlon@martini.nu>
parents: 0
diff changeset
   221
        $r->print("<div class=\"outline\">\n");
1ae1a79094fa ModPerl2 update. This code was actually released (before it was in a
Mahlon E. Smith <mahlon@martini.nu>
parents: 0
diff changeset
   222
        $r->print("<ul>\n") unless $opt{'debug'};
1ae1a79094fa ModPerl2 update. This code was actually released (before it was in a
Mahlon E. Smith <mahlon@martini.nu>
parents: 0
diff changeset
   223
        my $i = 0;
1ae1a79094fa ModPerl2 update. This code was actually released (before it was in a
Mahlon E. Smith <mahlon@martini.nu>
parents: 0
diff changeset
   224
        foreach ( @$data ) {
1ae1a79094fa ModPerl2 update. This code was actually released (before it was in a
Mahlon E. Smith <mahlon@martini.nu>
parents: 0
diff changeset
   225
            my ( $level, $line ) = @$_;
1ae1a79094fa ModPerl2 update. This code was actually released (before it was in a
Mahlon E. Smith <mahlon@martini.nu>
parents: 0
diff changeset
   226
1ae1a79094fa ModPerl2 update. This code was actually released (before it was in a
Mahlon E. Smith <mahlon@martini.nu>
parents: 0
diff changeset
   227
            if ( $opt{'debug'} ) {
1ae1a79094fa ModPerl2 update. This code was actually released (before it was in a
Mahlon E. Smith <mahlon@martini.nu>
parents: 0
diff changeset
   228
                my $in = "&nbsp;" x $level x 4;
1ae1a79094fa ModPerl2 update. This code was actually released (before it was in a
Mahlon E. Smith <mahlon@martini.nu>
parents: 0
diff changeset
   229
                $r->print( "$level:$in $line<br />\n" );
1ae1a79094fa ModPerl2 update. This code was actually released (before it was in a
Mahlon E. Smith <mahlon@martini.nu>
parents: 0
diff changeset
   230
                next;
1ae1a79094fa ModPerl2 update. This code was actually released (before it was in a
Mahlon E. Smith <mahlon@martini.nu>
parents: 0
diff changeset
   231
            }
1ae1a79094fa ModPerl2 update. This code was actually released (before it was in a
Mahlon E. Smith <mahlon@martini.nu>
parents: 0
diff changeset
   232
1ae1a79094fa ModPerl2 update. This code was actually released (before it was in a
Mahlon E. Smith <mahlon@martini.nu>
parents: 0
diff changeset
   233
            my $next_level = $data->[ $i+1 ] ? $data->[ $i+1 ]->[0] : 0;
1ae1a79094fa ModPerl2 update. This code was actually released (before it was in a
Mahlon E. Smith <mahlon@martini.nu>
parents: 0
diff changeset
   234
            my $in = "\t" x $level;
1ae1a79094fa ModPerl2 update. This code was actually released (before it was in a
Mahlon E. Smith <mahlon@martini.nu>
parents: 0
diff changeset
   235
1ae1a79094fa ModPerl2 update. This code was actually released (before it was in a
Mahlon E. Smith <mahlon@martini.nu>
parents: 0
diff changeset
   236
            $line =~ s#$re{'time'}#<span class="time">$1</span>#g;
1ae1a79094fa ModPerl2 update. This code was actually released (before it was in a
Mahlon E. Smith <mahlon@martini.nu>
parents: 0
diff changeset
   237
            $line =~ s#$re{date}#<span class="date">$1</span>#g;
1ae1a79094fa ModPerl2 update. This code was actually released (before it was in a
Mahlon E. Smith <mahlon@martini.nu>
parents: 0
diff changeset
   238
            $line =~ s#$re{percent}#$1 <span class="percent">$2%</span>#;
0
868dae1581ff Initial commit and migration to Mercurial.
Mahlon E. Smith <mahlon@martini.nu>
parents:
diff changeset
   239
868dae1581ff Initial commit and migration to Mercurial.
Mahlon E. Smith <mahlon@martini.nu>
parents:
diff changeset
   240
            # append counts
1
1ae1a79094fa ModPerl2 update. This code was actually released (before it was in a
Mahlon E. Smith <mahlon@martini.nu>
parents: 0
diff changeset
   241
            if ( $i == 0 && $opt{counts} && $line !~ $re{comment} ) {
0
868dae1581ff Initial commit and migration to Mercurial.
Mahlon E. Smith <mahlon@martini.nu>
parents:
diff changeset
   242
                my $itmstr  = $subs == 1    ? 'item'    : 'items';
868dae1581ff Initial commit and migration to Mercurial.
Mahlon E. Smith <mahlon@martini.nu>
parents:
diff changeset
   243
                my $sitmstr = $subsubs == 1 ? 'subitem' : 'subitems';
1
1ae1a79094fa ModPerl2 update. This code was actually released (before it was in a
Mahlon E. Smith <mahlon@martini.nu>
parents: 0
diff changeset
   244
                $line .= " <span class=\"counts\">$subs $itmstr, $subsubs $sitmstr</span>";
0
868dae1581ff Initial commit and migration to Mercurial.
Mahlon E. Smith <mahlon@martini.nu>
parents:
diff changeset
   245
            }
868dae1581ff Initial commit and migration to Mercurial.
Mahlon E. Smith <mahlon@martini.nu>
parents:
diff changeset
   246
1
1ae1a79094fa ModPerl2 update. This code was actually released (before it was in a
Mahlon E. Smith <mahlon@martini.nu>
parents: 0
diff changeset
   247
            my $li_class = '>';
1ae1a79094fa ModPerl2 update. This code was actually released (before it was in a
Mahlon E. Smith <mahlon@martini.nu>
parents: 0
diff changeset
   248
            $li_class = ' class="todo">'    if $line =~ s#$re{todo}##;
1ae1a79094fa ModPerl2 update. This code was actually released (before it was in a
Mahlon E. Smith <mahlon@martini.nu>
parents: 0
diff changeset
   249
            $li_class = ' class="done">'    if $line =~ s#$re{done}##;
1ae1a79094fa ModPerl2 update. This code was actually released (before it was in a
Mahlon E. Smith <mahlon@martini.nu>
parents: 0
diff changeset
   250
            $li_class = ' class="comment">' if $line =~ s#$re{comment}#$1#;
1ae1a79094fa ModPerl2 update. This code was actually released (before it was in a
Mahlon E. Smith <mahlon@martini.nu>
parents: 0
diff changeset
   251
1ae1a79094fa ModPerl2 update. This code was actually released (before it was in a
Mahlon E. Smith <mahlon@martini.nu>
parents: 0
diff changeset
   252
            if ( $next_level == $level || $next_level == 0 ) {
1ae1a79094fa ModPerl2 update. This code was actually released (before it was in a
Mahlon E. Smith <mahlon@martini.nu>
parents: 0
diff changeset
   253
                $r->print( "$in<li" . $li_class . "$line</li>\n" );
0
868dae1581ff Initial commit and migration to Mercurial.
Mahlon E. Smith <mahlon@martini.nu>
parents:
diff changeset
   254
            }
868dae1581ff Initial commit and migration to Mercurial.
Mahlon E. Smith <mahlon@martini.nu>
parents:
diff changeset
   255
1
1ae1a79094fa ModPerl2 update. This code was actually released (before it was in a
Mahlon E. Smith <mahlon@martini.nu>
parents: 0
diff changeset
   256
            elsif ( $next_level < $level ) {
1ae1a79094fa ModPerl2 update. This code was actually released (before it was in a
Mahlon E. Smith <mahlon@martini.nu>
parents: 0
diff changeset
   257
                $r->print( "$in<li" . $li_class . "$line</li>\n" );
1ae1a79094fa ModPerl2 update. This code was actually released (before it was in a
Mahlon E. Smith <mahlon@martini.nu>
parents: 0
diff changeset
   258
                for (my $x = $level - 1; $x >= $next_level; $x--) {
1ae1a79094fa ModPerl2 update. This code was actually released (before it was in a
Mahlon E. Smith <mahlon@martini.nu>
parents: 0
diff changeset
   259
                    my $in = "\t" x $x;
1ae1a79094fa ModPerl2 update. This code was actually released (before it was in a
Mahlon E. Smith <mahlon@martini.nu>
parents: 0
diff changeset
   260
                    $r->print( "$in</ul>\n$in</li>\n" );
1ae1a79094fa ModPerl2 update. This code was actually released (before it was in a
Mahlon E. Smith <mahlon@martini.nu>
parents: 0
diff changeset
   261
                }
1ae1a79094fa ModPerl2 update. This code was actually released (before it was in a
Mahlon E. Smith <mahlon@martini.nu>
parents: 0
diff changeset
   262
            }
0
868dae1581ff Initial commit and migration to Mercurial.
Mahlon E. Smith <mahlon@martini.nu>
parents:
diff changeset
   263
1
1ae1a79094fa ModPerl2 update. This code was actually released (before it was in a
Mahlon E. Smith <mahlon@martini.nu>
parents: 0
diff changeset
   264
            else {
1ae1a79094fa ModPerl2 update. This code was actually released (before it was in a
Mahlon E. Smith <mahlon@martini.nu>
parents: 0
diff changeset
   265
                # implicit: $next_level > $level AND $next_level != 0
1ae1a79094fa ModPerl2 update. This code was actually released (before it was in a
Mahlon E. Smith <mahlon@martini.nu>
parents: 0
diff changeset
   266
                $r->print("$in<li" . $li_class . "$line\n$in<ul>\n");
1ae1a79094fa ModPerl2 update. This code was actually released (before it was in a
Mahlon E. Smith <mahlon@martini.nu>
parents: 0
diff changeset
   267
            }
1ae1a79094fa ModPerl2 update. This code was actually released (before it was in a
Mahlon E. Smith <mahlon@martini.nu>
parents: 0
diff changeset
   268
1ae1a79094fa ModPerl2 update. This code was actually released (before it was in a
Mahlon E. Smith <mahlon@martini.nu>
parents: 0
diff changeset
   269
            $i++;
0
868dae1581ff Initial commit and migration to Mercurial.
Mahlon E. Smith <mahlon@martini.nu>
parents:
diff changeset
   270
        }
1
1ae1a79094fa ModPerl2 update. This code was actually released (before it was in a
Mahlon E. Smith <mahlon@martini.nu>
parents: 0
diff changeset
   271
1ae1a79094fa ModPerl2 update. This code was actually released (before it was in a
Mahlon E. Smith <mahlon@martini.nu>
parents: 0
diff changeset
   272
        unless ( $opt{'debug'} ) {
1ae1a79094fa ModPerl2 update. This code was actually released (before it was in a
Mahlon E. Smith <mahlon@martini.nu>
parents: 0
diff changeset
   273
            for (my $x = $data->[ scalar @$data - 1]->[0] - 1; $x > 0; $x--) {
1ae1a79094fa ModPerl2 update. This code was actually released (before it was in a
Mahlon E. Smith <mahlon@martini.nu>
parents: 0
diff changeset
   274
                my $in = "\t" x $x;
1ae1a79094fa ModPerl2 update. This code was actually released (before it was in a
Mahlon E. Smith <mahlon@martini.nu>
parents: 0
diff changeset
   275
                $r->print( "$in</ul>\n$in</li>\n" );
1ae1a79094fa ModPerl2 update. This code was actually released (before it was in a
Mahlon E. Smith <mahlon@martini.nu>
parents: 0
diff changeset
   276
            }
1ae1a79094fa ModPerl2 update. This code was actually released (before it was in a
Mahlon E. Smith <mahlon@martini.nu>
parents: 0
diff changeset
   277
            $r->print( "</ul>\n" );
1ae1a79094fa ModPerl2 update. This code was actually released (before it was in a
Mahlon E. Smith <mahlon@martini.nu>
parents: 0
diff changeset
   278
        }
1ae1a79094fa ModPerl2 update. This code was actually released (before it was in a
Mahlon E. Smith <mahlon@martini.nu>
parents: 0
diff changeset
   279
        $r->print( "</div>\n\n" );
0
868dae1581ff Initial commit and migration to Mercurial.
Mahlon E. Smith <mahlon@martini.nu>
parents:
diff changeset
   280
    }
868dae1581ff Initial commit and migration to Mercurial.
Mahlon E. Smith <mahlon@martini.nu>
parents:
diff changeset
   281
868dae1581ff Initial commit and migration to Mercurial.
Mahlon E. Smith <mahlon@martini.nu>
parents:
diff changeset
   282
    my $t1 = Time::HiRes::gettimeofday;
868dae1581ff Initial commit and migration to Mercurial.
Mahlon E. Smith <mahlon@martini.nu>
parents:
diff changeset
   283
    my $td = sprintf("%0.3f", $t1 - $t0);
1
1ae1a79094fa ModPerl2 update. This code was actually released (before it was in a
Mahlon E. Smith <mahlon@martini.nu>
parents: 0
diff changeset
   284
    $r->print("    <div class=\"timer\">OTL parsed in $td secs</div>\n") if $opt{timer};
0
868dae1581ff Initial commit and migration to Mercurial.
Mahlon E. Smith <mahlon@martini.nu>
parents:
diff changeset
   285
    $r->print(<<EHTML);
868dae1581ff Initial commit and migration to Mercurial.
Mahlon E. Smith <mahlon@martini.nu>
parents:
diff changeset
   286
    </body>
868dae1581ff Initial commit and migration to Mercurial.
Mahlon E. Smith <mahlon@martini.nu>
parents:
diff changeset
   287
</html>
868dae1581ff Initial commit and migration to Mercurial.
Mahlon E. Smith <mahlon@martini.nu>
parents:
diff changeset
   288
EHTML
868dae1581ff Initial commit and migration to Mercurial.
Mahlon E. Smith <mahlon@martini.nu>
parents:
diff changeset
   289
868dae1581ff Initial commit and migration to Mercurial.
Mahlon E. Smith <mahlon@martini.nu>
parents:
diff changeset
   290
    return OK;
868dae1581ff Initial commit and migration to Mercurial.
Mahlon E. Smith <mahlon@martini.nu>
parents:
diff changeset
   291
}
868dae1581ff Initial commit and migration to Mercurial.
Mahlon E. Smith <mahlon@martini.nu>
parents:
diff changeset
   292
868dae1581ff Initial commit and migration to Mercurial.
Mahlon E. Smith <mahlon@martini.nu>
parents:
diff changeset
   293
sub sorter
868dae1581ff Initial commit and migration to Mercurial.
Mahlon E. Smith <mahlon@martini.nu>
parents:
diff changeset
   294
{
868dae1581ff Initial commit and migration to Mercurial.
Mahlon E. Smith <mahlon@martini.nu>
parents:
diff changeset
   295
    my ($opt, $re) = @_;
868dae1581ff Initial commit and migration to Mercurial.
Mahlon E. Smith <mahlon@martini.nu>
parents:
diff changeset
   296
    return 0 unless $opt->{sorttype};
868dae1581ff Initial commit and migration to Mercurial.
Mahlon E. Smith <mahlon@martini.nu>
parents:
diff changeset
   297
    my ($sa, $sb);
868dae1581ff Initial commit and migration to Mercurial.
Mahlon E. Smith <mahlon@martini.nu>
parents:
diff changeset
   298
    if ($opt->{sorttype} eq 'percent') {
868dae1581ff Initial commit and migration to Mercurial.
Mahlon E. Smith <mahlon@martini.nu>
parents:
diff changeset
   299
        $sa = $2 if $a =~ $re->{percent};
868dae1581ff Initial commit and migration to Mercurial.
Mahlon E. Smith <mahlon@martini.nu>
parents:
diff changeset
   300
        $sb = $2 if $b =~ $re->{percent};
868dae1581ff Initial commit and migration to Mercurial.
Mahlon E. Smith <mahlon@martini.nu>
parents:
diff changeset
   301
        return $opt->{sortrev} ? $sb <=> $sa : $sa <=> $sb;
868dae1581ff Initial commit and migration to Mercurial.
Mahlon E. Smith <mahlon@martini.nu>
parents:
diff changeset
   302
    }
868dae1581ff Initial commit and migration to Mercurial.
Mahlon E. Smith <mahlon@martini.nu>
parents:
diff changeset
   303
    else {
868dae1581ff Initial commit and migration to Mercurial.
Mahlon E. Smith <mahlon@martini.nu>
parents:
diff changeset
   304
        $sa = $1 if $a =~ $re->{linetext};
868dae1581ff Initial commit and migration to Mercurial.
Mahlon E. Smith <mahlon@martini.nu>
parents:
diff changeset
   305
        $sb = $1 if $b =~ $re->{linetext};
868dae1581ff Initial commit and migration to Mercurial.
Mahlon E. Smith <mahlon@martini.nu>
parents:
diff changeset
   306
        return $opt->{sortrev} ? $sb cmp $sa : $sa cmp $sb;
868dae1581ff Initial commit and migration to Mercurial.
Mahlon E. Smith <mahlon@martini.nu>
parents:
diff changeset
   307
    }
868dae1581ff Initial commit and migration to Mercurial.
Mahlon E. Smith <mahlon@martini.nu>
parents:
diff changeset
   308
}
868dae1581ff Initial commit and migration to Mercurial.
Mahlon E. Smith <mahlon@martini.nu>
parents:
diff changeset
   309
868dae1581ff Initial commit and migration to Mercurial.
Mahlon E. Smith <mahlon@martini.nu>
parents:
diff changeset
   310
1;
1
1ae1a79094fa ModPerl2 update. This code was actually released (before it was in a
Mahlon E. Smith <mahlon@martini.nu>
parents: 0
diff changeset
   311