[poe-commits] extras/wiki index.cgi,1.4,1.5
Brought to you by:
rcaputo
From: <rc...@us...> - 2003-08-31 18:58:04
|
Update of /cvsroot/poe/extras/wiki In directory sc8-pr-cvs1:/tmp/cvs-serv6301 Modified Files: index.cgi Log Message: Extend vim outline support to include bulleted and todo-list styles. Index: index.cgi =================================================================== RCS file: /cvsroot/poe/extras/wiki/index.cgi,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** index.cgi 9 Jun 2003 04:39:28 -0000 1.4 --- index.cgi 31 Aug 2003 18:58:00 -0000 1.5 *************** *** 1328,1332 **** s/\<tests\>\s*\n?((.|\n)*?)\<\/tests\>/&StoreTests($1)/ige; s/\<projects\>\s*\n?((.|\n)*?)\<\/projects\>/&StoreProjects($1)/ige; ! s/\<outline\>\s*\n?((.|\n)*?)\<\/outline\>/&StoreOutline($1)/ige; s/\<components\>\s*\n?((.|\n)*?)\<\/components\>/&StoreComponents($1)/ige; --- 1328,1334 ---- s/\<tests\>\s*\n?((.|\n)*?)\<\/tests\>/&StoreTests($1)/ige; s/\<projects\>\s*\n?((.|\n)*?)\<\/projects\>/&StoreProjects($1)/ige; ! s/\<outline\>\s*\n?((.|\n)*?)\<\/outline\>/&StoreOutline($1,"bullets")/ige; ! s/\<outline-head\>\s*\n?((.|\n)*?)\<\/outline\>/&StoreOutline($1,"headers")/ige; ! s/\<outline-todo\>\s*\n?((.|\n)*?)\<\/outline\>/&StoreOutline($1,"todo")/ige; s/\<components\>\s*\n?((.|\n)*?)\<\/components\>/&StoreComponents($1)/ige; *************** *** 1411,1415 **** foreach (split(/\n/, $pageText)) { # Process lines one-at-a-time $_ .= "\n"; ! if (s/^(\;+)([^:]+\:?)\:/<dt>$2<dd>/) { $code = "DL"; $depth = length $1; --- 1413,1417 ---- foreach (split(/\n/, $pageText)) { # Process lines one-at-a-time $_ .= "\n"; ! if (s/^(\;+)([^:]+\:?)\:?/<dt>$2<dd>/) { $code = "DL"; $depth = length $1; *************** *** 1795,1800 **** } sub StoreOutline { ! my $source = shift; # The Wiki has munged $/, so we munge it back. By the time we get --- 1797,1812 ---- } + my %otl_colors = ( + "?" => "C0C0C0", + "-" => "008000", + "=" => "00C000", + "+" => "00FF00", + "*" => "000000", + "#" => "800000", + ); + sub StoreOutline { ! my ($source, $type) = @_; ! $type = "headers" unless defined $type; # The Wiki has munged $/, so we munge it back. By the time we get *************** *** 1810,1813 **** --- 1822,1827 ---- while ($source =~ m/^(.*)$/mig) { my $line = $1; + + # Headings. if ($line =~ s/^(\t+)//) { $level = length $1; *************** *** 1820,1824 **** if ($line =~ s/^\| //) { $line =~ s/^\s*$//; ! push @outline, $line; next; } --- 1834,1855 ---- if ($line =~ s/^\| //) { $line =~ s/^\s*$//; ! ! if ($type eq "todo") { ! # Can't use : in todo lists, because it's a special wiki character. ! $line =~ s/:/:/g; ! ! # This line continues a pipe, and it's not pre-formatted. ! if (@outline and $outline[-1] =~ /^:/ and $line !~ /^\s/) { ! $outline[-1] =~ s/\s+$//; ! $outline[-1] .= " $line"; ! } ! else { ! my $stuff = ":" x ($level + 1); ! push @outline, "$stuff$line"; ! } ! } ! else { ! push @outline, $line; ! } next; } *************** *** 1830,1838 **** } ! my $stuff = "=" x ($level + 1); ! push @outline, "$stuff $line $stuff\n"; } if (@outline) { return WikiLinesToHtml(join "\n", @outline); } --- 1861,1939 ---- } ! if ($type eq "headers") { ! my $stuff = "=" x ($level + 1); ! push @outline, "$stuff $line $stuff\n"; ! next; ! } ! ! if ($type eq "bullets") { ! my $stuff = "*" x ($level + 1); ! push @outline, "$stuff $line"; ! next; ! } ! ! if ($type eq "todo") { ! my $stuff = ";" x ($level+1); ! $line =~ s/^([\!-\/\:-\@\[-\`\{-\~])\s+/<tt>$1 <\/tt>/; ! my $bullet = $1; ! ! $line =~ s/\:/:/g; ! ! # TODO - Make this use style sheets! ! my $color; ! if (exists $otl_colors{$bullet}) { ! $color = $otl_colors{$bullet}; ! } ! else { ! $color = "F08080"; ! } ! ! push @outline, "$stuff <font color='$color'>$line</font>"; ! next; ! } ! ! push @outline, "?($type,$level) $line"; } if (@outline) { + for (1..$#outline-1) { + next if $outline[$_] =~ /\S/; + if ($outline[$_-1] =~ /^(\s+)/) { + my $match = $1; + if ($outline[$_+1] =~ /^$match/) { + $outline[$_] = $match; + } + } + } + + if ($type eq "todo") { + unshift( + @outline, + " \? = Maybe. An idea without a plan.", + " \- = Planned.", + " \= = Started. Actively being worked on.", + " \+ = Almost done.", + " \* = Done. Hooray!", + " \# = Blocked. Someone or something is in the way.", + ); + } + + # # Wrap indented blocks in <pre></pre>. + # my $index = @outline; + # my $outside_pre = 1; + # while ($index--) { + # if ($outline[$index] =~ /^ /) { + # if ($outside_pre) { + # splice(@outline, $index+1, 0, "</pre>"); + # $outside_pre = 0; + # } + # next; + # } + # unless ($outside_pre) { + # splice(@outline, $index, 0, "<pre>"); + # $outside_pre = 1; + # } + # } + return WikiLinesToHtml(join "\n", @outline); } *************** *** 4461,4465 **** $text =~ s/(<tests>((.|\n)*?)<\/tests>)/&StoreTests($1)/smige; $text =~ s/(<projects>((.|\n)*?)<\/projects>)/&StoreProjects($1)/smige; ! $text =~ s/(<outline>((.|\n)*?)<\/outline>)/&StoreOutline($1)/smige; $text =~ s/(<components>((.|\n)*?)<\/components>)/&StoreComponents($1)/smige; $text =~ s/(<nowiki>((.|\n)*?)<\/nowiki>)/&StoreRaw($1)/ige; --- 4562,4568 ---- $text =~ s/(<tests>((.|\n)*?)<\/tests>)/&StoreTests($1)/smige; $text =~ s/(<projects>((.|\n)*?)<\/projects>)/&StoreProjects($1)/smige; ! $text =~ s/(<outline>((.|\n)*?)<\/outline>)/&StoreOutline($1,"bullets")/smige; ! $text =~ s/(<outline-head>((.|\n)*?)<\/outline>)/&StoreOutline($1,"headers")/smige; ! $text =~ s/(<outline-todo>((.|\n)*?)<\/outline>)/&StoreOutline($1,"todo")/smige; $text =~ s/(<components>((.|\n)*?)<\/components>)/&StoreComponents($1)/smige; $text =~ s/(<nowiki>((.|\n)*?)<\/nowiki>)/&StoreRaw($1)/ige; |