Handle Edit



Here we create an editor out of html forms. There are a lot of forms-challenged browsers out there so we watch out for a couple of known problems.

  sub HandleEdit {
    $title = $CookedInput{edit} || $CookedInput{copy};
    $title =~ /^$LinkPattern$/ || &AbortScript("edit: improper name: $title");
    %old = &RetrievePage($title);

Get the text or its copy as appropriate.

    $_ = $CookedInput{copy} ? $old{copy} : $old{text};
    $note = 'Copy of ' if $CookedInput{copy};

Some browsers for the Macintosh get confused by both CR and LF in an entry field. So we nix the CRs as we escape the usual html metacharacters.

    s/\r\n/\n/g;
    &EscapeMetaCharacters;

IBM's WebExplorer expands any tabs we might send it. So we go ahead and check the space-to-tab conversion when we send it text.

    $convert = "checked" if $ENV{HTTP_USER_AGENT} =~ /WebExplorer/;  

print <<EOF ; <head> <title>Edit $note$title</title> </head> <body> <form method="POST" action="$ScriptUrl"> <h1>$note$title <input type="submit" value=" Save "> <input type="reset" value=" Reset "> </h1> <TEXTAREA NAME="text" ROWS=12 COLS=60 wrap=virtual>$_</TEXTAREA><br> <input type="checkbox" name="convert" value="tabs" $convert> I can't type tabs. Please <a href="$ScriptUrl?ConvertSpacesToTabs">ConvertSpacesToTabs</a> for me when I save.<p> <a href="$ScriptUrl?GoodStyle">GoodStyle</a> tips for editing.<br> <a href="$ScriptUrl?links=$title">EditLinks</a> to other web servers.<br> EOF

print <<EOF if $old{copy} && !$CookedInput{copy}; <a href="$ScriptUrl?copy=$title">EditCopy</a> from previous author.<br> EOF

print <<EOF ; <input type="hidden" size=1 name="post" value="$title"> </form> </body> EOF

}

 

Last edited January 16, 2002
Return to WelcomeVisitors