--- suikawiki/script/wiki.cgi 2003/01/04 03:32:55 1.49 +++ suikawiki/script/wiki.cgi 2003/01/12 09:15:06 1.50 @@ -7,13 +7,13 @@ use strict; use lib qw(./lib); use CGI::Carp qw(fatalsToBrowser); -our $VERSION = do{my @r=(q$Revision: 1.49 $=~/\d+/g);sprintf "%d."."%02d" x $#r,@r}; - +our $VERSION = do{my @r=(q$Revision: 1.50 $=~/\d+/g);sprintf "%d."."%02d" x $#r,@r}; +binmode STDOUT; binmode STDIN; require 'wikidata/suikawiki-config.ph'; use Fcntl; ############################## our %fmt; ## formatter objects -my %embed_command = ( +our %embed_command = ( searched => '^\[\[#searched:([^\]]+)\]\]$', form => qr/\[\[\#form(?:\(([A-Za-z0-9-]+)\))?:'((?:[^'\\]|\\.)*)':'((?:[^'\\]|\\.)*)'(?::'((?:[^'\\]|\\.)*)')?\]\]/, ); @@ -26,22 +26,14 @@ our $database = bless {}, 'wiki::dummy'; my %interwiki; ############################## -my %page_command = ( - $PageName{RssPage} => 'rss', -); my %command_do = ( - read => \&do_read, - TEXT_CSS => \&do_output_css, - edit => \&do_view, + read => \&do_view, adminchangepassword => \&do_adminchangepassword, write => \&do_write, searchform => \&do_searchform, comment => \&do_comment, RandomJump => \&do_random_jump, - rss => \&do_rss, - diff => \&do_view, wikiform => \&do_wikiform, - map => \&do_view, ); my $UA = ''; ## User agent name $| = 1; @@ -59,47 +51,59 @@ &close_db; } -sub do_read { +sub do_view { my $content = $database{$form{mypage}}; my $lm = $database->mtime ($form{mypage}); wiki::referer::add ($form{mypage}, $ENV{HTTP_REFERER}); wiki::useragent::add ($ENV{HTTP_USER_AGENT}); - my @toc; - my ($magic, $content) = &SuikaWiki::Plugin::magic_and_content (undef, $content); - $magic ||= '#?SuikaWiki/0.9'; + &load_formatter ('view'); + my $view = $form{mycmd}; + if ($view eq 'edit') { + $view = 'adminedit' if $form{admin}; + } elsif ($view =~ /[^0-9A-Za-z]/) { + $view = 'view' + } + my ($magic, $content) = &SuikaWiki::Plugin::magic_and_content (undef, $content); + $magic ||= '#?SuikaWiki/0.9'; + my $o = bless {param => \%form, page => $form{mypage}, toc => [], + magic => $magic, content => $content, + formatter => $fmt{view}, &_compatible_options ()}, 'SuikaWiki::Plugin'; + if (!ref $ViewDefinition{$view} || !&{$ViewDefinition{$view}->{check}} ($o)) { + print "Status: 406 Unsupported Media Type\n"; + $view = '-UnsupportedMediaType'; + } + my $media = $ViewDefinition{$view}->{media}; + if ($ViewDefinition{$view}->{xmedia} && $UA =~ /Gecko/) { + $media = $ViewDefinition{$view}->{xmedia}; + $o->{media} = $media; + } if ($magic =~ m!^\#\?SuikaWiki/0.9!) { - my $expires = time; - if ($magic =~ /interactive="yes"/) { - $lm = $expires; - } else { - $expires += 120; - } - &print_header ($form{mypage}, -last_modified => $lm, -expires => $expires, - -content_format => $magic, -noindex => ($magic =~ /obsoleted="yes"/ ? 1 : 0)); + &print_header ($form{mypage}, -last_modified => ($magic =~ /interactive="yes"/ ? $lm : time), + -expires => ($magic =~ /interactive="yes"/ ? 1 : undef), o => $o, + -media => $media, -magic => $magic, content => $content); } else { - &print_header($form{mypage}, -expires => time + 120, -content_format => $magic, -last_modified => $lm); + &print_header($form{mypage}, -media => $media, + -magic => $magic, -last_modified => $lm, o => $o); } - &load_formatter ('view'); - print $fmt{view}->replace ($ViewDefinition{read} => bless {param => \%form, page => $form{mypage}, toc => \@toc, formatter => $fmt{view}, &_compatible_options ()}, 'SuikaWiki::Plugin'); + print $fmt{view}->replace ($ViewDefinition{$view}->{template} => $o); } -sub do_output_css { - wiki::referer::add ($form{mypage}, $ENV{HTTP_REFERER}); - wiki::useragent::add ($ENV{HTTP_USER_AGENT}); - my $content = $database{$form{mypage}}; - if ($content =~ m#^\s*/\*\s*W3C-CSS#) { - my $lm = gmtime $database->mtime ($form{mypage}); - 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 { +sub _do_view_msg (%) { + my %option = @_; + &load_formatter ('view'); + my $o = bless {param => \%form, page => $option{-page}, toc => [], condition => \%option, + formatter => $fmt{view}, &_compatible_options ()}, 'SuikaWiki::Plugin'; + unless (&{$ViewDefinition{$option{-view}}->{check}} ($o)) { print "Status: 406 Unsupported Media Type\n"; - &print_header('WikiPageIsNotCSS', -noindex => 1); - &load_formatter ('view'); - print $fmt{view}->replace ($ViewDefinition{read} => bless {param => \%form, page => 'WikiPageIsNotCSS', toc => [], formatter => $fmt{view}, &_compatible_options ()}, 'SuikaWiki::Plugin'); + $option{-view} = '-UnsupportedMediaType'; } + my $media = $ViewDefinition{$option{-view}}->{media}; + if ($ViewDefinition{$option{-view}}->{xmedia} && $UA =~ /Gecko/) { + $media = $ViewDefinition{$option{-view}}->{xmedia}; + $o->{media} = $media; + } + &print_header($option{-page}, -media => $media, o => $o, -goto => $option{-goto}); + print $fmt{view}->replace ($ViewDefinition{$option{-view}}->{template} => $o); } sub id_and_name ($) { @@ -111,28 +115,18 @@ } } -sub do_view { - wiki::referer::add ($form{mypage}, $ENV{HTTP_REFERER}); - wiki::useragent::add ($ENV{HTTP_USER_AGENT}); - &print_header($form{mypage}, -noindex => 1, -expires => time+60); - &load_formatter ('view'); - my $view = $form{mycmd}; - if ($view eq 'edit') { - $view = 'adminedit' if $form{admin}; - } elsif ($view =~ /[^0-9A-Za-z]/) { - $view = 'view' - } - print $fmt{view}->replace ($ViewDefinition{$view} => bless {param => \%form, page => $form{mypage}, toc => [], formatter => $fmt{view}, &_compatible_options ()}, 'SuikaWiki::Plugin'); -} - sub do_adminchangepassword { if ($form{mynewpassword} ne $form{mynewpassword2}) { - &print_error(&Resource('Error:PasswordMismatch')); + &_do_view_msg (-view => '-error', -page => $form{mypage}, + error_message => &Resource ('Error:PasswordMismatch')); + return; } my ($validpassword_crypt) = $database->meta (AdminPassword => $PageName{AdminSpecialPage}); if ($validpassword_crypt) { if (not &valid_password($form{myoldpassword})) { - &print_error(&Resource('Error:PasswordIsIncorrect')); + &_do_view_msg (-view => '-error', -page => $form{mypage}, + error_message => &Resource ('Error:PasswordIsIncorrect')); + return; } } my ($sec, $min, $hour, $day, $mon, $year, $weekday) = localtime(time); @@ -141,9 +135,8 @@ my $salt2 = $token[($sec + $min*60 + $hour*60*60) % scalar(@token)]; my $crypted = crypt($form{mynewpassword}, "$salt1$salt2"); $database->meta (AdminPassword => $PageName{AdminSpecialPage} => $crypted); - - &print_header('CompletedSuccessfully', -noindex => 1); - &print_message(&Resource('Error:PasswordIsChanged')); + + &_do_view_msg (-view => '-wrote', -page => $form{mypage}); } sub valid_password ($) { @@ -157,16 +150,14 @@ } if (not &is_editable($form{mypage})) { - &print_header($form{mypage}, -noindex => 1); - &print_message(&Resource('Error:ThisPageIsUneditable')); + &_do_view_msg (-view => '-error', -page => $form{mypage}, + error_message => &Resource ('Error:ThisPageIsUneditable')); return; } ## Check confliction if ($form{myLastModified} ne $database->mtime ($form{mypage})) { - &print_header($form{mypage}, -noindex => 1); - &load_formatter ('view'); - print $fmt{view}->replace ($ViewDefinition{-conflict} => bless {param => \%form, page => $form{mypage}, toc => [], formatter => $fmt{view}, &_compatible_options ()}, 'SuikaWiki::Plugin'); + &_do_view_msg (-view => '-conflict', -page => $form{mypage}); return; } @@ -184,14 +175,10 @@ } elsif ($form{__wikiform_anchor_index}) { $fragment .= qq(#wikiform-$form{__wikiform_anchor_index}); } - &print_header($form{mypage}, -noindex => 1, -goto => $url_cgi.'?mycmd='.&encode($form{after_edit_cmd}||'read').';mypage='.&encode($form{mypage}).qq(;x-param=@{[time.[0..9]->[rand 10]]}$fragment)); - &load_formatter ('view'); - print $fmt{view}->replace ($ViewDefinition{-wrote} => bless {param => \%form, page => $form{mypage}, formatter => $fmt{view}, &_compatible_options ()}, 'SuikaWiki::Plugin'); + &_do_view_msg (-view => '-wrote', -page => $form{mypage}, -goto => $url_cgi.'?mycmd='.&encode($form{after_edit_cmd}||'read').';mypage='.&encode($form{mypage}).qq(;x-param=@{[time.[0..9]->[rand 10]]}$fragment)); } else { delete $database{$form{mypage}}; - &print_header($form{mypage}, -noindex => 1); - &load_formatter ('view'); - print $fmt{view}->replace ($ViewDefinition{-deleted} => bless {param => \%form, page => $form{mypage}, formatter => $fmt{view}, &_compatible_options ()}, 'SuikaWiki::Plugin'); + &_do_view_msg (-view => '-deleted', -page => $form{mypage}); } } @@ -225,24 +212,15 @@ sub do_random_jump { my @list = keys %database; my $name = &encode ($list[rand @list]); - my $scheme = 'http'; - $scheme = lc $1 if $main::ENV{SERVER_PROTOCOL} =~ m#([A-Za-z0-9+.%-]+)#; - print "Location: $scheme://$main::ENV{SERVER_NAME}:$main::ENV{SERVER_PORT}$url_cgi?$name\n"; + print "Location: $uri{wiki}?$name\n"; print "\n"; } -sub print_error { - my ($msg) = @_; - &print_header($PageName{ErrorPage}, -noindex => 1); - print qq(

$msg

); - exit(0); -} - sub print_header ($;%) { my ($page, %option) = @_; my @head; - $option{body_class} = &is_frozen($page) ? 'frozen' : 'normal'; - $option{body_class} .= " wiki-page-obsoleted" if $option{-content_format} =~ /obsoleted="yes"/; + $option{o}->{-header}->{class} = &is_frozen($page) ? 'frozen' : ''; + $option{o}->{-header}->{class} .= " wiki-page-obsoleted" if $option{-magic} =~ /obsoleted="yes"/; if ($option{-goto}) { if ($UA =~ m#Opera|MSIE 2\.#) { ## WARNING: This code may output unsafe HTML document if @@ -250,6 +228,9 @@ $option{-goto} =~ tr/;/&/ if $UA =~ m#Opera#; print qq{Refresh: 0; url=$option{-goto}\n}; push @head, qq(); + } elsif ($UA =~ /Gecko/) { + print qq{Refresh: 0; url="$option{-goto}"\n}; + push @head, qq(); } else { $option{-goto} =~ tr/;/&/ if $UA =~ m#Mozilla/[1-4]\.#; print qq{Refresh: 0; url="$option{-goto}"\n}; @@ -257,38 +238,30 @@ } } 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 ($option{-expires} != -1) { + if (defined $option{-expires}) { ## TODO: Don't use asctime + print qq{Expires: @{[scalar gmtime (time + $option{-expires})]}\n}; + } elsif ($option{-media}->{expires} != -1) { + print qq{Expires: @{[scalar gmtime (time + $option{-media}->{expires})]}\n}; + } } - if ($UA =~ m#Mozilla/2#) { - my $ct = qq{text/html; charset=@{[&get_charset_name($kanjicode,compatible=>1)]}}; + if ($option{-media}->{charset} && $UA =~ m#Mozilla/2#) { + my $ct = qq{$option{-media}->{type}; charset=@{[&get_charset_name($kanjicode,compatible=>1)]}}; print qq{Content-Type: $ct\n}; - push @head, qq{}; - } elsif ($UA =~ m#Infomosaic#) { - print qq{Content-Type: text/html\n}; + $option{o}->{-header}->{meta_ct} = qq{\n}; + } elsif (!$option{-media}->{charset} || $UA =~ m#Infomosaic#) { + print qq{Content-Type: $option{-media}->{type}\n}; } else { - print qq{Content-Type: text/html; charset=@{[&get_charset_name($kanjicode)]}\n}; + my $type = $option{-media}->{type}; + $type = 'application/xml' if $type eq 'application/rss+xml'; + print qq{Content-Type: $type; charset=@{[&get_charset_name($kanjicode)]}\n}; } - push @head, qq(@{[&escape($page)]}); - if ($UA !~ m#Mozilla/[1-4]\.# || $UA =~ m#MSIE (?:[4-9]\.|\d\d)#) { - push @head, qq() if $option{-noindex}; - my ($Links, $links) = &make_navigate_links ($page); - #print $Links; ## Link: fields - $links = join "\n", (@head, $links); - print <<"EOD"; + print <<"EOD"; ## TODO: Content-Language: $lang Content-Style-Type: text/css - - - -$links - EOD + $option{o}->{-header}->{links} = join "\n", (@head); } sub get_charset_name ($;%) { @@ -303,63 +276,6 @@ $charset; } -sub _navigate_links (@) { - my ($page) = @_; - my $editable = (&is_editable($page) && !&is_frozen($page)) ? 1 : 0; - my $cookedpage = &encode($page); - <@{[&Resource('EditThisPage',escape=>1)]} | ) - : qq() - ]} - @{[&Resource('ViewThisPage',escape=>1)]} | - @{[&Resource('ShowMapOfThisPage',escape=>1)]} | - @{[&Resource('GoToCreatePage',escape=>1)]} | - @{[&Resource('GoToIndexPage',escape=>1)]} | - @{[&Resource('GoToHomePage',escape=>1)]} | - @{[&Resource('GoToSearchPage',escape=>1)]} | - @{[&Resource('GoSomewhere',escape=>1)]} | - @{[&Resource('GoToRecentChanges',escape=>1)]} -EOH -} - -sub make_navigate_links ($) { - my $page = shift; - my @link; - push @link, {rel=>'edit', href=>"$url_cgi?mycmd=edit;mypage=@{[&encode($page)]}", class=>"wiki-command", title=>&Resource('EditThisPageLink')} if &is_editable ($page) && !&is_frozen ($page); - push @link, {rel=>'edit', href=>"$url_cgi?mycmd=edit;admin=1;mypage=@{[&encode($page)]}", class=>"wiki-command", title=>&Resource('AdminEditThisPageLink')} if &is_editable ($page) || &is_frozen ($page); - push @link, {rel=>'view', href=>"$url_cgi?mycmd=read;mypage=@{[&encode($page)]};x-p=@{[time.[0..9]->[rand 10]]}", class=>'wiki-command', title=>&Resource('ViewThisPageLink')}; - push @link, {rel=>'myself', href=>"$url_cgi?@{[&encode($page)]}", class=>'wiki', title=>&Resource('GoToMyselfLink')}; - push @link, {rel=>'index', href=>"$url_cgi?$PageName{IndexPage}", class=>'wiki', title=>&Resource('GoToIndexPageLink')}; - push @link, {rel=>'home', href=>"$url_cgi?$PageName{FrontPage}", class=>'wiki', title=>&Resource('GoToHomePageLink')}; - push @link, {rel=>'News', href=>"$url_cgi?WikiNews", class=>'wiki', title=>&Resource('GoToWikiNewsLink')}; - push @link, {rel=>'News', href=>"$url_cgi?$PageName{RecentChanges}", class=>"wiki", title=>&Resource('GoToRecentChangesLink')}; - push @link, {rel=>'News', href=>"$url_cgi?$PageName{RssPage}", class=>"wiki", title=>&Resource('GoToRssPageLink'), type=>'application/xml'}; - push @link, {rel=>'search', href=>"$url_cgi?$PageName{SearchPage}", class=>'wiki', title=>&Resource('GoToSearchPageLink')}; - push @link, {rel=>'help', href=>"$url_cgi?WikiHelp", class=>'wiki', title=>&Resource('GoToWikiHelpLink')}; - push @link, {rel=>'copyright', href=>"$url_cgi?WikiPageLicense", class=>'wiki', title=>&Resource('GoToWikiPageLicenseLink')}; - push @link, {rel=>'jump', href=>qq(javascript:var%20WikiName=prompt('Please%20input%20the%20WikiName:','','Jump%20to%20SuikaWiki');if(WikiName)%7B_content.location.href='$url_cgi%3F'+encodeURIComponent(WikiName)%7D), class=>'wiki-cmd', title=>&Resource('JumpToLink')}; - push @link, {rel=>'jump', href=>qq(javascript:var%20WikiName=prompt('Please%20input%20the%20WikiName:','','Jump%20to%20SuikaWiki');if(WikiName)%7B_content.location.href='$url_cgi%3Fmycmd=edit;mypage='+encodeURIComponent(WikiName)%7D), class=>'wiki-cmd', title=>&Resource('JumpToEditLink')}; - push @link, {rel=>'lucky', href=>"$url_cgi?mycmd=RandomJump;x-param=@{[time.[0..9]->[rand 10]]}", class=>'wiki randomlink', title=>&Resource('GoSomewhereLink')}; - push @link, {rel=>'history', href=>$uri{cvs_wikipage}.do{my $s=$page;$s=~s/(.)/sprintf '%02X', ord $1/ges;$s}.'.txt', title=>&Resource('ViewHistoryOfThisPageLink'),hreflang=>'en'} if $uri{cvs_wikipage}; - push @link, {rel=>'history', href=>"$url_cgi?mycmd=diff;mypage=@{[&encode($page)]}", title=>&Resource('ViewDiffOfThisPageLink'), class=>'wiki-command'} if $wiki::diff::UseDiff; - push @link, {rel=>'contents', href=>"$url_cgi?mycmd=map;mypage=@{[&encode($page)]}", title=>&Resource('ShowMapOfThisPageLink'), class=>'wiki-command'}; - my ($Links, $links) = ('', ''); - for my $e (@link) { - $links .= qq({href}>); - for my $attr (qw/rel rev href title class type hreflang charset/) { - $links .= qq( $attr="@{[&escape($e->{$attr})]}") if $e->{$attr}; - } - for my $attr (qw/rel rev title/) { - $Links .= qq(; $attr="@{[do{$e->{$attr} =~ s/([\\\"])/\\$1/g; $e->{$attr}}]}") if $e->{$attr}; - } - $links .= qq(>\n); - $Links .= qq(\n); - } - wantarray ? ($Links, $links) : $Links; -} - sub escape { my $s = shift; $s =~ s|\x0D\x0A|\x0A|g; @@ -383,9 +299,11 @@ sub convert_format ($$$;%) { my ($content, $d => $t, %option) = @_; &load_formatter ('format'); - my $f = $fmt{format}->{$d.'_to_'.$t}; + my $f = SuikaWiki::Plugin->format_converter ($d => $t); if (ref $f) { $option{content} = $content; + $option{from} = $d; + $option{to} = $t; &$f ({}, bless (\%option, 'SuikaWiki::Plugin')); } elsif ($t =~ /HTML|xml/) { length $content ? '
'.&escape($content).'
' : ''; @@ -629,17 +547,17 @@ $fmt{form_option}->replace ($option, $param); $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->{output}->{page} ||= $form{mypage}; $param->{form_disabled} = 1 if $database->meta (IsFrozen => $form{mypage}); my $target_form = $param->{output}->{id}; my $r = ''; $r = <{output}->{form};
- - - - - + + + + + EOH $r .= qq() if $UA =~ m#Mozilla/[12]\.#; $r .= $fmt{form_input}->replace ($definition, $param); @@ -653,11 +571,6 @@ } }} -sub print_message { - my ($msg) = @_; - print qq(

@{[&escape($msg)]}

); -} - sub init_form { ## TODO: Support multipart/form-data my $query = ''; @@ -668,13 +581,8 @@ 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}) { - $form{mycmd} = $page_command{$query}; - $form{mypage} = $query; - } else { $form{mypage} = $query; $form{mycmd} = $database{$form{mypage}} ? 'read' : 'edit'; - } } else { for (split /[;&]/, $query) { if (my ($n, $v) = split /=/, $_, 2) { @@ -686,12 +594,8 @@ $form{mypage} = $form{epage}; $form{mypage} =~ s/([0-9A-F]{2})/ord hex $1/g; } - if ($page_command{$form{mypage}} && $form{mycmd} eq 'read') { - $form{mypage} = &code_convert(\$form{mypage}, $kanjicode); - $form{mycmd} = $page_command{$form{mypage}}; - } } - $form{mypage} ||= 'HomePage'; + $form{mypage} ||= $PageName{FrontPage}; $form{mypage} =~ tr/\x00-\x1F\x7F//d; $form{mycmd} ||= 'read'; @@ -738,16 +642,16 @@ sub open_db { if ($modifier_dbtype eq 'dbmopen') { - dbmopen(%database, $PathTo{WikiDataBase}, 0666) or &print_error("(dbmopen) $PathTo{WikiDataBase}"); + dbmopen(%database, $PathTo{WikiDataBase}, 0666) or die "(dbmopen) $PathTo{WikiDataBase}"; } elsif ($modifier_dbtype eq 'AnyDBM_File') { 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(%database, "AnyDBM_File", $PathTo{WikiDataBase}, O_RDWR|O_CREAT, 0666) or die ("(tie AnyDBM_File) $PathTo{WikiDataBase}"); } elsif ($modifier_dbtype eq 'Yuki::YukiWikiDB') { eval q{use Yuki::YukiWikiDB}; - tie(%database, "Yuki::YukiWikiDB", $PathTo{WikiDataBase}) or &print_error("(tie Yuki::YukiWikiDB) $PathTo{WikiDataBase}"); + tie(%database, "Yuki::YukiWikiDB", $PathTo{WikiDataBase}) or die ("(tie Yuki::YukiWikiDB) $PathTo{WikiDataBase}"); } else { ## Yuki::YukiWikiDB || Yuki::YukiWikiDBMeta 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}"); + $database = tie(%database, $modifier_dbtype => $PathTo{WikiDataBase}, -lock => 2, -backup => $wiki::diff::UseDiff) or die ("(tie $modifier_dbtype) $PathTo{WikiDataBase}"); } } @@ -783,23 +687,23 @@ EOH $f .= <<"EOD"; - @{[ $option{conflict} ? '' : qq() ]} - @{[ $option{admin} ? qq() : "" ]} [@{[&get_new_anchor_index($option{content})]}]
- - -
+ @{[ $option{conflict} ? '' : qq() ]} + @{[ $option{admin} ? qq() : "" ]} [@{[&get_new_anchor_index($option{content})]}]
+ + +
@{[ $option{admin} ? qq( - -
) + +
) : "" ]} @{[ $option{conflict} ? "" : qq( -
- +
+ $afteredit ) ]} @@ -810,7 +714,7 @@ sub is_editable { my ($page) = @_; - $page =~ /[\x00-\x1F\x7F]/ ? 0 : 1; + $page =~ /[\x00-\x20\x7F]/ ? 0 : 1; } sub decode { @@ -822,7 +726,7 @@ sub encode { my $s = shift; - $s =~ s/([^0-9A-Za-z_-])/sprintf '%%%02X', ord $1/g; + $s =~ s/([^0-9A-Za-z_-])/sprintf '%%%02X', ord $1/ge; $s; } @@ -858,8 +762,9 @@ # You are admin. return 0; } else { - &print_error(&Resource('Error:PasswordIsIncorrect')); - return 1; + &_do_view_msg (-view => '-error', -page => $form{mypage}, + error_message => &Resource ('Error:PasswordIsIncorrect')); + exit; } } @@ -921,25 +826,25 @@ my $lastmodified = $database->mtime ($form{mypage}); return <<"EOD";

- - - - - + + + + + @{[&Resource('WikiForm:WikiComment:Name=',escape=>1)]} - - - + + +

EOD } else { return <<"EOD";
- - + + @{[&Resource('WikiForm:WikiComment:Name=',escape=>1)]} - - + +
EOD } @@ -1050,48 +955,6 @@ return $$contentref; } -sub do_rss { - eval q{use Yuki::RSS}; - my $rss = new Yuki::RSS( - version => '1.0', - encoding => &get_charset_name ($kanjicode), - ); - my $scheme = 'http'; - $scheme = lc $1 if $main::ENV{SERVER_PROTOCOL} =~ m#([A-Za-z0-9+.%-]+)#; - my $myuri = "$scheme://$main::ENV{SERVER_NAME}:$main::ENV{SERVER_PORT}$url_cgi"; - $rss->stylesheet ( - href => $myuri . "?mycmd=TEXT_CSS;mypage=WikiStyle:RSS", - type => 'text/css', - ); - $rss->channel( - title => &Resource ('RSS:WikiTitle'), - link => $myuri, - description => &Resource ('RSS:WikiDescription'), - 'dc:language' => $lang, - ); - my $recentchanges = $database{RecentChanges}; - my $count = 0; - foreach (split(/\n/, $recentchanges)) { - last if ($count >= 15); - if (/\[\[([^]]+)\]\]/) { - my $title = $1; - $rss->add_item ( - title => &escape($title), - link => $myuri . '?' . &encode($title), - description => &escape(&get_subjectline($title,delimiter=>'')), - 'dc:date' => $database->mtime ($title), - ); - $count++; - } - } - # print RSS information (as XML). - print <<"EOD" -Content-type: application/xml; charset=@{[&get_charset_name ($kanjicode)]} - -@{[$rss->as_string]} -EOD -} - sub _rfc3339_date ($) { my @time = gmtime (shift); sprintf '%04d-%02d-%02dT%02d:%02d:%02d+00:00', $time[5]+1900,$time[4]+1,@time[3,2,1,0]; @@ -1236,6 +1099,7 @@ our $plugin_directory; our %List; our %Index; + push @main::INC, $plugin_directory.'/../..'; sub escape ($$) { main::escape ($_[1]) } sub unescape ($$) { main::unescape ($_[1]) } @@ -1245,15 +1109,21 @@ sub resource ($$;%) { shift; &main::Resource (@_) } sub uri ($$) { $main::uri{$_[1]} } sub new_index ($$) { ++$Index{$_[1]} } +sub user_agent_names ($) { $main::UA } sub magic_and_content ($$) { - my $page = $_[1]; - $page =~ s!^((?:\#\?|/\*|<\?)[^\x02\x0A\x0D]+)[\x02\x0A\x0D]+!!s; - ($1, $page); + my ($magic, $page) = ('', $_[1]); + $magic = $1 if $page =~ s!^((?:\#\?|/\*|<\?)[^\x02\x0A\x0D]+)[\x02\x0A\x0D]+!!s; + ($magic, $page); } sub formatter ($$) { &main::load_formatter ($_[1]); $main::fmt{$_[1]}; } +sub format_converter ($$$) { + &main::load_formatter ('format'); + $main::fmt{format}->{($_[1]=~/([A-Za-z0-9]\S+)/?$1:'SuikaWiki/0.9').'_to_'.$_[2]} + || $main::fmt{format}->{($_[1]=~/([A-Za-z0-9](?:(?!\/)\S)+)/?$1:'SuikaWiki').'_to_'.$_[2]}; +} sub regist ($@) { my $pack = shift;