14 years ago 20010907

0a1,110
The first line of a script can call out the interpreter
that is to evaluate it. This script is two perl program.

  # PerlInterpreter must be the first line of the file.

Statements at the front of the script explain ownership
and point readers to these pages for elaborate
documentation.

  # InitialComments

Standard output will collect text encoded
in html. We may write it at any time,
such as in AbortScript. Here we alert the
ServerDaemon that we are sending it html.

  print "Content-type: text/html\n\n";
  print '<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"'."\n";
  print '"http://www.w3.org/TR/html40/loose.dtd">'."\n";
  print '<html>';

All of our commands retrieve pages from a database so we
will go ahead and open it now. We derive the path to
the db file from the name of the script. That way we can
use one script (with links or aliases) to serve many
databases. (Perl implementations vary in the best way to open dbm files. See http:wiki?DbmProblems for a discussion.)

Relative urls with a scheme prefix (like 'http:') break in mozilla, and violate RFC 2396 which closes the loophole introduced in RFC 1630.

  dbmopen(%db, $DataBase , 0666) || &AbortScript("can't open $DataBase");

Requests are passed as heavily encoded character strings
that we massage (cook) into a dictionary of keyword bindings.
Here we probe that input for requests we know how to handle.

  $CookedInput{browse} && &HandleBrowse;
  $CookedInput{edit} && &HandleEdit;
  $CookedInput{copy} && &HandleEdit;
  $CookedInput{links} && &HandleLinks;
  $CookedInput{search} && &HandleSearch;

The post command is the only one that writes into
the database. The dbm libraries require that we protect
it from simultaneous writes. So, we'll close the db now and
let HandlePost reopen & close it inside a CriticalSection
should this be a post.

  dbmclose (%db);
  if ($ENV{REQUEST_METHOD} eq POST) {
        $CookedInput{post} && &HandlePost;
  }

Now we're done, unless we're debugging.
Then we will take this opportunity to dump
important bindings on the bottom of the generated page.

  # &DumpBinding(*CookedInput);
  # &DumpBinding(*old);
[What about a more liberal Wiki Naming Convention to make each symbol linkable? -- FridemarPache]
[Sounds great. How about perl symbol naming on perl lines, wiki naming on wiki lines? -- IanKjos]

  # &DumpBinding(*ENV);
  print "</html>";

For changes see WikiChangeLog.




InitialComments
ScriptName
DataBase
AbortScript
DefaultTitle
LinkPattern
DefaultRequest
RawInput
FieldSeparator
CookedInput
LogoUrl
LogoImage
ScriptUrl
RetrievePage
EscapeMetaCharacters
InPlaceUrl
TranslationToken
EmitCode
AsAnchor
AsLink
SearchForm
PrintBodyText
HandleBrowse
ConvertSpacesToTabs
HandleEdit
HandleLinks
HandleSearch
CookSpaces
LockDirectory
RequestLock
BackupCopy
DateToday
ReplacePage
ReleaseLock
SignatureUrl
HandlePost
DumpBinding
WikiInHyperPerl




11 years ago WikiInHyperPerl