目次
YukiWiki本体/プラグインの改造/新機能追加についての記録 (最終更新 2006/03/10)
基本方針TODOオリジナルのYukiWikiに追加した機能のリストWiki Spam 対策http://www.hyuki.com/diary/20050125080555 に従って、対策をほどこす。ページの作成/修正/削除の通知メイルのサブジェクトにページ名とモードを追加する
Subject: [Wiki]を Subject: [Wiki] $page $modeに変更。
アクセスログをとる
my $access_data_log = 'log保存ディレクトリ名/ログファイル名';を加える。
sub accesslog { #Accesslog by T.Tsukamoto my ( $a_sec,$a_min,$a_hour,$a_day,$a_mon,$a_year,$a_wday ) = localtime(time); $a_mon++; $a_year=$a_year+1900; open(LOG, ">>$access_data_log"); print LOG "$a_mon/$a_day/$a_year, $a_hour:$a_min:$a_sec, $ENV{'REMOTE_ADDR'}, $ENV{'HTTP_USER_AGENT'}, $ENV{'HTTP_REFERER'}, $form{mypage}\n"; close(LOG); }
# &test_convert; &main; &accesslog; exit(0);
YukiWiki 凍結ページでもコメントを書けるようにする(2004年10月7日実施)http://hpcgi2.nifty.com/tokd/index.cgi?YukiWikiModifiedVersion *** 1112,1117 **** --- 1112,1122 ---- my ($willbefrozen) = $form{myfrozen}; if (not $isfrozen and not $willbefrozen) { # You need no check. + return 0; + } elsif ($isfrozen and $form{mycmd} eq 'comment') { + # keep frozen + $form{myfrozen} = 1; + # Comment is always allowed. return 0; } elsif (valid_password($form{mypassword})) { # You are admin.に基づき、sub frozen_reject を修正。
サイドメニューバーを付けるnekyoさんのPyukiWikiを参考にして、
my $use_SideBar = 1; my $SideBar = 'SideBar';を追加。
sub do_read { &print_header($form{mypage}); &print_content($database{$form{mypage}}); &print_footer($form{mypage}); }を sub do_read { &print_header($form{mypage}); if ($use_SideBar){ my $MypageBK = $form{mypage}; print <<"EOD"; <table width="100%" border="0"> <tr> <td class="sidebar" valign="top"> <div id="sidebar"> EOD $form{mypage} = $SideBar; &print_content($database{$form{mypage}}); print <<"EOD"; </div> </td> <td class="pbody" valign="top"> EOD $form{mypage} = $MypageBK; &print_content($database{$form{mypage}}); print <<"EOD"; </td> </tr> </table> EOD }else{ &print_content($database{$form{mypage}}); } &print_footer($form{mypage}); }に変更。
ここの wiki.css です。...適当にいじっただけなので、変なところはご指摘ください。 /* * wiki.css for http://www.ps23.org/tamio/YukiWiki/ * 2004/11/25 */ body.normal { margin: .1em 1% .1em 1%; background-color: white; color: black; /* font-family: monospace; */ font-size: 12px; } body.frozen { color: black; background: #eee; font-size: 12px; } .preview { color: black; background: #fcc; font-size: 12px; } p { margin: 1em 0 1em 1em; line-height: 120%; font-size: 12px; } pre, ul, li { line-height: 120%; font-size: 12px; } a { } a:hover { color: red; background-color: white; text-decoration: underline; } a img { border: none; } .tools { text-align: left; padding: 0 .1em 0 .1em; font-size: 12px; margin: 0 0 0 0; } .header { text-align: left; border: #999 1px solid; color: black; background: #fdd; padding: .1em .5em .1em .5em; margin: .2em 0 0 0; font-size: 160%; /* font-family: "Courier New", monospace; */ } .footer { font-style: normal; /* italic */ text-align: right; font-size: 80%; } .InterWiki { color: black; background: #eee; } h2 { text-align: left; border: #999 1px solid; color: black; background: #cfc; padding: .1em .5em .1em .5em; font-size: 140%; /* margin: .2em 0 0 0;*/ } h3 { text-align: left; border-bottom: #999 1px solid; color: black; background: #cef; padding: .1em .5em .1em .5em; /* font-size: 110%;*/ /* margin: .2em 0 0 0; */ } h4 { text-align: left; border-bottom: #999 1px solid; color: black; background: #def; padding: .1em .5em .1em .5em; /* font-size: 100%;*/ /* margin: .2em 0 0 0; */ } .date { font-family: monospace; } /* verbatim */ pre.verbatim-hard { background-color: #eef; border: #ccf 1px solid; padding: 1em 1em 1em 1em; margin-left: 1em; margin-right: 1em; } pre.verbatim-soft { background-color: #eef; border: #ccf 1px solid; padding: 1em 1em 1em 1em; margin-left: 1em; margin-right: 1em; } /* SideBar */ td.sidebar { background: #fff; } td.pbody { background: #fff; } div#sidebar { width:10em; font-size: 100%; padding:0px; margin:0px; word-break:break-all; overflow:hidden; } div#sidebar ul { margin:0px 0px 0px .5em; padding:0px 0px 0px .5em; } div#sidebar ul li { line-height:110%; } div#sidebar h3 { font-size:100%; } div#sidebar h4 { font-size:100%; } /* SideBar End */ /* diff */ .added { color: blue; } .deleted { color: red; } .same { color: #666; } .diff { color: black; background: #eee; } /* table */ table { background: #ccf; } td { margin: 1px; padding: 5px; background: #eef; } .error { } /* * Styles for printer. */ @media print { form { display: none; } .header { color: black; border: none; text-align: center; /* font-size: large; */ margin-bottom: 1em; } h2 { border: none; border-bottom: #ccc 1px solid; border-left: #ccc .5em solid; } h3 { border: none; border-bottom: #ccc 1px solid; } h4 { border: none; } a:hover { color: black; text-decoration: none; } a { text-decoration: none; } a.editlink { display: none; } .footer { display: none; } body { } .tools { display: none; } p { font-family: Serif; } td.sidebar { display: none; } }
リンクをクリックした時に新しいWindowを開くwiki.cgiを変更する方法(パラメータで選択)1)wiki.cgi の冒頭部分で my $use_popupwindow = 1; # Pop up new window when link is clicked. と設定。 2)sub make_link の } else { return qq(<a href="$chunk">$chunk</a>); となっているところを、 } else { if ($use_popupwindow){ return qq(<a href="$chunk" target="_blank">$chunk</a>); }else{ return qq(<a href="$chunk">$chunk</a>); } に変更 pluginによる方法 (YukiWikiのlink.plを元にwlink.plを作成)#### wlink #### use strict; package wlink; sub plugin_inline { my ($escaped_argument) = @_; my ($caption, $url) = split(/,/, $escaped_argument); if ($url =~ /^(mailto|http|https|ftp):/) { return qq(<a href="$url" target="_blank">$caption</a>); } else { return qq(&link($escaped_argument)); } } sub plugin_usage { return { name => 'wlink', version => '1.1t', author => 'based on link:Hiroshi Yuki <hyuki@hyuki.com>/modified by Tamio Tsukamoto', syntax => '&wlink(caption,url)', description => 'Create link with given caption.. and open new window', example => "Please visit &wlink(Hiroshi Yuki,http://www.hyuki.com/).", }; } 1; 番号付きリスト(行の先頭に「+」を書く)+起床 +洗顔 +朝食
wiki.cgi の sub text_to_htmlの 番号無しのリストの後に } elsif (/^(\+{1,3})(.+)/) { &back_push('ol', length($1), \@saved, \@result); push(@result, '<li>' . &inline($2) . '</li>'); を追加 強制改行(行末にチルダ「~」を付ける)このように~ 強制改行~ できます。~このように 強制改行 できます。 wiki.cgi の sub inline に $line =~ s|~$|<br>|g; # ~\n -> <br> を追加
コメント行(行の先頭に「//」を付ける)//コメントです wiki.cgi の sub inline に ## Imported from PyukiWiki $line =~ s|^//.*$||g; # Comment を追加 左よせ、センタリング、右よせwiki.cgiを修正する方法LEFT:左よせ CENTER:センタリング RIGHT:右寄せ 左よせ
センタリング
右寄せ
wiki.cgi の sub inline に ## Imported from PyukiWiki $line =~ s!^(LEFT|CENTER|RIGHT):(.*)$!<div style="text-align:$1">$2</div>!g; を追加 pluginによる方法(left.pl,center.pl,right.plを新規作成)#### left.pl #### use strict; package left; sub plugin_inline { my ($escaped_argument) = @_; return qq(<div align="left">$escaped_argument</div>); } sub plugin_usage { return { name => 'left', version => '1.0', author => 'Tamio Tsukamoto<tamio@mb.infoweb.ne.jp>', syntax => '&left(STRING)', description => 'Align Left', example => '&left(String)', }; } 1; #### center.pl #### use strict; package center; sub plugin_inline { my ($escaped_argument) = @_; return qq(<center>$escaped_argument</center>); } sub plugin_usage { return { name => 'center', version => '1.0', author => 'Tamio Tsukamoto<tamio@mb.infoweb.ne.jp>', syntax => '¢er(STRING)', description => 'center', example => '¢er(String)', }; } 1; #### right.pl #### use strict; package right; sub plugin_inline { my ($escaped_argument) = @_; return qq(<div align="right">$escaped_argument</div>); } sub plugin_usage { return { name => 'right', version => '1.0', author => 'Tamio Tsukamoto<tamio@mb.infoweb.ne.jp>', syntax => '&right(STRING)', description => 'Align Right', example => '&right(String)', }; } 1;
アンダーライン、取消線wiki.cgiを変更する方法%%%アンダーライン%%%、%%取消線%%アンダーライン、 wiki.cgi の sub inline に $line =~ s|%%%([^%]*)%%%|<U>$1</U>|g; # Under Line $line =~ s|%%([^%]*)%%|<S>$1</S>|g; # Delete Line を追加 plugin による方法取消線は結城浩さんの del.plを入手、 アンダーラインは、新たにunder.plを作成。#### under.pl #### use strict; package under; sub plugin_inline { my ($escaped_argument) = @_; return qq(<U>$escaped_argument</U>); } sub plugin_usage { return { name => 'under', version => '1.0', author => 'Tamio Tsukamoto<tamio@mb.infoweb.ne.jp>', syntax => '&under(STRING)', description => 'under (Inline).', example => '&under(String)', }; } 1; 色を変えるwiki.cgiを変更する方法RED:RED BLUE:BLUE GREEN:GREENRED BLUE GREEN wiki.cgi の sub inline に ## Thanks to hash $line =~ s!^(RED|BLUE|GREEN):(.*)$!<font color="$1">$2</font>!g; # Color を追加 pluginによる方法(color.plを新規作成)pluginでも&color(RED,赤にできます)。pluginでも赤にできます。 ##### color.pl ###### use strict; package color; sub plugin_inline { my ($escaped_argument) = @_; my ($color_name, $string) = split(/,/, $escaped_argument); return qq(<font color="$color_name">$string</font>); } sub plugin_usage { return { name => 'color', version => '1.0', author => 'Tamio Tsukamoto<tamio@mb.infoweb.ne.jp>', syntax => '&color(COLOR_NAME,STRING)', description => 'Change Font Color (Inline).', example => '&color(RED,Red String)', }; } 1; フォントの大きさを変えるwiki.cgiを変更する方法LARGE:LARGE SMALL:SMALLLARGE SMALL wiki.cgi の sub inline に $line =~ s!^(LARGE):(.*)$!<font size="+1">$2</font>!g; # font size $line =~ s!^(SMALL):(.*)$!<font size="-1">$2</font>!g; # font size を追加 pluginによる方法(size.plを新規作成)pluginでも&size(+20,大きく)も&size(-3,小さく)もできます。pluginでも大きくも小さくもできます。 #### size.pl #### use strict; package size; sub plugin_inline { my ($escaped_argument) = @_; my ($font_size, $string) = split(/,/, $escaped_argument); return qq(<font size="$font_size">$string</font>); } sub plugin_usage { return { name => 'size', version => '1.0', author => 'Tamio Tsukamoto<tamio@mb.infoweb.ne.jp>', syntax => '&size(Font_Size,STRING)', description => 'Change Font Size(Inline).', example => '&size(+20,HUGE FONT)', }; } 1; 上付き文字、下付き文字wiki.cgiを変更する方法e^^-kt^^, CH__3__OHe-kt, CH3OH
wiki.cgi の sub inline に $line =~ s|\^\^([^\^]*)\^\^|<SUP>$1</SUP>|g; # SuperScript $line =~ s|__([^_]*)__|<SUB>$1</SUB>|g; # SubScript を追加 plugin による方法PyukiWiki 0.0.7より対応した plugin sup.pl, sub.plを用いる。 http://nekyo.hp.infoseek.co.jp/ を参照。
アマゾン(Amazon)関係の pluginamazont.pl結城浩さんのamazon.plを元に、ISBNよりリンクから該当書籍だけの新しいウインドウを開く amazont.plを作成。use strict; package amazont; my $id = 'ここにアフィリエイトIDを記述'; sub plugin_inline { my ($escaped_argument) = @_; my ($caption, $number) = split(/,/, $escaped_argument); return qq(<a href="http://www.amazon.co.jp/exec/obidos/ASIN/$number/$id/ref=nosim" target="_blank">$caption</a>); } sub plugin_usage { return { name => 'amazont', version => '1.1', author => 'Based on amazon.pl by Hiroshi Yuki <hyuki@hyuki.com> modified by Tamio Tsukamoto', syntax => '&amazont(caption,isbn)', description => 'Create link to amazon.(Popup a New Window)', example => 'Please read &amazont(Alice in Cryptographic World,4797322977).', }; } 1; Amazon.plアマゾンへのリンクを本の写真付きで生成するプラグイン。 $idはアフィリエイトIDを記述。ImageIDは和書は 09 、洋書は 01 。use strict; package Amazon; my $id = 'ここにアフィリエイトIDを記述'; sub plugin_inline { my ($escaped_argument) = @_; my ($iid,$isbn) = split(/,/, $escaped_argument); return qq( <a href="http://www.amazon.co.jp/exec/obidos/ASIN/$isbn/$id/ref=nosim" target="_blank"> <img src="http://images-jp.amazon.com/images/P/$isbn.$iid.MZZZZZZZ.jpg" alt=""></a>); } sub plugin_usage { return { name => 'Amazon', version => '1.1', author => 'Tamio Tsukamoto<tamio@mb.infoweb.ne.jp>', syntax => '&Amazonf(ImageID,ISBN)', description => 'Create link to Amazon with Image.', example => '&Amazon(01,0895792524).', }; } 1;
他サイトから導入したプラグインYukiWiki公式サイトのプラグイン機能のページ にある、或はそこからのリンクから、amazon.plcalendar.pllinktree.plmimetex.plrssmix.plrssview.plsearch.plsearchbox.plsearchform.plsimilarity.plを入手し、追加。 |