--- suikawiki/script/wiki.cgi 2002/12/25 02:04:11 1.41 +++ suikawiki/script/wiki.cgi 2002/12/30 03:20:06 1.42 @@ -16,16 +16,14 @@ # my $modifier_dbtype = 'dbmopen'; # Fast, not available on some server, page size limited. my $modifier_dbtype = 'YukiWikiDB'; # Slow, available on all environment. my $modifier_dir_data = './wikidata'; # Your data directory. -our $url_cgi = '/~wakaba/-temp/wiki/wiki'; ## MUST be started by '/' -############################## -# -# You MAY modify following variables. -# -$SuikaWiki::Plugin::plugin_directory = q(./SuikaWiki/Plugin/); -my $file_touch = "$modifier_dir_data/touched.txt"; +our $url_cgi = '/~wakaba/-temp/wiki/wiki'; + ## - MUST be started by '/' + ## - MUST NOT include [&<>"] and/or non-URI characters our %uri; -$uri{stylesheet} = $url_cgi.'?mycmd=TEXT_CSS;mypage=WikiHTMLStyle'; +$uri{wiki} = $url_cgi; $uri{cvs_wikipage} = '/gate/cvs/wakaba/suikawiki/wiki/'; +$SuikaWiki::Plugin::plugin_directory = q(./SuikaWiki/Plugin/); +my $file_touch = "$modifier_dir_data/touched.txt"; ############################## # # You MAY, but do NOT NEED modify following variables. @@ -42,6 +40,9 @@ my $ErrorPage = 'ErrorPage'; my $RssPage = 'RssPage'; my $AdminSpecialPage = 'Admin Special Page'; # must include spaces. +my %PageName = ( + DefaultStyleForHTML => 'WikiHTMLStyle', +); ############################## my %fmt; ## formatter objects my %embed_command = ( @@ -56,15 +57,12 @@ my $lang = 'ja'; my %fixedpage = ( $IndexPage => 1, - $CreatePage => 1, $ErrorPage => 1, $RssPage => 1, RecentChanges => 1, - $SearchPage => 1, AdminChangePassword => 1, CompletedSuccessfully => 1, WikiUserAgentList => 1, - WikiPluginInfo => 1, ); my %form; my %database; @@ -74,11 +72,8 @@ ############################## my %page_command = ( $IndexPage => 'index', - $SearchPage => 'searchform', - $CreatePage => 'create', $RssPage => 'rss', AdminChangePassword => 'adminchangepasswordform', - WikiPluginInfo => 'x_WikiPluginInfo', ); my %command_do = ( read => \&do_read, @@ -90,15 +85,11 @@ write => \&do_write, index => \&do_index, searchform => \&do_searchform, - search => \&do_search, - create => \&do_create, - createresult => \&do_createresult, comment => \&do_comment, RandomJump => \&do_random_jump, rss => \&do_rss, diff => \&do_diff, wikiform => \&do_wikiform, - x_WikiPluginInfo => \&do_wikiplugininfo, map => \&do_map, ); my $UA = ''; ## User agent name @@ -112,7 +103,7 @@ if ($command_do{$form{mycmd}}) { &{$command_do{$form{mycmd}}}; } else { - &{$command_do{$form{read}}}; + &{$command_do{read}}; } &close_db; } @@ -137,14 +128,14 @@ $cf = $1 if $content =~ s#^(?:/\*\s*|[\#<]\?)?([A-Z][A-Za-z0-9-]+/[0-9.]+(?:[^0-9.\x0D\x0A][^\x0D\x0A]*)?)[\x0D\x0A]+##s; if ($cf =~ m!^(?:\#\?)?SuikaWiki/0.9(?:$|\s)!) { #print gmtime."Header...\n"; - &print_header ($form{mypage}, -last_modified => $lm, - -content_format => $cf, -noindex => $cf =~ /obsoleted="yes"/); + &print_header ($form{mypage}, -last_modified => $lm, -expires => time + 120, + -content_format => $cf, -noindex => ($cf =~ /obsoleted="yes"/ ? 1 : 0)); #print "\n". gmtime."Body...\n"; &print_content ($content, content_format => $cf, last_modified => $lm, -toc => \@toc); print &text_to_html (q([[#comment]])) if $cf !~ /obsoleted="yes"/ && !$fixedpage{$form{mypage}}; } else { - &print_header($form{mypage}, -last_modified => $lm); + &print_header($form{mypage}, -expires => time + 120, -last_modified => $lm); print "
@{[&escape($content)]}
"; } if ($c) { @@ -167,6 +158,7 @@ my $lm = gmtime &get_info($form{mypage}, $info_LastModified); print "Content-Type: text/css; charset=@{[&get_charset_name($kanjicode)]}\n"; print "Last-Modified: $lm\n"; + print "Expires: @{[scalar gmtime time+3600]}\n"; ## TODO: don't use asctime print "\n"; print $content; } else { @@ -188,12 +180,14 @@ sub do_edit { my ($page) = &unarmor_name(&armor_name($form{mypage})); - &print_header($page, -noindex => 1); if (not &is_editable($page)) { + &print_header($page, -noindex => 1); &print_message(&Resource('Error:ThisPageIsUneditable')); } elsif (&is_frozen($page)) { + &print_header($page, -noindex => 1); &print_message(&Resource('Error:ThisPageIsUneditable')); } else { + &print_header($page, -noindex => 1, -expires => time+60); &print_editform($database{$page}, &get_info($page, $info_LastModified), admin=>0); } wiki::referer::add ($form{mypage}, $ENV{HTTP_REFERER}); @@ -335,20 +329,6 @@ } } -sub do_searchform { - &print_header($SearchPage); - &print_searchform(""); - &print_footer($SearchPage); -} - -sub do_search { - my $word = $form{mymsg}; - &print_header($SearchPage); - &print_searchform(&escape($word)); - print scalar get_search_result ($word, -output_not_found => 1, -match_myself => 1); - &print_footer($SearchPage); -} - sub get_search_result ($;%) { my $word = lc shift; my %option = @_; @@ -372,19 +352,6 @@ wantarray? ($r, scalar @r): $r; } -sub do_create { - &print_header($CreatePage); - print <<"EOD"; -
- - @{[&Resource('InputPageNameEdited',escape=>1)]}
- -
-
-EOD - &print_footer($CreatePage); -} - sub do_random_jump { my @list = keys %database; my $name = &encode ($list[rand @list]); @@ -421,6 +388,9 @@ } } print qq{Last-Modified: @{[scalar gmtime $option{-last_modified}]}\n} if $option{-last_modified}; + if ($option{-expires}) { + print qq{Expires: @{[scalar gmtime $option{-expires}]}\n}; + } if ($UA =~ m#Mozilla/2#) { my $ct = qq{text/html; charset=@{[&get_charset_name($kanjicode,compatible=>1)]}}; print qq{Content-Type: $ct\n}; @@ -431,8 +401,9 @@ print qq{Content-Type: text/html; charset=@{[&get_charset_name($kanjicode)]}\n}; } push @head, qq(@{[&escape($page)]}); - push @head, qq() if $option{-noindex}; my ($Links, $links) = &make_navigate_links ($page); #print $Links; ## Link: fields @@ -529,8 +500,8 @@ sub print_footer { my ($page, $lm) = @_; my $epage = &encode ($page); - my $cvslog1 = q$Revision: 1.41 $; - my $cvslog2 = q$Date: 2002/12/25 02:04:11 $; + my $cvslog1 = q$Revision: 1.42 $; + my $cvslog2 = q$Date: 2002/12/30 03:20:06 $; print_navigate_links ($page); print <<"EOD"; @{[ $lm ? qq(
@{[&Resource('LastModified=',escape=>1)]}@{[&_rfc3339_date ($lm)]}
) : '' ]} @@ -759,7 +730,7 @@ return qq($ename); } } else { - return qq($ename@{[&Resource('JumpAndEditWikiPageMark',escape=>1)]}); + return qq($ename@{[&Resource('JumpAndEditWikiPageMark',escape=>1)]}); } } @@ -817,11 +788,13 @@ $option = &unescape ($option); $option =~ s/\\(.)/$1/g; $fmt{form_option}->replace ($option, $param); - $definition .= ' %submit;' if $definition !~ /%submit/ && !$param->{output}->{nosubmit}; + $param->{output}->{form} = 1 unless defined $param->{output}->{form}; + $definition .= ' %submit;' if $definition !~ /%submit/ && !$param->{output}->{nosubmit} && $param->{output}->{form}; my $target_page = $param->{output}->{page} || $form{mypage}; $param->{form_disabled} = 1 if $fixedpage{$target_page}; my $target_form = $param->{output}->{id}; - my $r = <{output}->{form};
@@ -831,9 +804,7 @@ EOH $r .= qq() if $UA =~ m#Mozilla/[12]\.#; $r .= $fmt{form_input}->replace ($definition, $param); - $r .= < -EOH + $r .= "\n" if $param->{output}->{form}; $r; } else { ## No input-interface WikiForm qq(); @@ -855,7 +826,7 @@ read STDIN, $query, $main::ENV{CONTENT_LENGTH}; } $query .= ($query ? ';' : '') . $main::ENV{QUERY_STRING}; - if ($main::ENV{QUERY_STRING} && $main::ENV{QUERY_STRING} !~ /[&;=]/) { + if ($main::ENV{REQUEST_METHOD} ne 'POST' && $main::ENV{QUERY_STRING} && $main::ENV{QUERY_STRING} !~ /[&;=]/) { my $query = &decode($main::ENV{QUERY_STRING}); $query = &code_convert(\$query, $kanjicode); if ($page_command{$query}) { @@ -993,17 +964,6 @@ } } -sub print_searchform { - my ($word) = @_; - print <<"EOD"; -
- - - -
-EOD -} - sub print_editform { my ($mymsg, $lastmodified, %mode) = @_; my $frozen = &is_frozen($form{mypage}); @@ -1499,12 +1459,6 @@ sub __get_database ($) { $database{ $_[0] } } sub __set_database ($$) { $database{ $_[0] } = $_[1] } -sub do_wikiplugininfo { - &print_header (q(WikiPluginInfo)); - print text_to_html (&SuikaWiki::Plugin::make_info_page); - &print_footer (q(WikiPluginInfo)); -} - sub do_map { my $page = $form{mypage}; &print_header ($page); @@ -1665,6 +1619,8 @@ sub encode ($$) { main::encode ($_[1]) } sub decode ($$) { main::decode ($_[1]) } sub __get_datetime ($) { main::get_now () } +sub resource ($$;%) { shift; &main::Resource (@_) } +sub uri ($$) { $main::uri{$_[1]} } sub regist ($@) { my $pack = shift; @@ -1683,36 +1639,6 @@ } } -sub make_info_page () { - my $r = <property (); - $r .= <{name}''' (Version $prop->{version}) -<$prop->{uri}> - -Provide: -@{[do{my $t = ''; for my $f (@{$prop->{provide}||[]}) { - $t .= qq(-''$f''\n); - for (sort grep m#^\Q$f\E/#, keys %{$prop->{partinfo}}) { - $t .= qq(--''$_'' -- $prop->{partinfo}->{$_}\n); - } -}$t}]} - -EOH - } - } - $r; -} - &import_plugins (); package wiki::conneg;