author | Mahlon E. Smith <mahlon@martini.nu> |
Wed, 02 Dec 2009 17:00:38 -0800 | |
changeset 4 | 4fe151fd3b80 |
parent 3 | 1b5eb968d2c4 |
permissions | -rwxr-xr-x |
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 |
# |
3
1b5eb968d2c4
* Use a 'user block' character instead of a 'body block' for the settings line,
Mahlon E. Smith <mahlon@martini.nu>
parents:
1
diff
changeset
|
4 |
# Copyright (c) 2006-2009, Mahlon E. Smith <mahlon@martini.nu> |
1
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 |
{ |
3
1b5eb968d2c4
* Use a 'user block' character instead of a 'body block' for the settings line,
Mahlon E. Smith <mahlon@martini.nu>
parents:
1
diff
changeset
|
43 |
my $VERSION = '0.6'; |
1
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\]) /, |
3
1b5eb968d2c4
* Use a 'user block' character instead of a 'body block' for the settings line,
Mahlon E. Smith <mahlon@martini.nu>
parents:
1
diff
changeset
|
73 |
user => qr/^(?:\t+)?\<(.+)/, |
1b5eb968d2c4
* Use a 'user block' character instead of a 'body block' for the settings line,
Mahlon E. Smith <mahlon@martini.nu>
parents:
1
diff
changeset
|
74 |
user_wrap => qr/^(?:\t+)?\>(.+)/, |
1b5eb968d2c4
* Use a 'user block' character instead of a 'body block' for the settings line,
Mahlon E. Smith <mahlon@martini.nu>
parents:
1
diff
changeset
|
75 |
body_wrap => qr/^(?:\t+)?:(.+)/, |
1b5eb968d2c4
* Use a 'user block' character instead of a 'body block' for the settings line,
Mahlon E. Smith <mahlon@martini.nu>
parents:
1
diff
changeset
|
76 |
body => qr/^(?:\t+)?;(.+)/, |
1
1ae1a79094fa
ModPerl2 update. This code was actually released (before it was in a
Mahlon E. Smith <mahlon@martini.nu>
parents:
0
diff
changeset
|
77 |
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
|
78 |
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
|
79 |
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
|
80 |
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
|
81 |
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
|
82 |
|
1ae1a79094fa
ModPerl2 update. This code was actually released (before it was in a
Mahlon E. Smith <mahlon@martini.nu>
parents:
0
diff
changeset
|
83 |
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
|
84 |
hideline => qr/(?:\t+)?\#/, |
0
868dae1581ff
Initial commit and migration to Mercurial.
Mahlon E. Smith <mahlon@martini.nu>
parents:
diff
changeset
|
85 |
); |
868dae1581ff
Initial commit and migration to Mercurial.
Mahlon E. Smith <mahlon@martini.nu>
parents:
diff
changeset
|
86 |
|
1
1ae1a79094fa
ModPerl2 update. This code was actually released (before it was in a
Mahlon E. Smith <mahlon@martini.nu>
parents:
0
diff
changeset
|
87 |
# 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
|
88 |
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
|
89 |
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
|
90 |
do { |
868dae1581ff
Initial commit and migration to Mercurial.
Mahlon E. Smith <mahlon@martini.nu>
parents:
diff
changeset
|
91 |
local $/ = undef; |
868dae1581ff
Initial commit and migration to Mercurial.
Mahlon E. Smith <mahlon@martini.nu>
parents:
diff
changeset
|
92 |
$data = <OTL>; # shlorp |
868dae1581ff
Initial commit and migration to Mercurial.
Mahlon E. Smith <mahlon@martini.nu>
parents:
diff
changeset
|
93 |
}; |
868dae1581ff
Initial commit and migration to Mercurial.
Mahlon E. Smith <mahlon@martini.nu>
parents:
diff
changeset
|
94 |
close OTL; |
868dae1581ff
Initial commit and migration to Mercurial.
Mahlon E. Smith <mahlon@martini.nu>
parents:
diff
changeset
|
95 |
|
868dae1581ff
Initial commit and migration to Mercurial.
Mahlon E. Smith <mahlon@martini.nu>
parents:
diff
changeset
|
96 |
# 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
|
97 |
if ( $get->{'show'} && $get->{show} eq 'source' ) { |
0
868dae1581ff
Initial commit and migration to Mercurial.
Mahlon E. Smith <mahlon@martini.nu>
parents:
diff
changeset
|
98 |
$r->content_type('text/plain'); |
868dae1581ff
Initial commit and migration to Mercurial.
Mahlon E. Smith <mahlon@martini.nu>
parents:
diff
changeset
|
99 |
$r->print( $data ); |
868dae1581ff
Initial commit and migration to Mercurial.
Mahlon E. Smith <mahlon@martini.nu>
parents:
diff
changeset
|
100 |
return OK; |
868dae1581ff
Initial commit and migration to Mercurial.
Mahlon E. Smith <mahlon@martini.nu>
parents:
diff
changeset
|
101 |
} |
868dae1581ff
Initial commit and migration to Mercurial.
Mahlon E. Smith <mahlon@martini.nu>
parents:
diff
changeset
|
102 |
|
868dae1581ff
Initial commit and migration to Mercurial.
Mahlon E. Smith <mahlon@martini.nu>
parents:
diff
changeset
|
103 |
# divide each outline into groups |
868dae1581ff
Initial commit and migration to Mercurial.
Mahlon E. Smith <mahlon@martini.nu>
parents:
diff
changeset
|
104 |
# skip blocks that start with a comment '#' |
868dae1581ff
Initial commit and migration to Mercurial.
Mahlon E. Smith <mahlon@martini.nu>
parents:
diff
changeset
|
105 |
@blocks = grep { $_ !~ /^\#/ } split /\n\n+/, $data; |
868dae1581ff
Initial commit and migration to Mercurial.
Mahlon E. Smith <mahlon@martini.nu>
parents:
diff
changeset
|
106 |
|
868dae1581ff
Initial commit and migration to Mercurial.
Mahlon E. Smith <mahlon@martini.nu>
parents:
diff
changeset
|
107 |
# get optional settings and otl title |
868dae1581ff
Initial commit and migration to Mercurial.
Mahlon E. Smith <mahlon@martini.nu>
parents:
diff
changeset
|
108 |
{ |
868dae1581ff
Initial commit and migration to Mercurial.
Mahlon E. Smith <mahlon@martini.nu>
parents:
diff
changeset
|
109 |
my $settings = shift @blocks; |
3
1b5eb968d2c4
* Use a 'user block' character instead of a 'body block' for the settings line,
Mahlon E. Smith <mahlon@martini.nu>
parents:
1
diff
changeset
|
110 |
if ($settings =~ $re{user}) { |
1b5eb968d2c4
* Use a 'user block' character instead of a 'body block' for the settings line,
Mahlon E. Smith <mahlon@martini.nu>
parents:
1
diff
changeset
|
111 |
%opt = map { split /=/ } split /\s?:/, $1; |
0
868dae1581ff
Initial commit and migration to Mercurial.
Mahlon E. Smith <mahlon@martini.nu>
parents:
diff
changeset
|
112 |
} |
868dae1581ff
Initial commit and migration to Mercurial.
Mahlon E. Smith <mahlon@martini.nu>
parents:
diff
changeset
|
113 |
|
868dae1581ff
Initial commit and migration to Mercurial.
Mahlon E. Smith <mahlon@martini.nu>
parents:
diff
changeset
|
114 |
# if the first group wasn't a comment, |
868dae1581ff
Initial commit and migration to Mercurial.
Mahlon E. Smith <mahlon@martini.nu>
parents:
diff
changeset
|
115 |
# we probably just aren't using a settings |
868dae1581ff
Initial commit and migration to Mercurial.
Mahlon E. Smith <mahlon@martini.nu>
parents:
diff
changeset
|
116 |
# line. push the group back into place. |
868dae1581ff
Initial commit and migration to Mercurial.
Mahlon E. Smith <mahlon@martini.nu>
parents:
diff
changeset
|
117 |
else { |
868dae1581ff
Initial commit and migration to Mercurial.
Mahlon E. Smith <mahlon@martini.nu>
parents:
diff
changeset
|
118 |
unshift @blocks, $settings; |
868dae1581ff
Initial commit and migration to Mercurial.
Mahlon E. Smith <mahlon@martini.nu>
parents:
diff
changeset
|
119 |
} |
868dae1581ff
Initial commit and migration to Mercurial.
Mahlon E. Smith <mahlon@martini.nu>
parents:
diff
changeset
|
120 |
} |
868dae1581ff
Initial commit and migration to Mercurial.
Mahlon E. Smith <mahlon@martini.nu>
parents:
diff
changeset
|
121 |
|
3
1b5eb968d2c4
* Use a 'user block' character instead of a 'body block' for the settings line,
Mahlon E. Smith <mahlon@martini.nu>
parents:
1
diff
changeset
|
122 |
# Now that we have tried to detect settings, |
1b5eb968d2c4
* Use a 'user block' character instead of a 'body block' for the settings line,
Mahlon E. Smith <mahlon@martini.nu>
parents:
1
diff
changeset
|
123 |
# remove any level 0 blocks that are user data. |
1b5eb968d2c4
* Use a 'user block' character instead of a 'body block' for the settings line,
Mahlon E. Smith <mahlon@martini.nu>
parents:
1
diff
changeset
|
124 |
@blocks = grep { $_ !~ /^[\<\>]/ } @blocks; |
1b5eb968d2c4
* Use a 'user block' character instead of a 'body block' for the settings line,
Mahlon E. Smith <mahlon@martini.nu>
parents:
1
diff
changeset
|
125 |
|
0
868dae1581ff
Initial commit and migration to Mercurial.
Mahlon E. Smith <mahlon@martini.nu>
parents:
diff
changeset
|
126 |
# 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
|
127 |
$opt{$_} = $get->{$_} foreach keys %$get; |
0
868dae1581ff
Initial commit and migration to Mercurial.
Mahlon E. Smith <mahlon@martini.nu>
parents:
diff
changeset
|
128 |
|
868dae1581ff
Initial commit and migration to Mercurial.
Mahlon E. Smith <mahlon@martini.nu>
parents:
diff
changeset
|
129 |
# set title (fallback to file uri) |
868dae1581ff
Initial commit and migration to Mercurial.
Mahlon E. Smith <mahlon@martini.nu>
parents:
diff
changeset
|
130 |
$title = |
868dae1581ff
Initial commit and migration to Mercurial.
Mahlon E. Smith <mahlon@martini.nu>
parents:
diff
changeset
|
131 |
$opt{title} |
868dae1581ff
Initial commit and migration to Mercurial.
Mahlon E. Smith <mahlon@martini.nu>
parents:
diff
changeset
|
132 |
? $opt{title} |
868dae1581ff
Initial commit and migration to Mercurial.
Mahlon E. Smith <mahlon@martini.nu>
parents:
diff
changeset
|
133 |
: $1 if $uri =~ $re{title}; |
868dae1581ff
Initial commit and migration to Mercurial.
Mahlon E. Smith <mahlon@martini.nu>
parents:
diff
changeset
|
134 |
|
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 |
# start html output |
0
868dae1581ff
Initial commit and migration to Mercurial.
Mahlon E. Smith <mahlon@martini.nu>
parents:
diff
changeset
|
136 |
$r->content_type('text/html'); |
868dae1581ff
Initial commit and migration to Mercurial.
Mahlon E. Smith <mahlon@martini.nu>
parents:
diff
changeset
|
137 |
$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
|
138 |
<!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
|
139 |
<html> |
868dae1581ff
Initial commit and migration to Mercurial.
Mahlon E. Smith <mahlon@martini.nu>
parents:
diff
changeset
|
140 |
<!-- |
868dae1581ff
Initial commit and migration to Mercurial.
Mahlon E. Smith <mahlon@martini.nu>
parents:
diff
changeset
|
141 |
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
|
142 |
Mahlon E. Smith <mahlon\@martini.nu> |
3
1b5eb968d2c4
* Use a 'user block' character instead of a 'body block' for the settings line,
Mahlon E. Smith <mahlon@martini.nu>
parents:
1
diff
changeset
|
143 |
http://projects.martini.nu/apache-otl/ |
0
868dae1581ff
Initial commit and migration to Mercurial.
Mahlon E. Smith <mahlon@martini.nu>
parents:
diff
changeset
|
144 |
|
1
1ae1a79094fa
ModPerl2 update. This code was actually released (before it was in a
Mahlon E. Smith <mahlon@martini.nu>
parents:
0
diff
changeset
|
145 |
Get VimOutliner at: http://www.vimoutliner.org/ |
0
868dae1581ff
Initial commit and migration to Mercurial.
Mahlon E. Smith <mahlon@martini.nu>
parents:
diff
changeset
|
146 |
--> |
868dae1581ff
Initial commit and migration to Mercurial.
Mahlon E. Smith <mahlon@martini.nu>
parents:
diff
changeset
|
147 |
<head> |
868dae1581ff
Initial commit and migration to Mercurial.
Mahlon E. Smith <mahlon@martini.nu>
parents:
diff
changeset
|
148 |
<title>$title</title> |
868dae1581ff
Initial commit and migration to Mercurial.
Mahlon E. Smith <mahlon@martini.nu>
parents:
diff
changeset
|
149 |
EHTML |
868dae1581ff
Initial commit and migration to Mercurial.
Mahlon E. Smith <mahlon@martini.nu>
parents:
diff
changeset
|
150 |
|
1
1ae1a79094fa
ModPerl2 update. This code was actually released (before it was in a
Mahlon E. Smith <mahlon@martini.nu>
parents:
0
diff
changeset
|
151 |
# 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
|
152 |
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
|
153 |
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
|
154 |
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
|
155 |
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
|
156 |
} |
1ae1a79094fa
ModPerl2 update. This code was actually released (before it was in a
Mahlon E. Smith <mahlon@martini.nu>
parents:
0
diff
changeset
|
157 |
} |
1ae1a79094fa
ModPerl2 update. This code was actually released (before it was in a
Mahlon E. Smith <mahlon@martini.nu>
parents:
0
diff
changeset
|
158 |
|
1ae1a79094fa
ModPerl2 update. This code was actually released (before it was in a
Mahlon E. Smith <mahlon@martini.nu>
parents:
0
diff
changeset
|
159 |
# 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
|
160 |
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
|
161 |
$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
|
162 |
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
|
163 |
$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
|
164 |
$r->print( ' ' x 4, "<body>\n" ); |
0
868dae1581ff
Initial commit and migration to Mercurial.
Mahlon E. Smith <mahlon@martini.nu>
parents:
diff
changeset
|
165 |
} else { |
868dae1581ff
Initial commit and migration to Mercurial.
Mahlon E. Smith <mahlon@martini.nu>
parents:
diff
changeset
|
166 |
$r->print(<<EHTML); |
868dae1581ff
Initial commit and migration to Mercurial.
Mahlon E. Smith <mahlon@martini.nu>
parents:
diff
changeset
|
167 |
</head> |
868dae1581ff
Initial commit and migration to Mercurial.
Mahlon E. Smith <mahlon@martini.nu>
parents:
diff
changeset
|
168 |
<body> |
868dae1581ff
Initial commit and migration to Mercurial.
Mahlon E. Smith <mahlon@martini.nu>
parents:
diff
changeset
|
169 |
EHTML |
868dae1581ff
Initial commit and migration to Mercurial.
Mahlon E. Smith <mahlon@martini.nu>
parents:
diff
changeset
|
170 |
} |
868dae1581ff
Initial commit and migration to Mercurial.
Mahlon E. Smith <mahlon@martini.nu>
parents:
diff
changeset
|
171 |
|
1
1ae1a79094fa
ModPerl2 update. This code was actually released (before it was in a
Mahlon E. Smith <mahlon@martini.nu>
parents:
0
diff
changeset
|
172 |
# title, last modification times |
0
868dae1581ff
Initial commit and migration to Mercurial.
Mahlon E. Smith <mahlon@martini.nu>
parents:
diff
changeset
|
173 |
$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
|
174 |
$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
|
175 |
if ($opt{legend}) { |
868dae1581ff
Initial commit and migration to Mercurial.
Mahlon E. Smith <mahlon@martini.nu>
parents:
diff
changeset
|
176 |
$r->print(<<EHTML); |
868dae1581ff
Initial commit and migration to Mercurial.
Mahlon E. Smith <mahlon@martini.nu>
parents:
diff
changeset
|
177 |
<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
|
178 |
<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
|
179 |
<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
|
180 |
</div> |
868dae1581ff
Initial commit and migration to Mercurial.
Mahlon E. Smith <mahlon@martini.nu>
parents:
diff
changeset
|
181 |
EHTML |
868dae1581ff
Initial commit and migration to Mercurial.
Mahlon E. Smith <mahlon@martini.nu>
parents:
diff
changeset
|
182 |
} |
1
1ae1a79094fa
ModPerl2 update. This code was actually released (before it was in a
Mahlon E. Smith <mahlon@martini.nu>
parents:
0
diff
changeset
|
183 |
|
1ae1a79094fa
ModPerl2 update. This code was actually released (before it was in a
Mahlon E. Smith <mahlon@martini.nu>
parents:
0
diff
changeset
|
184 |
# sorter |
0
868dae1581ff
Initial commit and migration to Mercurial.
Mahlon E. Smith <mahlon@martini.nu>
parents:
diff
changeset
|
185 |
if ($opt{sort}) { |
868dae1581ff
Initial commit and migration to Mercurial.
Mahlon E. Smith <mahlon@martini.nu>
parents:
diff
changeset
|
186 |
my %sorts = ( |
868dae1581ff
Initial commit and migration to Mercurial.
Mahlon E. Smith <mahlon@martini.nu>
parents:
diff
changeset
|
187 |
alpha => 'alphabetical', |
868dae1581ff
Initial commit and migration to Mercurial.
Mahlon E. Smith <mahlon@martini.nu>
parents:
diff
changeset
|
188 |
percent => 'percentages', |
868dae1581ff
Initial commit and migration to Mercurial.
Mahlon E. Smith <mahlon@martini.nu>
parents:
diff
changeset
|
189 |
); |
868dae1581ff
Initial commit and migration to Mercurial.
Mahlon E. Smith <mahlon@martini.nu>
parents:
diff
changeset
|
190 |
$r->print("<div class=\"sort\">Sort: \n"); |
868dae1581ff
Initial commit and migration to Mercurial.
Mahlon E. Smith <mahlon@martini.nu>
parents:
diff
changeset
|
191 |
foreach (sort keys %sorts) { |
868dae1581ff
Initial commit and migration to Mercurial.
Mahlon E. Smith <mahlon@martini.nu>
parents:
diff
changeset
|
192 |
if ($opt{sorttype} eq $_ && $opt{sortrev}) { |
868dae1581ff
Initial commit and migration to Mercurial.
Mahlon E. Smith <mahlon@martini.nu>
parents:
diff
changeset
|
193 |
$r->print("<a href=\"$uri?sorttype=$_\">$sorts{$_}</a> "); |
868dae1581ff
Initial commit and migration to Mercurial.
Mahlon E. Smith <mahlon@martini.nu>
parents:
diff
changeset
|
194 |
} elsif ($opt{sorttype} eq $_ && ! $opt{sortrev}) { |
868dae1581ff
Initial commit and migration to Mercurial.
Mahlon E. Smith <mahlon@martini.nu>
parents:
diff
changeset
|
195 |
$r->print("<a href=\"$uri?sorttype=$_&sortrev=1\">$sorts{$_}</a> "); |
868dae1581ff
Initial commit and migration to Mercurial.
Mahlon E. Smith <mahlon@martini.nu>
parents:
diff
changeset
|
196 |
} else { |
868dae1581ff
Initial commit and migration to Mercurial.
Mahlon E. Smith <mahlon@martini.nu>
parents:
diff
changeset
|
197 |
$r->print("<a href=\"$uri?sorttype=$_\">$sorts{$_}</a> "); |
868dae1581ff
Initial commit and migration to Mercurial.
Mahlon E. Smith <mahlon@martini.nu>
parents:
diff
changeset
|
198 |
} |
868dae1581ff
Initial commit and migration to Mercurial.
Mahlon E. Smith <mahlon@martini.nu>
parents:
diff
changeset
|
199 |
} |
868dae1581ff
Initial commit and migration to Mercurial.
Mahlon E. Smith <mahlon@martini.nu>
parents:
diff
changeset
|
200 |
$r->print("</div>\n"); |
868dae1581ff
Initial commit and migration to Mercurial.
Mahlon E. Smith <mahlon@martini.nu>
parents:
diff
changeset
|
201 |
} |
868dae1581ff
Initial commit and migration to Mercurial.
Mahlon E. Smith <mahlon@martini.nu>
parents:
diff
changeset
|
202 |
|
868dae1581ff
Initial commit and migration to Mercurial.
Mahlon E. Smith <mahlon@martini.nu>
parents:
diff
changeset
|
203 |
foreach my $block ( sort { sorter(\%opt, \%re) } @blocks ) { |
868dae1581ff
Initial commit and migration to Mercurial.
Mahlon E. Smith <mahlon@martini.nu>
parents:
diff
changeset
|
204 |
# separate outline items |
3
1b5eb968d2c4
* Use a 'user block' character instead of a 'body block' for the settings line,
Mahlon E. Smith <mahlon@martini.nu>
parents:
1
diff
changeset
|
205 |
my @lines; |
1b5eb968d2c4
* Use a 'user block' character instead of a 'body block' for the settings line,
Mahlon E. Smith <mahlon@martini.nu>
parents:
1
diff
changeset
|
206 |
foreach my $line ( split /\n/, $block ) { |
1b5eb968d2c4
* Use a 'user block' character instead of a 'body block' for the settings line,
Mahlon E. Smith <mahlon@martini.nu>
parents:
1
diff
changeset
|
207 |
push @lines, $line unless $line =~ $re{hideline} || |
1b5eb968d2c4
* Use a 'user block' character instead of a 'body block' for the settings line,
Mahlon E. Smith <mahlon@martini.nu>
parents:
1
diff
changeset
|
208 |
$line =~ $re{user} || $line =~ $re{user_wrap}; |
1b5eb968d2c4
* Use a 'user block' character instead of a 'body block' for the settings line,
Mahlon E. Smith <mahlon@martini.nu>
parents:
1
diff
changeset
|
209 |
} |
1b5eb968d2c4
* Use a 'user block' character instead of a 'body block' for the settings line,
Mahlon E. Smith <mahlon@martini.nu>
parents:
1
diff
changeset
|
210 |
|
1
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 $data = []; |
1ae1a79094fa
ModPerl2 update. This code was actually released (before it was in a
Mahlon E. Smith <mahlon@martini.nu>
parents:
0
diff
changeset
|
212 |
|
1ae1a79094fa
ModPerl2 update. This code was actually released (before it was in a
Mahlon E. Smith <mahlon@martini.nu>
parents:
0
diff
changeset
|
213 |
# 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
|
214 |
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
|
215 |
foreach ( @lines ) { |
3
1b5eb968d2c4
* Use a 'user block' character instead of a 'body block' for the settings line,
Mahlon E. Smith <mahlon@martini.nu>
parents:
1
diff
changeset
|
216 |
if (/$re{body_wrap}/) { |
1
1ae1a79094fa
ModPerl2 update. This code was actually released (before it was in a
Mahlon E. Smith <mahlon@martini.nu>
parents:
0
diff
changeset
|
217 |
$comments++; |
1ae1a79094fa
ModPerl2 update. This code was actually released (before it was in a
Mahlon E. Smith <mahlon@martini.nu>
parents:
0
diff
changeset
|
218 |
} |
1ae1a79094fa
ModPerl2 update. This code was actually released (before it was in a
Mahlon E. Smith <mahlon@martini.nu>
parents:
0
diff
changeset
|
219 |
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
|
220 |
$subs++; |
0
868dae1581ff
Initial commit and migration to Mercurial.
Mahlon E. Smith <mahlon@martini.nu>
parents:
diff
changeset
|
221 |
} |
1
1ae1a79094fa
ModPerl2 update. This code was actually released (before it was in a
Mahlon E. Smith <mahlon@martini.nu>
parents:
0
diff
changeset
|
222 |
|
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 $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
|
224 |
$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
|
225 |
$level++; |
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 |
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
|
228 |
push @$data, [ $level, $_ ]; |
0
868dae1581ff
Initial commit and migration to Mercurial.
Mahlon E. Smith <mahlon@martini.nu>
parents:
diff
changeset
|
229 |
} |
1
1ae1a79094fa
ModPerl2 update. This code was actually released (before it was in a
Mahlon E. Smith <mahlon@martini.nu>
parents:
0
diff
changeset
|
230 |
$subsubs = ( scalar @lines - 1 ) - $subs - $comments; |
0
868dae1581ff
Initial commit and migration to Mercurial.
Mahlon E. Smith <mahlon@martini.nu>
parents:
diff
changeset
|
231 |
|
1
1ae1a79094fa
ModPerl2 update. This code was actually released (before it was in a
Mahlon E. Smith <mahlon@martini.nu>
parents:
0
diff
changeset
|
232 |
# 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
|
233 |
$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
|
234 |
$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
|
235 |
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
|
236 |
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
|
237 |
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
|
238 |
|
1ae1a79094fa
ModPerl2 update. This code was actually released (before it was in a
Mahlon E. Smith <mahlon@martini.nu>
parents:
0
diff
changeset
|
239 |
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
|
240 |
my $in = " " 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
|
241 |
$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
|
242 |
next; |
1ae1a79094fa
ModPerl2 update. This code was actually released (before it was in a
Mahlon E. Smith <mahlon@martini.nu>
parents:
0
diff
changeset
|
243 |
} |
1ae1a79094fa
ModPerl2 update. This code was actually released (before it was in a
Mahlon E. Smith <mahlon@martini.nu>
parents:
0
diff
changeset
|
244 |
|
1ae1a79094fa
ModPerl2 update. This code was actually released (before it was in a
Mahlon E. Smith <mahlon@martini.nu>
parents:
0
diff
changeset
|
245 |
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
|
246 |
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
|
247 |
|
1ae1a79094fa
ModPerl2 update. This code was actually released (before it was in a
Mahlon E. Smith <mahlon@martini.nu>
parents:
0
diff
changeset
|
248 |
$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
|
249 |
$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
|
250 |
$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
|
251 |
|
868dae1581ff
Initial commit and migration to Mercurial.
Mahlon E. Smith <mahlon@martini.nu>
parents:
diff
changeset
|
252 |
# 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
|
253 |
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
|
254 |
my $itmstr = $subs == 1 ? 'item' : 'items'; |
868dae1581ff
Initial commit and migration to Mercurial.
Mahlon E. Smith <mahlon@martini.nu>
parents:
diff
changeset
|
255 |
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
|
256 |
$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
|
257 |
} |
868dae1581ff
Initial commit and migration to Mercurial.
Mahlon E. Smith <mahlon@martini.nu>
parents:
diff
changeset
|
258 |
|
1
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 $li_class = '>'; |
3
1b5eb968d2c4
* Use a 'user block' character instead of a 'body block' for the settings line,
Mahlon E. Smith <mahlon@martini.nu>
parents:
1
diff
changeset
|
260 |
$li_class = ' class="todo">' if $line =~ s#$re{todo}##; |
1b5eb968d2c4
* Use a 'user block' character instead of a 'body block' for the settings line,
Mahlon E. Smith <mahlon@martini.nu>
parents:
1
diff
changeset
|
261 |
$li_class = ' class="done">' if $line =~ s#$re{done}##; |
1b5eb968d2c4
* Use a 'user block' character instead of a 'body block' for the settings line,
Mahlon E. Smith <mahlon@martini.nu>
parents:
1
diff
changeset
|
262 |
$li_class = ' class="comment_pre">' if $line =~ s#$re{body}#$1#; |
1b5eb968d2c4
* Use a 'user block' character instead of a 'body block' for the settings line,
Mahlon E. Smith <mahlon@martini.nu>
parents:
1
diff
changeset
|
263 |
$li_class = ' class="comment">' if $line =~ s#$re{body_wrap}#$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
|
264 |
|
1ae1a79094fa
ModPerl2 update. This code was actually released (before it was in a
Mahlon E. Smith <mahlon@martini.nu>
parents:
0
diff
changeset
|
265 |
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
|
266 |
$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
|
267 |
} |
868dae1581ff
Initial commit and migration to Mercurial.
Mahlon E. Smith <mahlon@martini.nu>
parents:
diff
changeset
|
268 |
|
1
1ae1a79094fa
ModPerl2 update. This code was actually released (before it was in a
Mahlon E. Smith <mahlon@martini.nu>
parents:
0
diff
changeset
|
269 |
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
|
270 |
$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
|
271 |
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
|
272 |
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
|
273 |
$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
|
274 |
} |
1ae1a79094fa
ModPerl2 update. This code was actually released (before it was in a
Mahlon E. Smith <mahlon@martini.nu>
parents:
0
diff
changeset
|
275 |
} |
0
868dae1581ff
Initial commit and migration to Mercurial.
Mahlon E. Smith <mahlon@martini.nu>
parents:
diff
changeset
|
276 |
|
1
1ae1a79094fa
ModPerl2 update. This code was actually released (before it was in a
Mahlon E. Smith <mahlon@martini.nu>
parents:
0
diff
changeset
|
277 |
else { |
1ae1a79094fa
ModPerl2 update. This code was actually released (before it was in a
Mahlon E. Smith <mahlon@martini.nu>
parents:
0
diff
changeset
|
278 |
# 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
|
279 |
$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
|
280 |
} |
1ae1a79094fa
ModPerl2 update. This code was actually released (before it was in a
Mahlon E. Smith <mahlon@martini.nu>
parents:
0
diff
changeset
|
281 |
|
1ae1a79094fa
ModPerl2 update. This code was actually released (before it was in a
Mahlon E. Smith <mahlon@martini.nu>
parents:
0
diff
changeset
|
282 |
$i++; |
0
868dae1581ff
Initial commit and migration to Mercurial.
Mahlon E. Smith <mahlon@martini.nu>
parents:
diff
changeset
|
283 |
} |
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 |
|
1ae1a79094fa
ModPerl2 update. This code was actually released (before it was in a
Mahlon E. Smith <mahlon@martini.nu>
parents:
0
diff
changeset
|
285 |
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
|
286 |
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
|
287 |
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
|
288 |
$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
|
289 |
} |
1ae1a79094fa
ModPerl2 update. This code was actually released (before it was in a
Mahlon E. Smith <mahlon@martini.nu>
parents:
0
diff
changeset
|
290 |
$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
|
291 |
} |
1ae1a79094fa
ModPerl2 update. This code was actually released (before it was in a
Mahlon E. Smith <mahlon@martini.nu>
parents:
0
diff
changeset
|
292 |
$r->print( "</div>\n\n" ); |
0
868dae1581ff
Initial commit and migration to Mercurial.
Mahlon E. Smith <mahlon@martini.nu>
parents:
diff
changeset
|
293 |
} |
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 $t1 = Time::HiRes::gettimeofday; |
868dae1581ff
Initial commit and migration to Mercurial.
Mahlon E. Smith <mahlon@martini.nu>
parents:
diff
changeset
|
296 |
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
|
297 |
$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
|
298 |
$r->print(<<EHTML); |
868dae1581ff
Initial commit and migration to Mercurial.
Mahlon E. Smith <mahlon@martini.nu>
parents:
diff
changeset
|
299 |
</body> |
868dae1581ff
Initial commit and migration to Mercurial.
Mahlon E. Smith <mahlon@martini.nu>
parents:
diff
changeset
|
300 |
</html> |
868dae1581ff
Initial commit and migration to Mercurial.
Mahlon E. Smith <mahlon@martini.nu>
parents:
diff
changeset
|
301 |
EHTML |
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 |
return OK; |
868dae1581ff
Initial commit and migration to Mercurial.
Mahlon E. Smith <mahlon@martini.nu>
parents:
diff
changeset
|
304 |
} |
868dae1581ff
Initial commit and migration to Mercurial.
Mahlon E. Smith <mahlon@martini.nu>
parents:
diff
changeset
|
305 |
|
868dae1581ff
Initial commit and migration to Mercurial.
Mahlon E. Smith <mahlon@martini.nu>
parents:
diff
changeset
|
306 |
sub sorter |
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 |
my ($opt, $re) = @_; |
868dae1581ff
Initial commit and migration to Mercurial.
Mahlon E. Smith <mahlon@martini.nu>
parents:
diff
changeset
|
309 |
return 0 unless $opt->{sorttype}; |
868dae1581ff
Initial commit and migration to Mercurial.
Mahlon E. Smith <mahlon@martini.nu>
parents:
diff
changeset
|
310 |
my ($sa, $sb); |
868dae1581ff
Initial commit and migration to Mercurial.
Mahlon E. Smith <mahlon@martini.nu>
parents:
diff
changeset
|
311 |
if ($opt->{sorttype} eq 'percent') { |
868dae1581ff
Initial commit and migration to Mercurial.
Mahlon E. Smith <mahlon@martini.nu>
parents:
diff
changeset
|
312 |
$sa = $2 if $a =~ $re->{percent}; |
868dae1581ff
Initial commit and migration to Mercurial.
Mahlon E. Smith <mahlon@martini.nu>
parents:
diff
changeset
|
313 |
$sb = $2 if $b =~ $re->{percent}; |
868dae1581ff
Initial commit and migration to Mercurial.
Mahlon E. Smith <mahlon@martini.nu>
parents:
diff
changeset
|
314 |
return $opt->{sortrev} ? $sb <=> $sa : $sa <=> $sb; |
868dae1581ff
Initial commit and migration to Mercurial.
Mahlon E. Smith <mahlon@martini.nu>
parents:
diff
changeset
|
315 |
} |
868dae1581ff
Initial commit and migration to Mercurial.
Mahlon E. Smith <mahlon@martini.nu>
parents:
diff
changeset
|
316 |
else { |
868dae1581ff
Initial commit and migration to Mercurial.
Mahlon E. Smith <mahlon@martini.nu>
parents:
diff
changeset
|
317 |
$sa = $1 if $a =~ $re->{linetext}; |
868dae1581ff
Initial commit and migration to Mercurial.
Mahlon E. Smith <mahlon@martini.nu>
parents:
diff
changeset
|
318 |
$sb = $1 if $b =~ $re->{linetext}; |
868dae1581ff
Initial commit and migration to Mercurial.
Mahlon E. Smith <mahlon@martini.nu>
parents:
diff
changeset
|
319 |
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
|
320 |
} |
868dae1581ff
Initial commit and migration to Mercurial.
Mahlon E. Smith <mahlon@martini.nu>
parents:
diff
changeset
|
321 |
} |
868dae1581ff
Initial commit and migration to Mercurial.
Mahlon E. Smith <mahlon@martini.nu>
parents:
diff
changeset
|
322 |
|
868dae1581ff
Initial commit and migration to Mercurial.
Mahlon E. Smith <mahlon@martini.nu>
parents:
diff
changeset
|
323 |
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
|
324 |