--- pdf 2006-10-18 17:17:57.559553464 -0400
+++ /usr/lib/cgi-bin/twiki/pdf 2006-08-15 11:51:07.000000000 -0400
@@ -38,12 +38,15 @@
# Please define your paths here
# !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
-# local path to your twiki data
-my $localWebDir = "/usr/local/apache2/twiki/";
-# web URL of your twiki instalation
-my $webDirUrl = "https://ike.nzqa.solnet.co.nz/twiki/";
+# local path to your twiki pub directory
+my $localWebDir = "/var/www/twiki/pub";
+# any web URLs that may refer to your pub directory
+my @webDirUrls = ("https://qix.demiurgestudios.com/twiki/pub",
+ "https://qix/twiki/pub",
+ "/twiki/pub",
+ );
# specify path to htmldoc
-my $htmldocCmd = "/usr/local/bin/htmldoc";
+my $htmldocCmd = "/usr/bin/htmldoc";
&main();
@@ -169,7 +172,7 @@
}
END {
# close temporary file:
- unlink("$tmpFile.html") or die "Failed to unlink $tmpFile.html : $!";
+ unlink("$tmpFile.html") or die "Failed to unlink $tmpFile.html : $!";
}
#
@@ -182,7 +185,9 @@
my ($htmlData) = @_;
# correct referenced images
- $htmlData =~ s/
//g;
@@ -257,20 +262,17 @@
my $meta = "";
my $rev = $query->param( "rev" );
my $maxrev = 1;
- my $extra = "";
- my $wikiUserName = &TWiki::userToWikiName( $userName );
+ my $wikiUserName = &TWiki::Func::userToWikiName( $userName );
my $revdate = "";
my $revuser = "";
- my $viewRaw = $query->param( "raw" ) || "";
my $unlock = $query->param( "unlock" ) || "";
my $skin = $query->param( "skin" ) || "plain";
my $viewMeta = $query->param( "meta" ) || "";
- if ($viewMeta) { $viewRaw = "debug"; }
# get view template, standard view or a view with a different skin
- $tmpl = &TWiki::Store::readTemplate( "view", $skin );
+ $tmpl = &TWiki::Func::readTemplate( "view", $skin );
if( ! $tmpl ) {
- TWiki::writeHeader( $query );
+ TWiki::Func::writeHeader( $query );
print "
\n"
. "TWiki Installation Error
\n"
. "Template file view.tmpl not found or template directory \n"
@@ -280,28 +282,23 @@
exit;
}
- if( ! &TWiki::Store::webExists( $webName ) ) {
- my $url = &TWiki::getOopsUrl( $webName, $topic, "oopsnoweb" );
- TWiki::redirect( $query, $url );
+ if( ! &TWiki::Func::webExists( $webName ) ) {
+ my $url = &TWiki::Func::getOopsUrl( $webName, $topic, "oopsnoweb" );
+ TWiki::Func::redirectCgiQuery( $query, $url );
exit;
}
if( $unlock eq "on" ) {
# unlock topic, user cancelled out of edit
- &TWiki::Store::lockTopic( $topic, "on" );
+ &TWiki::Func::setTopicEditLock( $webName, $topic, 0 );
}
# Most recent topic read in even if earlier topic requested - makes code simpler and performance impact should be minimal
- my $topicExists = &TWiki::Store::topicExists( $webName, $topic );
+ my $topicExists = &TWiki::Func::topicExists( $webName, $topic );
if( $topicExists ) {
- $text = &TWiki::Store::readTopicRaw( $webName, $topic );
+ ( $meta, $text ) = &TWiki::Func::readTopic( $webName, $topic );
+ ( $revdate, $revuser, $maxrev ) = $meta->getRevisionInfo();
- if( ! $viewRaw ) {
- ( $meta, $text ) = &TWiki::Store::_extractMetaData( $webName, $topic , $text );
- # ( $meta, $text ) = &TWiki::Store::readTopic( $webName, $topic );
- }
- ( $revdate, $revuser, $maxrev ) = &TWiki::Store::getRevisionInfoFromMeta( $webName, $topic, $meta, "isoFormat" );
-
if( $rev ) {
$rev =~ s/r?1\.//go; # cut 'r' and major
if( $rev < 1 ) { $rev = 1; }
@@ -311,108 +308,36 @@
}
if( $rev < $maxrev ) {
- if( $viewRaw ) {
- $text = &TWiki::Store::readTopicRaw( $webName, $topic, "1.$rev" );
- } else {
- ( $meta, $text ) = &TWiki::Store::readTopicVersion( $webName, $topic, "1.$rev" );
- }
- ( $revdate, $revuser ) = &TWiki::Store::getRevisionInfo( $webName, $topic, "1.$rev", 1 );
- $extra .= "r1.$rev";
+ ( $meta, $text ) = &TWiki::Func::readTopic( $webName, $topic, $rev );
+ ( $revdate, $revuser ) = $meta->getRevisionInfo();
}
-
} else {
- $rev = 1;
- if( ( &TWiki::isWikiName( $topic ) ) || ( $topic =~ /^[A-Z]{3,}$/ ) ) {
- ( $meta, $text ) = &TWiki::Store::readTemplateTopic( "WebTopicViewTemplate" );
- } else {
- ( $meta, $text ) = &TWiki::Store::readTemplateTopic( "WebTopicNonWikiTemplate" );
- }
- $extra .= " (not exist)";
- }
-
- if( $viewRaw ) {
- my $vtext = "";
- if( $viewRaw !~ /debug/i ) {
- $text =~ s/%META[\:A-Z]*{[^\}]*}%[\n\r]*//gos;
- }
+ throw TWiki::OopsException( 'accessdenied',
+ def => 'no_such_topic',
+ web => $webName,
+ topic => $topic );
}
# check access permission
# To Do: Need to protect also %INCLUDE% and search
- my $viewAccessOK = &TWiki::Access::checkAccessPermission( "view", $wikiUserName, $text, $topic, $webName );
- if( ! $viewAccessOK ) {
- # user could not be authenticated, may be not logged in yet?
- my $viewauthFile = $ENV{'SCRIPT_FILENAME'};
- $viewauthFile =~ s|/view|/viewauth|o;
- if( ( ! $theRemoteUser ) && (-e $viewauthFile ) ) {
- # try again with authenticated viewauth script
- # instead of non authenticated view script
- my $url = $ENV{"REQUEST_URI"};
- if( $url ) {
- # $url i.e. is "twiki/bin/view.cgi/Web/Topic?cms1=val1&cmd2=val2"
- $url =~ s|/view|/viewauth|o;
- $url = "$TWiki::urlHost$url";
- } else {
- $url = "$TWiki::urlHost$scriptUrlPath/$viewauthFile/$webName/$topic";
- }
- TWiki::redirect( $query, $url );
- exit;
- }
- }
+ my $viewAccessOK = &TWiki::Func::checkAccessPermission( "view", $wikiUserName, $text, $topic, $webName );
if( ! $viewAccessOK ) {
- my $url = &TWiki::getOopsUrl( $webName, $topic, "oopsaccessview" );
- TWiki::redirect( $query, $url );
- exit;
+ my $url = &TWiki::Func::getOopsUrl( $webName, $topic, "oopsaccessview" );
+ TWiki::Func::redirectCgiQuery( $query, $url );
+ exit;
}
+ # Remove TOC, since we put one in the left bar anyway
+ $text =~ s/%TOC(\{.*?\})?%//g;
- if( ! $viewRaw ) {
- $text = &TWiki::handleCommonTags( $text, $topic );
- $text = &TWiki::Render::getRenderedVersion( $text );
- }
+ $text = &TWiki::Func::expandCommonVariables( $text, $topic, $webName );
+ $text = &TWiki::Func::renderText( $text );
- if( $TWiki::doLogTopicView ) {
- # write log entry
- &TWiki::Store::writeLog( "view", "$webName.$topic", $extra );
- }
-
- my( $mirrorSiteName, $mirrorViewURL, $mirrorLink, $mirrorNote ) = &TWiki::readOnlyMirrorWeb( $webName );
-
- if( $mirrorSiteName ) {
- # disable edit and attach
- $tmpl =~ s/%EDITTOPIC%/$mirrorLink | Edit<\/strike>/o;
- $tmpl =~ s/]*?>Attach<\/a>/Attach<\/strike>/oi;
- if( $topicExists ) {
- # remove the NOINDEX meta tag
- $tmpl =~ s/]*>//goi;
- } else {
- $text = "";
- }
- $tmpl =~ s/%REVTITLE%//go;
-
- } elsif( $rev < $maxrev ) {
- # disable edit of previous revisions - FIXME consider change to use two templates
- $tmpl =~ s/%EDITTOPIC%/Edit<\/strike>/o;
- $tmpl =~ s/]*?>Attach<\/a>/Attach<\/strike>/oi;
- $tmpl =~ s|]*?>Rename/move<\/a>|Rename/move<\/strike>|oi;
- $tmpl =~ s/%REVTITLE%/\(r1.$rev\)/go;
- $tmpl =~ s/%REVARG%/&rev=1.$rev/go;
- } else {
- if( $topicExists ) {
- my( $sec, $min, $hour, $day, $mon, $year ) = gmtime( time() );
- my $timestring = sprintf("%.2u%.2u%.2u%.2u%.2u",$mon+1,$day,$hour,$min,$sec);
- $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;
- $tmpl =~ s/%REVARG%//go;
+ my $revTitle = '';
+ if( defined($rev) and $rev < $maxrev ) {
+ $revTitle = "(r$rev)";
}
+ $tmpl =~ s/%REVTITLE%/$revTitle/g;
my $i = $maxrev;
my $j = $maxrev;
@@ -441,21 +366,12 @@
}
$tmpl =~ s/%REVISIONS%/$revisions/go;
- if( $topicExists ) {
- $revuser = &TWiki::userToWikiName( $revuser );
- my $temp = &TWiki::Render::getRenderedVersion( "r1.$rev - $revdate GMT - $revuser" );
- $tmpl =~ s/%REVINFO%/$temp$mirrorNote/go;
- } else {
- $tmpl =~ s/%REVINFO%/$mirrorNote/go;
- }
+ $revuser = &TWiki::Func::userToWikiName( $revuser );
+ my $temp = &TWiki::Func::renderText( "r1.$rev - $revdate GMT - $revuser" );
+ $tmpl =~ s/%REVINFO%/$temp/go;
- $tmpl = &TWiki::handleCommonTags( $tmpl, $topic );
- if( $viewRaw ) {
- $tmpl =~ s/%META{[^}]*}%//go;
- } else {
- $tmpl = &TWiki::handleMetaTags( $webName, $topic, $tmpl, $meta, ( $rev == $maxrev ) );
- }
- $tmpl = &TWiki::Render::getRenderedVersion( $tmpl, "", $meta ); ## better to use meta rendering?
+ $tmpl = &TWiki::Func::expandCommonVariables( $tmpl, $topic, $webName );
+ $tmpl = &TWiki::Func::renderText( $tmpl, "", $meta ); ## better to use meta rendering?
$tmpl =~ s/%TEXT%/$text/go;
$tmpl =~ s/%MAXREV%/1.$maxrev/go;
$tmpl =~ s/%CURRREV%/1.$rev/go;