source: README @ 1b5eb968d2c4

Revision 1b5eb968d2c4, 3.7 KB checked in by Mahlon E. Smith <mahlon@…>, 2 years ago (diff)
  • Use a 'user block' character instead of a 'body block' for the settings line,

as suggested by David J. Patrick <djp@…>.

  • Ignore all user blocks (wrapped or otherwise.)
  • Display body (not wrapped) text as 'pre' in css.

diff --git a/Apache/OTL.pm b/Apache/OTL.pm
--- a/Apache/OTL.pm
+++ b/Apache/OTL.pm
@@ -1,7 +1,7 @@

#
# VimOutliner? (OTL) XHTML pretty printer for mod_perl2/apache2.
#

-# Copyright (c) 2006, Mahlon E. Smith <mahlon@…>
+# Copyright (c) 2006-2009, Mahlon E. Smith <mahlon@…>

# All rights reserved.
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions are met:

@@ -40,7 +40,7 @@

sub handler
{

  • my $VERSION = '0.5';

+ my $VERSION = '0.6';

my $ID = '$Id$';
my $r = shift;
my $t0 = Time::HiRes::gettimeofday;

@@ -70,7 +70,10 @@

percent => qr/(\[.\]) (\d+)%/,
todo => qr/(\[_\]) /,
done => qr/(\[X\]) /,

  • comment => qr/(?:\t+)?:(.+)/,

+ user => qr/(?:\t+)?\<(.+)/,
+ user_wrap => qr/(?:\t+)?\>(.+)/,
+ body_wrap => qr/
(?:\t+)?:(.+)/,
+ body => qr/(?:\t+)?;(.+)/,

time => qr/(\d{2}:\d{2}:\d{2})/,
date => qr/(\d{2,4}-\d{2}-\d{2})/,
subitem => qr/\t(?!\t)/,

@@ -104,8 +107,8 @@

# get optional settings and otl title
{

my $settings = shift @blocks;

  • if ($settings =~ $re{comment}) {
  • %opt = map { split /=/ } split /\s?:/, $settings;

+ if ($settings =~ $re{user}) {
+ %opt = map { split /=/ } split /\s?:/, $1;

}

# if the first group wasn't a comment,

@@ -116,6 +119,10 @@

}

}

+ # Now that we have tried to detect settings,
+ # remove any level 0 blocks that are user data.
+ @blocks = grep { $_ !~ /[\<\>]/ } @blocks;
+

# GET args override settings
$opt{$_} = $get->{$_} foreach keys %$get;

@@ -133,7 +140,7 @@

<!--

generated by otl_handler $VERSION
Mahlon E. Smith <mahlon\@martini.nu>

+ http://projects.martini.nu/apache-otl/

Get VimOutliner? at:  http://www.vimoutliner.org/

-->

@@ -195,13 +202,18 @@

foreach my $block ( sort { sorter(\%opt, \%re) } @blocks ) {

# separate outline items

  • my @lines = grep { $_ !~ /$re{'hideline'}/ } split /\n/, $block;

+ my @lines;
+ foreach my $line ( split /\n/, $block ) {

+ push @lines, $line unless $line =~ $re{hideline} + $line =~ $re{user}
$line =~ $re{user_wrap};

+ }
+

my $data = [];

# build structure and get item counts
my ( $subs, $comments, $subsubs ) = ( 0, 0, 0 );
foreach ( @lines ) {

  • if (/$re{comment}/) {

+ if (/$re{body_wrap}/) {

$comments++;

}
elsif (/$re{subitem}/) {

@@ -245,9 +257,10 @@

}

my $li_class = '>';

  • $li_class = ' class="todo">' if $line =~ s#$re{todo}##;
  • $li_class = ' class="done">' if $line =~ s#$re{done}##;
  • $li_class = ' class="comment">' if $line =~ s#$re{comment}#$1#;

+ $li_class = ' class="todo">' if $line =~ s#$re{todo}##;
+ $li_class = ' class="done">' if $line =~ s#$re{done}##;
+ $li_class = ' class="comment_pre">' if $line =~ s#$re{body}#$1#;
+ $li_class = ' class="comment">' if $line =~ s#$re{body_wrap}#$1#;

if ( $next_level == $level
$next_level == 0 ) {

$r->print( "$in<li" . $li_class . "$line</li>\n" );

diff --git a/README b/README
--- a/README
+++ b/README
@@ -45,8 +45,9 @@

---------------------------------------------------------------------

Settings for the otl_handler are stored on the first line of the otl

-files themselves, prefixed by a colon. See the sample.otl for an
-example settings line. All settings are entirely optional.
+files themselves, prefixed by the 'user no wrap' character, '<'. See
+the sample.otl for an example settings line. All settings are entirely
+optional.

title

Type: string

diff --git a/sample.otl b/sample.otl
--- a/sample.otl
+++ b/sample.otl
@@ -1,4 +1,4 @@
-:title=Sample OTL list :counts=1 :timer=1 :style=styles/theme1.css :legend=1 :last_mod=1
+<:title=Sample OTL list :counts=1 :timer=1 :style=styles/theme1.css :legend=1 :last_mod=1

: Theme examples:
: <a href="sample.otl">basic</a> <a href="sample.otl?counts=0&amp;style=styles/theme2.css&amp;legend=0&amp;js=/javascript/jquery.js,/javascript/theme2.js">advanced</a> <a href="sample.otl?counts=0&amp;style=styles/theme3.css&amp;legend=0&amp;timer=0&amp;js=/javascript/jquery.js,/javascript/theme3.js&amp;sort=1">advanced2</a>

diff --git a/styles/theme1.css b/styles/theme1.css
--- a/styles/theme1.css
+++ b/styles/theme1.css
@@ -37,6 +37,13 @@

font-family: sans;

}

+.comment_pre
+{
+ font-style: normal;
+ font-family: courier;
+ white-space: pre;
+}
+

.counts
{

margin-left: 10px;

diff --git a/styles/theme2.css b/styles/theme2.css
--- a/styles/theme2.css
+++ b/styles/theme2.css
@@ -131,6 +131,13 @@

border-right: 1px solid #666;

}

+.comment_pre
+{
+ font-style: normal;
+ font-family: courier;
+ white-space: pre;
+}
+

.comment:hover
{

border-top: 1px solid #aaa;

diff --git a/styles/theme3.css b/styles/theme3.css
--- a/styles/theme3.css
+++ b/styles/theme3.css
@@ -88,6 +88,13 @@

margin-bottom: 3px;

}

+#content .comment_pre
+{
+ font-style: normal;
+ font-family: courier;
+ white-space: pre;
+}
+

#content
{

position: absolute;

Line 
1
2                                                       WHAT IS THIS?
3---------------------------------------------------------------------
4
5Vimoutliner already comes with some otl to HTML converters that work
6quite well.  I maintain a few different otl files, that are displayed
7on a internal intranet - the step of converting to HTML on every little
8change before upload was becoming mildly irritating, and countering my
9near legendary laziness.
10
11This mod_perl handler teaches apache how to pretty print otl natively.
12
13Now, I can just edit the otl files directly - skip the conversion step
14altogether, and let Apache make some delicious looking outlines.
15
16
17                                                        INSTALLATION
18---------------------------------------------------------------------
19
20First of all, prerequisites!
21
22    - apache2
23    - mod_perl2
24    - libapreq2 (Apache2::Request)
25
26Add the following lines in your httpd.conf, or in a
27separate otl.conf in the apache Includes directory:
28
29    -------------------------
30    PerlSwitches -I/path/to/perl/libraries
31    PerlModule Apache::OTL
32
33    <FilesMatch ".*\.otl">
34        SetHandler perl-script
35        PerlResponseHandler Apache::OTL
36    </FilesMatch>
37    -------------------------
38
39Doublecheck that your apreq2 module is setup to load, as well.
40
41That's it.  Apache will now pretty-print all your otl files.
42
43
44                                                            SETTINGS
45---------------------------------------------------------------------
46
47Settings for the otl_handler are stored on the first line of the otl
48files themselves, prefixed by the 'user no wrap' character, '<'. See
49the sample.otl for an example settings line.  All settings are entirely
50optional.
51
52title
53    Type: string
54    Default: filename
55
56    The title of the OTL.  Used as a header, and the html title.
57    If this is not set, the html title is derived from the filename.
58
59
60style
61    Type: string
62    Default: none
63
64    A path to css style(s).
65    Comma separated values load different files in order.
66    Media type defaults to 'screen', if the css name contains the
67    string 'print' anywhere, the media type is changed to print.
68
69    :style=/css/otl_style.css,/css/print_style.css
70
71js
72    Type: string
73    Default: none
74
75    Use javascript?  If set, loads an external javascript library.
76    Comma separated values load diff files in order.
77
78
79last_mod
80    Type: boolean
81    Default: 0
82
83    Show modification time of the otl file?
84
85   
86legend
87    Type: boolean
88    Default: 0
89
90    Display small legend for todo and done items?
91
92
93sort
94    Type: boolean
95    Default: 0
96
97    Show sort links?
98
99
100sorttype
101    Type: string
102    Default: none
103
104    Default sorting method.  Valid values are
105        percent
106        alpha
107
108
109sortrev
110    Type: boolean
111    Default: 0
112
113    Should we default to reverse sorting?
114
115
116counts
117    Type: boolean
118    Default: 0
119
120    Count and display sub items?
121
122
123timer
124    Type: boolean
125    Default: 0
126
127    Display how long the parser took to generate the html?
128
129
130
131                                                      INCLUDED FILES
132---------------------------------------------------------------------
133
134/Apache/OTL.pm
135    The mod_perl content handler.
136
137/javascript/*
138    Example (but functional!) javascript.  Create line numbers,
139    various eye candies, and clickable folds.
140
141    This requires the 'jquery.js' library, also included.
142
143/sample.otl
144    An example vimoutliner file, with optional settings.
145
146/styles/*
147    "Theme" examples for customizing OTL display.
148
149
150                                                    ACKNOWLEDGEMENTS
151---------------------------------------------------------------------
152
153Thanks to Nathan Dabney <nathan.dabney@gmail.com> and
154Michael Granger <ged@faeriemud.org> for their help and advice!
155
Note: See TracBrowser for help on using the repository browser.