#!/usr/bin/perl -wT -I. # # TWiki WikiClone (see $wikiversion in wiki.pm for version) # # Based on parts of Ward Cunninghams original Wiki and JosWiki. # Copyright (C) 1998 Markus Peter - SPiN GmbH (warpi@spin.de) # Some changes by Dave Harris (drh@bhresearch.co.uk) incorporated # Copyright (C) 1999 Peter Thoeny, peter.thoeny@takefive.com , # TakeFive Software Inc. # # This program is free software; you can redistribute it and/or # modify it under the terms of the GNU General Public License # as published by the Free Software Foundation; either version 2 # of the License, or (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details, published at # http://www.gnu.ai.mit.edu/copyleft/gpl.html # Copied from "view" and modified to work around print bugs # in Netscape 4.72 for Linux. # Written by Richard Bennett (richard.bennett@nuix.com.au) # # This module uses a new template called "printable" instead of # "view". use CGI; use wiki; $query= new CGI; ##### for debug only: Remove next 2 comments (but redirect does not work) #open(STDERR,'>&STDOUT'); # redirect error to browser #$| = 1; # no buffering print "Content-type: text/html\n\n"; &main(); sub main { my $thePathInfo = $query->path_info(); my $theRemoteUser = $query->remote_user(); my $theTopic = $query->param( 'topic' ); my $theUrl = $query->url; ( $topic, $webName, $scriptUrlPath ) = &wiki::initialize( $thePathInfo, $theRemoteUser, $theTopic, $theUrl ); my $tmpl= "", $text=""; my $rev= $query->param( "rev" ); my $maxrev = 1; my $extra = ""; if( ! &wiki::webExists( $webName ) ) { $tmpl= &wiki::readTemplate( "noweb" ); $tmpl = &wiki::handleCommonTags( $tmpl, $topic ); print $tmpl; return; } $tmpl= &wiki::readTemplate( "printable" ); my $topicExists = &wiki::topicExists( $webName, $topic ); if( $topicExists ) { $maxrev = &wiki::getRevisionNumber( $topic ); $maxrev =~ s/1\.//go; # cut major if( $rev ) { $rev =~ s/1\.//go; # cut major if( $rev < 1 ) { $rev = 1; } if( $rev > $maxrev ) { $rev = $maxrev; } $text= &wiki::readVersion( $topic, "1.$rev" ); $extra .= "r1.$rev"; } else { $text= &wiki::readTopic( $topic ); $rev= $maxrev; } } else { $rev = 1; if( &wiki::isWikiName( $topic ) ) { $text= &wiki::readTemplate( "notext" ); } else { $text= &wiki::readTemplate( "notwiki" ); } $extra .= " (not exist)"; } $text = &wiki::handleCommonTags( $text, $topic ); $text = &wiki::getRenderedVersion( $text ); if( $wiki::doLogTopicView ) { # write log entry &wiki::writeLog( "printable", "$webName.$topic", $extra ); } if( $rev < $maxrev ) { # disable edit of previous revisions $tmpl =~ s/%EDITTOPIC%/Edit/go; $tmpl =~ s/%REVTITLE%/\(r1.$rev\)/go; } else { if( $topicExists ) { $tmpl =~ s/%EDITTOPIC%/Edit<\/B><\/A>/go; # remove the NOINDEX meta tag $tmpl =~ s/]*>//goi; } else { $tmpl =~ s/%EDITTOPIC%/Create<\/B><\/A>/go; } $tmpl =~ s/%REVTITLE%//go; } my $i = $maxrev; my $j = $maxrev; my $revisions = ""; my $breakRev = 0; if( ( $wiki::numberOfRevisions > 0 ) && ( $wiki::numberOfRevisions < $maxrev ) ) { $breakRev = $maxrev - $wiki::numberOfRevisions + 1; } while( $i > 0 ) { if( $i eq $rev) { $revisions = "$revisions | r1.$i"; } else { $revisions = "$revisions | r1.$i"; } if( $i != 1 ) { if( $i == $breakRev ) { $revisions = "$revisions | >..."; $i = 1; } else { $j = $i - 1; $revisions = "$revisions | >"; } } $i = $i - 1; } $tmpl =~ s/%REVISIONS%/$revisions/go; if( $topicExists ) { my( $date, $user ) = &wiki::getRevisionInfo( $topic, "1.$rev", 1 ); $user = &wiki::userToWikiName( $user ); my $temp = &wiki::getRenderedVersion( "r1.$rev - $date by $user" ); $tmpl =~ s/%REVINFO%/$temp/go; } else { $tmpl =~ s/%REVINFO%//go; } $tmpl = &wiki::handleCommonTags( $tmpl, $topic ); $tmpl =~ s/%TEXT%/$text/go; # Mod from "view" to remove non-printing problems in Netscape 4.72 for Linux (RB) # Remove the TWikiCat insertions $tmpl =~ s/\