#!/usr/bin/perl # -------------------------------------------------------- PerlInterpreter # PerlInterpreter must be the first line of the file. # # Copyright (c) 1995, Cunningham & Cunningham, Inc. # # This program is based on code that is copyright Cunningham & Cummingham, Inc. # Used with permission. Cunningham & Cunningham, Inc. are not responsible for # any behaviour of the program or any damages that it may cause. # # Peter Merel's patch to this program is # # Copyright (C) 1997 Peter Merel. # # Peter Merel's patch to this program is free software; you can redistribute # it and/or modify it under the terms of the GNU Library General Public # License as published by the Free Software Foundation; either version 2 of # the License, or (at your option) any later version. # # Peter Merel's patch to 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 Library # General Public License for more details. # # You should have received a copy of the GNU Library General Public License # along with this library; if not, write to the Free Foundation, Inc., 59 # Temple Place, Suite 330, Boston, MA 02111-1307 USA # # Code here that is copyright Cunningham & Cunningham is not available under # this license. For permission to use this code in any way you must apply # to Cunningham & Cunningham via ward@c2.com # # -------------------------------------------------------- InitialComments # # autoflush # $| = 1; @path = split('/', "$ENV{SCRIPT_NAME}"); $ScriptName = pop(@path); # -------------------------------------------------------- ScriptName $DataBase = "/serv/wiki/$ScriptName"; # -------------------------------------------------------- DataBase $DefaultTitle = Tunes . Wiki ; # -------------------------------------------------------- DefaultTitle # # slightly changed to accomodate TLAs as well as WikiNames # $LinkPattern = "[A-Z][a-z]*[A-Z0-9][A-Z0-9a-z]*"; # -------------------------------------------------------- LinkPattern $DefaultRequest = "browse"; # -------------------------------------------------------- DefaultRequest $LogoUrl2 = 'http://127.0.0.1/uw_sm.gif'; # -------------------------------------------------------- LogoUrl $LogoImage = ""; # -------------------------------------------------------- LogoImage $ScriptUrl = "http://www2.tunes.org/cgi-bin/$ScriptName"; # -------------------------------------------------------- ScriptUrl $SignatureUrl = "http://127.0.0.1/uw_sm.gif"; # -------------------------------------------------------- SignatureUrl $WaybackLogo = ""; # -------------------------------------------------------- WaybackLogo if ($ENV{REQUEST_METHOD} eq GET) { $RawInput = $ENV{QUERY_STRING} || $DefaultTitle; $RawInput =~ s/^($LinkPattern)/$DefaultRequest=$1/; } if ($ENV{REQUEST_METHOD} eq POST) { read(STDIN, $RawInput, $ENV{CONTENT_LENGTH}); } # -------------------------------------------------------- RawInput $FieldSeparator = "\263"; # -------------------------------------------------------- FieldSeparator foreach $_ (split(/&/, $RawInput)) { s/\+/ /g; s/\%(..)/pack(C, hex($1))/geo; s/$FieldSeparator//g; ($_, $CookedInput) = split (/=/, $_, 2); $CookedInput{$_} = $CookedInput; } # -------------------------------------------------------- CookedInput sub AbortScript { local ($msg) = @_; print <TunesWiki Can't Process Your Request $msg

This information has been logged.
We are sorry for any inconvenience. EOF die "

$msg
"; } # -------------------------------------------------------- AbortScript sub RetrievePage { local($title) = pop(@_); if ( -f "$title.db") { $CookedInput{date} =~ s/-/ /g; $CookedInput{date} ? open IN, "cvs update -p -D \"$CookedInput{date} GMT\" $title.db|" : open IN, "<$title.db" ; # # gotta check return status of CVS ... # # # stuff whole file into %db # undef $/; $db{$title} = ; close IN; $db{$title} = undef if $db{$title} =~ /^cvs/; # this only happens if cvs can't find the rev. } split ( $FieldSeparator, $db{$title} || ( $CookedInput{date} ? "text${FieldSeparator}$title not defined $CookedInput{date}." : "text${FieldSeparator}Describe $title here." ) ); # print "RetrievePage:\n"; # &DumpBinding(@_); } # -------------------------------------------------------- RetrievePage sub EscapeMetaCharacters { s/&/&/g; s//>/g; } # -------------------------------------------------------- EscapeMetaCharacters sub InPlaceUrl { local($num) = (@_); local($ref) = $InPlaceUrl[$num]; $ref =~ /\.(jpg|gif)$/ ? "" : "$ref" ; } # -------------------------------------------------------- InPlaceUrl $TranslationToken = $FieldSeparator; # -------------------------------------------------------- TranslationToken sub EmitCode { ($code, $depth) = @_; while (@code > $depth) { local($_) = pop @code; print "\n" } while (@code < $depth) { push (@code, ($code)); print "<$code>\n" } if ($code[$#code] ne $code) { print "<$code>\n"; $code[$#code] = $code; } } # -------------------------------------------------------- EmitCode sub AsAnchor { local($title) = pop(@_); $CookedInput{date} =~ s/ /-/g; $datestring = $CookedInput{date} ? "&date=$CookedInput{date}" : ""; ( -f "$title.db" ) ? "$title<\/a>" : "$title(?)<\/a>"; } # -------------------------------------------------------- AsAnchor sub AsLink { local($num) = (@_); local($ref) = $old{"r$num"}; defined $ref ? ($ref =~ /\.(jpg|gif)$/ ? "" : "[$num]<\/a>") : "[$num]"; } # -------------------------------------------------------- AsLink sub PrintBodyText { s/\\\n/ /g; foreach (split(/\n/, $_)) { # # stack off the URLs out so they don't get munged # $InPlaceUrl=0; while ( s / \b ((http)|(ftp)|(mailto)|(news)|(file)|(gopher)) : [^\s\<\>\[\]"'\(\)]* [^\s\<\>\[\]"'\(\)\,\.\?] / $TranslationToken$InPlaceUrl$TranslationToken /x ) { $InPlaceUrl[$InPlaceUrl++] = $&; } $code = ""; # # encapsulate indenting changes # s/^\s*$/

/ && ($code = '...'); s/^(\t+)(.+):\t/

$2
/ && &EmitCode(DL, length $1); s/^(\t+)\*/
  • / && &EmitCode(UL, length $1); s/^(\t+)\d\.?/
  • / && &EmitCode(OL, length $1); /^\s/ && &EmitCode(PRE, 1); $code || &EmitCode("", 0); # # add some formatting doohickeys # s/'{3}(.*?)'{3}/$1<\/strong>/g; s/'{2}(.*?)'{2}/$1<\/em>/g; s/^-----*/
    /; s/\b$LinkPattern\b/&AsAnchor($&)/geo; s/\[(\d+)\]/&AsLink($1)/geo; s/$TranslationToken(\d+)$TranslationToken/&InPlaceUrl($1)/geo; print "$_\n"; } &EmitCode("", 0); } # -------------------------------------------------------- PrintBodyText sub HandleWayback { $title = $CookedInput{wayback}; print < Wayback: $title

    Select revision