I leave it to SomebodyElse? to decide how long to preserve this old info --RiVer
Since there have been so many patches, I'm going to start moving them to subpages of WikiPatches (like WikiPatches/LineEnds).
Page caching bug(s):
I think http://www.mnot.net/cache_docs/ is a good document on the issue.
I installed UseModWiki at our site, and run into this problem immediately. Since our users use maybe all the possible browsers ranging from lynx to Opera to IE to anything else, I had to find a solution.
--- usemod092/wiki.pl Sun Apr 22 00:44:10 2001 +++ wiki.cgi Sun Apr 29 00:01:57 2001 @@ -973,6 +973,8 @@ sub GetHttpHeader { my $cookie; + my $now; + $now = gmtime; if (defined($SetCookie{'id'})) { $cookie = "$CookieName=" . "rev&" . $SetCookie{'rev'} @@ -981,12 +983,20 @@ $cookie .= ";expires=Fri, 08-Sep-2010 19:48:23 GMT"; if ($HttpCharset ne '') { return $q->header(-cookie=>$cookie, + -pragma=>"no-cache", + -cache_control=>"no-cache", + -last_modified=>"$now", + -expires=>"+10s", -type=>"text/html; charset=$HttpCharset"); } return $q->header(-cookie=>$cookie); } if ($HttpCharset ne '') { - return $q->header(-type=>"text/html; charset=$HttpCharset"); + return $q->header(-type=>"text/html; charset=$HttpCharset", + -pragma=>"no-cache", + -cache_control=>"no-cache", + -last_modified=>"$now", + -expires=>"+10s"); } return $q->header(); }
When both are active, "==== Subtitle ====" gets formatted as "<HR>", not as a header "<H4>Subtitle</H4>". Patch:
sub CommonMarkup { ... if ($ThinLine) { s/----+/<hr noshade size=1>/g; ##!! s/====+/<hr noshade size=2>/g; # collides with H4 !! } else { s/----+/<hr>\n/g; } ... }--HaJoGurt
perhaps
s/^\s*====+\s*$/<hr noshade size=2>/gmx;can be used instead. As long as you do not expect
==== heading ====to create a level 4 heading, everything should be fine. --Ken
Not a bugfix. This enables usemod to render simple tables. Tables are handled somewhat like text within "<pre> </pre>". Note that this patch doesn't work with 0.92 as it sets 'use strict', and the patch uses a global variable $tag. To make it work, you need to add $tag to the 'my' declaration right after the 'sub WikiLinesToHtml'. ==Viktor Haag Sorry, I must have lost the line "my ($tag);" somehow. Patch now repaired --HaJoGurt
| Col1 | Col2 | Col3gets formatted as
<TABLE BORDER=0> <TR><TD> Col1</TD> <td> Col2 </td> <td> Col3 </td> </TR> </table>The Patch:
sub CommonMarkup { ... ## Tables: s/^\|([^|]+)[^|]/<TR><TD>$1<\/TD>\n/g; # start of line: new table-row s/\|([^|]+)[^|]/<td>$1<\/td>\n/g; # new field } return $_; } sub WikiLinesToHtml { ... my ($tag); ... } elsif (/^[ \t].*\S/) { $code = "PRE"; $depth = 1; #%% Table => PRE: } elsif (/^[\|\+].*\S/) { $code = "TABLE"; $depth = 1; # } else { $depth = 0; } while (@htmlStack > $depth) { # Close tags as needed # $pageHtml .= "</" . pop(@htmlStack) . ">\n"; #%% $tag = pop(@htmlStack); if ($tag eq "TABLE") { $pageHtml .= "</TR>\n"; $tag = "table" }; $pageHtml .= "</" . $tag . ">\n"; } if ($depth > 0) { $depth = $IndentLimit if ($depth > $IndentLimit); ...#! while (@htmlStack < $depth) { push(@htmlStack, $code); #%% if ($code eq "TABLE") { $pageHtml .= "<TABLE BORDER=0>\n"; } else { $pageHtml .= "<$code>\n"; }; } }Next project: Specify different styles, like FONT and BGCOLOR, for each row, column and/or cell :-) By the way, the original code at "...#!" above can be left out. I think that will fix a bug with mixed / nested lists :
# Foo ** Ding ** Dong # Bar ** Ping ** Pong ---- * Foo ## Ding ## Dong * Bar ## Ping ## Pongwill then look like:
1. Foo + Ding + Dong 2. Bar + Ping + Pong ---- * Foo 1. Ding 2. Dong * Bar 1. Ping 2. Pong--HaJoGurt
sub CommonMarkup { ... if ($doLines) { ... s/(@*)@@@(.*?)@@@/$1<FONT COLOR="red"><B>$2<\/B><\/FONT>/g; s/(\^*)\^\^\^(.*?)\^\^\^/$1<FONT COLOR="green">$2<\/FONT>/g; s/(~*)~~~(.*?)~~~/$1<FONT COLOR="blue">$2<\/FONT>/g; s/(-*)---(.*?)---/$1<FONT SIZE="-1">$2<\/FONT>/g; s/(\+*)\+\+\+(.*?)\+\+\+/$1<FONT SIZE="+1">$2<\/FONT>/g; ## Tables: ... } return $_; }--HaJoGurt For red text, I decided it was more meaningful to just write
<red>Red text</red>
. I placed the following after the expression matching <tt/>
.
s/\<red\>(.*?)\<\/red\>/&StoreRaw('<span style="color:red">') . $1 . '<\/span>'/geis;I don't think @@@ really means red to me. It's too cooked. But either way, you should use the <span/> tag, not <font/>. And if you do, don't forget to StoreRaw() it! That colon gets matched later for the dictionary lists, as I discovered. :( -- SunirShah The above "@@@" for "red" was ment as an quick and easy way to mark something as "super-bold", e.g. for warnings etc. --HaJoGurt
package UseModWiki; use strict; local $| = 1; # Do not buffer output (localized for mod_perl) #%% use POSIX; # strftime ... sub CalcDay { my ($ts) = @_; $ts += $TimeZoneOffset; # my ($sec, $min, $hour, $mday, $mon, $year) = localtime($ts); # return ("January", "February", "March", "April", "May", "June", # "July", "August", "September", "October", "November", # "December")[$mon]. " " . $mday . ", " . ($year+1900); #%% return ( strftime "%Y-%m-%d", localtime($ts) ); }--HaJoGurt Hans, I've put this into my CVS usemod at 203.79.72.169 as detailed in the template section -- timeless
$BracketText = 1; # 1 = allow [URL text], 0 = no link descriptions, 2 = allow, but don't emit surrounding bracketsAdd to StoreBracketUrl?
sub StoreBracketUrl? { my ($url, $text) = @_; if ($text eq "") { $text = &GetBracketUrlIndex?($url); } return &StoreRaw("<a href=\"$url\">$text</a>") if 2 == $BracketText; return &StoreRaw("<a href=\"$url\">[$text]</a>"); }and similarly to StoreBracketLink?:
sub StoreBracketLink? { my ($name, $text) = @_; return &StoreRaw(&GetPageLinkText($name, "$text")) if 2 == $BracketText; return &StoreRaw(&GetPageLinkText($name, "[$text]")); }and StoreBracketInterPage?:
sub StoreBracketInterPage? { my ($id, $text) = @_; my ($site, $remotePage, $url, $index); ($site, $remotePage) = split(/:/, $id, 2); $remotePage =~ s/&/&/g; # Unquote common URL HTML $url = &GetSiteUrl($site); if ($text ne "") { #return "[$id]" if ($url eq ""); if ($url eq "") { return "$id $text" if 2 == $BracketText; return "[$id $text]"; } } else { #return "[$id]" if ($url eq ""); if ($url eq "") { return "$id" if 2 == $BracketText; return "[$id]"; } $text = &GetBracketUrlIndex?($id); } $url .= $remotePage; return &StoreRaw("<a href=\"$url\">$text</a>") if 2 == $BracketText; return &StoreRaw("<a href=\"$url\">[$text]</a>"); }
sub GetPageLinkText { my ($id, $name) = @_;
$id =~ s|^/|$MainPage/|; if ($FreeLinks) { $id = &FreeToNormal($id); $name =~ s/_/ /g; } $name =~ s/^\///g if (!$SubSlachText?); return &ScriptLink($id, $name); }
s/([^#])#(\w+)#/$1 . ++$Counters{$2}/ge;to CommonMarkup. I did this just after the <tt> expression. This will match things like #foo# #foo# #bar# #foo# #bar# in the text, emitting 1 2 1 3 2. -- SunirShah
--- usemod092/wiki.pl Sat Apr 21 17:44:10 2001 +++ wiki.pl Thu Aug 9 07:54:51 2001 @@ -1087,14 +1087,14 @@ my ($id) = @_; my ($main, $bartext); - $bartext = &GetPageLink($HomePage); + $bartext = T('home') . ': ' . &GetPageLink($HomePage); if ($id =~ m|/|) { $main = $id; $main =~ s|/.*||; # Only the main page name (remove subpage) - $bartext .= " | " . &GetPageLink($main); + $bartext .= " | " . T('up') . ': ' . &GetPageLink($main); } - $bartext .= " | " . &GetPageLink($RCName); - $bartext .= " | " . &GetPrefsLink(); + $bartext .= " | " . T('scan') . ': ' . &GetPageLink($RCName); + $bartext .= " | " . T('login') . ': ' . &GetPrefsLink(); if (&GetParam("linkrandom", 0)) { $bartext .= " | " . &GetRandomLink(); }-- PeterKaminski Note: When the HTML template functionality is complete, this will be obsolete... I imagine something like this in the HTML template: '<wiki object="GetPageLink"/> | <wiki object="GetPrefsLink?"/>' -- timeless
--- usemod092/wiki.pl Sat Apr 21 17:44:10 2001 +++ wiki.pl Sun Aug 12 11:08:33 2001 @@ -1482,11 +1482,11 @@ $first = "<a href=\"http://shop.barnesandnoble.com/bookSearch/" . "isbnInquiry.asp?isbn=$num\">"; $second = "<a href=\"http://www.amazon.com/exec/obidos/" - . "ISBN=$num\">" . T('alternate') . "</a>"; + . "ISBN=$num\">"; $third = "<a href=\"http://www.pricescan.com/books/" - . "BookDetail.asp?isbn=$num\">" . T('search') . "</a>"; + . "BookDetail.asp?isbn=$num\">"; $html = $first . "ISBN " . $rawprint . "</a> "; - $html .= "($second, $third)"; + $html .= "($second" . T('alternate') . "</a>, " . $third . T('search') . "</a>)"; $html .= " " if ($rawnum =~ / $/); # Add space if old ISBN had space. return $html; }-- PeterKaminski
my $target = ""; if ($PopWindows) { $target = "target=\"_self\""; } else { $target = ""; }
if ($PopWindows) { $html .= qq(<BASE target="_blank">\n); }what would be nice is for a user to select their preference --EricScheid Unfortunately if you make that a user preference, it will break the page caching feature. ---
Try it at http://koeln.ccc.de/~drt/wiki.cgi?action=rc&sincelastvisit=1
Hacked by the teenagemutantninjaheroecoders - http://c0re.jp/ --- wiki.cgi.orig Wed Aug 29 14:37:51 2001 +++ wiki.cgi Wed Aug 29 15:53:23 2001 @@ -463,6 +463,14 @@ $fullHtml .= &WikiToHTML($Text{'text'}); $fullHtml .= "<hr>\n" if (!&GetParam('embed', $EmbedWiki)); if (($id eq $RCName) || (T($RCName) eq $id) || (T($id) eq $RCName)) { + + if (&GetParam("sincelastvisit", 0)) { + my $cookie1 = $q->cookie(-name => $CookieName? . "-RC", + -value => time(), + -expires => '+60d'); + print "Set-Cookie: $cookie1\r\n"; + } + print $fullHtml; &DoRc(); print "<hr>\n" if (!&GetParam('embed', $EmbedWiki)); @@ -492,7 +500,10 @@ my $starttime = 0; my $showbar = 0;
- if (&GetParam("from", 0)) { + if (&GetParam("sincelastvisit", 0)) { + $starttime = $q->cookie($CookieName?."-RC"); + + } elsif (&GetParam("from", 0)) { $starttime = &GetParam("from", 0); print "<h2>" . Ts('Updates since %s', &TimeToText?($starttime)) . "</h2>\n";
Get it at http://c0re.jp/c0de/misc/usemod-0.92-changessincelastvisit.patch
$GlobalCSS = '/default.css';The Patch:
--- /home/matt/wiki/index.cgi Fri Sep 21 22:48:18 2001 +++ index.cgi Fri Sep 21 22:14:45 2001 @@ -48,7 +48,7 @@ $RCName $ShowEdits $ThinLine $LinkPattern $InterLinkPattern $InterSitePattern $UrlProtocols $UrlPattern $ImageExtensions $RFCPattern $ISBNPattern - $FS $FS1 $FS2 $FS3 $CookieName $SiteBase + $FS $FS1 $FS2 $FS3 $CookieName $SiteBase $GlobalCSS ); # Other global variables. Must be C<use vars> because they're @@ -67,6 +67,7 @@ $UseConfig = 1; # 1 = use config file, 0 = do not look for config # Default configuration (used if UseConfig is 0) +$GlobalCSS = ""; # path to global css style sheet $CookieName = "Wiki"; # Name for this wiki (for multi-wiki sites) $SiteName = "Wiki"; # Name of site (used for titles) $HomePage = "HomePage"; # Home page (change space to _) @@ -915,14 +916,19 @@ } else { $result = $q->header(); } - + + my %args; + if($GlobalCSS) { + $args{'-style'} = { 'src' => $GlobalCSS }; + } + if ($SiteBase ne "") { $result .= $q->start_html('-title' => "$SiteName: $title", '-xbase' => $SiteBase, - '-BGCOLOR' => 'white'); + '-BGCOLOR' => 'white', %args); } else { $result .= $q->start_html('-title' => "$SiteName: $title", - '-BGCOLOR' => 'white'); + '-BGCOLOR' => 'white', %args); } if ($oldId ne "") { $result .= $q->h3("(redirected from " @@ -1025,8 +1031,8 @@ sub GetSearchForm { my ($result); - $result = "Search: " . $q->textfield(-name=>'search', -size=>20) - . &GetHiddenValue("dosearch", 1); + #$result = "Search: " . $q->textfield(-name=>'search', -size=>20) + # . &GetHiddenValue("dosearch", 1); return $result; }
--- wiki.pl Sun Apr 22 02:44:10 2001 +++ ../usemod092-patched/wiki.pl Sat Oct 20 18:26:24 2001 @@ -38,7 +38,7 @@ $UseSubpage $UseCache $RawHtml $SimpleLinks $NonEnglish $LogoLeft $KeepDays $HtmlTags $HtmlLinks $UseDiffLog $KeepMajor $KeepAuthor $FreeUpper $EmailNotify $SendMail $EmailFrom $FastGlob $EmbedWiki - $ScriptTZ $BracketText $UseAmPm $UseConfig $UseIndex $UseLookup + $ScriptTZ $BracketText $UseAmPm $ConfigFile $UseIndex $UseLookup $RedirType $AdminPass $EditPass $UseHeadings $NetworkFile $BracketWiki $FreeLinks $WikiLinks $AdminDelete $FreeLinkPattern $RCName $RunCGI $ShowEdits $ThinLine $LinkPattern $InterLinkPattern $InterSitePattern @@ -55,10 +55,16 @@ $q $Now $UserID $TimeZoneOffset $ScriptName $BrowseCode $OtherCode); # == Configuration ===================================================== -$DataDir = "/tmp/mywikidb"; # Main wiki directory -$UseConfig = 1; # 1 = use config file, 0 = do not look for config +# twm: changed this to contain the name of the config file rather than +# having only a boolean variable UseConfig. +# Of course this required a few changes later on, but only a few. -# Default configuration (used if UseConfig is 0) +$ConfigFile = "/etc/wiki.conf"; # Name of config file; if "" defaults are used + +# Default configuration (used if ConfigFile is "") + +#twm: This should also go into the config file +$DataDir = "/usr/local/data/webserver/wiki.s2h.cx"; # Main wiki directory $CookieName = "Wiki"; # Name for this wiki (for multi-wiki sites) $SiteName = "Wiki"; # Name of site (used for titles) $HomePage = "HomePage"; # Home page (change space to _) @@ -145,8 +151,8 @@ # The "main" program, called at the end of this script file. sub DoWikiRequest { - if ($UseConfig && (-f "$DataDir/config")) { - do "$DataDir/config"; # Later consider error checking? + if ( ("$ConfigFile") && (-f "$ConfigFile")) { + do "$ConfigFile"; # Later consider error checking? } &InitLinkPatterns(); if (!&DoCacheBrowse()) {So you just set $ConfigFile to "/etc/wiki.conf" and put the config file there. -- twm