1 |
#!/usr/bin/perl |
#!/usr/bin/perl |
|
#!perl |
|
|
# |
|
2 |
# wiki.cgi - This is YukiWiki, yet another Wiki clone. |
# wiki.cgi - This is YukiWiki, yet another Wiki clone. |
3 |
# |
# |
|
# Copyright (C) 2000-2002 by Hiroshi Yuki. |
|
|
# <hyuki@hyuki.com> |
|
|
# http://www.hyuki.com/yukiwiki/ |
|
|
# |
|
4 |
# This program is free software; you can redistribute it and/or |
# This program is free software; you can redistribute it and/or |
5 |
# modify it under the same terms as Perl itself. |
# modify it under the same terms as Perl itself. |
|
# |
|
|
############################## |
|
|
# |
|
|
# walwiki.cgi based on yukiwiki.cgi - Yet another WikiWikiWeb clone. |
|
|
# |
|
|
# WalWikiの現バージョンは、YukiWiki 2.0.beta1をベースにしています。 |
|
|
# |
|
|
# * 更新内容 |
|
|
# |
|
|
# 2.0.beta1.wal.1 on 2002/05/19,22:32:19 |
|
|
# (1) Footerの変更 |
|
|
# (2) WikiNameの拡張 : PerlCEも包含、PPMInstallは含まない |
|
|
# (3) 別名リンク([別名 URL])に対応。 |
|
|
# (4) ISBNをアマゾン.jpのAsociateプログラムリンクに変換。 |
|
|
# (5) [[#box:InterWikiName]]でInterWikiなテキストボックス生成 |
|
|
# (6) HTMLモード対応。 |
|
|
# |
|
|
# 旧2.0.alpha0.wal.3版までの修正の内、以下に変更があります。 |
|
|
# ・以下はYukiWiki2に実装されたため、独自コードはなくなりました。 |
|
|
# - インラインの画像変換 |
|
|
# - YukiWikiDB対応 |
|
|
# - テーブル |
|
|
# - DB関連モジュールuseのeval化 |
|
|
# - BracketNameによるキーからブラケットを排除 |
|
|
# ・ISBN番号への対応はWalWiki2.0より、InterWikiへのAdd-Onになりました。 |
|
|
# [[ISBN http://www.amazon.co.jp/exec/obidos/ASIN/isbn($1)/walrdigi-22]]のように登録。 |
|
|
# |
|
|
#======================================= |
|
6 |
|
|
|
# Walrus add (debug) start |
|
|
my $walrus_log; |
|
|
my $walrus_debugging = 0; |
|
|
# Walrus add (debug) end |
|
|
|
|
|
# Libraries. |
|
7 |
use strict; |
use strict; |
8 |
use lib qw(./WalWiki/lib); |
use lib qw(./lib); |
|
use CGI qw(:standard); |
|
9 |
use CGI::Carp qw(fatalsToBrowser); |
use CGI::Carp qw(fatalsToBrowser); |
10 |
use Yuki::RSS; |
our $VERSION = do{my @r=(q$Revision$=~/\d+/g);sprintf "%d."."%02d" x $#r,@r}; |
11 |
use Yuki::DiffText qw(difftext); |
|
12 |
use Yuki::YukiWikiDB; |
require 'wikidata/suikawiki-config.ph'; |
|
use AnyDBM_File; |
|
|
require 'jcode.pl'; |
|
|
# use Jcode; |
|
13 |
use Fcntl; |
use Fcntl; |
|
my $version = '2.0.beta1.2002-05-29'; |
|
|
my $walversion; |
|
|
############################## |
|
|
# |
|
|
# You MUST modify following '$modifier_...' variables. |
|
|
# |
|
|
my $modifier_mail = 'w@suika.fam.cx'; # Your mail address, like 'walrus@digit.que.ne.jp'. |
|
|
my $modifier_url = 'http://suika.fam.cx/~wakaba/'; # Your web page, like 'http://digit.que.ne.jp/work/'. |
|
|
my $modifier_name = '和'; # Your name, like 'Makio Tsukamoto'. |
|
|
# my $modifier_dbtype = 'AnyDBM_File'; # Fast, not available on some server, page size limited. |
|
|
# my $modifier_dbtype = 'dbmopen'; # Fast, not available on some server, page size limited. |
|
|
my $modifier_dbtype = 'YukiWikiDB'; # Slow, available on all environment. |
|
|
# my $modifier_sendmail = '/usr/sbin/sendmail -t -n'; # Your sendmail. |
|
|
my $modifier_sendmail = ''; # If you don't need mail notification. |
|
|
my $modifier_dir_data = './wikidata'; # Your data directory. |
|
|
my $modifier_rss_title = "WalWiki $walversion"; |
|
|
my $modifier_rss_link = 'http://suika.fam.cx/~wakaba/-temp/wiki2/wiki'; # Blank is not allowed. |
|
|
my $modifier_rss_description = 'This is WalWiki, yet another Wiki clone based on YukiWiki'; |
|
|
############################## |
|
|
# |
|
|
# You MAY modify following variables. |
|
|
# |
|
|
my $file_touch = "$modifier_dir_data/touched.txt"; |
|
|
my $file_resource = "$modifier_dir_data/resource.txt"; |
|
|
my $file_FrontPage = "$modifier_dir_data/frontpage.txt"; |
|
|
my $file_conflict = "$modifier_dir_data/conflict.txt"; |
|
|
my $file_format = "$modifier_dir_data/format.txt"; |
|
|
my $url_cgi = 'wiki'; |
|
|
my $url_stylesheet = 'wiki-style.css'; |
|
|
my $icontag = '<img src="/icons/folder" alt="*" width="40" height="40" />'; |
|
|
my $maxrecent = 50; |
|
|
my $cols = 80; |
|
|
my $rows = 20; |
|
14 |
############################## |
############################## |
15 |
# |
my %fmt; ## formatter objects |
16 |
# You MAY, but do NOT NEED modify following variables. |
my %embed_command = ( |
17 |
# |
searched => '^\[\[#searched:([^\]]+)\]\]$', |
18 |
my $dataname = "$modifier_dir_data/wiki"; |
form => qr/\[\[\#form(?:\(([A-Za-z0-9-]+)\))?:'((?:[^'\\]|\\.)*)':'((?:[^'\\]|\\.)*)'(?::'((?:[^'\\]|\\.)*)')?\]\]/, |
|
my $infoname = "$modifier_dir_data/info"; |
|
|
my $diffname = "$modifier_dir_data/diff"; |
|
|
my $editchar = '?'; |
|
|
my $subject_delimiter = ' - '; |
|
|
my $use_autoimg = 1; # automatically convert image URL into <img> tag. |
|
|
my $use_exists = 0; # If you can use 'exists' method for your DB. |
|
|
############################## |
|
|
my $InterWikiName = 'InterWikiName'; |
|
|
my $RecentChanges = 'RecentChanges'; |
|
|
my $AdminChangePassword = 'AdminChangePassword'; |
|
|
my $CompletedSuccessfully = 'CompletedSuccessfully'; |
|
|
my $FrontPage = 'HomePage'; |
|
|
my $IndexPage = 'IndexPage'; |
|
|
my $SearchPage = 'SearchPage'; |
|
|
my $CreatePage = 'CreatePage'; |
|
|
my $ErrorPage = 'ErrorPage'; |
|
|
my $RssPage = 'RssPage'; |
|
|
my $AdminSpecialPage = 'Admin Special Page'; # must include spaces. |
|
|
############################## |
|
|
# my $wiki_name = '\b([A-Z][a-z]+([A-Z][a-z]+)+)\b'; # Walrus del (2) |
|
|
my $wiki_name = '\b([A-Z][a-z]+([A-Z][a-z]*)+)\b'; # Walrus add (2) |
|
|
my $bracket_name = '\[\[(\S+?)\]\]'; |
|
|
my $embedded_name = '\[\[(#\S+?)\]\]'; |
|
|
my $interwiki_definition = '\[\[(\S+?)\ (\S+?)\]\]'; |
|
|
my $interwiki_name = '([^:]+):([^:].*)'; |
|
|
############################## |
|
|
my $embed_comment = '[[#comment]]'; |
|
|
my $embed_rcomment = '[[#rcomment]]'; |
|
|
my $embed_interwiki = '^\[\[#(box|text|password):(\S+)\]\]$'; # Walrus add (5) |
|
|
############################## |
|
|
my $info_LastModified = 'LastModified'; |
|
|
my $info_IsFrozen = 'IsFrozen'; |
|
|
my $info_AdminPassword = 'AdminPassword'; |
|
|
############################## |
|
|
my $kanjicode = 'euc'; |
|
|
my $charset = 'EUC-JP'; |
|
|
my $lang = 'ja'; |
|
|
my %fixedpage = ( |
|
|
$IndexPage => 1, |
|
|
$CreatePage => 1, |
|
|
$ErrorPage => 1, |
|
|
$RssPage => 1, |
|
|
$RecentChanges => 1, |
|
|
$SearchPage => 1, |
|
|
$AdminChangePassword => 1, |
|
|
$CompletedSuccessfully => 1, |
|
|
#$FrontPage => 1, |
|
19 |
); |
); |
20 |
|
our ($modifier_dbtype,$url_cgi,%uri,%PathTo,$use_exists); |
21 |
|
our (%PageName,$kanjicode,$lang,%FixedPage); |
22 |
|
|
23 |
|
############################## |
24 |
my %form; |
my %form; |
25 |
my %database; |
our %database; |
26 |
my %infobase; |
our $database = bless {}, 'wiki::dummy'; |
|
my %diffbase; |
|
|
my %resource; |
|
27 |
my %interwiki; |
my %interwiki; |
28 |
############################## |
############################## |
29 |
my %page_command = ( |
my %page_command = ( |
30 |
$IndexPage => 'index', |
$PageName{RssPage} => 'rss', |
|
$SearchPage => 'searchform', |
|
|
$CreatePage => 'create', |
|
|
$RssPage => 'rss', |
|
|
$AdminChangePassword => 'adminchangepasswordform', |
|
|
#$FrontPage => 'FrontPage', |
|
31 |
); |
); |
32 |
my %command_do = ( |
my %command_do = ( |
33 |
read => \&do_read, |
read => \&do_read, |
34 |
|
TEXT_CSS => \&do_output_css, |
35 |
edit => \&do_edit, |
edit => \&do_edit, |
36 |
adminedit => \&do_adminedit, |
adminedit => \&do_adminedit, |
|
adminchangepasswordform => \&do_adminchangepasswordform, |
|
37 |
adminchangepassword => \&do_adminchangepassword, |
adminchangepassword => \&do_adminchangepassword, |
38 |
write => \&do_write, |
write => \&do_write, |
|
index => \&do_index, |
|
39 |
searchform => \&do_searchform, |
searchform => \&do_searchform, |
|
search => \&do_search, |
|
|
create => \&do_create, |
|
|
createresult => \&do_createresult, |
|
|
FrontPage => \&do_FrontPage, |
|
40 |
comment => \&do_comment, |
comment => \&do_comment, |
41 |
|
RandomJump => \&do_random_jump, |
42 |
rss => \&do_rss, |
rss => \&do_rss, |
43 |
diff => \&do_diff, |
diff => \&do_diff, |
44 |
interwikibox => \&do_interwiki_box, # Walrus add (5) |
wikiform => \&do_wikiform, |
45 |
|
map => \&do_map, |
46 |
); |
); |
47 |
############################## |
my $UA = ''; ## User agent name |
48 |
my @ignore_html_page = ('FrontPage'); # Walrus add (6) |
$| = 1; |
|
my @ignore_html_tags = ('a', 'br', 'img'); # Walrus add (6) |
|
|
my $walversion = '2.0.beta1.wal.1'; # Walrus add (1) |
|
|
############################## |
|
|
# &test_convert; |
|
|
&main; |
|
|
exit(0); |
|
49 |
############################## |
############################## |
50 |
|
|
51 |
sub main { |
sub main { |
52 |
&init_resource; |
$UA = $main::ENV{HTTP_USER_AGENT}; |
53 |
&open_db; |
&open_db; |
54 |
&init_form; |
&init_form; |
|
&init_InterWikiName; |
|
55 |
if ($command_do{$form{mycmd}}) { |
if ($command_do{$form{mycmd}}) { |
56 |
&{$command_do{$form{mycmd}}}; |
&{$command_do{$form{mycmd}}}; |
57 |
} else { |
} else { |
58 |
&do_FrontPage; |
&{$command_do{read}}; |
59 |
} |
} |
60 |
&close_db; |
&close_db; |
61 |
} |
} |
62 |
|
|
63 |
sub do_read { |
sub do_read { |
64 |
&print_header($form{mypage}); |
my $content = $database{$form{mypage}}; |
65 |
&print_content($database{$form{mypage}}); |
my $lm = $database->mtime ($form{mypage}); |
66 |
&print_footer($form{mypage}); |
wiki::referer::add ($form{mypage}, $ENV{HTTP_REFERER}); |
67 |
|
wiki::useragent::add ($ENV{HTTP_USER_AGENT}); |
68 |
|
my ($r, $c) = get_search_result ($form{mypage}); |
69 |
|
my $rl = wiki::referer::list_html ($form{mypage}); |
70 |
|
my @toc; |
71 |
|
push @toc, qq(-<a href="#wikipage-see-also">@{[&Resource('SeeAlso',escape=>1)]}</a>) if $c; |
72 |
|
push @toc, qq(-<a href="#wikipage-referer">@{[&Resource('Referers',escape=>1)]}</a>) if $rl; |
73 |
|
my $cf = 'SuikaWiki/0.9'; |
74 |
|
## Should be support at least: |
75 |
|
## - 'SuikaWiki/0.9' CRLF |
76 |
|
## - 'H2H/' ("0.9" / "1.0" / "1.1") CRLF |
77 |
|
## - "/*" WSP* 'W3C-CSS/' ("1.0" / "2.0") "*/" CRLF |
78 |
|
$cf = $1 if $content =~ s#^(?:/\*\s*|[\#<]\?)?([A-Z][A-Za-z0-9-]+/[0-9.]+(?:[^0-9.\x0D\x0A][^\x0D\x0A]*)?)[\x0D\x0A]+##s; |
79 |
|
if ($cf =~ m!^(?:\#\?)?SuikaWiki/0.9(?:$|\s)!) { |
80 |
|
my $expires = time; |
81 |
|
if ($cf =~ /interactive="yes"/) { |
82 |
|
$lm = $expires; |
83 |
|
} else { |
84 |
|
$expires += 120; |
85 |
|
} |
86 |
|
&print_header ($form{mypage}, -last_modified => $lm, -expires => $expires, |
87 |
|
-content_format => $cf, -noindex => ($cf =~ /obsoleted="yes"/ ? 1 : 0)); |
88 |
|
&print_content ($content, content_format => $cf, last_modified => $lm, |
89 |
|
-toc => \@toc); |
90 |
|
print &text_to_html (q([[#comment]])) if $cf !~ /obsoleted="yes"/ && !$FixedPage{$form{mypage}}; |
91 |
|
} else { |
92 |
|
&print_header($form{mypage}, -expires => time + 120, -last_modified => $lm); |
93 |
|
print "<pre>@{[&escape($content)]}</pre>"; |
94 |
|
} |
95 |
|
if ($c) { |
96 |
|
print qq{<h2 @{[&id_and_name('wikipage-see-also')]}>@{[&Resource('SeeAlso',escape=>1)]}</h2>}; |
97 |
|
print $r; |
98 |
|
} |
99 |
|
if ($rl) { |
100 |
|
print qq(<div @{[&id_and_name('wikipage-referer')]}><h2>@{[&Resource('Referers',escape=>1)]}</h2>\n$rl</div>\n); |
101 |
|
} |
102 |
|
#print "\n". gmtime."Footer...\n"; |
103 |
|
&print_footer($form{mypage}, $lm); |
104 |
|
#print "\n". gmtime."Fin...\n"; |
105 |
|
} |
106 |
|
|
107 |
|
sub do_output_css { |
108 |
|
wiki::referer::add ($form{mypage}, $ENV{HTTP_REFERER}); |
109 |
|
wiki::useragent::add ($ENV{HTTP_USER_AGENT}); |
110 |
|
my $content = $database{$form{mypage}}; |
111 |
|
if ($content =~ m#^\s*/\*\s*W3C-CSS#) { |
112 |
|
my $lm = gmtime $database->mtime ($form{mypage}); |
113 |
|
print "Content-Type: text/css; charset=@{[&get_charset_name($kanjicode)]}\n"; |
114 |
|
print "Last-Modified: $lm\n"; |
115 |
|
print "Expires: @{[scalar gmtime time+3600]}\n"; ## TODO: don't use asctime |
116 |
|
print "\n"; |
117 |
|
print $content; |
118 |
|
} else { |
119 |
|
print "Status: 406 Unsupported Media Type\n"; |
120 |
|
&print_header('WikiPageIsNotCSS', -noindex => 1); |
121 |
|
&print_content($database{WikiPageIsNotCSS}); |
122 |
|
&print_footer('WikiPageIsNotCSS'); |
123 |
|
} |
124 |
|
} |
125 |
|
|
126 |
|
sub id_and_name ($) { |
127 |
|
my $name = shift; |
128 |
|
if ($UA =~ m#Mozilla/[12]\.|Microsoft Internet Explorer#) { |
129 |
|
qq{id="$name"><a name="$name"></a}; |
130 |
|
} else { |
131 |
|
qq{id="$name"}; |
132 |
|
} |
133 |
} |
} |
134 |
|
|
135 |
sub do_edit { |
sub do_edit { |
136 |
my ($page) = &unarmor_name(&armor_name($form{mypage})); |
my ($page) = &unarmor_name(&armor_name($form{mypage})); |
|
&print_header($page); |
|
137 |
if (not &is_editable($page)) { |
if (not &is_editable($page)) { |
138 |
&print_message($resource{cantchange}); |
&print_header($page, -noindex => 1, -expires => time+60); |
139 |
|
&print_message(&Resource('Error:ThisPageIsUneditable')); |
140 |
} elsif (&is_frozen($page)) { |
} elsif (&is_frozen($page)) { |
141 |
&print_message($resource{cantchange}); |
&print_header($page, -noindex => 1, -expires => time+60); |
142 |
|
&print_message(&Resource('Error:ThisPageIsUneditable')); |
143 |
} else { |
} else { |
144 |
&print_editform($database{$page}, &get_info($page, $info_LastModified), admin=>0); |
&print_header($page, -noindex => 1, -expires => time+60); |
145 |
|
&print_editform($database{$page}, $database->mtime ($page), admin=>0); |
146 |
|
} |
147 |
|
wiki::referer::add ($form{mypage}, $ENV{HTTP_REFERER}); |
148 |
|
wiki::useragent::add ($ENV{HTTP_USER_AGENT}); |
149 |
|
my ($r, $c) = get_search_result ($form{mypage}); |
150 |
|
my $rl = wiki::referer::list_html ($form{mypage}); |
151 |
|
if ($c) { |
152 |
|
print qq{<h2 id="wikipage-see-also">@{[&Resource('SeeAlso',escape=>1)]}</h2>}; |
153 |
|
print $r; |
154 |
|
} |
155 |
|
if ($rl) { |
156 |
|
print qq(<div id="wikipage-referer"><h2>@{[&Resource('Referers',escape=>1)]}</h2>\n$rl</div>\n); |
157 |
} |
} |
158 |
&print_footer($page); |
&print_footer($page); |
159 |
} |
} |
160 |
|
|
161 |
sub do_adminedit { |
sub do_adminedit { |
162 |
my ($page) = &unarmor_name(&armor_name($form{mypage})); |
my ($page) = &unarmor_name(&armor_name($form{mypage})); |
163 |
&print_header($page); |
&print_header($page, -noindex => 1, -expires => time+60); |
164 |
if (not &is_editable($page)) { |
if (not &is_editable($page)) { |
165 |
&print_message($resource{cantchange}); |
&print_message(&Resource('Error:ThisPageIsUneditable')); |
166 |
} else { |
} else { |
167 |
&print_message($resource{passwordneeded}); |
&print_message(&Resource('Error:PasswordIsNotSpecified')); |
168 |
&print_editform($database{$page}, &get_info($page, $info_LastModified), admin=>1); |
&print_editform($database{$page}, $database->mtime ($page), admin=>1); |
169 |
} |
} |
170 |
&print_footer($page); |
&print_footer($page); |
171 |
} |
} |
172 |
|
|
|
sub do_adminchangepasswordform { |
|
|
&print_header($AdminChangePassword); |
|
|
&print_passwordform; |
|
|
&print_footer($AdminChangePassword); |
|
|
} |
|
|
|
|
173 |
sub do_adminchangepassword { |
sub do_adminchangepassword { |
174 |
if ($form{mynewpassword} ne $form{mynewpassword2}) { |
if ($form{mynewpassword} ne $form{mynewpassword2}) { |
175 |
&print_error($resource{passwordmismatcherror}); |
&print_error(&Resource('Error:PasswordMismatch')); |
176 |
} |
} |
177 |
my ($validpassword_crypt) = &get_info($AdminSpecialPage, $info_AdminPassword); |
my ($validpassword_crypt) = $database->meta (AdminPassword => $PageName{AdminSpecialPage}); |
178 |
if ($validpassword_crypt) { |
if ($validpassword_crypt) { |
179 |
if (not &valid_password($form{myoldpassword})) { |
if (not &valid_password($form{myoldpassword})) { |
180 |
&send_mail_to_admin(<<"EOD", "AdminChangePassword"); |
&print_error(&Resource('Error:PasswordIsIncorrect')); |
|
myoldpassword=$form{myoldpassword} |
|
|
mynewpassword=$form{mynewpassword} |
|
|
mynewpassword2=$form{mynewpassword2} |
|
|
EOD |
|
|
&print_error($resource{passworderror}); |
|
181 |
} |
} |
182 |
} |
} |
183 |
my ($sec, $min, $hour, $day, $mon, $year, $weekday) = localtime(time); |
my ($sec, $min, $hour, $day, $mon, $year, $weekday) = localtime(time); |
185 |
my $salt1 = $token[(time | $$) % scalar(@token)]; |
my $salt1 = $token[(time | $$) % scalar(@token)]; |
186 |
my $salt2 = $token[($sec + $min*60 + $hour*60*60) % scalar(@token)]; |
my $salt2 = $token[($sec + $min*60 + $hour*60*60) % scalar(@token)]; |
187 |
my $crypted = crypt($form{mynewpassword}, "$salt1$salt2"); |
my $crypted = crypt($form{mynewpassword}, "$salt1$salt2"); |
188 |
&set_info($AdminSpecialPage, $info_AdminPassword, $crypted); |
$database->meta (AdminPassword => $PageName{AdminSpecialPage} => $crypted); |
189 |
|
|
190 |
&print_header($CompletedSuccessfully); |
&print_header('CompletedSuccessfully', -noindex => 1); |
191 |
&print_message($resource{passwordchanged}); |
&print_message(&Resource('Error:PasswordIsChanged')); |
192 |
&print_footer($CompletedSuccessfully); |
&print_footer('CompletedSuccessfully'); |
193 |
} |
} |
194 |
|
|
195 |
sub do_index { |
sub valid_password ($) { |
196 |
&print_header($IndexPage); |
my ($validpassword_crypt) = $database->meta (AdminPassword => $PageName{AdminSpecialPage}); |
197 |
print qq(<ul>); |
return crypt (shift, $validpassword_crypt) eq $validpassword_crypt ? 1 : 0; |
|
foreach my $page (sort keys %database) { |
|
|
if (&is_editable($page)) { |
|
|
print qq(<li><a href="$url_cgi?@{[&encode($page)]}">$page</a>@{[&escape(&get_subjectline($page))]}</li>); |
|
|
# print qq(<li>@{[&get_info($page, $info_IsFrozen)]}</li>); |
|
|
# print qq(<li>@{[0 + &is_frozen($page)]}</li>); |
|
|
} |
|
|
} |
|
|
print qq(</ul>); |
|
|
&print_footer($IndexPage); |
|
198 |
} |
} |
199 |
|
|
200 |
sub do_write { |
sub do_write { |
203 |
} |
} |
204 |
|
|
205 |
if (not &is_editable($form{mypage})) { |
if (not &is_editable($form{mypage})) { |
206 |
&print_header($form{mypage}); |
&print_header($form{mypage}, -noindex => 1); |
207 |
&print_message($resource{cantchange}); |
&print_message(&Resource('Error:ThisPageIsUneditable')); |
208 |
&print_footer($form{mypage}); |
&print_footer($form{mypage}); |
209 |
return; |
return; |
210 |
} |
} |
213 |
return; |
return; |
214 |
} |
} |
215 |
|
|
|
# Making diff |
|
|
{ |
|
|
&open_diff; |
|
|
my @msg1 = split(/\n/, $database{$form{mypage}}); |
|
|
my @msg2 = split(/\n/, $form{mymsg}); |
|
|
$diffbase{$form{mypage}} = &difftext(\@msg1, \@msg2); |
|
|
&close_diff; |
|
|
} |
|
|
|
|
216 |
if ($form{mymsg}) { |
if ($form{mymsg}) { |
217 |
$database{$form{mypage}} = $form{mymsg}; |
if ($form{mytouch} || !ref $database) { |
218 |
&send_mail_to_admin($form{mypage}, "Modify"); |
$database{$form{mypage}} = $form{mymsg}; |
219 |
if ($form{mytouch}) { |
} else { |
220 |
&set_info($form{mypage}, $info_LastModified, '' . localtime); |
$database->STORE ($form{mypage} => $form{mymsg}, -touch => 0); |
|
&update_recent_changes; |
|
221 |
} |
} |
222 |
&set_info($form{mypage}, $info_IsFrozen, 0 + $form{myfrozen}); |
$database->meta (IsFrozen => $form{mypage} => 0 + $form{myfrozen}); |
223 |
&print_header($CompletedSuccessfully); |
my $fragment = ''; |
224 |
&print_message($resource{saved}); |
$fragment .= qq(;after_edit_cmd=@{[&encode($form{after_edit_cmd})]}) if $form{after_edit_cmd}; |
225 |
&print_content("$resource{continuereading} @{[&armor_name($form{mypage})]}"); |
if ($form{__comment_anchor_index}) { |
226 |
&print_footer($CompletedSuccessfully); |
$fragment .= qq(#anchor-$form{__comment_anchor_index}); |
227 |
|
} elsif ($form{__wikiform_anchor_index}) { |
228 |
|
$fragment .= qq(#wikiform-$form{__wikiform_anchor_index}); |
229 |
|
} |
230 |
|
&print_header('CompletedSuccessfully', -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)); |
231 |
|
&print_message(&Resource('Error:SavedSuccessfully')); |
232 |
|
&print_content(&Resource('Error:ContinueReading')." @{[&armor_name($form{mypage})]}"); |
233 |
|
&print_footer('CompletedSuccessfully'); |
234 |
} else { |
} else { |
|
&send_mail_to_admin($form{mypage}, "Delete"); |
|
235 |
delete $database{$form{mypage}}; |
delete $database{$form{mypage}}; |
236 |
delete $infobase{$form{mypage}}; |
&print_header($form{mypage}, -noindex => 1); |
237 |
if ($form{mytouch}) { |
&print_message(&Resource('Error:PageIsDeletedSuccessfully')); |
|
&update_recent_changes; |
|
|
} |
|
|
&print_header($form{mypage}); |
|
|
&print_message($resource{deleted}); |
|
238 |
&print_footer($form{mypage}); |
&print_footer($form{mypage}); |
239 |
} |
} |
240 |
} |
} |
241 |
|
|
242 |
sub do_searchform { |
sub get_search_result ($;%) { |
243 |
&print_header($SearchPage); |
my $word = lc shift; |
244 |
&print_searchform(""); |
my %option = @_; |
245 |
&print_footer($SearchPage); |
my @r; |
246 |
} |
foreach my $page (keys %database) { |
247 |
|
next if !$option{-match_myself} && ($page eq $word); |
248 |
sub do_search { |
my $content = lc $database{$page}; |
249 |
my $word = &escape($form{mymsg}); |
if (index (lc $page, $word) > -1) { |
250 |
&print_header($SearchPage); |
my $c = $content =~ s/\Q$word\E//g; |
251 |
&print_searchform($word); |
push @r, [$page, $c+20]; |
252 |
my $counter = 0; |
} elsif (index ($word, lc $page) > -1) { |
253 |
foreach my $page (sort keys %database) { |
my $c = $content =~ s/\Q$word\E//g; |
254 |
next if $page =~ /^$RecentChanges$/; |
push @r, [$page, $c+10]; |
255 |
if ($database{$page} =~ /\Q$form{mymsg}\E/ or $page =~ /\Q$form{mymsg}\E/) { |
} elsif (my $c = $content =~ s/\Q$word\E//g) { |
256 |
if ($counter == 0) { |
push @r, [$page, $c]; |
257 |
print qq|<ul>|; |
} |
258 |
} |
} |
259 |
print qq(<li><a href ="$url_cgi?@{[&encode($page)]}">$page</a>@{[&escape(&get_subjectline($page))]}</li>); |
#my $em = sub { my $s = shift; $s =~ s#(\Q$word\E)#<em>$1</em>#gi; $s }; |
260 |
$counter++; |
my $r = join "\n", map {qq(<li>[$_->[1]] <a href ="$url_cgi?@{[&encode($_->[0])]}" class="wiki">@{[&escape($_->[0])]}</a> <span class="wikipage-summary">@{[&escape(&get_subjectline($_->[0]))]}</span></li>)} sort {$b->[1] <=> $a->[1] || $a->[0] cmp $b->[0]} @r; |
261 |
} |
$r = qq|<ul class="search-result">$r</ul>| if $r; |
262 |
} |
wantarray? ($r, scalar @r): $r; |
263 |
if ($counter == 0) { |
} |
264 |
&print_message($resource{notfound}); |
|
265 |
} else { |
sub do_random_jump { |
266 |
print qq|</ul>|; |
my @list = keys %database; |
267 |
} |
my $name = &encode ($list[rand @list]); |
268 |
&print_footer($SearchPage); |
my $scheme = 'http'; |
269 |
} |
$scheme = lc $1 if $main::ENV{SERVER_PROTOCOL} =~ m#([A-Za-z0-9+.%-]+)#; |
270 |
|
print "Location: $scheme://$main::ENV{SERVER_NAME}:$main::ENV{SERVER_PORT}$url_cgi?$name\n"; |
271 |
sub do_create { |
print "\n"; |
|
&print_header($CreatePage); |
|
|
print <<"EOD"; |
|
|
<form action="$url_cgi" method="post"> |
|
|
<input type="hidden" name="mycmd" value="edit"> |
|
|
<strong>$resource{newpagename}</strong><br> |
|
|
<input type="text" name="mypage" value="" size="20"> |
|
|
<input type="submit" value="$resource{createbutton}"><br> |
|
|
</form> |
|
|
EOD |
|
|
&print_footer($CreatePage); |
|
|
} |
|
|
|
|
|
sub do_FrontPage { |
|
|
open(FILE, $file_FrontPage) or &print_error("($file_FrontPage)"); |
|
|
my $content = join('', <FILE>); |
|
|
&code_convert(\$content, $kanjicode); |
|
|
close(FILE); |
|
|
&print_header($FrontPage); |
|
|
&print_content($content); |
|
|
&print_footer($FrontPage); |
|
272 |
} |
} |
273 |
|
|
274 |
sub print_error { |
sub print_error { |
275 |
my ($msg) = @_; |
my ($msg) = @_; |
276 |
&print_header($ErrorPage); |
&print_header($PageName{ErrorPage}, -noindex => 1); |
277 |
print qq(<p><strong class="error">$msg</strong></p>); |
print qq(<p><strong class="error">$msg</strong></p>); |
278 |
&print_footer($ErrorPage); |
&print_footer($PageName{ErrorPage}); |
279 |
exit(0); |
exit(0); |
280 |
} |
} |
281 |
|
|
282 |
sub print_header { |
sub print_header ($;%) { |
283 |
my ($page) = @_; |
my ($page, %option) = @_; |
284 |
my $bodyclass = "normal"; |
my @head; |
285 |
my $editable = 0; |
$option{body_class} = &is_frozen($page) ? 'frozen' : 'normal'; |
286 |
my $admineditable = 0; |
$option{body_class} .= " wiki-page-obsoleted" if $option{-content_format} =~ /obsoleted="yes"/; |
287 |
if (&is_frozen($page) and $form{mycmd} =~ /^(read|write)$/) { |
if ($option{-goto}) { |
288 |
$editable = 0; |
if ($UA =~ m#Opera|MSIE 2\.#) { |
289 |
$admineditable = 1; |
## WARNING: This code may output unsafe HTML document if |
290 |
$bodyclass = "frozen"; |
## $option{-goto} is not clean. |
291 |
} elsif (&is_editable($page) and $form{mycmd} =~ /^(read|write)$/) { |
$option{-goto} =~ tr/;/&/ if $UA =~ m#Opera#; |
292 |
$admineditable = 1; |
print qq{Refresh: 0; url=$option{-goto}\n}; |
293 |
$editable = 1; |
push @head, qq(<meta http-equiv="refresh" content="0; url=$option{-goto}">); |
294 |
} else { |
} else { |
295 |
$editable = 0; |
$option{-goto} =~ tr/;/&/ if $UA =~ m#Mozilla/[1-4]\.#; |
296 |
|
print qq{Refresh: 0; url="$option{-goto}"\n}; |
297 |
|
push @head, qq(<meta http-equiv="refresh" content="0; url="@{[&escape($option{-goto})]}"">); |
298 |
|
} |
299 |
} |
} |
300 |
my $cookedpage = &encode($page); |
print qq{Last-Modified: @{[scalar gmtime $option{-last_modified}]}\n} if $option{-last_modified}; |
301 |
|
if ($option{-expires}) { |
302 |
|
print qq{Expires: @{[scalar gmtime $option{-expires}]}\n}; |
303 |
|
} |
304 |
|
if ($UA =~ m#Mozilla/2#) { |
305 |
|
my $ct = qq{text/html; charset=@{[&get_charset_name($kanjicode,compatible=>1)]}}; |
306 |
|
print qq{Content-Type: $ct\n}; |
307 |
|
push @head, qq{<meta http-equiv="content-type" content="$ct">}; |
308 |
|
} elsif ($UA =~ m#Infomosaic#) { |
309 |
|
print qq{Content-Type: text/html\n}; |
310 |
|
} else { |
311 |
|
print qq{Content-Type: text/html; charset=@{[&get_charset_name($kanjicode)]}\n}; |
312 |
|
} |
313 |
|
push @head, qq(<title>@{[&escape($page)]}</title>); |
314 |
|
if ($UA !~ m#Mozilla/[1-4]\.# || $UA =~ m#MSIE (?:[4-9]\.|\d\d)#) { |
315 |
|
push @head, qq(<link rel="stylesheet" type="text/css"). |
316 |
|
qq( href="@{[&escape($uri{wiki}.'?mycmd=TEXT_CSS;mypage='.&encode($PageName{DefaultStyleForHTML}).';x-lm='.$database->mtime ($PageName{DefaultStyleForHTML}))]}"); |
317 |
|
} |
318 |
|
push @head, q(<meta name="ROBOTS" content="NOINDEX">) if $option{-noindex}; |
319 |
|
my ($Links, $links) = &make_navigate_links ($page); |
320 |
|
#print $Links; ## Link: fields |
321 |
|
$links = join "\n", (@head, $links); |
322 |
print <<"EOD"; |
print <<"EOD"; |
|
Content-type: text/html; charset=$charset |
|
323 |
Content-Language: $lang |
Content-Language: $lang |
324 |
Content-Style-Type: text/css |
Content-Style-Type: text/css |
325 |
|
|
326 |
<!DOCTYPE html |
<!-- <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" |
327 |
PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" |
"http://www.w3.org/TR/html4/loose.dtd"> + RUBY --> |
328 |
"http://www.w3.org/TR/html4/loose.dtd"> |
<html lang="$lang" class="$option{body_class}"> |
329 |
<html lang="$lang"> |
<head profile="http://suika.fam.cx/~wakaba/-temp/wiki/wiki?WikiHTMLMetaProfile"> |
330 |
<head> |
$links |
|
<title>$page @{[&escape(&get_subjectline($page))]}</title> |
|
|
<link rel="index" href="$url_cgi?$IndexPage"> |
|
|
<link rev="made" href="mailto:$modifier_mail"> |
|
|
<link rel="stylesheet" type="text/css" href="$url_stylesheet"> |
|
331 |
</head> |
</head> |
332 |
<body class="$bodyclass"> |
<body class="$option{body_class}"> |
333 |
|
EOD |
334 |
|
&print_navigate_links ($page); |
335 |
|
print <<EOD; |
336 |
|
<h1 class="header">@{[&escape($page)]}</h1> |
337 |
|
EOD |
338 |
|
} |
339 |
|
|
340 |
|
sub get_charset_name ($;%) { |
341 |
|
my ($charset, %option) = (lc shift, @_); |
342 |
|
if ($charset =~ 'euc') { |
343 |
|
$charset = $option{compatible} ? 'x-euc-jp' : 'euc-jp'; |
344 |
|
} elsif ($charset =~ 'sjis' || $charset =~ 'shift') { |
345 |
|
$charset = $option{compatible} ? 'x-sjis' : 'shift_jis'; |
346 |
|
} elsif ($charset =~ 'jis') { |
347 |
|
$charset = 'iso-2022-jp'; |
348 |
|
} |
349 |
|
$charset; |
350 |
|
} |
351 |
|
|
352 |
|
sub print_navigate_links (@) { |
353 |
|
my ($page) = @_; |
354 |
|
my $editable = (&is_editable($page) && !&is_frozen($page)) ? 1 : 0; |
355 |
|
my $cookedpage = &encode($page); |
356 |
|
print <<EOH; |
357 |
<div class="tools"> |
<div class="tools"> |
|
@{[ $admineditable |
|
|
? qq(<a title="$resource{admineditthispage}" href="$url_cgi?mycmd=adminedit;mypage=$cookedpage">$resource{admineditbutton}</a> | ) |
|
|
: qq() |
|
|
]} |
|
358 |
@{[ $editable |
@{[ $editable |
359 |
? qq(<a title="$resource{editthispage}" href="$url_cgi?mycmd=edit;mypage=$cookedpage">$resource{editbutton}</a> | ) |
? qq(<a title="@{[&Resource('EditThisPageLong',escape=>1)]}" href="$url_cgi?mycmd=edit;mypage=$cookedpage" accesskey="E" class="wiki-cmd">@{[&Resource('EditThisPage',escape=>1)]}</a> | ) |
|
: qq() |
|
|
]} |
|
|
@{[ $admineditable |
|
|
? qq(<a href="$url_cgi?mycmd=diff;mypage=$cookedpage">$resource{diffbutton}</a> | ) |
|
360 |
: qq() |
: qq() |
361 |
]} |
]} |
362 |
<a href="$url_cgi?$CreatePage">$resource{createbutton}</a> | |
<a href="$url_cgi?mycmd=read;mypage=$cookedpage;x-param=@{[time.[0..9]->[rand 10]]}" class="wiki-cmd" title="@{[&Resource('ViewThisPageLong',escape=>1)]}">@{[&Resource('ViewThisPage',escape=>1)]}</a> | |
363 |
<a href="$url_cgi?$IndexPage">$resource{indexbutton}</a> | |
<a href="$url_cgi?mycmd=map;mypage=$cookedpage" class="wiki-cmd" title="@{[&Resource('ShowMapOfThisPageLong',escape=>1)]}">@{[&Resource('ShowMapOfThisPage',escape=>1)]}</a> | |
364 |
<a href="$url_cgi?$RssPage">$resource{rssbutton}</a> | |
<a href="$url_cgi?$PageName{CreatePage}" class="wiki" title="@{[&Resource('GoToCreatePageLong',escape=>1)]}">@{[&Resource('GoToCreatePage',escape=>1)]}</a> | |
365 |
<a href="$url_cgi?$FrontPage">$FrontPage</a> | |
<a href="$url_cgi?$PageName{IndexPage}" class="wiki" title="@{[&Resource('GoToIndexPageLong',escape=>1)]}">@{[&Resource('GoToIndexPage',escape=>1)]}</a> | |
366 |
<a href="$url_cgi?$SearchPage">$resource{searchbutton}</a> | |
<a href="$url_cgi?$PageName{FrontPage}" class="wiki" title="@{[&Resource('GoToHomePageLong',escape=>1)]}">@{[&Resource('GoToHomePage',escape=>1)]}</a> | |
367 |
<a href="$url_cgi?$RecentChanges">$resource{recentchangesbutton}</a> |
<a href="$url_cgi?$PageName{SearchPage}" class="wiki" title="@{[&Resource('GoToSearchPageLong',escape=>1)]}">@{[&Resource('GoToSearchPage',escape=>1)]}</a> | |
368 |
|
<a href="$url_cgi?mycmd=RandomJump;x-param=@{[time.[0..9]->[rand 10]]}" class="wiki randomlink" title="@{[&Resource('GoSomewhereLong',escape=>1)]}">@{[&Resource('GoSomewhere',escape=>1)]}</a> | |
369 |
|
<a href="$url_cgi?$PageName{RecentChanges}" class="wiki" title="@{[&Resource('GoToRecentChangesLong',escape=>1)]}">@{[&Resource('GoToRecentChanges',escape=>1)]}</a> |
370 |
</div> |
</div> |
371 |
<h1 class="header"><a |
EOH |
372 |
title="$resource{searchthispage}" |
} |
373 |
href="$url_cgi?mycmd=search;mymsg=$cookedpage">$page</a>@{[&escape(&get_subjectline($page))]}</h1> |
|
374 |
EOD |
sub make_navigate_links ($) { |
375 |
|
my $page = shift; |
376 |
|
my @link; |
377 |
|
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); |
378 |
|
push @link, {rel=>'edit', href=>"$url_cgi?mycmd=adminedit;mypage=@{[&encode($page)]}", class=>"wiki-command", title=>&Resource('AdminEditThisPageLink')} if &is_editable ($page) || &is_frozen ($page); |
379 |
|
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')}; |
380 |
|
push @link, {rel=>'myself', href=>"$url_cgi?@{[&encode($page)]}", class=>'wiki', title=>&Resource('GoToMyselfLink')}; |
381 |
|
push @link, {rel=>'index', href=>"$url_cgi?$PageName{IndexPage}", class=>'wiki', title=>&Resource('GoToIndexPageLink')}; |
382 |
|
push @link, {rel=>'home', href=>"$url_cgi?$PageName{FrontPage}", class=>'wiki', title=>&Resource('GoToHomePageLink')}; |
383 |
|
push @link, {rel=>'News', href=>"$url_cgi?WikiNews", class=>'wiki', title=>&Resource('GoToWikiNewsLink')}; |
384 |
|
push @link, {rel=>'News', href=>"$url_cgi?$PageName{RecentChanges}", class=>"wiki", title=>&Resource('GoToRecentChangesLink')}; |
385 |
|
push @link, {rel=>'News', href=>"$url_cgi?$PageName{RssPage}", class=>"wiki", title=>&Resource('GoToRssPageLink'), type=>'application/xml'}; |
386 |
|
push @link, {rel=>'search', href=>"$url_cgi?$PageName{SearchPage}", class=>'wiki', title=>&Resource('GoToSearchPageLink')}; |
387 |
|
push @link, {rel=>'help', href=>"$url_cgi?WikiHelp", class=>'wiki', title=>&Resource('GoToWikiHelpLink')}; |
388 |
|
push @link, {rel=>'copyright', href=>"$url_cgi?WikiPageLicense", class=>'wiki', title=>&Resource('GoToWikiPageLicenseLink')}; |
389 |
|
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')}; |
390 |
|
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')}; |
391 |
|
push @link, {rel=>'lucky', href=>"$url_cgi?mycmd=RandomJump;x-param=@{[time.[0..9]->[rand 10]]}", class=>'wiki randomlink', title=>&Resource('GoSomewhereLink')}; |
392 |
|
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}; |
393 |
|
push @link, {rel=>'history', href=>"$url_cgi?mycmd=diff;mypage=@{[&encode($page)]}", title=>&Resource('ViewDiffOfThisPageLink'), class=>'wiki-command'} if $wiki::diff::UseDiff; |
394 |
|
push @link, {rel=>'contents', href=>"$url_cgi?mycmd=map;mypage=@{[&encode($page)]}", title=>&Resource('ShowMapOfThisPageLink'), class=>'wiki-command'}; |
395 |
|
my ($Links, $links) = ('', ''); |
396 |
|
for my $e (@link) { |
397 |
|
$links .= qq(<link); |
398 |
|
$Links .= qq(Link: <$e->{href}>); |
399 |
|
for my $attr (qw/rel rev href title class type hreflang charset/) { |
400 |
|
$links .= qq( $attr="@{[&escape($e->{$attr})]}") if $e->{$attr}; |
401 |
|
} |
402 |
|
for my $attr (qw/rel rev title/) { |
403 |
|
$Links .= qq(; $attr="@{[do{$e->{$attr} =~ s/([\\\"])/\\$1/g; $e->{$attr}}]}") if $e->{$attr}; |
404 |
|
} |
405 |
|
$links .= qq(>\n); |
406 |
|
$Links .= qq(\n); |
407 |
|
} |
408 |
|
wantarray ? ($Links, $links) : $Links; |
409 |
} |
} |
410 |
|
|
411 |
sub print_footer { |
sub print_footer { |
412 |
my ($page) = @_; |
my ($page, $lm) = @_; |
413 |
$walrus_log = ($walrus_debugging) ? &text_to_html("----\n$walrus_log") : ''; # Walrus add (debug) |
my $epage = &encode ($page); |
414 |
# Walrus mod (1) start |
my $cvslog1 = q$Revision$; |
415 |
my $cvslog = '$Revision$ $Date$'; |
my $cvslog2 = q$Date$; |
416 |
print <<"EOD"; |
print_navigate_links ($page); |
417 |
|
print <<"EOD"; |
418 |
|
@{[ $lm ? qq(<div id="wikipage-last-modified">@{[&Resource('LastModified=',escape=>1)]}@{[&_rfc3339_date ($lm)]}</div>) : '' ]} |
419 |
<div class="footer"> |
<div class="footer"> |
420 |
<p> |
<a href="http://www.hyuki.com/yukiwiki/" title="YukiWiki 2.0.beta1.2002-05-29 © 2000-2002 by Hiroshi Yuki">@{[&Resource('About:Name:YukiWiki',escape=>1)]}</a> <a href="http://digit.que.ne.jp/work/" title="WalWiki 2.0.beta1.wal.1 © 2000-2002 by Makio Tsukamoto">@{[&Resource('About:Name:WalWiki',escape=>1)]}</a> |
421 |
<a href="http://digit.que.ne.jp/work/">WalWiki</a> $walversion © 2000-2002 by <a href="http://digit.que.ne.jp/">Makio Tsukamoto</a>.<br /> |
<a href="/gate/cvs/wakaba/wiki/" title="@{[&Resource('About:SuikaWiki:JumpToCVS',escape=>1)]} ($cvslog2)">@{[&Resource('About:Name:SuikaWiki',escape=>1)]} $cvslog1</a> |
|
based on <a href="http://www.hyuki.com/yukiwiki/">YukiWiki</a> $version © 2000-2002 by <a href="http://www.hyuki.com/">Hiroshi Yuki</a>.<br /> |
|
|
<a href="/gate/cvs/wakaba/wiki/" title="CVS Repository"> |
|
|
$cvslog |
|
|
</a> |
|
|
</p> |
|
|
<div class="navigation"> |
|
|
[<a href="/" title="このサーバーの首頁">/</a> |
|
|
<a href="/map" title="このサーバーの案内">地図</a> |
|
|
<a href="/search/" title="このサーバーの検索">検索</a>] |
|
422 |
</div> |
</div> |
|
</div> |
|
|
$walrus_log |
|
423 |
</body> |
</body> |
424 |
</html> |
</html> |
425 |
EOD |
EOD |
|
# print <<"EOD"; |
|
|
# <hr> |
|
|
# <address class="footer"> |
|
|
# <a href="http://www.hyuki.com/yukiwiki/">YukiWiki</a> $version |
|
|
# © 2000-2002 by <a href="http://www.hyuki.com/">Hiroshi Yuki</a>.<br /> |
|
|
# Modified by <a href="$modifier_url">$modifier_name</a>. |
|
|
# </address> |
|
|
# <p class="footer"> |
|
|
# <a href="http://www.hyuki.com/yukiwiki/">$icontag</a> |
|
|
# </p> |
|
|
# </body> |
|
|
# </html> |
|
|
# EOD |
|
|
# Walrus mod (1) end |
|
426 |
} |
} |
427 |
|
|
428 |
sub escape { |
sub escape { |
429 |
my $s = shift; |
my $s = shift; |
430 |
$s =~ s|\r\n|\n|g; |
$s =~ s|\r\n|\n|g; |
431 |
$s =~ s|\&|&|g; |
$s =~ s|&|&|g; |
432 |
$s =~ s|<|<|g; |
$s =~ s|<|<|g; |
433 |
$s =~ s|>|>|g; |
$s =~ s|>|>|g; |
434 |
$s =~ s|"|"|g; |
$s =~ s|"|"|g; |
438 |
sub unescape { |
sub unescape { |
439 |
my $s = shift; |
my $s = shift; |
440 |
# $s =~ s|\n|\r\n|g; |
# $s =~ s|\n|\r\n|g; |
441 |
$s =~ s|\&|\&|g; |
$s =~ s|<|<|g; |
442 |
$s =~ s|\<|\<|g; |
$s =~ s|>|>|g; |
443 |
$s =~ s|\>|\>|g; |
$s =~ s|"|"|g; |
444 |
$s =~ s|\"|\"|g; |
$s =~ s|&|&|g; |
445 |
return $s; |
return $s; |
446 |
} |
} |
447 |
|
|
448 |
sub print_content { |
sub print_content ($;$) { |
449 |
my ($rawcontent) = @_; |
my ($rawcontent, %option) = @_; |
450 |
print &text_to_html($rawcontent, toc=>1); |
print &text_to_html($rawcontent, toc=>1, %option); |
451 |
} |
} |
452 |
|
|
453 |
sub text_to_html { |
sub text_to_html { |
454 |
my ($txt, %option) = @_; |
my ($txt, %option) = @_; |
455 |
my (@txt) = split(/\n/, $txt); |
my @toc; |
456 |
my (@toc); |
my @toc2 = @{$option{-toc}||[]}; |
457 |
my $tocnum = 0; |
my $tocnum = 0; |
458 |
|
|
459 |
|
## Load constants |
460 |
|
my %const; |
461 |
|
if ($option{content_format} =~ /import="([^"]+)"/) { |
462 |
|
for (split /\s*,\s*/, $1) { |
463 |
|
my $wp = $database{$_}; |
464 |
|
if ($wp =~ m!^\#\?SuikaWikiConst/1.0!) { |
465 |
|
wiki::suikawikiconst::to_hash ($wp => \%const); |
466 |
|
} |
467 |
|
} |
468 |
|
} |
469 |
|
|
470 |
|
$txt =~ s{__&&([^&]+)&&__}{defined $const{$1}?$const{$1}:qq(__&&$1&&__)}ge; |
471 |
|
my (@txt) = split(/\n/, $txt); |
472 |
my (@saved, @result); |
my (@saved, @result); |
473 |
unshift(@saved, "</p>"); |
unshift(@saved, "</p>"); |
474 |
push(@result, "<p>"); |
push(@result, "<p>"); |
475 |
foreach (@txt) { |
foreach (@txt) { |
476 |
chomp; |
chomp; |
477 |
# Walrus mod (6) start |
if (/^\*\*\*\*\*([^\x0D\x0A]*)/) { |
478 |
#if ($saved[0] eq '</html>') { |
push(@toc, qq(----- <a href="#i$tocnum">@{[&escape($1)||$tocnum]}</a>\n)); |
479 |
# if (/<\/html>/i) { splice(@saved); } |
push(@result, splice(@saved), qq(<h6 @{[&id_and_name("i$tocnum")]}>) . &inline($1, const => \%const) . '</h6>'); |
|
# else { push (@result, &html_to_ignored_html($_)); } |
|
|
#} elsif (/^<html>/i and &is_ignore_html($form{mypage})) { |
|
|
# push(@result, splice(@saved)); |
|
|
# push(@saved, '</html>'); |
|
|
#} els |
|
|
if (/^\*\*\*\*\*(.*)/) { |
|
|
push(@toc, qq(-- <a href="#i$tocnum">@{[&escape($1)]}</a>\n)); |
|
|
push(@result, splice(@saved), qq(<h6 id="i$tocnum">) . &inline($1) . '</h6>'); |
|
480 |
$tocnum++; |
$tocnum++; |
481 |
} elsif (/^\*\*\*\*(.*)/) { |
} elsif (/^\*\*\*\*([^\x0D\x0A]*)/) { |
482 |
push(@toc, qq(-- <a href="#i$tocnum">@{[&escape($1)]}</a>\n)); |
push(@toc, qq(---- <a href="#i$tocnum">@{[&escape($1)||$tocnum]}</a>\n)); |
483 |
push(@result, splice(@saved), qq(<h5 id="i$tocnum">) . &inline($1) . '</h5>'); |
push(@result, splice(@saved), qq(<h5 @{[&id_and_name("i$tocnum")]}>) . &inline($1, const => \%const) . '</h5>'); |
484 |
$tocnum++; |
$tocnum++; |
485 |
} elsif (/^\*\*\*(.*)/) { |
} elsif (/^\*\*\*([^\x0D\x0A]*)/) { |
486 |
push(@toc, qq(-- <a href="#i$tocnum">@{[&escape($1)]}</a>\n)); |
push(@toc, qq(--- <a href="#i$tocnum">@{[&escape($1)||$tocnum]}</a>\n)); |
487 |
push(@result, splice(@saved), qq(<h4 id="i$tocnum">) . &inline($1) . '</h4>'); |
push(@result, splice(@saved), qq(<h4 @{[&id_and_name("i$tocnum")]}>) . &inline($1, const => \%const) . '</h4>'); |
488 |
$tocnum++; |
$tocnum++; |
489 |
} elsif (/^\*\*(.*)/) { |
} elsif (/^\*\*([^\x0D\x0A]*)/) { |
490 |
# if (/^\*\*(.*)/) { |
# if (/^\*\*(.*)/) { |
491 |
# Walrus mod (6) end |
# Walrus mod (6) end |
492 |
push(@toc, qq(-- <a href="#i$tocnum">@{[&escape($1)]}</a>\n)); |
push(@toc, qq(-- <a href="#i$tocnum">@{[&escape($1)||$tocnum]}</a>\n)); |
493 |
push(@result, splice(@saved), qq(<h3><a name="i$tocnum"> </a>) . &inline($1) . '</h3>'); |
push(@result, splice(@saved), qq(<h3 @{[&id_and_name("i$tocnum")]}>) . &inline($1, const => \%const) . '</h3>'); |
494 |
$tocnum++; |
$tocnum++; |
495 |
} elsif (/^\*(.*)/) { |
} elsif (/^\*([^\x0D\x0A]*)/) { |
496 |
push(@toc, qq(- <a href="#i$tocnum">@{[&escape($1)]}</a>\n)); |
push(@toc, qq(- <a href="#i$tocnum">@{[&escape($1)||$tocnum]}</a>\n)); |
497 |
push(@result, splice(@saved), qq(<h2><a name="i$tocnum"> </a>) . &inline($1) . '</h2>'); |
push(@result, splice(@saved), qq(<h2 @{[&id_and_name("i$tocnum")]}>) . &inline($1, const => \%const) . '</h2>'); |
498 |
$tocnum++; |
$tocnum++; |
499 |
#} elsif (/^----/) { |
} elsif (/^(={1,6})(.*)/) { |
|
# push(@result, splice(@saved), '<hr>'); |
|
|
} elsif (/^(={1,5})(.*)/) { |
|
500 |
&back_push('ol', length($1), \@saved, \@result); |
&back_push('ol', length($1), \@saved, \@result); |
501 |
push(@result, '<li>' . &inline($2) . '</li>'); |
push(@result, '<li>' . &inline($2, const => \%const) . '</li>'); |
502 |
} elsif (/^(-{1,5})(.*)/) { |
} elsif (/^(-{1,6})(.*)/) { |
503 |
&back_push('ul', length($1), \@saved, \@result); |
&back_push('ul', length($1), \@saved, \@result); |
504 |
push(@result, '<li>' . &inline($2) . '</li>'); |
my ($pf, $l) = ('', $2); |
505 |
|
if (!$main::_EMBEDED && $l =~ s/^\s*\[([0-9]+)\]//) { |
506 |
|
my $num = 0+$1; |
507 |
|
$pf = qq(<a name="anchor-$num" id="anchor-$num" class="anchor">[$num]</a>); |
508 |
|
} |
509 |
|
push(@result, '<li>' . $pf . &inline ($l, const => \%const) . '</li>'); |
510 |
} elsif (/^:([^:]+):(.*)/) { |
} elsif (/^:([^:]+):(.*)/) { |
511 |
&back_push('dl', 1, \@saved, \@result); |
&back_push('dl', 1, \@saved, \@result); |
512 |
push(@result, '<dt>' . &inline($1) . '</dt>', '<dd>' . &inline($2) . '</dd>'); |
push(@result, '<dt>' . &inline($1, const => \%const) . '</dt>', '<dd>' . &inline($2, const => \%const) . '</dd>'); |
513 |
} elsif (/^(>{1,5})(.*)/) { |
} elsif (/^(?!>>\d)(>{1,5})(.*)/) { |
514 |
&back_push('blockquote', length($1), \@saved, \@result); |
&back_push('blockquote', length($1), \@saved, \@result); |
515 |
push(@result, &inline($2)); |
push @result, "<p>"; |
516 |
|
push(@result, &inline($2, const => \%const)); |
517 |
|
unshift @saved, "</p>"; |
518 |
} elsif (/^\s*$/) { |
} elsif (/^\s*$/) { |
519 |
push(@result, splice(@saved)); |
push(@result, splice(@saved)); |
|
unshift(@saved, "</p>"); |
|
520 |
push(@result, "<p>"); |
push(@result, "<p>"); |
521 |
|
unshift(@saved, "</p>"); |
522 |
} elsif (/^(\s+.*)$/) { |
} elsif (/^(\s+.*)$/) { |
523 |
&back_push('pre', 1, \@saved, \@result); |
&back_push('pre', 1, \@saved, \@result); |
524 |
#push(@result, &escape($1)); # Not &inline, but &escape |
push(@result, &inline($1, const => \%const)); |
525 |
push(@result, &inline($1)); # Not &inline, but &escape |
} elsif (/^\,(.*?)[\x0D\x0A]*$/) { |
526 |
# } elsif (/^\,(.*)$/) { # Walrus del (BF) |
&back_push('table', 1, \@saved, \@result); |
|
} elsif (/^\,(.*?)[\x0D\x0A]*$/) { # Walrus add (BF) |
|
|
&back_push('table', 1, \@saved, \@result, ' border="1"'); |
|
527 |
####### |
####### |
528 |
# This part is taken from Mr. Ohzaki's Perl Memo and Makio Tsukamoto's WalWiki. |
# This part is taken from Mr. Ohzaki's Perl Memo and Makio Tsukamoto's WalWiki. |
529 |
# XXXXX |
# XXXXX |
537 |
$colspan[$i]++; |
$colspan[$i]++; |
538 |
} |
} |
539 |
$colspan[$i] = ($colspan[$i] > 1) ? sprintf(' colspan="%d"', $colspan[$i]) : ''; |
$colspan[$i] = ($colspan[$i] > 1) ? sprintf(' colspan="%d"', $colspan[$i]) : ''; |
540 |
$value[$i] = sprintf('<td%s%s>%s</td>', $align[$i], $colspan[$i], &inline($value[$i])); |
$value[$i] = sprintf('<td%s%s>%s</td>', $align[$i], $colspan[$i], &inline($value[$i], const => \%const)); |
541 |
} else { |
} else { |
542 |
$value[$i] = ''; |
$value[$i] = ''; |
543 |
} |
} |
545 |
push(@result, join('', '<tr>', @value, '</tr>')); |
push(@result, join('', '<tr>', @value, '</tr>')); |
546 |
# XXXXX |
# XXXXX |
547 |
####### |
####### |
548 |
|
} elsif (/^\[(INS|DEL|PRE)\[\s*$/) { |
549 |
|
push @result, splice (@saved), '<'.lc($1).'>'; |
550 |
|
unshift @saved, "</p>"; |
551 |
|
push @result, "<p>"; |
552 |
|
} elsif (/^\](INS|DEL|PRE)\]\s*$/) { |
553 |
|
push @result, splice (@saved), '</'.lc($1).'>'; |
554 |
|
} elsif (/^\[([0-9]+)\](.*)$/ && !$main::_EMBEDED) { |
555 |
|
my $num = 0+$1; |
556 |
|
push @result, qq(<a name="anchor-$num" id="anchor-$num" class="anchor">[$num]</a>); |
557 |
|
push @result, &inline ($2, const => \%const); |
558 |
} else { |
} else { |
559 |
push(@result, &inline($_)); |
push(@result, &inline($_, const => \%const)); |
560 |
} |
} |
561 |
} |
} |
562 |
push(@result, splice(@saved)); |
push(@result, splice(@saved)); |
563 |
|
|
564 |
|
my $toc = ''; |
565 |
if ($option{toc}) { |
if ($option{toc}) { |
566 |
# Convert @toc (table of contents) to HTML. |
# Convert @toc (table of contents) to HTML. |
567 |
# This part is taken from Makio Tsukamoto's WalWiki. |
# This part is taken from Makio Tsukamoto's WalWiki. |
568 |
my (@tocsaved, @tocresult); |
my (@tocsaved, @tocresult); |
569 |
foreach (@toc) { |
foreach (@toc,@toc2) { |
570 |
if (/^(-{1,3})(.*)/) { |
if (/^(-{1,6})(.*)$/) { |
571 |
&back_push('ul', length($1), \@tocsaved, \@tocresult); |
&back_push('ul', length($1), \@tocsaved, \@tocresult); |
572 |
push(@tocresult, '<li>' . $2 . '</li>'); |
push(@tocresult, '<li>' . $2 . '</li>'); |
573 |
} |
} |
574 |
} |
} |
575 |
push(@tocresult, splice(@tocsaved)); |
push(@tocresult, splice(@tocsaved)); |
576 |
return join("\n", @tocresult, @result); |
$toc = join("\n", @tocresult); |
577 |
} else { |
$toc = $toc ? qq(<div id="wikipage-toc">$toc</div>) : ''; |
|
return join("\n", @result); |
|
578 |
} |
} |
579 |
|
$toc .= join("\n", @result); |
580 |
|
$toc =~ s#<p>\n</p>##g; |
581 |
|
$toc =~ s#[\x0D\x0A]+</#</#g; |
582 |
|
$toc =~ s#<pre>\n#<pre>#g; |
583 |
|
$toc; |
584 |
} |
} |
585 |
|
|
586 |
sub back_push { |
sub back_push { |
597 |
} |
} |
598 |
} |
} |
599 |
|
|
600 |
sub inline { |
sub inline ($;%) { |
601 |
my ($line) = @_; |
my ($line, %option) = @_; |
602 |
$line = &escape($line); |
$line = &escape($line); |
603 |
$line =~ s|'''([^']+?)'''|<strong>$1</strong>|g; |
$line =~ s{$embed_command{form}}{&make_custom_form ($1, $2, $3, $4)}ge; |
604 |
$line =~ s|''([^']+?)''|<em>$1</em>|g; |
$line =~ s{\[(INS|DEL|SUP|SUB|VAR|CODE|KBD|SAMP|DFN)(?:\(([A-Za-z0-9\x20-]+)\))?\[(.+?)\]\]}{<@{[lc $1]}@{[$2 ? qq( class="$2") : '']}>$3</@{[lc $1]}>}g; |
605 |
$line =~ s|(\d\d\d\d-\d\d-\d\d \(\w\w\w\) \d\d:\d\d:\d\d)|<span class="date">$1</span>|g; # Date |
$line =~ s:\[(WEAK)\[(.+?)\]\]:<span class="@{[lc $1]}">$2</span>:g; |
606 |
$line =~ s! |
$line =~ s:\[ABBR\[([^]]+)\] \[([^]]+)\]\]:<acronym title="$2">$1</acronym>:g; |
607 |
( |
$line =~ s:\[RUBYB\[([^]]+)\] \[([^]]+)\] \[([^]]+)\]\]:<span class="ruby"><ruby class="rb"><rb>$1</rb><rp>(</rp><rt>$2</rt><rp>)</rp></ruby><span class="rp"> (</span><span class="rt-below">$3</span><span class="rp">) </span></span>:g; |
608 |
(?:<(?:mailto|http|https|ftp|urn):[\x21-\x7E]*)> |
$line =~ s:\[RUBY\[([^]]+)\] \[([^]]+)\]\]:<ruby><rb>$1</rb><rp>(</rp><rt>$2</rt><rp>)</rp></ruby>:g; |
609 |
| |
$line =~ s:\[RUBYB\[([^]]+)\] \[([^]]+)\]\]:<span class="ruby"><span class="rb">$1</span><span class="rp"> (</span><span class="rt-below">$2</span><span class="rp">) </span></span>:g; |
610 |
($bracket_name) # [[likethis]], [[#comment]], [[Friend:remotelink]] |
$line =~ s|'''([^']+)'''|<strong>$1</strong>|g; |
611 |
| |
$line =~ s|''([^']+)''|<em>$1</em>|g; |
612 |
($interwiki_definition) # [[Friend http://somewhere/?q=sjis($1)]] |
$line =~ s{ |
613 |
#| |
(\[\[(\#\S+?)\]\]) |
614 |
# ($wiki_name) |
|\[\[([^[]+?)](?:>>([0-9]+))?] |
615 |
) |
|>>([0-9]+) |
616 |
! |
|<([A-Za-z0-9%]+:(?:(?!>).)+)> |
617 |
&make_link($1) |
}{ |
618 |
!gex; |
my ($l, $page,$anchor, $anum, $uri) = ($1, $3,$4, 0+$5, $6); |
619 |
|
if ($l) { |
620 |
|
&embedded_to_html($1); |
621 |
|
} elsif (defined $page) { |
622 |
|
&make_wikilink ($page, anchor => 0+$anchor); |
623 |
|
} elsif ($anum) { |
624 |
|
qq(<a href="#anchor-$anum" class="wiki-anchor">>>$anum</a>); |
625 |
|
} elsif ($uri) { |
626 |
|
&make_urilink ($uri); |
627 |
|
} |
628 |
|
}gex; |
629 |
return $line; |
return $line; |
630 |
} |
} |
631 |
|
|
632 |
sub make_link { |
sub make_wikilink ($%) { |
633 |
my $chunk = shift; |
my ($ename, %option) = @_; |
634 |
# Walrus add (3) start |
my $name = &unescape ($ename); |
635 |
my $name = $chunk; |
if ($database{$name}) { |
636 |
$name =~ s/^<(.*)>$/$1/; |
my $subject = &escape (&get_subjectline ($name, delimiter => '')); |
637 |
if ($chunk =~ /^\[\[([^ ]+?) ([^ ]+?)\]\]$/ and $form{mypage} ne $InterWikiName) { |
if ($option{anchor}) { |
638 |
($name, $chunk) = ($1, $2); |
return qq(<a title="$subject" href="$url_cgi?@{[&encode($name)]}#anchor-$option{anchor}" class="wiki">$ename>>$option{anchor}</a>); |
639 |
} elsif ($chunk =~ /^mailto:(.*)$/) { |
} else { |
640 |
$name = $1; |
return qq(<a title="$subject" href="$url_cgi?@{[&encode($name)]}" class="wiki">$ename</a>); |
641 |
} |
} |
642 |
if ($use_autoimg and $name =~ /^(http|https|ftp|):.+\.(png|gif|jpe?g)/) { |
} else { |
643 |
$name = qq(<img src="$name">) ; |
return qq(<a title="@{[&Resource('JumpAndEditWikiPage',escape=>1)]}" href="$url_cgi?@{[&escape($name)]}" class="wiki not-exist">$ename<span class="mark">@{[&Resource('JumpAndEditWikiPageMark',escape=>1)]}</span></a>); |
644 |
} |
} |
645 |
$name = &unarmor_name($name); |
} |
646 |
# Walrus add (3) end |
|
647 |
if ($chunk =~ /^(http|https|ftp):/) { |
sub make_urilink ($;%) { |
648 |
# Walrus mod (3) start |
require URI; |
649 |
# if ($use_autoimg and $chunk =~ /\.(gif|png|jpeg|jpg)$/) { |
my $uri = shift; |
650 |
# return qq(<a href="$chunk"><img src="$chunk"></a>); |
if ($uri =~ s/^IW://) { ## InterWiki (not URI) |
651 |
# } else { |
$uri = &unescape ($uri); |
652 |
# return qq(<a href="$chunk">$chunk</a>); |
if ($uri =~ /^([^\x00-\x2F\x3A-\x40\x5B-\x60\x7B-\x7F]+|"(?:\\.|[^"\\])+"):([^\x00-\x2F\x3A-\x40\x5B-\x60\x7B-\x7F]+|"(?:\\.|[^"\\])+")$/) { |
653 |
# } |
my ($site, $name) = ($1, $2); |
654 |
return qq(<a href="$chunk">$name</a>); |
for ($site, $name) { |
655 |
# Walrus mod (3) end |
if (s/^"//) { s/"$//; s/\\(.)/$1/g } |
656 |
} elsif ($chunk =~ m#^urn:[0-9A-Za-z_:;/.-]+#) { |
} |
657 |
return qq|<<a href="/uri-res/N2L?${name}">$name</a>>|; |
&init_InterWikiName () unless $interwiki{'[[]]'}; |
658 |
} elsif ($chunk =~ /^mailto:(.*)/) { |
if ($interwiki{$site}) { |
659 |
# return qq(<a href="$chunk">$2</a>); # Walrus del (3) |
&load_formatter ('interwiki'); |
660 |
return qq(<<a href="$chunk">$name</a>>); # Walrus add (3) |
my $uri = &escape ($fmt{interwiki}->replace ($interwiki{$site} => {site => $site, name => $name})); |
661 |
} elsif ($chunk =~ /^$interwiki_definition$/) { |
$site = &escape ($site); $name = &escape ($name); |
662 |
# return qq(<span class="InterWiki">$chunk</span>); # Walrus del (3) |
qq(<<a href="$uri" class="out-of-wiki interwiki" title="$name ($site); URI: <$uri>"><span class="interwiki-site">$site:</span><span class="interwiki-name">$name</span></a>>); |
663 |
return qq(<span class="InterWiki">$name</span>); # Walrus add (3) |
} else { |
664 |
} elsif ($chunk =~ /^$embedded_name$/) { |
qq(<@{[&Resource('Error:UnknownInterWikiName=',escape=>1)]}@{[&escape ($site)]}>); |
|
return &embedded_to_html($chunk); |
|
|
} else { |
|
|
$chunk = &unarmor_name($chunk); |
|
|
$chunk = &unescape($chunk); # To treat '&' or '>' or '<' correctly. |
|
|
my $cookedchunk = &encode($chunk); |
|
|
if ($chunk =~ /^$interwiki_name$/) { |
|
|
my ($intername, $localname) = ($1, $2); |
|
|
my $remoteurl = $interwiki{$intername}; |
|
|
if ($remoteurl) { |
|
|
# $remoteurl =~ s/\b(euc|sjis|ykwk|asis)\(\$1\)/&interwiki_convert($1, $localname)/e; # Walrus del (4) |
|
|
$remoteurl =~ s/\b(euc|sjis|ykwk|asis|isbn)\(\$1\)/&interwiki_convert($1, $localname)/e; # Walrus add (4) |
|
|
# return qq(<a href="$remoteurl">$chunk</a>); # Walrus del (3) |
|
|
return qq(<a href="$remoteurl">$name</a>); # Walrus add (3) |
|
|
} else { |
|
|
# return $chunk; # Walrus del (3) |
|
|
return $name; # Walrus add (3) |
|
|
} |
|
|
} elsif ($database{$chunk}) { |
|
|
my $subject = &escape(&get_subjectline($chunk, delimiter => '')); |
|
|
# return qq(<a title="$subject" href="$url_cgi?$cookedchunk">$chunk</a>); # Walrus del (3) |
|
|
return qq(<a title="$subject" href="$url_cgi?$cookedchunk">$name</a>); # Walrus add (3) |
|
|
} elsif ($page_command{$chunk}) { |
|
|
# return qq(<a title="$chunk" href="$url_cgi?$cookedchunk">$chunk</a>); # Walrus del (3) |
|
|
return qq(<a title="$chunk" href="$url_cgi?$cookedchunk" class="wiki">$name</a>); # Walrus add (3) |
|
|
} else { |
|
|
return qq(<a title="$resource{editthispage}" href="$url_cgi?mycmd=edit;mypage=$cookedchunk" class="wiki">$name<span class="mark">$editchar</span></a>); |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
# Walrus add (6) start |
|
|
sub is_ignore_html { |
|
|
my ($pagename) = @_; |
|
|
foreach (@ignore_html_page) { |
|
|
return 1 if ($pagename eq $_); |
|
|
} |
|
|
return 0; |
|
|
} |
|
|
# Walrus add (6) end |
|
|
|
|
|
# Walrus add (6) start |
|
|
sub html_to_ignored_html { |
|
|
my $str = shift(@_); |
|
|
my $text_regex = q{[^<]*}; |
|
|
my $tag_regex_ = q{[^"'<>]*(?:"[^"]*"[^"'<>]*|'[^']*'[^"'<>]*)*(?:>|(?=<)|$(?!\n))}; #'}}}} |
|
|
my $comment_tag_regex = '<!(?:--[^-]*-(?:[^-]+-)*?-(?:[^>-]*(?:-[^>-]+)*?)??)*(?:>|$(?!\n)|--.*$)'; |
|
|
my $tag_regex = qq{$comment_tag_regex|<$tag_regex_}; |
|
|
my $ignored = join('|', @ignore_html_tags); |
|
|
my $result = ''; |
|
|
while ($str =~ /($text_regex)($tag_regex)?/gso) { |
|
|
last if $1 eq '' and $2 eq ''; |
|
|
$result .= $1; |
|
|
my $tag_tmp = $2; |
|
|
$result .= ($tag_tmp =~ /^<\/?($ignored)(?![0-9A-Za-z])/i) ? $tag_tmp : &escape($tag_tmp); |
|
|
if ($tag_tmp =~ /^<(XMP|PLAINTEXT|SCRIPT)(?![0-9A-Za-z])/i) { |
|
|
$str =~ /(.*?)(?:<\/$1(?![0-9A-Za-z])$tag_regex_|$)/gsi; |
|
|
$result .= &escape($1); |
|
665 |
} |
} |
666 |
|
} else { |
667 |
|
qq(<@{[&Resource('Error:InvalidInterWiki=',escape=>1)]}@{[&escape($uri)]}>); |
668 |
} |
} |
669 |
return $result; |
} elsif ($uri =~ /^urn:/) { ## URN |
670 |
} |
my $uri2 = &escape (URI->new ('/uri-res/N2L?'.&unescape ($uri), 'http')->canonical); |
671 |
# Walrus add (6) end |
qq(<<a href="$uri2" title="URI: <$uri> (via <$uri2>)" class="out-of-wiki urn">$uri</a>>); |
672 |
|
} elsif ($uri =~ s/^MAIL://) { ## mail address (not URI) |
673 |
|
my $uri2 = &escape (URI->new ('mailto:'.&unescape ($uri))->canonical); |
674 |
|
qq(<<a href="$uri2" class="out-of-wiki mail">$uri</a>>); |
675 |
|
} elsif ($uri =~ s/^IMG(?:\([^)]+\))?://) { ## image (not URI itself) |
676 |
|
my $uri2 = &escape (URI->new (&unescape ($uri))->canonical); |
677 |
|
qq(<img src="$uri2" alt="" title="URI: <$uri2>" class="out-of-wiki">); |
678 |
|
} else { ## misc. URI |
679 |
|
CGI::Carp::warningsToBrowser (0); |
680 |
|
my $uri2 = &escape (URI->new (&unescape ($uri))->canonical); |
681 |
|
CGI::Carp::warningsToBrowser (1); |
682 |
|
qq(<<a href="$uri2" title="URI: <$uri2>" class="out-of-wiki">$uri</a>>); |
683 |
|
} |
684 |
|
} |
685 |
|
|
686 |
|
{my $FormIndex = 0; |
687 |
|
sub make_custom_form ($$$$) { |
688 |
|
my ($wfname, $definition, $template, $option) = @_; |
689 |
|
## $template and $option is currently not used in this procedure. |
690 |
|
unless ($main::_EMBEDED) { |
691 |
|
$FormIndex++; |
692 |
|
if (length $definition) { |
693 |
|
my $param = bless {}, 'SuikaWiki::Plugin'; |
694 |
|
my $lastmodified = $database->mtime ($form{mypage}); |
695 |
|
&load_formatter (qw/form_input form_option/); |
696 |
|
$definition = &unescape ($definition); |
697 |
|
$definition =~ s/\\(.)/$1/g; |
698 |
|
$option = &unescape ($option); |
699 |
|
$option =~ s/\\(.)/$1/g; |
700 |
|
$fmt{form_option}->replace ($option, $param); |
701 |
|
$param->{output}->{form} = 1 unless defined $param->{output}->{form}; |
702 |
|
$definition .= ' %submit;' if $definition !~ /%submit/ && !$param->{output}->{nosubmit} && $param->{output}->{form}; |
703 |
|
my $target_page = $param->{output}->{page} || $form{mypage}; |
704 |
|
$param->{form_disabled} = 1 if $FixedPage{$target_page}; |
705 |
|
my $target_form = $param->{output}->{id}; |
706 |
|
my $r = ''; |
707 |
|
$r = <<EOH if $param->{output}->{form}; |
708 |
|
<form method="post" action="$url_cgi" id="wikiform-$FormIndex" class="wikiform"> |
709 |
|
<input type="hidden" name="mycmd" value="@{[$param->{form_disabled}?'read':'wikiform']}"> |
710 |
|
<input type="hidden" name="mypage" value="@{[&escape($target_page)]}"> |
711 |
|
<input type="hidden" name="myLastModified" value="$lastmodified"> |
712 |
|
<input type="hidden" name="mytouch" value="on"> |
713 |
|
<input type="hidden" name="@{[$target_form? qq(wikiform_targetform" value="@{[&escape($target_form)]}) : qq(wikiform_index" value="$FormIndex)]}"> |
714 |
|
EOH |
715 |
|
$r .= qq(<a name="wikiform-$FormIndex"></a>) if $UA =~ m#Mozilla/[12]\.#; |
716 |
|
$r .= $fmt{form_input}->replace ($definition, $param); |
717 |
|
$r .= "</form>\n" if $param->{output}->{form}; |
718 |
|
$r; |
719 |
|
} else { ## No input-interface WikiForm |
720 |
|
qq(<a id="wikiform-$FormIndex" name="wikiform-$FormIndex"><!-- #form --></a>); |
721 |
|
} |
722 |
|
} else { |
723 |
|
qq(<ins class="wiki-error">@{[&Resource('Error:WikiForm:EmbedIsNotSupported',escape=>1)]}</ins>); |
724 |
|
} |
725 |
|
}} |
726 |
|
|
727 |
sub print_message { |
sub print_message { |
728 |
my ($msg) = @_; |
my ($msg) = @_; |
729 |
print qq(<p><strong>$msg</strong></p>); |
print qq(<p><strong>@{[&escape($msg)]}</strong></p>); |
730 |
} |
} |
731 |
|
|
732 |
sub init_form { |
sub init_form { |
733 |
if (param()) { |
## TODO: Support multipart/form-data |
734 |
foreach my $var (param()) { |
my $query = ''; |
735 |
$form{$var} = param($var); |
if (uc $main::ENV{REQUEST_METHOD} eq 'POST') { |
736 |
} |
read STDIN, $query, $main::ENV{CONTENT_LENGTH}; |
737 |
} else { |
} |
738 |
$ENV{QUERY_STRING} = $FrontPage; |
$query .= ($query ? ';' : '') . $main::ENV{QUERY_STRING}; |
739 |
} |
if ($main::ENV{REQUEST_METHOD} ne 'POST' && $main::ENV{QUERY_STRING} && $main::ENV{QUERY_STRING} !~ /[&;=]/) { |
740 |
|
my $query = &decode($main::ENV{QUERY_STRING}); |
741 |
my $query = &decode($ENV{QUERY_STRING}); |
$query = &code_convert(\$query, $kanjicode); |
742 |
if ($page_command{$query}) { |
if ($page_command{$query}) { |
743 |
$form{mycmd} = $page_command{$query}; |
$form{mycmd} = $page_command{$query}; |
744 |
$form{mypage} = $query; |
$form{mypage} = $query; |
745 |
} elsif ($query =~ /^($wiki_name)$/) { |
} else { |
|
$form{mycmd} = 'read'; |
|
|
$form{mypage} = $1; |
|
|
} elsif ($database{$query}) { |
|
|
$form{mycmd} = 'read'; |
|
746 |
$form{mypage} = $query; |
$form{mypage} = $query; |
747 |
|
$form{mycmd} = $database{$form{mypage}} ? 'read' : 'edit'; |
748 |
|
} |
749 |
|
} else { |
750 |
|
for (split /[;&]/, $query) { |
751 |
|
if (my ($n, $v) = split /=/, $_, 2) { |
752 |
|
for ($n, $v) {tr/+/ /; s/%([0-9A-Fa-f][0-9A-Fa-f])/pack 'C', hex $1/ge}; |
753 |
|
$form{$n} = $v; |
754 |
|
} |
755 |
|
} |
756 |
|
unless (defined $form{mypage}) { |
757 |
|
$form{mypage} = $form{epage}; |
758 |
|
$form{mypage} =~ s/([0-9A-F]{2})/ord hex $1/g; |
759 |
|
} |
760 |
|
if ($page_command{$form{mypage}} && $form{mycmd} eq 'read') { |
761 |
|
$form{mypage} = &code_convert(\$form{mypage}, $kanjicode); |
762 |
|
$form{mycmd} = $page_command{$form{mypage}}; |
763 |
|
} |
764 |
} |
} |
765 |
|
$form{mypage} ||= 'HomePage'; |
766 |
|
$form{mycmd} ||= 'read'; |
767 |
|
|
768 |
# mypreview_edit -> do_edit, with preview. |
# mypreview_edit -> do_edit, with preview. |
769 |
# mypreview_adminedit -> do_adminedit, with preview. |
# mypreview_adminedit -> do_adminedit, with preview. |
775 |
} |
} |
776 |
} |
} |
777 |
|
|
778 |
# |
# |
779 |
# $form{mycmd} is frozen here. |
# $form{mycmd} is frozen here. |
780 |
# |
# |
781 |
|
|
782 |
|
for (grep /^wikiform__/, keys %form) { |
783 |
|
$form{$_} = &code_convert (\$form{$_}, $kanjicode); |
784 |
|
} |
785 |
$form{mymsg} = &code_convert(\$form{mymsg}, $kanjicode); |
$form{mymsg} = &code_convert(\$form{mymsg}, $kanjicode); |
786 |
$form{myname} = &code_convert(\$form{myname}, $kanjicode); |
$form{myname} = &code_convert(\$form{myname}, $kanjicode); |
787 |
} |
} |
788 |
|
|
789 |
sub update_recent_changes { |
{my %SubjectLine; |
|
my $update = "- @{[&get_now]} @{[&armor_name($form{mypage})]} @{[&get_subjectline($form{mypage})]}"; |
|
|
my @oldupdates = split(/\r?\n/, $database{$RecentChanges}); |
|
|
my @updates; |
|
|
foreach (@oldupdates) { |
|
|
/^\- \d\d\d\d\-\d\d\-\d\d \(...\) \d\d:\d\d:\d\d (\S+)/; # date format. |
|
|
my $name = &unarmor_name($1); |
|
|
if (&is_exist_page($name) and ($name ne $form{mypage})) { |
|
|
push(@updates, $_); |
|
|
} |
|
|
} |
|
|
if (&is_exist_page($form{mypage})) { |
|
|
unshift(@updates, $update); |
|
|
} |
|
|
splice(@updates, $maxrecent + 1); |
|
|
$database{$RecentChanges} = join("\n", @updates); |
|
|
if ($file_touch) { |
|
|
open(FILE, "> $file_touch"); |
|
|
print FILE localtime() . "\n"; |
|
|
close(FILE); |
|
|
} |
|
|
} |
|
|
|
|
790 |
sub get_subjectline { |
sub get_subjectline { |
791 |
my ($page, %option) = @_; |
my ($page, %option) = @_; |
792 |
if (not &is_editable($page)) { |
unless (defined $SubjectLine{$page}) { |
793 |
return ""; |
if (not &is_editable($page)) { |
794 |
|
$SubjectLine{$page} = ""; |
795 |
|
} else { |
796 |
|
$SubjectLine{$page} = $database{$page}; |
797 |
|
$SubjectLine{$page} =~ s!^\#\?[^\x0A\x0D]+[\x0A\x0D]*!!s; |
798 |
|
$SubjectLine{$page} =~ s/\x0D?\x0A.*//s; |
799 |
|
} |
800 |
|
} |
801 |
|
if (length $SubjectLine{$page}) { |
802 |
|
$option{delimiter} = defined $option{delimiter} ? $option{delimiter} : &Resource('Title-Summary Delimiter'); |
803 |
|
$option{delimiter}.$SubjectLine{$page}.$option{tail}; |
804 |
} else { |
} else { |
805 |
# Delimiter check. |
''; |
|
my $delim = $subject_delimiter; |
|
|
if (defined($option{delimiter})) { |
|
|
$delim = $option{delimiter}; |
|
|
} |
|
|
|
|
|
# Get the subject of the page. |
|
|
my $subject = $database{$page}; |
|
|
$subject =~ s/\r?\n.*//s; |
|
|
return "$delim$subject"; |
|
806 |
} |
} |
807 |
} |
}} |
|
|
|
|
sub send_mail_to_admin { |
|
|
my ($page, $mode) = @_; |
|
|
return unless $modifier_sendmail; |
|
|
my $message = <<"EOD"; |
|
|
To: $modifier_mail |
|
|
From: $modifier_mail |
|
|
Subject: [Wiki] |
|
|
MIME-Version: 1.0 |
|
|
Content-Type: text/plain; charset=ISO-2022-JP |
|
|
Content-Transfer-Encoding: 7bit |
|
|
|
|
|
-------- |
|
|
MODE = $mode |
|
|
REMOTE_ADDR = $ENV{REMOTE_ADDR} |
|
|
REMOTE_HOST = $ENV{REMOTE_HOST} |
|
|
-------- |
|
|
$page |
|
|
-------- |
|
|
$database{$page} |
|
|
-------- |
|
|
EOD |
|
|
&code_convert(\$message, 'jis'); |
|
|
open(MAIL, "| $modifier_sendmail"); |
|
|
print MAIL $message; |
|
|
close(MAIL); |
|
|
} |
|
808 |
|
|
809 |
sub open_db { |
sub open_db { |
810 |
if ($modifier_dbtype eq 'dbmopen') { |
if ($modifier_dbtype eq 'dbmopen') { |
811 |
dbmopen(%database, $dataname, 0666) or &print_error("(dbmopen) $dataname"); |
dbmopen(%database, $PathTo{WikiDataBase}, 0666) or &print_error("(dbmopen) $PathTo{WikiDataBase}"); |
|
dbmopen(%infobase, $infoname, 0666) or &print_error("(dbmopen) $infoname"); |
|
812 |
} elsif ($modifier_dbtype eq 'AnyDBM_File') { |
} elsif ($modifier_dbtype eq 'AnyDBM_File') { |
813 |
tie(%database, "AnyDBM_File", $dataname, O_RDWR|O_CREAT, 0666) or &print_error("(tie AnyDBM_File) $dataname"); |
eval q{use AnyDBM_File}; |
814 |
tie(%infobase, "AnyDBM_File", $infoname, O_RDWR|O_CREAT, 0666) or &print_error("(tie AnyDBM_File) $infoname"); |
tie(%database, "AnyDBM_File", $PathTo{WikiDataBase}, O_RDWR|O_CREAT, 0666) or &print_error("(tie AnyDBM_File) $PathTo{WikiDataBase}"); |
815 |
} else { |
} elsif ($modifier_dbtype eq 'Yuki::YukiWikiDB') { |
816 |
tie(%database, "Yuki::YukiWikiDB", $dataname) or &print_error("(tie Yuki::YukiWikiDB) $dataname"); |
eval q{use Yuki::YukiWikiDB}; |
817 |
tie(%infobase, "Yuki::YukiWikiDB", $infoname) or &print_error("(tie Yuki::YukiWikiDB) $infoname"); |
tie(%database, "Yuki::YukiWikiDB", $PathTo{WikiDataBase}) or &print_error("(tie Yuki::YukiWikiDB) $PathTo{WikiDataBase}"); |
818 |
|
} else { ## Yuki::YukiWikiDB || Yuki::YukiWikiDBMeta |
819 |
|
eval qq{use $modifier_dbtype}; |
820 |
|
$database = tie(%database, $modifier_dbtype => $PathTo{WikiDataBase}, -lock => 2, -backup => $wiki::diff::UseDiff) or &print_error("(tie $modifier_dbtype) $PathTo{WikiDataBase}"); |
821 |
} |
} |
822 |
} |
} |
823 |
|
|
824 |
sub close_db { |
sub close_db { |
825 |
if ($modifier_dbtype eq 'dbmopen') { |
if ($modifier_dbtype eq 'dbmopen') { |
826 |
dbmclose(%database); |
dbmclose(%database); |
|
dbmclose(%infobase); |
|
|
} elsif ($modifier_dbtype eq 'AnyDBM_File') { |
|
|
untie(%database); |
|
|
untie(%infobase); |
|
827 |
} else { |
} else { |
828 |
untie(%database); |
untie(%database); |
|
untie(%infobase); |
|
|
} |
|
|
} |
|
|
|
|
|
sub open_diff { |
|
|
if ($modifier_dbtype eq 'dbmopen') { |
|
|
dbmopen(%diffbase, $diffname, 0666) or &print_error("(dbmopen) $diffname"); |
|
|
} elsif ($modifier_dbtype eq 'AnyDBM_File') { |
|
|
tie(%diffbase, "AnyDBM_File", $diffname, O_RDWR|O_CREAT, 0666) or &print_error("(tie AnyDBM_File) $diffname"); |
|
|
} else { |
|
|
tie(%diffbase, "Yuki::YukiWikiDB", $diffname) or &print_error("(tie Yuki::YukiWikiDB) $diffname"); |
|
829 |
} |
} |
830 |
} |
} |
831 |
|
|
|
sub close_diff { |
|
|
if ($modifier_dbtype eq 'dbmopen') { |
|
|
dbmclose(%diffbase); |
|
|
} elsif ($modifier_dbtype eq 'AnyDBM_File') { |
|
|
untie(%diffbase); |
|
|
} else { |
|
|
untie(%diffbase); |
|
|
} |
|
|
} |
|
|
|
|
|
sub print_searchform { |
|
|
my ($word) = @_; |
|
|
print <<"EOD"; |
|
|
<form action="$url_cgi" method="get"> |
|
|
<input type="hidden" name="mycmd" value="search"> |
|
|
<input type="text" name="mymsg" value="$word" size="20"> |
|
|
<input type="submit" value="$resource{searchbutton}"> |
|
|
</form> |
|
|
EOD |
|
|
} |
|
|
|
|
832 |
sub print_editform { |
sub print_editform { |
833 |
my ($mymsg, $lastmodified, %mode) = @_; |
my ($mymsg, $lastmodified, %mode) = @_; |
834 |
my $frozen = &is_frozen($form{mypage}); |
my $frozen = &is_frozen($form{mypage}); |
836 |
if ($form{mypreview}) { |
if ($form{mypreview}) { |
837 |
if ($form{mymsg}) { |
if ($form{mymsg}) { |
838 |
unless ($mode{conflict}) { |
unless ($mode{conflict}) { |
839 |
print qq(<h3>$resource{previewtitle}</h3>\n); |
print qq(<h3>@{[&Resource('Preview:Title',escape=>1)]}</h3>\n); |
840 |
print qq($resource{previewnotice}\n); |
print qq(<p>@{[&Resource('Preview:Notice',escape=>1)]}</p>\n); |
841 |
print qq(<div class="preview">\n); |
print qq(<div class="preview">\n); |
842 |
&print_content($form{mymsg}); |
&print_content($form{mymsg}); |
843 |
print qq(</div>\n); |
print qq(</div>\n); |
844 |
} |
} |
845 |
} else { |
} else { |
846 |
print qq($resource{previewempty}); |
print @{[&Resource('Preview:Empty',escape=>1)]}; |
847 |
} |
} |
848 |
$mymsg = &escape($form{mymsg}); |
$mymsg = &escape($form{mymsg}); |
849 |
} else { |
} else { |
850 |
$mymsg = &escape($mymsg); |
$mymsg = &escape($mymsg || $database{NewPageTemplate}); |
851 |
} |
} |
852 |
|
my $magic = ''; |
853 |
|
$magic = $1 if $mymsg =~ m/^([^\x0A\x0D]+)/s; |
854 |
|
|
855 |
my $edit = $mode{admin} ? 'adminedit' : 'edit'; |
my $edit = $mode{admin} ? 'adminedit' : 'edit'; |
856 |
|
my $selected = 'read'; |
857 |
|
if ($form{after_edit_cmd}) { |
858 |
|
$selected = $form{after_edit_cmd}; |
859 |
|
} elsif ($magic =~ /Const|Config|CSS/) { |
860 |
|
$selected = 'edit'; |
861 |
|
} |
862 |
|
my $afteredit = <<EOH; |
863 |
|
<select name="after_edit_cmd"> |
864 |
|
<option value="read" label="@{[&Resource('Edit:SaveAndView',escape=>1)]}"@{[$selected eq 'read' ? ' selected="selected"':'']}>@{[&Resource('Edit:SaveAndView',escape=>1)]}</option> |
865 |
|
<option value="edit" label="@{[&Resource('Edit:SaveAndEdit',escape=>1)]}"@{[$selected eq 'edit' ? ' selected="selected"':'']}>@{[&Resource('Edit:SaveAndEdit',escape=>1)]}</option> |
866 |
|
</select> |
867 |
|
EOH |
868 |
|
|
869 |
print <<"EOD"; |
print <<"EOD"; |
870 |
<form action="$url_cgi" method="post"> |
<form action="$url_cgi" method="post"> |
871 |
@{[ $mode{admin} ? qq($resource{frozenpassword} <input type="password" name="mypassword" value="$form{mypassword}" size="10"><br>) : "" ]} |
<h2>@{[&Resource('Edit:Title',escape=>1)]}</h2> |
872 |
|
@{[ $mode{conflict} ? '' : qq(<input type="submit" name="mypreview_write" value="@{[&Resource('Edit:Save',escape=>1)]}"><kbd>S</kbd>) ]} |
873 |
|
@{[ $mode{admin} ? qq(<label>@{[&Resource('Edit:Password=',escape=>1)]}<input type="password" name="mypassword" value="" size="10"></label>) : "" ]} [@{[do {my $n = 0; |
874 |
|
$mymsg =~ s/(?:-+\s)?\[([0-9]+)\]/$n = $1 if $1 > $n; $&/mge; |
875 |
|
++$n}]}]<br> |
876 |
<input type="hidden" name="myLastModified" value="$lastmodified"> |
<input type="hidden" name="myLastModified" value="$lastmodified"> |
877 |
<input type="hidden" name="mypage" value="$form{mypage}"> |
<input type="hidden" name="mypage" value="@{[&escape($form{mypage})]}"> |
878 |
<textarea cols="$cols" rows="$rows" name="mymsg" wrap="off">$mymsg</textarea><br> |
<textarea cols="@{[&Resource('Edit:Form:Cols')+0||80]}" rows="@{[&Resource('Edit:Form:Rows')+0||20]}" name="mymsg" tabindex="1">$mymsg</textarea><br> |
879 |
@{[ |
@{[ |
880 |
$mode{admin} ? |
$mode{admin} ? |
881 |
qq( |
qq( |
882 |
<input type="radio" name="myfrozen" value="1" @{[$frozen ? qq(checked="checked") : ""]}>$resource{frozenbutton} |
<label><input type="radio" name="myfrozen" value="1" @{[$frozen ? qq(checked="checked") : ""]}>@{[&Resource('Edit:Freeze',escape=>1)]}</label> |
883 |
<input type="radio" name="myfrozen" value="0" @{[$frozen ? "" : qq(checked="checked")]}>$resource{notfrozenbutton}<br>) |
<label><input type="radio" name="myfrozen" value="0" @{[$frozen ? "" : qq(checked="checked")]}>@{[&Resource('Edit:DontFreeze',escape=>1)]}</label><br>) |
884 |
: "" |
: "" |
885 |
]} |
]} |
886 |
@{[ |
@{[ |
887 |
$mode{conflict} ? "" : |
$mode{conflict} ? "" : |
888 |
qq( |
qq( |
889 |
<input type="checkbox" name="mytouch" value="on" checked="checked">$resource{touch}<br> |
<label><input type="checkbox" name="mytouch" value="on" checked="checked">@{[&Resource('Edit:UpdateTimeStamp',escape=>1)]}</label><br> |
890 |
<input type="submit" name="mypreview_$edit" value="$resource{previewbutton}"> |
<input type="submit" name="mypreview_$edit" value="@{[&Resource('Edit:Preview',escape=>1)]}"> |
891 |
<input type="submit" name="mypreview_write" value="$resource{savebutton}"><br> |
<label><input type="submit" name="mypreview_write" value="@{[&Resource('Edit:Save',escape=>1)]}" accesskey="S"><kbd>S</kbd></label> |
892 |
|
$afteredit |
893 |
) |
) |
894 |
]} |
]} |
895 |
</form> |
</form> |
896 |
EOD |
EOD |
897 |
unless ($mode{conflict}) { |
unless ($mode{conflict}) { |
898 |
# Show the format rule. |
## Show help text |
899 |
open(FILE, $file_format) or &print_error("($file_format)"); |
my $help = $database{WikiEditHelp}; |
900 |
my $content = join('', <FILE>); |
$help =~ s!^\#\?([A-Z][A-Za-z0-9-]+/[0-9.]+(?:[^0-9.\x0D\x0A][^\x0D\x0A]*)?)[\x0D\x0A]+!!s; |
901 |
&code_convert(\$content, $kanjicode); |
print &text_to_html ($help, toc => 0); |
|
close(FILE); |
|
|
print &text_to_html($content, toc=>0); |
|
902 |
} |
} |
903 |
} |
} |
904 |
|
|
|
sub print_passwordform { |
|
|
print <<"EOD"; |
|
|
<form action="$url_cgi" method="post"> |
|
|
<input type="hidden" name="mycmd" value="adminchangepassword"> |
|
|
$resource{oldpassword} <input type="password" name="myoldpassword" size="10"><br> |
|
|
$resource{newpassword} <input type="password" name="mynewpassword" size="10"><br> |
|
|
$resource{newpassword2} <input type="password" name="mynewpassword2" size="10"><br> |
|
|
<input type="submit" value="$resource{changepasswordbutton}"><br> |
|
|
</form> |
|
|
EOD |
|
|
} |
|
|
|
|
905 |
sub is_editable { |
sub is_editable { |
906 |
my ($page) = @_; |
my ($page) = @_; |
907 |
if (&is_bracket_name($page)) { |
if ($FixedPage{$page} || $page =~ /\s/ || $page =~ /^\#/) { |
|
return 0; |
|
|
} elsif ($fixedpage{$page}) { |
|
|
return 0; |
|
|
} elsif ($page =~ /\s/) { |
|
|
return 0; |
|
|
} elsif ($page =~ /^\#/) { |
|
|
return 0; |
|
|
} elsif ($page =~ /^$interwiki_name$/) { |
|
908 |
return 0; |
return 0; |
909 |
} else { |
} else { |
910 |
return 1; |
return 1; |
914 |
# armor_name: |
# armor_name: |
915 |
# WikiName -> WikiName |
# WikiName -> WikiName |
916 |
# not_wiki_name -> [[not_wiki_name]] |
# not_wiki_name -> [[not_wiki_name]] |
917 |
sub armor_name { |
sub armor_name { qq([[$_[0]]]) } |
|
my ($name) = @_; |
|
|
if ($name =~ /^$wiki_name$/) { |
|
|
return $name; |
|
|
} else { |
|
|
return "[[$name]]"; |
|
|
} |
|
|
} |
|
918 |
|
|
919 |
# unarmor_name: |
# unarmor_name: |
920 |
# [[bracket_name]] -> bracket_name |
# [[bracket_name]] -> bracket_name |
921 |
# WikiName -> WikiName |
# WikiName -> WikiName |
922 |
sub unarmor_name { |
sub unarmor_name { |
923 |
my ($name) = @_; |
my ($name) = @_; |
924 |
if ($name =~ /^$bracket_name$/) { |
if ($name =~ /^\[\[(\S+?)\]\]$/) { |
925 |
return $1; |
return $1; |
926 |
} else { |
} else { |
927 |
return $name; |
return $name; |
928 |
} |
} |
929 |
} |
} |
930 |
|
|
|
sub is_bracket_name { |
|
|
my ($name) = @_; |
|
|
if ($name =~ /^$bracket_name$/) { |
|
|
return 1; |
|
|
} else { |
|
|
return 0; |
|
|
} |
|
|
} |
|
|
|
|
931 |
sub decode { |
sub decode { |
932 |
my ($s) = @_; |
my ($s) = @_; |
933 |
$s =~ tr/+/ /; |
$s =~ tr/+/ /; |
948 |
return $encoded; |
return $encoded; |
949 |
} |
} |
950 |
|
|
|
sub init_resource { |
|
|
open(FILE, $file_resource) or &print_error("(resource)"); |
|
|
while (<FILE>) { |
|
|
chomp; |
|
|
next if /^#/; |
|
|
my ($key, $value) = split(/=/, $_, 2); |
|
|
$resource{$key} = &code_convert(\$value, $kanjicode); |
|
|
} |
|
|
close(FILE); |
|
|
} |
|
|
|
|
951 |
sub conflict { |
sub conflict { |
952 |
my ($page, $rawmsg) = @_; |
my ($page, $rawmsg) = @_; |
953 |
if ($form{myLastModified} eq &get_info($page, $info_LastModified)) { |
if ($form{myLastModified} eq $database->mtime ($page)) { |
954 |
return 0; |
return 0; |
955 |
} |
} |
956 |
open(FILE, $file_conflict) or &print_error("(conflict)"); |
&print_header($page, -noindex => 1); |
957 |
my $content = join('', <FILE>); |
&print_content(&Resource('Error:Conflict')); |
|
&code_convert(\$content, $kanjicode); |
|
|
close(FILE); |
|
|
&print_header($page); |
|
|
&print_content($content); |
|
958 |
&print_editform($rawmsg, $form{myLastModified}, frozen=>0, conflict=>1); |
&print_editform($rawmsg, $form{myLastModified}, frozen=>0, conflict=>1); |
959 |
&print_footer($page); |
&print_footer($page); |
960 |
return 1; |
return 1; |
961 |
} |
} |
962 |
|
|
963 |
sub get_now { |
sub get_now { |
964 |
my (@week) = qw(Sun Mon Tue Wed Thu Fri Sat); |
my ($sec, $min, $hour, $day, $mon, $year) = localtime(time); |
|
my ($sec, $min, $hour, $day, $mon, $year, $weekday) = localtime(time); |
|
965 |
$year += 1900; |
$year += 1900; |
966 |
$mon++; |
$mon++; |
967 |
$mon = "0$mon" if $mon < 10; |
$mon = "0$mon" if $mon < 10; |
968 |
$day = "0$day" if $day < 10; |
$day = "0$day" if $day < 10; |
969 |
$hour = "0$hour" if $hour < 10; |
$hour = "0$hour" if $hour < 10; |
970 |
$min = "0$min" if $min < 10; |
$min = "0$min" if $min < 10; |
971 |
$sec = "0$sec" if $sec < 10; |
#$sec = "0$sec" if $sec < 10; |
972 |
$weekday = $week[$weekday]; |
return "$year-$mon-$day $hour:$min"; |
|
return "$year-$mon-$day ($weekday) $hour:$min:$sec"; |
|
973 |
} |
} |
974 |
|
|
|
# [[YukiWiki http://www.hyuki.com/yukiwiki/wiki.cgi?euc($1)]] |
|
975 |
sub init_InterWikiName { |
sub init_InterWikiName { |
976 |
my $content = $database{$InterWikiName}; |
my @content = split /\n/, $database{InterWikiName}; |
977 |
while ($content =~ /\[\[(\S+) +(\S+)\]\]/g) { |
for (@content) { |
978 |
my ($name, $url) = ($1, $2); |
if (/^([^#]\S*)\s+(\S[^\x0A\x0D]+)/) { |
979 |
$interwiki{$name} = $url; |
$interwiki{$1} = $2; |
980 |
} |
} |
981 |
} |
} |
982 |
|
$interwiki{'[[]]'} = 1; ## dummy |
|
sub interwiki_convert { |
|
|
my ($type, $localname) = @_; |
|
|
if ($type eq 'sjis' or $type eq 'euc') { |
|
|
&code_convert(\$localname, $type); |
|
|
return &encode($localname); |
|
|
} elsif ($type eq 'ykwk') { |
|
|
# for YukiWiki1 |
|
|
if ($localname =~ /^$wiki_name$/) { |
|
|
return $localname; |
|
|
} else { |
|
|
&code_convert(\$localname, 'sjis'); |
|
|
return &encode("[[" . $localname . "]]"); |
|
|
} |
|
|
} elsif ($type eq 'asis') { |
|
|
return $localname; |
|
|
# Walrus add (4) start |
|
|
} elsif ($type eq 'isbn') { |
|
|
$localname = join('', ($localname =~ /[0-9x]/g)) if ($localname =~ /^(\d-?){9}[\dx]$/); |
|
|
return $localname; |
|
|
# Walrus add (4) end |
|
|
} else { |
|
|
return $localname; |
|
|
} |
|
|
} |
|
|
|
|
|
sub get_info { |
|
|
my ($page, $key) = @_; |
|
|
my %info = map { split(/=/, $_, 2) } split(/\n/, $infobase{$page}); |
|
|
return $info{$key}; |
|
|
} |
|
|
|
|
|
sub set_info { |
|
|
my ($page, $key, $value) = @_; |
|
|
my %info = map { split(/=/, $_, 2) } split(/\n/, $infobase{$page}); |
|
|
$info{$key} = $value; |
|
|
my $s = ''; |
|
|
for (keys %info) { |
|
|
$s .= "$_=$info{$_}\n"; |
|
|
} |
|
|
$infobase{$page} = $s; |
|
983 |
} |
} |
984 |
|
|
985 |
sub frozen_reject { |
sub frozen_reject { |
986 |
my ($isfrozen) = &get_info($form{mypage}, $info_IsFrozen); |
my ($isfrozen) = $database->meta (IsFrozen => $form{mypage}); |
987 |
my ($willbefrozen) = $form{myfrozen}; |
my ($willbefrozen) = $form{myfrozen}; |
988 |
if (not $isfrozen and not $willbefrozen) { |
if (not $isfrozen and not $willbefrozen) { |
989 |
# You need no check. |
# You need no check. |
992 |
# You are admin. |
# You are admin. |
993 |
return 0; |
return 0; |
994 |
} else { |
} else { |
995 |
&print_error($resource{passworderror}); |
&print_error(&Resource('Error:PasswordIsIncorrect')); |
|
return 1; |
|
|
} |
|
|
} |
|
|
|
|
|
sub valid_password { |
|
|
my ($givenpassword) = @_; |
|
|
my ($validpassword_crypt) = &get_info($AdminSpecialPage, $info_AdminPassword); |
|
|
if (crypt($givenpassword, $validpassword_crypt) eq $validpassword_crypt) { |
|
996 |
return 1; |
return 1; |
|
} else { |
|
|
return 0; |
|
997 |
} |
} |
998 |
} |
} |
999 |
|
|
1000 |
sub is_frozen { |
sub is_frozen ($) { $database->meta (IsFrozen => $_[0]) ? 1 : 0 } |
|
my ($page) = @_; |
|
|
if (&get_info($page, $info_IsFrozen)) { |
|
|
return 1; |
|
|
} else { |
|
|
return 0; |
|
|
} |
|
|
} |
|
1001 |
|
|
1002 |
sub do_comment { |
sub do_comment { |
1003 |
my ($content) = $database{$form{mypage}}; |
my ($content) = $database{$form{mypage}}; |
1004 |
my $datestr = &get_now; |
my $default_name; ## this code does not strict. |
1005 |
my $namestr = $form{myname} ? " ''[[$form{myname}]]'' : " : " "; |
$default_name = $1 if $content =~ /default-name="([^"]+)"/; |
1006 |
if ($content =~ s/(\Q$embed_comment\E)/- $datestr$namestr$form{mymsg}\n$1/) { |
my $datestr = '[WEAK['.&get_now.']]'; |
1007 |
; |
my $namestr = $form{myname} || $default_name || &Resource('WikiForm:WikiComment:DefaultName'); |
1008 |
} else { |
($namestr = '', $datestr = '') if $form{myname} eq 'nodate'; |
1009 |
$content =~ s/(\Q$embed_rcomment\E)/$1\n- $datestr$namestr$form{mymsg}/; |
if ($namestr =~ /^(?:>>)?[0-9]/) { |
1010 |
|
$namestr = qq( ''$namestr'': ); |
1011 |
|
} elsif (length $namestr) { |
1012 |
|
$namestr = qq( ''[[$namestr]]'': ); |
1013 |
|
} |
1014 |
|
my $anchor = &get_new_anchor_index ($content); |
1015 |
|
my $i = 1; my $o = 0; |
1016 |
|
$content =~ s{(\[\[\#r?comment\]\])}{ |
1017 |
|
my $embed = $1; |
1018 |
|
if ($i == $form{comment_index}) { |
1019 |
|
if ($embed ne '[[#rcomment]]') { |
1020 |
|
$embed = "- [$anchor] $datestr$namestr$form{mymsg}\n$embed"; $o = 1; |
1021 |
|
} else { |
1022 |
|
$embed .= "\n- [$anchor] $datestr$namestr$form{mymsg}"; $o = 1; |
1023 |
|
} |
1024 |
|
} |
1025 |
|
$i++; $embed; |
1026 |
|
}ge; |
1027 |
|
unless ($o) { |
1028 |
|
$content = "#?SuikaWiki/0.9\n\n" unless $content; |
1029 |
|
$content .= "\n" unless $content =~ /\n$/s; |
1030 |
|
$content .= "- [$anchor] $datestr$namestr$form{mymsg}\n"; |
1031 |
} |
} |
1032 |
if ($form{mymsg}) { |
$form{__comment_anchor_index} = $anchor; |
1033 |
|
if ($form{mymsg} || $form{myname}) { |
1034 |
$form{mymsg} = $content; |
$form{mymsg} = $content; |
1035 |
$form{mytouch} = 'on'; |
$form{mytouch} = 'on'; |
1036 |
&do_write; |
&do_write; |
1040 |
} |
} |
1041 |
} |
} |
1042 |
|
|
1043 |
|
sub get_new_anchor_index ($) { |
1044 |
|
my $content = shift; |
1045 |
|
my $anchor = 0; |
1046 |
|
$content =~ s/^(?:[-=]+\s*)?\[([0-9]+)\]/$anchor = $1 if $1 > $anchor; $&/mge; |
1047 |
|
$anchor + 1; |
1048 |
|
} |
1049 |
|
|
1050 |
|
my $CommentIndex = 0; |
1051 |
sub embedded_to_html { |
sub embedded_to_html { |
1052 |
my ($embedded) = @_; |
my ($embedded) = @_; |
1053 |
if ($embedded eq $embed_comment or $embedded eq $embed_rcomment) { |
if ($embedded eq '[[#comment]]' or $embedded eq '[[#rcomment]]') { |
1054 |
my $lastmodified = &get_info($form{mypage}, $info_LastModified); |
unless ($main::_EMBEDED) { |
1055 |
|
my $lastmodified = $database->mtime ($form{mypage}); |
1056 |
return <<"EOD"; |
return <<"EOD"; |
1057 |
<form action="$url_cgi" method="post"> |
<form action="$url_cgi" method="post" id="x-comment-@{[++$CommentIndex]}" class="comment"><p> |
1058 |
<input type="hidden" name="mycmd" value="comment"> |
<input type="hidden" name="mycmd" value="comment"> |
1059 |
<input type="hidden" name="mypage" value="$form{mypage}"> |
<input type="hidden" name="mypage" value="$form{mypage}"> |
1060 |
<input type="hidden" name="myLastModified" value="$lastmodified"> |
<input type="hidden" name="myLastModified" value="$lastmodified"> |
1061 |
<input type="hidden" name="mytouch" value="on"> |
<input type="hidden" name="mytouch" value="on"> |
1062 |
$resource{yourname} |
<input type="hidden" name="comment_index" value="$CommentIndex"> |
1063 |
<input type="text" name="myname" value="" size="10"> |
@{[&Resource('WikiForm:WikiComment:Name=',escape=>1)]} |
1064 |
<input type="text" name="mymsg" value="" size="40"> |
<input type="text" name="myname" value="" size="10" class="comment-name"> |
1065 |
<input type="submit" value="$resource{commentbutton}"> |
<input type="text" name="mymsg" value="" size="60" class="comment-msg"> |
1066 |
</form> |
<input type="submit" value="@{[&Resource('WikiForm:Add',escape=>1)]}" title="@{[&Resource('WikiForm:AddLong',escape=>1)]}" class="comment-submit"> |
1067 |
|
</p></form> |
1068 |
|
EOD |
1069 |
|
} else { |
1070 |
|
return <<"EOD"; |
1071 |
|
<del><form action="$url_cgi" method="get"> |
1072 |
|
<input type="hidden" name="mycmd" value="read"> |
1073 |
|
<input type="hidden" name="mypage" value="$form{mypage}"> |
1074 |
|
@{[&Resource('WikiForm:WikiComment:Name=',escape=>1)]} |
1075 |
|
<input type="text" name="myname" value="" size="10" disabled="disabled"> |
1076 |
|
<input type="text" name="mymsg" value="" size="60" disabled="disabled"> |
1077 |
|
</form></del> |
1078 |
EOD |
EOD |
1079 |
# Walrus add (5) start |
} |
1080 |
} elsif ($embedded =~ /$embed_interwiki/ and my $remoteurl = $interwiki{$2}) { |
} elsif ($embedded =~ /$embed_command{searched}/) { |
1081 |
$_ = &make_interwiki_box($1, $2); |
return get_search_result ($1, -match_myself => 1); |
1082 |
return ($_) ? $_ : $embedded; |
} elsif ($embedded =~ /^\[\[\#embed:(.+)\]\]$/) { |
1083 |
# Walrus add (5) end |
my ($name, $r) = ($1, ''); |
1084 |
} else { |
if ($main::_EMBEDED != 1) { |
1085 |
return $embedded; |
my ($content, $cf) = ($database{$name}, 'SuikaWiki/0.9'); |
1086 |
|
$cf = $1 if $content =~ s!^(?:[\#<]\?|/\*\s*)?([A-Z][A-Za-z0-9-]+/[0-9.]+(?:[^0-9.][^\x0D\x0A]*)?)[\x0D\x0A]+!!s; |
1087 |
|
if ($cf =~ m!^(?:\#\?)?SuikaWiki/0.9(?:$|\s)!) { |
1088 |
|
$main::_EMBEDED = 1; |
1089 |
|
$r = &text_to_html ($content, content_format => $cf); |
1090 |
|
$main::_EMBEDED = 0; |
1091 |
|
} elsif (length $content) { |
1092 |
|
$r = "<pre>@{[&escape ($content)]}</pre>"; |
1093 |
|
} else { |
1094 |
|
$r = &text_to_html ("[INS[\n[[$name]]: @{[&Resource('Embed:PageNotFound')]}\n]INS]\n", content_format => 'SuikaWiki/0.9'); |
1095 |
|
} |
1096 |
|
} else { ## nested #EMBED |
1097 |
|
$r = &text_to_html ("[INS[\n[[$name]]: @{[&Resource('Embed:Nested',escape=>1)]}\n]INS]\n", content_format => 'SuikaWiki/0.9'); |
1098 |
|
} |
1099 |
|
return qq(<blockquote title="@{[&escape($name)]}" class="wiki-embed">$r<div class="cite-note">『<cite><a href="$url_cgi?@{[&encode($name)]}" class="wiki">@{[&escape($name)]}</a></cite>』</div></blockquote>); |
1100 |
|
} elsif ($embedded =~ /^\[\[\#randomlink:(.+)\]\]$/) { |
1101 |
|
return qq(<a href="$url_cgi?mycmd=RandomJump;x-param=@{[time.[0..9]->[rand 10]]}" class="wiki randomlink">$1</a>); |
1102 |
|
} else { |
1103 |
|
return $embedded; |
1104 |
|
} |
1105 |
|
} |
1106 |
|
|
1107 |
|
sub load_formatter (@) { |
1108 |
|
for my $t (@_) { |
1109 |
|
unless ($fmt{$t}) { |
1110 |
|
require Message::Util::Formatter; |
1111 |
|
$fmt{$t} = Message::Util::Formatter->new; |
1112 |
|
for (@{$SuikaWiki::Plugin::List{'wiki'.$t}||[]}) { |
1113 |
|
$_->load_formatter ($fmt{$t}, type => 'wiki'.$t); |
1114 |
|
} |
1115 |
|
} |
1116 |
} |
} |
1117 |
} |
} |
1118 |
|
|
1119 |
# Walrus add (5) start |
sub do_wikiform { |
1120 |
sub do_interwiki_box { |
my $content = $database{$form{mypage}}; |
1121 |
my $remoteurl = $interwiki{$form{'myintername'}}; |
my $anchor = &get_new_anchor_index ($content); |
1122 |
if ($remoteurl) { |
&load_formatter (qw/form_template form_option/); |
1123 |
$remoteurl =~ s/\b(euc|sjis|ykwk|asis|isbn)\(\$1\)/&interwiki_convert($1, $form{'mylocalname'})/e; |
my $write = 0; |
1124 |
print "Location: $remoteurl\n\n"; |
my $i = 1; |
1125 |
exit(1); |
$content =~ s{$embed_command{form}}{ |
1126 |
|
my ($embed, $wfname, $template, $option) = ($&, $1, $3, $4); |
1127 |
|
if (($wfname && $wfname eq $form{wikiform_targetform}) |
1128 |
|
|| $i == $form{wikiform_index}) { |
1129 |
|
$template =~ s/\\(.)/$1/g; |
1130 |
|
$option =~ s/\\(.)/$1/g; |
1131 |
|
my $param = bless {}, 'SuikaWiki::Plugin'; |
1132 |
|
$param->{page} = $form{mypage}; |
1133 |
|
$param->{form_index} = $i; |
1134 |
|
$param->{form_name} = $wfname; |
1135 |
|
$param->{anchor_index} = $anchor; |
1136 |
|
$param->{argv} = \%form; |
1137 |
|
$param->{default_name} = $1 if $content =~ /default-name="([^"]+)"/; |
1138 |
|
$param->{default_name} ||= &Resource('WikiForm:WikiComment:DefaultName'); |
1139 |
|
$fmt{form_option}->replace ($option, $param); |
1140 |
|
my $t = 1; |
1141 |
|
for (@{$param->{require}||[]}) { |
1142 |
|
(undef $t, last) unless length $param->{argv}->{'wikiform__'.$_}; |
1143 |
|
} |
1144 |
|
$t = $fmt{form_template}->replace ($template, $param) if $t; |
1145 |
|
if (length $t) { |
1146 |
|
if ($param->{output}->{reverse}) { |
1147 |
|
$embed .= "\n" . $t; |
1148 |
|
} else { |
1149 |
|
$embed = $t . "\n" . $embed; |
1150 |
|
} |
1151 |
|
$write = 1; |
1152 |
|
$form{__comment_anchor_index} = $anchor |
1153 |
|
if $param->{anchor_index_}; ## $anchor is used! |
1154 |
|
} |
1155 |
|
$form{__wikiform_anchor_index} = $i; |
1156 |
|
undef $form{wikiform_targetform}; ## make sure never to match |
1157 |
|
undef $form{wikiform_index}; ## with WikiForm in rest of page |
1158 |
|
} |
1159 |
|
$i++; $embed; |
1160 |
|
}ge; |
1161 |
|
unless ($write) { |
1162 |
|
#$content = "#?SuikaWiki/0.9\n\n" unless $content; |
1163 |
|
#$content .= "\n" unless $content =~ /\n$/s; |
1164 |
|
# |
1165 |
|
} |
1166 |
|
if ($write) { |
1167 |
|
$form{mymsg} = $content; |
1168 |
|
$form{mytouch} = 'on'; |
1169 |
|
&do_write; |
1170 |
} else { |
} else { |
1171 |
|
$form{mycmd} = 'read'; |
1172 |
&do_read; |
&do_read; |
1173 |
} |
} |
1174 |
} |
} |
|
# Walrus add (5) end |
|
|
|
|
|
# Walrus add (5) start |
|
|
sub make_interwiki_box { |
|
|
my ($localname, $intername) = @_; |
|
|
my %ignoretype = ( |
|
|
'box' => 'text', |
|
|
'text' => 'text', |
|
|
'pass' => 'password', |
|
|
'password' => 'password' |
|
|
); |
|
|
my $converted = ($ignoretype{$localname}) ? <<EOD : undef; |
|
|
<form action="$url_cgi" method="post"> |
|
|
<input type="hidden" name="mycmd" value="interwikibox"> |
|
|
<input type="hidden" name="mypage" value="$form{mypage}"> |
|
|
<input type="hidden" name="myintername" value="$intername"> |
|
|
$intername: |
|
|
<input type="$ignoretype{$localname}" name="mylocalname" value="" size="10"> |
|
|
<input type="submit" value="Submit"> |
|
|
</form> |
|
|
EOD |
|
|
} |
|
|
# Walrus add (5) end |
|
1175 |
|
|
1176 |
sub code_convert { |
sub code_convert { |
1177 |
my ($contentref, $kanjicode) = @_; |
require Jcode; |
1178 |
# &Jcode::convert($contentref, $kanjicode); # for Jcode.pm |
my ($contentref, $code) = (shift, shift || $kanjicode); |
1179 |
&jcode::convert($contentref, $kanjicode); # for jcode.pl |
$code = 'jis' if $code =~ /iso/; |
1180 |
|
$code = 'euc' if $code =~ /euc/; |
1181 |
|
$code = 'sjis' if $code =~ /shift/; |
1182 |
|
$code = 'utf8' if $code =~ /utf/; |
1183 |
|
$$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; |
1184 |
return $$contentref; |
return $$contentref; |
1185 |
} |
} |
1186 |
|
|
|
sub test_convert { |
|
|
my $txt = &text_to_html(<<"EOD", toc=>1); |
|
|
*HEADER1 |
|
|
**HEADER1-1 |
|
|
-ITEM1 |
|
|
-ITEM2 |
|
|
-ITEM3 |
|
|
PAR1PAR1PAR1PAR1PAR1PAR1PAR1PAR1PAR1PAR1PAR1PAR1PAR1PAR1PAR1PAR1 |
|
|
PAR1PAR1PAR1PAR1PAR1PAR1''BOLD''PAR1PAR1PAR1PAR1PAR1PAR1PAR1PAR1 |
|
|
PAR1PAR1PAR1PAR1PAR1PAR1PAR1PAR1PAR1PAR1PAR1PAR1PAR1PAR1PAR1PAR1 |
|
|
|
|
|
PAR2PAR2PAR2PAR2PAR2PAR2PAR2PAR2PAR2PAR2PAR2PAR2PAR2PAR2PAR2PAR2 |
|
|
PAR2PAR2PAR2PAR2PAR2PAR2'''ITALIC'''PAR2PAR2PAR2PAR2PAR2PAR2PAR2 |
|
|
PAR2PAR2PAR2PAR2PAR2PAR2PAR2PAR2PAR2PAR2PAR2PAR2PAR2PAR2PAR2PAR2 |
|
|
**HEADER1-2 |
|
|
:TERM1:DESCRIPTION1 AND ''BOLD'' |
|
|
PAR1PAR1PAR1PAR1PAR1PAR1PAR1PAR1PAR1PAR1PAR1PAR1PAR1PAR1PAR1PAR1 |
|
|
PAR1PAR1PAR1PAR1PAR1PAR1''BOLD''PAR1PAR1PAR1PAR1PAR1PAR1PAR1PAR1 |
|
|
PAR1PAR1PAR1PAR1PAR1PAR1PAR1PAR1PAR1PAR1PAR1PAR1PAR1PAR1PAR1PAR1 |
|
|
:TERM2:DESCRIPTION2 |
|
|
:TERM3:DESCRIPTION3 |
|
|
---- |
|
|
*HEADER2 |
|
|
**HEADER2-1 |
|
|
http://www.hyuki.com/ |
|
|
**HEADER2-2 |
|
|
|
|
|
[[YukiWiki2]] |
|
|
|
|
|
PAR1PAR1PAR1PAR1PAR1PAR1PAR1PAR1PAR1PAR1PAR1PAR1PAR1PAR1PAR1PAR1 |
|
|
PAR1PAR1PAR1PAR1PAR1PAR1'''''BOLD ITALIC'''''PAR1PAR1PAR1PAR1PAR1 |
|
|
PAR1PAR1PAR1PAR1PAR1PAR1PAR1PAR1PAR1PAR1PAR1PAR1PAR1PAR1PAR1PAR1 |
|
|
>PAR2PAR2PAR2PAR2PAR2PAR2PAR2PAR2PAR2PAR2PAR2PAR2PAR2PAR2PAR2PAR2 |
|
|
>PAR2PAR2PAR2PAR2PAR2PAR2'''ITALIC'''PAR2PAR2PAR2PAR2PAR2PAR2PAR2 |
|
|
>PAR2PAR2PAR2PAR2PAR2PAR2PAR2PAR2PAR2PAR2PAR2PAR2PAR2PAR2PAR2PAR2 |
|
|
|
|
|
LEVEL0LEVEL0LEVEL0LEVEL0LEVEL0LEVEL0LEVEL0 |
|
|
|
|
|
>LEVEL1 |
|
|
>LEVEL1 |
|
|
>LEVEL1 |
|
|
>>LEVEL2 |
|
|
>>LEVEL2 |
|
|
>>LEVEL2 |
|
|
>>>LEVEL3 |
|
|
-HELLO-1 |
|
|
--HELLO-2 |
|
|
(HELLO-2, HELLO-2, HELLO-2) |
|
|
---HELLO-3 |
|
|
(HELLO-3, HELLO-3, HELLO-3) |
|
|
--HELLO-2 |
|
|
---HELLO-3 |
|
|
--HELLO-2 |
|
|
---HELLO-3 |
|
|
>>>LEVEL3 |
|
|
>>>LEVEL3 |
|
|
>>>LEVEL3 |
|
|
>>>LEVEL3 |
|
|
EOD |
|
|
print $txt; |
|
|
exit; |
|
|
} |
|
|
|
|
1187 |
sub do_diff { |
sub do_diff { |
|
if (not &is_editable($form{mypage})) { |
|
|
&do_read; |
|
|
return; |
|
|
} |
|
|
&open_diff; |
|
1188 |
my $title = $form{mypage}; |
my $title = $form{mypage}; |
1189 |
&print_header($title); |
&print_header($title, -noindex => 1); |
1190 |
$_ = &escape($diffbase{$form{mypage}}); |
print qq(<h2>@{[&Resource('Diff:Title',escape=>1)]}</h2>); |
1191 |
&close_diff; |
print qq(<p>@{[&Resource('Diff:Notice',escape=>1)]}</p>); |
|
print qq(<h3>$resource{difftitle}</h3>); |
|
|
print qq($resource{diffnotice}); |
|
1192 |
print qq(<pre class="diff">); |
print qq(<pre class="diff">); |
1193 |
foreach (split(/\n/, $_)) { |
for (split(/\n/, &escape ($database->traverse_diff ($form{mypage})))) { |
1194 |
if (/^\+(.*)/) { |
if (/^\+(.*)/) { |
1195 |
print qq(<b class="added">$1</b>\n); |
print qq(<ins class="added">$1</ins>\n); |
1196 |
} elsif (/^\-(.*)/) { |
} elsif (/^\-(.*)/) { |
1197 |
print qq(<s class="deleted">$1</s>\n); |
print qq(<del class="deleted">$1</del>\n); |
1198 |
} elsif (/^\=(.*)/) { |
} elsif (/^\=(.*)/) { |
1199 |
print qq(<span class="same">$1</span>\n); |
print qq(<span class="same">$1</span>\n); |
1200 |
} else { |
} else { |
1202 |
} |
} |
1203 |
} |
} |
1204 |
print qq(</pre>); |
print qq(</pre>); |
|
print qq(<hr>); |
|
1205 |
&print_footer($title); |
&print_footer($title); |
1206 |
} |
} |
1207 |
|
|
1208 |
sub do_rss { |
sub do_rss { |
1209 |
|
eval q{use Yuki::RSS}; |
1210 |
my $rss = new Yuki::RSS( |
my $rss = new Yuki::RSS( |
1211 |
version => '1.0', |
version => '1.0', |
1212 |
encoding => $charset, |
encoding => &get_charset_name ($kanjicode), |
1213 |
|
); |
1214 |
|
my $scheme = 'http'; |
1215 |
|
$scheme = lc $1 if $main::ENV{SERVER_PROTOCOL} =~ m#([A-Za-z0-9+.%-]+)#; |
1216 |
|
my $myuri = "$scheme://$main::ENV{SERVER_NAME}:$main::ENV{SERVER_PORT}$url_cgi"; |
1217 |
|
$rss->stylesheet ( |
1218 |
|
href => $myuri . "?mycmd=TEXT_CSS;mypage=WikiStyle:RSS", |
1219 |
|
type => 'text/css', |
1220 |
); |
); |
1221 |
$rss->channel( |
$rss->channel( |
1222 |
title => $modifier_rss_title, |
title => &Resource ('RSS:WikiTitle'), |
1223 |
link => $modifier_rss_link, |
link => $myuri, |
1224 |
description => $modifier_rss_description, |
description => &Resource ('RSS:WikiDescription'), |
1225 |
|
'dc:language' => $lang, |
1226 |
); |
); |
1227 |
my $recentchanges = $database{$RecentChanges}; |
my $recentchanges = $database{RecentChanges}; |
1228 |
my $count = 0; |
my $count = 0; |
1229 |
foreach (split(/\n/, $recentchanges)) { |
foreach (split(/\n/, $recentchanges)) { |
1230 |
last if ($count >= 15); |
last if ($count >= 15); |
1231 |
/^\- \d\d\d\d\-\d\d\-\d\d \(...\) \d\d:\d\d:\d\d (\S+)/; # date format. |
if (/\[\[([^]]+)\]\]/) { |
1232 |
my $title = &unarmor_name($1); |
my $title = $1; |
1233 |
my $escaped_title = &escape($title); |
$rss->add_item ( |
1234 |
my $link = $modifier_rss_link . '?' . &encode($title); |
title => &escape($title), |
1235 |
my $description = $escaped_title . &escape(&get_subjectline($title)); |
link => $myuri . '?' . &encode($title), |
1236 |
$rss->add_item( |
description => &escape(&get_subjectline($title,delimiter=>'')), |
1237 |
title => $escaped_title, |
'dc:date' => $database->mtime ($title), |
1238 |
link => $link, |
); |
1239 |
description => $description, |
$count++; |
1240 |
); |
} |
|
$count++; |
|
1241 |
} |
} |
1242 |
# print RSS information (as XML). |
# print RSS information (as XML). |
1243 |
print <<"EOD" |
print <<"EOD" |
1244 |
Content-type: text/xml |
Content-type: application/xml; charset=@{[&get_charset_name ($kanjicode)]} |
1245 |
|
|
1246 |
@{[$rss->as_string]} |
@{[$rss->as_string]} |
1247 |
EOD |
EOD |
1248 |
} |
} |
1249 |
|
|
1250 |
|
sub _rfc3339_date ($) { |
1251 |
|
my @time = gmtime (shift); |
1252 |
|
sprintf '%04d-%02d-%02dT%02d:%02d:%02d+00:00', $time[5]+1900,$time[4]+1,@time[3,2,1,0]; |
1253 |
|
} |
1254 |
|
|
1255 |
sub is_exist_page { |
sub is_exist_page { |
1256 |
my ($name) = @_; |
my ($name) = @_; |
1257 |
if ($use_exists) { |
if ($use_exists) { |
1261 |
} |
} |
1262 |
} |
} |
1263 |
|
|
1264 |
|
sub __get_database ($) { $database{ $_[0] } } |
1265 |
|
|
1266 |
|
sub do_map { |
1267 |
|
my $page = $form{mypage}; |
1268 |
|
&print_header ($page); |
1269 |
|
wiki::referer::add ($form{mypage}, $ENV{HTTP_REFERER}); |
1270 |
|
wiki::useragent::add ($ENV{HTTP_USER_AGENT}); |
1271 |
|
my ($r, $c) = get_search_result ($form{mypage}); |
1272 |
|
my $rl = wiki::referer::list_html ($form{mypage}); |
1273 |
|
print "<h2>@{[&Resource('Map:Title',escape=>1)]}</h2>\n<p>@{[&Resource('Map:Description',escape=>1)]}</p>\n"; |
1274 |
|
my %option = (level => 0+&Resource('Map:Depth'), weight_list => {}, not_exist => {}, |
1275 |
|
map_from_here => &Resource('Map:FromHere'), |
1276 |
|
map_from_here_description => &Resource('Map:FromHereLong')); |
1277 |
|
&wiki::map::make_list ($page, %option); |
1278 |
|
print &wiki::map::list_to_html ($page, $option{weight_list}, %option); |
1279 |
|
if ($c) { |
1280 |
|
print qq{<h2 id="wikipage-see-also">@{[&Resource('SeeAlso',escape=>1)]}</h2>}; |
1281 |
|
print $r; |
1282 |
|
} |
1283 |
|
if ($rl) { |
1284 |
|
print qq(<div id="wikipage-referer"><h2>@{[&Resource('Referers',escape=>1)]}</h2>\n$rl</div>\n); |
1285 |
|
} |
1286 |
|
&print_footer ($page); |
1287 |
|
} |
1288 |
|
|
1289 |
|
my %_Resource; |
1290 |
|
sub Resource ($;%) { |
1291 |
|
my ($s, %o) = @_; |
1292 |
|
unless (defined $_Resource{$s}) { |
1293 |
|
$_Resource{$_[0]} = &wiki::resource::get ($s, $_Resource{__option}); |
1294 |
|
} |
1295 |
|
$o{escape} ? &escape ($_Resource{$s}) : $_Resource{$s}; |
1296 |
|
} |
1297 |
|
|
1298 |
|
package wiki::referer; |
1299 |
|
sub add ($$) { |
1300 |
|
my $page = shift; |
1301 |
|
my $uri = shift; |
1302 |
|
unless (ref $uri) { |
1303 |
|
require URI; |
1304 |
|
$uri = URI->new ($uri); |
1305 |
|
## Some schemes do not have query part. |
1306 |
|
eval q{ $uri->query (undef) if $uri->query =~ /^[0-9]{6,8}$/ }; |
1307 |
|
$uri->fragment (undef); |
1308 |
|
} |
1309 |
|
$uri = $uri->canonical; |
1310 |
|
return unless $uri; |
1311 |
|
for my $regex (&get_dont_record) { |
1312 |
|
return if $uri =~ /$regex/; |
1313 |
|
} |
1314 |
|
my %list = get ($page); |
1315 |
|
$list{ $uri }++; |
1316 |
|
set ($page, \%list); |
1317 |
|
} |
1318 |
|
sub get ($) { split /"/, $main::database->meta (Referer => $_[0]) } |
1319 |
|
sub set ($%) { |
1320 |
|
my $page = shift; |
1321 |
|
my $list = shift; |
1322 |
|
$main::database->meta (Referer => $page => join '"', %$list); |
1323 |
|
} |
1324 |
|
|
1325 |
|
sub get_dont_record () { |
1326 |
|
map {s/\$/\\\$/g; s/\@/\\\@/g; $_} |
1327 |
|
grep !/^#/, |
1328 |
|
split /[\x0D\x0A]+/, &main::__get_database ('RefererDontRecord'); |
1329 |
|
} |
1330 |
|
sub get_site_name () { |
1331 |
|
my @lines = grep /[^#]/, split /[\x0D\x0A]+/, &main::__get_database('RefererSiteName'); |
1332 |
|
my @item; |
1333 |
|
for (@lines) { |
1334 |
|
next if /^#/; |
1335 |
|
my ($uri, $name) = split /\s+/, $_, 2; |
1336 |
|
$uri =~ s/\$/\\\$/g; $uri =~ s/\@/\\\@/g; $uri =~ s/\//\\\//g; |
1337 |
|
$name =~ s!([()/\\])!\\$1!g; $name =~ s/\$([0-9]+)/).__decode (\${$1}).q(/g; |
1338 |
|
push @item, [$uri, qq(q($name))]; |
1339 |
|
} |
1340 |
|
@item; |
1341 |
|
} |
1342 |
|
|
1343 |
|
sub list_html ($) { |
1344 |
|
my $page = shift; |
1345 |
|
my %list = get ($page); |
1346 |
|
my $r = ''; |
1347 |
|
my @name = get_site_name; |
1348 |
|
for my $uri (sort keys %list) { |
1349 |
|
my $title; |
1350 |
|
for my $item (@name) { |
1351 |
|
if ($uri =~ /$item->[0]/) { |
1352 |
|
$title = $uri; |
1353 |
|
eval qq{\$title =~ s/^.*$item->[0].*\$/$item->[1]/e} |
1354 |
|
or die $@ ;#. qq{\$title =~ s/^.*$item->[0].*\$/$item->[1]/e}; |
1355 |
|
last; |
1356 |
|
} |
1357 |
|
} |
1358 |
|
my $euri = main::escape ($uri); |
1359 |
|
if ($title) { |
1360 |
|
$r .= qq(<li>[$list{$uri}] <a href="$euri" title="URI: <$euri>">@{[main::escape ($title)]}</a></li>\n); |
1361 |
|
} else { |
1362 |
|
$r .= qq(<li>[$list{$uri}] <<a href="$euri">$euri</a>></li>\n); |
1363 |
|
} |
1364 |
|
} |
1365 |
|
$r ? qq(<ul>$r</ul>\n) : ''; |
1366 |
|
} |
1367 |
|
|
1368 |
|
sub __decode ($) { |
1369 |
|
my $s = shift; |
1370 |
|
$s =~ tr/+/ /; |
1371 |
|
$s =~ s/%([0-9A-Fa-f][0-9A-Fa-f])/chr hex $1/ge; |
1372 |
|
main::code_convert (\$s); |
1373 |
|
} |
1374 |
|
|
1375 |
|
package wiki::useragent; |
1376 |
|
our $UseLog; |
1377 |
|
|
1378 |
|
sub add ($) { |
1379 |
|
my $s = shift; |
1380 |
|
return unless length $s; |
1381 |
|
return unless $UseLog; |
1382 |
|
$s =~ s/([\x00-\x08\x0A-\x1F\x25\x7F-\xFF])/sprintf '%%%02X', unpack 'C', $1/ge; |
1383 |
|
my %ua; |
1384 |
|
for (split /\n/, &main::__get_database($main::PageName{UserAgentList})) { |
1385 |
|
if (/^-\[(\d+)\] (.+)$/) { |
1386 |
|
my ($t, $n) = ($1, $2); |
1387 |
|
$n =~ tr/\x0A\x0D//d; |
1388 |
|
$ua{$n} = $t; |
1389 |
|
} |
1390 |
|
} |
1391 |
|
$ua{$s}++; |
1392 |
|
my $s = qq(#?SuikaWiki/0.9\n); |
1393 |
|
for (sort {$ua{$a} <=> $ua{$b}} keys %ua) { |
1394 |
|
$s .= sprintf qq(-[%d] %s\n), $ua{$_}, $_; |
1395 |
|
} |
1396 |
|
$main::database->STORE ($main::PageName{UserAgentList} => $s, -touch => 0); |
1397 |
|
} |
1398 |
|
|
1399 |
|
package wiki::suikawikiconst; |
1400 |
|
|
1401 |
|
sub to_hash ($;$) { |
1402 |
|
my $page = shift; |
1403 |
|
my $h = shift || {}; |
1404 |
|
my $val; |
1405 |
|
for my $line (split /\n/, $page) { |
1406 |
|
$line =~ tr/\x0A\x0D//d; |
1407 |
|
if ($val && $line =~ s/^\s+//) { |
1408 |
|
$h->{$val} .= length $h->{$val} ? "\n" . $line : $line; |
1409 |
|
} elsif ($line =~ /^(.+):/) { |
1410 |
|
$val = $1; $h->{$val} = ''; |
1411 |
|
} |
1412 |
|
} |
1413 |
|
$h; |
1414 |
|
} |
1415 |
|
|
1416 |
|
package wiki::dummy; |
1417 |
|
sub mtime (@) {undef} |
1418 |
|
sub meta (@) {undef} |
1419 |
|
sub Yuki::YukiWikiDB2::meta (@) {undef} |
1420 |
|
|
1421 |
|
package SuikaWiki::Plugin; |
1422 |
|
our $plugin_directory; # defined in top of this file. |
1423 |
|
our %List; |
1424 |
|
|
1425 |
|
sub escape ($$) { main::escape ($_[1]) } |
1426 |
|
sub unescape ($$) { main::unescape ($_[1]) } |
1427 |
|
sub encode ($$) { main::encode ($_[1]) } |
1428 |
|
sub decode ($$) { main::decode ($_[1]) } |
1429 |
|
sub __get_datetime ($) { main::get_now () } |
1430 |
|
sub resource ($$;%) { shift; &main::Resource (@_) } |
1431 |
|
sub uri ($$) { $main::uri{$_[1]} } |
1432 |
|
|
1433 |
|
sub regist ($@) { |
1434 |
|
my $pack = shift; |
1435 |
|
for (@_) { |
1436 |
|
push @{$List{$_}}, $pack; |
1437 |
|
} |
1438 |
|
} |
1439 |
|
|
1440 |
|
sub import_plugins () { |
1441 |
|
opendir PDIR, $plugin_directory; |
1442 |
|
my @plugin = grep {s/\.pm$//} readdir (PDIR); |
1443 |
|
closedir PDIR; |
1444 |
|
for (@plugin) { |
1445 |
|
eval qq{ use SuikaWiki::Plugin::$_ } unless /[^A-Za-z0-9_]/; |
1446 |
|
push @{$List{_all}}, qq(SuikaWiki::Plugin::$_); |
1447 |
|
} |
1448 |
|
} |
1449 |
|
|
1450 |
|
&import_plugins (); |
1451 |
|
|
1452 |
|
package wiki::conneg; |
1453 |
|
|
1454 |
|
## BUG: this parser isn't strict. |
1455 |
|
sub get_accept_lang (;$) { |
1456 |
|
my $alang = shift || $main::ENV{HTTP_ACCEPT_LANGUAGE}; |
1457 |
|
my %alang = (ja => 0.0002, en => 0.0001); |
1458 |
|
my $i = 0.1; |
1459 |
|
for (split /\s*,\s*/, $alang) { |
1460 |
|
tr/\x09\x0A\x0D\x20//d; |
1461 |
|
if (/((?:(?!;q=).)+)(?:;q="?([0-9.]+)"?)?/) { |
1462 |
|
my $l = lc $1; $l =~ tr/\x22\x5C//d; |
1463 |
|
$alang{$l} = (defined $2 ? $2 : 1.000)*1000; |
1464 |
|
$alang{$l} += $i unless $alang{$l} == 0; |
1465 |
|
$i -= 0.001; |
1466 |
|
} |
1467 |
|
} |
1468 |
|
\%alang; |
1469 |
|
} |
1470 |
|
|
1471 |
|
package wiki::resource; |
1472 |
|
|
1473 |
|
sub get ($;\%) { |
1474 |
|
my ($resname, $option) = @_; |
1475 |
|
$option->{accept_language} ||= &wiki::conneg::get_accept_lang (); |
1476 |
|
$option->{resource} ||= {}; |
1477 |
|
my $v; |
1478 |
|
for my $lang (sort {$option->{accept_language}->{$b} <=> $option->{accept_language}->{$a}} grep {$option->{accept_language}->{$_}!=0} keys %{$option->{accept_language}}) { |
1479 |
|
while (length $lang) { |
1480 |
|
unless ($option->{accept_language}->{defined $option->{accept_language}->{$lang} ? $lang : '*'} == 0) { |
1481 |
|
$option->{resource}->{$lang} ||= &wiki::suikawikiconst::to_hash (&main::__get_database('WikiResource:'.$lang)); |
1482 |
|
$v = $option->{resource}->{$lang}->{$resname}; |
1483 |
|
last if defined $v; |
1484 |
|
} |
1485 |
|
$lang =~ s/[^+-]*$//; $lang =~ s/[+-]$//; |
1486 |
|
} |
1487 |
|
last if defined $v; |
1488 |
|
} |
1489 |
|
defined $v ? $v : $resname; |
1490 |
|
} |
1491 |
|
|
1492 |
|
package wiki::map; |
1493 |
|
|
1494 |
|
sub make_list ($;%) { |
1495 |
|
my ($page, %option) = @_; |
1496 |
|
$option{level} ||= 3; |
1497 |
|
my %weight; |
1498 |
|
my $content = &main::__get_database ($page); |
1499 |
|
$content =~ s{^\#\?([^\x0A\x0D]+)}{ |
1500 |
|
if ($1 =~ /import="([^"]+)"/) { |
1501 |
|
for (split /\s*,\s*/, $1) { |
1502 |
|
$weight{$_} += 2; |
1503 |
|
} |
1504 |
|
} |
1505 |
|
$&; |
1506 |
|
}ges; |
1507 |
|
## Bug: this code does not support content type. |
1508 |
|
$content =~ s{\[\[((?!\#)[^]]+)\](?:>>\d+)?\]}{ |
1509 |
|
$weight{$1}++; $&; |
1510 |
|
}ge; |
1511 |
|
delete $weight{$page}; ## Delete myself |
1512 |
|
for my $page (keys %weight) { |
1513 |
|
my $w = ($content =~ s/\Q$page\E/$&/g); |
1514 |
|
$weight{$page} += $w + $weight{$page}; ## Weight of [[name]] is x2. |
1515 |
|
($weight{$page} *= 0.1, $option{not_exist}->{$page} = 1) unless &main::is_exist_page ($page); |
1516 |
|
} |
1517 |
|
$option{weight_list}->{$page} = \%weight; |
1518 |
|
if (--$option{level}) { |
1519 |
|
for my $page (keys %weight) { |
1520 |
|
&make_list ($page, %option) unless $option{weight_list}->{$page}; |
1521 |
|
} |
1522 |
|
} |
1523 |
|
$option{weight_list}; |
1524 |
|
} |
1525 |
|
|
1526 |
|
sub list_to_html ($$;%) { |
1527 |
|
my ($Page, $wlist, %option) = @_; |
1528 |
|
my $r = ''; |
1529 |
|
$option{outputed}->{$Page} = 1; |
1530 |
|
for my $page (sort {$wlist->{$Page}->{$b} <=> $wlist->{$Page}->{$a}} keys %{$wlist->{$Page}}) { |
1531 |
|
$r .= qq(<li><span class="weight">[@{[0+$wlist->{$Page}->{$page}]}]</span> <a href="$main::url_cgi?@{[&main::encode($page)]}" class="wiki@{[$option{not_exist}->{$page}?' not-exist':'']}">@{[&main::escape ($page).($option{not_exist}->{$page}?qq(<span class="mark">@{[&main::Resource('JumpAndEditWikiPageMark',escape=>1)]}</span>):'')]}</a> <a href="$main::url_cgi?mycmd=map;mypage=@{[&main::encode($page)]}" class="wiki-cmd map-from-here" title="@{[&main::escape($option{map_from_here_description})]}">@{[&main::escape($option{map_from_here})]}</a> <span class="summary">@{[&main::escape(&main::get_subjectline($page))]}</span>); |
1532 |
|
unless ($option{outputed}->{$page}) { |
1533 |
|
$r .= &list_to_html ($page, $wlist, %option); |
1534 |
|
} |
1535 |
|
$r .= "</li>\n"; |
1536 |
|
} |
1537 |
|
$r ? qq(<ul class="map">$r</ul>) : ''; |
1538 |
|
} |
1539 |
|
|
1540 |
|
package main; |
1541 |
|
&main; |
1542 |
|
exit 0; |
1543 |
|
|
1544 |
1; |
1; |
1545 |
__END__ |
__END__ |
1546 |
=head1 NAME |
=head1 NAME |
1547 |
|
|
1548 |
wiki.cgi - This is YukiWiki, yet another Wiki clone. |
wiki.cgi --- SuikaWiki: Yet yet another Wiki engine |
|
|
|
|
=head1 DESCRIPTION |
|
|
|
|
|
YukiWiki is yet another Wiki clone. |
|
1549 |
|
|
1550 |
YukiWiki can treat Japanese WikiNames (enclosed with [[ and ]]). |
=head1 AUTHORS |
|
YukiWiki provides 'InterWiki' feature, RDF Site Summary (RSS), |
|
|
and some embedded commands (such as [[#comment]] to add comments). |
|
1551 |
|
|
1552 |
Read F<readme_en.txt> (English) or F<readme_ja.txt> (Japanese) in more detail. |
Hiroshi Yuki <hyuki@hyuki.com> <http://www.hyuki.com/yukiwiki/> |
1553 |
|
|
1554 |
=head1 AUTHOR |
Makio Tsukamoto <http://digit.que.ne.jp/> |
1555 |
|
|
1556 |
Hiroshi Yuki <hyuki@hyuki.com> http://www.hyuki.com/yukiwiki/ |
Wakaba <w@suika.fam.cx> |
1557 |
|
|
1558 |
=head1 LICENSE |
=head1 LICENSE |
1559 |
|
|
1560 |
Copyright (C) 2000-2002 by Hiroshi Yuki. |
Copyright (C) 2000-2003 AUTHORS |
1561 |
|
|
1562 |
This program is free software; you can redistribute it and/or |
This program is free software; you can redistribute it and/or |
1563 |
modify it under the same terms as Perl itself. |
modify it under the same terms as Perl itself. |