Changeset 1b5eb968d2c4


Ignore:
Timestamp:
10/29/09 15:27:35 (3 years ago)
Author:
Mahlon E. Smith <mahlon@…>
Branch:
default
Message:
  • 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;

Files:
7 edited

Legend:

Unmodified
Added
Removed
  • Apache/OTL.pm

    r1 r3  
    22# VimOutliner (OTL) XHTML pretty printer for mod_perl2/apache2. 
    33# 
    4 # Copyright (c) 2006, Mahlon E. Smith <mahlon@martini.nu> 
     4# Copyright (c) 2006-2009, Mahlon E. Smith <mahlon@martini.nu> 
    55# All rights reserved. 
    66# Redistribution and use in source and binary forms, with or without 
     
    4141sub handler 
    4242{ 
    43     my $VERSION = '0.5'; 
     43    my $VERSION = '0.6'; 
    4444    my $ID      = '$Id$'; 
    4545    my $r       = shift; 
     
    7171        todo        => qr/(\[_\]) /, 
    7272        done        => qr/(\[X\]) /, 
    73         comment     => qr/^(?:\t+)?:(.+)/, 
     73        user        => qr/^(?:\t+)?\<(.+)/, 
     74        user_wrap   => qr/^(?:\t+)?\>(.+)/, 
     75        body_wrap   => qr/^(?:\t+)?:(.+)/, 
     76        body        => qr/^(?:\t+)?;(.+)/, 
    7477        time        => qr/(\d{2}:\d{2}:\d{2})/, 
    7578        date        => qr/(\d{2,4}-\d{2}-\d{2})/, 
     
    105108    { 
    106109        my $settings = shift @blocks; 
    107         if ($settings =~ $re{comment}) { 
    108             %opt = map { split /=/ } split /\s?:/, $settings; 
     110        if ($settings =~ $re{user}) { 
     111            %opt = map { split /=/ } split /\s?:/, $1; 
    109112        } 
    110113         
     
    116119        } 
    117120    } 
     121 
     122    # Now that we have tried to detect settings, 
     123    # remove any level 0 blocks that are user data. 
     124    @blocks = grep { $_ !~ /^[\<\>]/ } @blocks; 
    118125 
    119126    # GET args override settings 
     
    134141        generated by otl_handler $VERSION 
    135142        Mahlon E. Smith <mahlon\@martini.nu> 
    136         http://www.martini.nu/ 
     143        http://projects.martini.nu/apache-otl/ 
    137144 
    138145        Get VimOutliner at: http://www.vimoutliner.org/ 
     
    196203    foreach my $block ( sort { sorter(\%opt, \%re) } @blocks ) { 
    197204        # separate outline items 
    198         my @lines = grep { $_ !~ /$re{'hideline'}/ } split /\n/, $block; 
     205        my @lines; 
     206        foreach my $line ( split /\n/, $block ) { 
     207            push @lines, $line unless $line =~ $re{hideline} || 
     208                $line =~ $re{user} || $line =~ $re{user_wrap}; 
     209        } 
     210 
    199211        my $data  = []; 
    200212 
     
    202214        my ( $subs, $comments, $subsubs ) = ( 0, 0, 0 ); 
    203215        foreach ( @lines ) { 
    204             if (/$re{comment}/) { 
     216            if (/$re{body_wrap}/) { 
    205217                $comments++; 
    206218            } 
     
    246258 
    247259            my $li_class = '>'; 
    248             $li_class = ' class="todo">'    if $line =~ s#$re{todo}##; 
    249             $li_class = ' class="done">'    if $line =~ s#$re{done}##; 
    250             $li_class = ' class="comment">' if $line =~ s#$re{comment}#$1#; 
     260            $li_class = ' class="todo">'        if $line =~ s#$re{todo}##; 
     261            $li_class = ' class="done">'        if $line =~ s#$re{done}##; 
     262            $li_class = ' class="comment_pre">' if $line =~ s#$re{body}#$1#; 
     263            $li_class = ' class="comment">'     if $line =~ s#$re{body_wrap}#$1#; 
    251264 
    252265            if ( $next_level == $level || $next_level == 0 ) { 
  • README

    r1 r3  
    4646 
    4747Settings for the otl_handler are stored on the first line of the otl 
    48 files themselves, prefixed by a colon.  See the sample.otl for an 
    49 example settings line.  All settings are entirely optional. 
     48files themselves, prefixed by the 'user no wrap' character, '<'. See 
     49the sample.otl for an example settings line.  All settings are entirely 
     50optional. 
    5051 
    5152title 
  • javascript/jquery.js

    r1 r3  
    77 * 
    88 * $Date: 2006-10-09 20:23:18 -0400 (Mon, 09 Oct 2006) $ 
    9  * $Rev: 413 $ 
     9 * $Rev$ 
    1010 */ 
    1111 
  • sample.otl

    r1 r3  
    1 :title=Sample OTL list :counts=1 :timer=1 :style=styles/theme1.css :legend=1 :last_mod=1 
     1<:title=Sample OTL list :counts=1 :timer=1 :style=styles/theme1.css :legend=1 :last_mod=1 
    22 
    33: Theme examples: 
  • styles/theme1.css

    r1 r3  
    3636    margin-bottom: 5px; 
    3737    font-family: sans; 
     38} 
     39 
     40.comment_pre 
     41 
     42    font-style: normal; 
     43    font-family: courier; 
     44    white-space: pre; 
    3845} 
    3946 
  • styles/theme2.css

    r1 r3  
    132132} 
    133133 
     134.comment_pre 
     135 
     136    font-style: normal; 
     137    font-family: courier; 
     138    white-space: pre; 
     139} 
     140 
    134141.comment:hover 
    135142{ 
  • styles/theme3.css

    r1 r3  
    8989} 
    9090 
     91#content .comment_pre 
     92 
     93    font-style: normal; 
     94    font-family: courier; 
     95    white-space: pre; 
     96} 
     97 
    9198#content 
    9299{ 
Note: See TracChangeset for help on using the changeset viewer.