--- suikawiki/script/wiki.cgi 2003/01/02 00:34:04 1.45 +++ suikawiki/script/wiki.cgi 2003/01/02 12:14:15 1.46 @@ -7,9 +7,9 @@ use strict; use lib qw(./lib); use CGI::Carp qw(fatalsToBrowser); +our $VERSION = do{my @r=(q$Revision: 1.46 $=~/\d+/g);sprintf "%d."."%02d" x $#r,@r}; require 'wikidata/suikawiki-config.ph'; -use Yuki::DiffText qw(difftext); use Fcntl; ############################## my %fmt; ## formatter objects @@ -25,13 +25,12 @@ my $info_IsFrozen = 'IsFrozen'; ############################## my %form; -my %database; +our %database; +our $database; my %infobase; -my %diffbase; my %interwiki; ############################## my %page_command = ( - $PageName{IndexPage} => 'index', $PageName{RssPage} => 'rss', ); my %command_do = ( @@ -41,7 +40,6 @@ adminedit => \&do_adminedit, adminchangepassword => \&do_adminchangepassword, write => \&do_write, - index => \&do_index, searchform => \&do_searchform, comment => \&do_comment, RandomJump => \&do_random_jump, @@ -201,29 +199,6 @@ return crypt (shift, $validpassword_crypt) eq $validpassword_crypt ? 1 : 0; } -sub do_index { - wiki::referer::add ($form{mypage}, $ENV{HTTP_REFERER}); - wiki::useragent::add ($ENV{HTTP_USER_AGENT}); - &print_header($PageName{IndexPage}); - print qq(
$1¡×%g; $line =~ s|'''([^']+)'''|$1|g; $line =~ s|''([^']+)''|$1|g; $line =~ s{ @@ -657,7 +619,7 @@ }{ my ($l, $page,$anchor, $anum, $uri) = ($1, $3,$4, 0+$5, $6); if ($l) { - return &embedded_to_html($1); + &embedded_to_html($1); } elsif (defined $page) { &make_wikilink ($page, anchor => 0+$anchor); } elsif ($anum) { @@ -826,30 +788,6 @@ $form{myname} = &code_convert(\$form{myname}, $kanjicode); } -sub update_recent_changes { - my $update = "- @{[&get_now]} [[$form{mypage}]] @{[&get_subjectline($form{mypage})]}"; - my @oldupdates = split(/\x0D?\x0A/, $database{RecentChanges}); - shift @oldupdates; ## '#?' magic line - my @updates; - foreach (@oldupdates) { - /^\- \d\d\d\d\-\d\d\-\d\d \d\d:\d\d \[\[([^]]+)\]\]/; - my $name = $1; - if ($name ne $form{mypage}) { - push @updates, $_; - } - } - if (&is_exist_page($form{mypage})) { - unshift @updates, $update; - } - splice @updates, (&Resource ('RecentChanges:Max') || 50) + 1; - $database{RecentChanges} = "#?SuikaWiki/0.9\n" . join("\n", @updates); - if ($PathTo{TouchFile}) { - open(FILE, "> ".$PathTo{TouchFile}); - print FILE localtime() . "\n"; - close(FILE); - } -} - {my %SubjectLine; sub get_subjectline { my ($page, %option) = @_; @@ -878,10 +816,14 @@ eval q{use AnyDBM_File}; tie(%database, "AnyDBM_File", $PathTo{WikiDataBase}, O_RDWR|O_CREAT, 0666) or &print_error("(tie AnyDBM_File) $PathTo{WikiDataBase}"); tie(%infobase, "AnyDBM_File", $PathTo{WikiInfoBase}, O_RDWR|O_CREAT, 0666) or &print_error("(tie AnyDBM_File) $PathTo{WikiInfoBase}"); - } else { + } elsif ($modifier_dbtype eq 'YukiWikiDB') { eval q{use Yuki::YukiWikiDB}; tie(%database, "Yuki::YukiWikiDB", $PathTo{WikiDataBase}) or &print_error("(tie Yuki::YukiWikiDB) $PathTo{WikiDataBase}"); tie(%infobase, "Yuki::YukiWikiDB", $PathTo{WikiInfoBase}) or &print_error("(tie Yuki::YukiWikiDB) $PathTo{WikiInfoBase}"); + } else { + eval qq{use $modifier_dbtype}; + $database = tie(%database, $modifier_dbtype => $PathTo{WikiDataBase}, -lock => 2, -backup => $wiki::diff::UseDiff) or &print_error("(tie $modifier_dbtype) $PathTo{WikiDataBase}"); + tie(%infobase, $modifier_dbtype => $PathTo{WikiInfoBase}, -lock => 2) or &print_error("(tie $modifier_dbtype) $PathTo{WikiInfoBase}"); } } @@ -889,35 +831,12 @@ if ($modifier_dbtype eq 'dbmopen') { dbmclose(%database); dbmclose(%infobase); - } elsif ($modifier_dbtype eq 'AnyDBM_File') { - untie(%database); - untie(%infobase); } else { untie(%database); untie(%infobase); } } -sub open_diff { - if ($modifier_dbtype eq 'dbmopen') { - dbmopen(%diffbase, $PathTo{WikiDiffBase}, 0666) or &print_error("(dbmopen) $PathTo{WikiDiffBase}"); - } elsif ($modifier_dbtype eq 'AnyDBM_File') { - tie(%diffbase, "AnyDBM_File", $PathTo{WikiDiffBase}, O_RDWR|O_CREAT, 0666) or &print_error("(tie AnyDBM_File) $PathTo{WikiDiffBase}"); - } else { - tie(%diffbase, "Yuki::YukiWikiDB", $PathTo{WikiDiffBase}) or &print_error("(tie Yuki::YukiWikiDB) $PathTo{WikiDiffBase}"); - } -} - -sub close_diff { - if ($modifier_dbtype eq 'dbmopen') { - dbmclose(%diffbase); - } elsif ($modifier_dbtype eq 'AnyDBM_File') { - untie(%diffbase); - } else { - untie(%diffbase); - } -} - sub print_editform { my ($mymsg, $lastmodified, %mode) = @_; my $frozen = &is_frozen($form{mypage}); @@ -1294,27 +1213,17 @@ $code = 'euc' if $code =~ /euc/; $code = 'sjis' if $code =~ /shift/; $code = 'utf8' if $code =~ /utf/; - #&Jcode::convert($contentref, $code); # for Jcode.pm -# &jcode::convert($contentref, $code); # for jcode.pl - #&Jcode::tr ($contentref, "\xA3\xB0-\xA3\xB9\xA3\xC1-\xA3\xDA\xA3\xE1-\xA3\xFA\xA1\xF5\xA1\xA4\xA1\xA5\xA1\xA7\xA1\xA8\xA1\xA9\xA1\xAA\xA1\xAE\xA1\xB0\xA1\xB2\xA1\xBF\xA1\xC3\xA1\xCA\xA1\xCB\xA1\xCE\xA1\xCF\xA1\xD0\xA1\xD1\xA1\xDC\xA1\xF0\xA1\xF3\xA1\xF4\xA1\xF6\xA1\xF7\xA1\xE1\xA2\xAF\xA2\xB0\xA2\xB2\xA2\xB1\xA1\xE4\xA1\xE3\xA1\xC0\xA1\xA1" => q(0-9A-Za-z&,.:;?!`^_/|()[]{}+$%#*@='"~-><\ )) if $code eq 'euc'; $$contentref = Jcode->new ($contentref)->tr ("\xA3\xB0-\xA3\xB9\xA3\xC1-\xA3\xDA\xA3\xE1-\xA3\xFA\xA1\xF5\xA1\xA4\xA1\xA5\xA1\xA7\xA1\xA8\xA1\xA9\xA1\xAA\xA1\xAE\xA1\xB0\xA1\xB2\xA1\xBF\xA1\xC3\xA1\xCA\xA1\xCB\xA1\xCE\xA1\xCF\xA1\xD0\xA1\xD1\xA1\xDC\xA1\xF0\xA1\xF3\xA1\xF4\xA1\xF6\xA1\xF7\xA1\xE1\xA2\xAF\xA2\xB0\xA2\xB2\xA2\xB1\xA1\xE4\xA1\xE3\xA1\xC0\xA1\xA1" => q(0-9A-Za-z&,.:;?!`^_/|()[]{}+$%#*@='"~-><\ ))->$code; return $$contentref; } sub do_diff { - if (not &is_editable($form{mypage})) { - &do_read; - return; - } - &open_diff; my $title = $form{mypage}; &print_header($title, -noindex => 1); - $_ = &escape($diffbase{$form{mypage}}); - &close_diff; - print qq(
@{[&Resource('Diff:Notice',escape=>1)]}
); print qq();
- foreach (split(/\n/, $_)) {
+ for (split(/\n/, &escape ($database->traverse_diff ($form{mypage})))) {
if (/^\+(.*)/) {
print qq($1\n);
} elsif (/^\-(.*)/) {
@@ -1521,7 +1430,7 @@
for (sort {$ua{$a} <=> $ua{$b}} keys %ua) {
$s .= sprintf qq(-[%d] %s\n), $ua{$_}, $_;
}
- &main::__set_database ($main::PageName{UserAgentList} => $s);
+ $main::database->STORE ($main::PageName{UserAgentList} => $s, -touch => 0);
}
package wiki::suikawikiconst;
@@ -1668,26 +1577,19 @@
__END__
=head1 NAME
-wiki.cgi - This is YukiWiki, yet another Wiki clone.
-walwiki.cgi based on yukiwiki.cgi - Yet another WikiWikiWeb clone.
-
-=head1 DESCRIPTION
-
-YukiWiki is yet another Wiki clone.
+wiki.cgi --- SuikaWiki: Yet yet another Wiki engine
-YukiWiki can treat Japanese WikiNames (enclosed with [[ and ]]).
-YukiWiki provides 'InterWiki' feature, RDF Site Summary (RSS),
-and some embedded commands (such as [[#comment]] to add comments).
+=head1 AUTHORS
-Read F (English) or F (Japanese) in more detail.
+Hiroshi Yuki
-=head1 AUTHOR
+Makio Tsukamoto
-Hiroshi Yuki http://www.hyuki.com/yukiwiki/
+Wakaba
=head1 LICENSE
-Copyright (C) 2000-2002 by Hiroshi Yuki.
+Copyright (C) 2000-2003 AUTHORS
This program is free software; you can redistribute it and/or
modify it under the same terms as Perl itself.