その他?
pukiwiki tips
機能追加 †
MenuBar を 右側にも表示 †
- cd plugin
- cp menu.inc.php menu2.inc.php
- vi menu2.inc.php
- function plugin_menu_convert()
- > function plugin_menu2_convert()
- index.php?MenuBar2 の編集
- vi pukiwiki.ini.php
- 追加 $menubar2 = 'MenuBar2';
- vi plugin/menu2.inc.php
- 変更 global $script,$vars,$menubar2;
- 変更 $page = ($menu === NULL) ? $menubar2 : $menu;
- vi skin/pukiwiki.skin.php
<?php if (arg_check('read') && exist_plugin_convert('menu')) { ?>
<table border="0" style="width:100%">
<tr>
<td class="menubar">
<div id="menubar"><?php echo do_plugin_convert('menu') ?></div>
</td>
<td valign="top">
<div id="body"><?php echo $body ?></div>
</td>
</tr>
</table>
に次を追加。
<?php if (exist_plugin_convert('menu2')) { ?>
<td class="menubar2">
<div id="menubar2">
<?php echo do_plugin_convert('menu2') ?>
</div>
</td>
<?php } ?>
以下のようになる。
<?php if (arg_check('read') && exist_plugin_convert('menu')) { ?>
<table border="0" style="width:100%">
<tr>
<td class="menubar">
<div id="menubar"><?php echo do_plugin_convert('menu') ?></div>
</td>
<td valign="top">
<div id="body"><?php echo $body ?></div>
</td>
<?php if (exist_plugin_convert('menu2')) { ?>
<td class="menubar2">
<div id="menubar2">
<?php echo do_plugin_convert('menu2') ?>
</div>
</td>
<?php } ?>
</tr>
</table>
ボタンの追加 †
はてなブックマーク ボタン †
<!-- hatebu -->
<a href="http://b.hatena.ne.jp/entry/<?php echo $link['reload'] ?>"
class="hatena-bookmark-button"
data-hatena-bookmark-title="dramsuko wiki"
data-hatena-bookmark-layout="standard-balloon"
title="このエントリーをはてなブックマークに追加">
<img src="http://b.st-hatena.com/images/entry-button/button-only.gif"
alt="このエントリーをはてなブックマークに追加"
width="20"
height="20"
style="border: none;" /></a>
<script type="text/javascript"
src="http://b.st-hatena.com/js/bookmark_button.js"
charset="utf-8"
async="async"></script>
Facebook like ボタン †
<!-- facebook core -->
<span id="fb-root"></span>
<script>(function(d, s, id) {
var js, fjs = d.getElementsByTagName(s)[0];
if (d.getElementById(id)) return;
js = d.createElement(s); js.id = id;
js.src = "//connect.facebook.net/ja_JP/all.js#xfbml=1";
fjs.parentNode.insertBefore(js, fjs);
}(document, 'script', 'facebook-jssdk'));</script>
<!-- /facebook core -->
<script>
<!--
var html = '<div class="fb-like" data-href="'+ encodeURIComponent(document.location) + '" data-send="false" data- layout="button_count" data-width="450" data-show-faces="true"></div>';
document.write(html);
-->
</script>
Twitter 共有ボタン †
<!-- Twitter -->
<a href="https://twitter.com/share" class="twitter-share-button" data-lang="ja">ツイート</a>
<script>!function(d,s,id){
var js,
fjs=d.getElementsByTagName(s) [0],
p=/^http:/.test(d.location)?'http':'https';
if(!d.getElementById(id)){
js=d.createElement(s);
js.id=id;
js.src=p+'://platform.twitter.com/widgets.js';
fjs.parentNode.insertBefore(js,fjs);
}
}(document, 'script', 'twitter-wjs');
</script>
google +1 ボタン †
<!-- google -->
<!-- Place this tag in your head or just before your close body tag. -->
<script type="text/javascript" src="https://apis.google.com/js/plusone.js">
</script>
<!-- Place this tag where you want the +1 button to render. -->
<div class="g-plusone" data-annotation="inline" data-width="300"
data-href="<? php echo $link['reload'] ?>"></div>
共有ボタンの追加 †
<script src="skin/jquery.min.js" type="text/javascript"></script>
<script src="skin/jquery.socialbutton.js" type="text/javascript"></script>
<!-- jquery.socialbutton -->
<style>
.clearfix:after {
content: ".";
display: block;
height: 0;
clear: both;
visibility: hidden;
}
.clearfix {
display: inline-block;
}
/* Hides from IE-mac \*/
* html .clearfix {
height: 1%;
}
.clearfix {
display: block;
}
/* End hide from IE-mac */
.block div {
margin-right: 15px;
float: left;
}
</style>
<script>
$(function() {
$('#evernote').socialbutton('evernote', {
url:document.URL,
button: 'site-mem-22',
styling: 'full'
});
$('#hatena').socialbutton('hatena', {
url:document.URL
});
$('#twitter').socialbutton('twitter', {
url:document.URL,
button: 'horizontal',
text: '',
via: 'YOUR_TWITTER_ID'
});
$('#facebook_like').socialbutton('facebook_like', {
button: 'button_count'
});
$('#google_plusone').socialbutton('google_plusone', {
lang: 'ja',
size: 'medium'
});
});
</script>
<br>
<div class="block clearfix">
<div id="evernote"></div>
<div id="hatena"></div>
<div id="twitter"></div>
<div id="google_plusone"></div>
<div id="facebook_like"></div>
</div>
bodycache 関連 †
patch コマンドによる適用 †
ls
bodycache.patch pukiwiki-1.5.1_utf8.zip
unzip pukiwiki-1.5.1_utf8.zip
cd pukiwiki-1.5.1_utf8
patch -p1 < ../bodycache.patch
reload.inc.php †
- PukiWikiのpluginディレクトリにreload.inc.phpを格納
- 「?cmd=reload&page=ページ名」にアクセス
- 指定したページのキャッシュが再生成
Pukiwiki全部からリンク切れリンクを探す †
[[index.php?plugin=yetlist>http://tar3.net/pukiwiki/index.php?plugin=yetlist]]
Counter 関連 †
Today : &counter(today);~
Yesterday : &counter(yesterday);~
Total : &counter(total);~
表全体を左側へ寄せる †
google analytics †
- vim ./skin/pukiwiki.skin.php
- </head>の前にスクリプトを追加
<?php echo $head_tag ?>
<script type=”text/javascript”>
var _gaq = _gaq || [];
_gaq.push([‘_setAccount’, ‘******’]);
_gaq.push([‘_trackPageview’]);
(function() {
var ga = document.createElement(‘script’); ga.type = ‘text/javascript’; ga.async = true;
ga.src = (‘https:’ == document.location.protocol ? ‘https://ssl’ : ‘http://www’) + ‘.google-analytics.com/ga.js’;
var s = document.getElementsByTagName(‘script’)[0]; s.parentNode.insertBefore(ga, s);
})();
</script>
</head>
pgid †
- pgidというURLから?を抜き数字に置き換えるプラグインがあった。
- 今は公式ページもなく動かない模様
リスト, 見出し, 箇条書きの段数を増やす, 4段以上, 4つ以上, †
参考サイト †
関連ファイルの変更 †
- やりたい事
- 以下の例では6段までに変更
- 水平線は「-を4つ以上並べ、行末まで空白以外の文字が現れない」にルール変更
- 以下のファイルを編集, lib/convert_html.php
- 変更箇所
- 変更前
237 function Heading(& $root, $text)
238 {
239 parent::Element();
240
241 $this->level = min(3, strspn($text, '*'));
242 list($text, $this->msg_top, $this->id) = $root->getAnchor($ text, $this->level);
243 $this->insert(Factory_Inline($text));
244 $this->level++; // h2,h3,h4
245 }
- 変更後
237 function Heading(& $root, $text)
238 {
239 parent::Element();
240
241 $this->level = min(6, strspn($text, '*'));
242 list($text, $this->msg_top, $this->id) = $root->getAnchor($ text, $this->level);
243 $this->insert(Factory_Inline($text));
244 $this->level++; // h2,h3,h4
245 }
- 変更箇所
- 変更前
307 $this->tag = $tag;
308 $this->tag2 = $tag2;
309 $this->level = min(3, strspn($text, $head));
310 $text = ltrim(substr($text, $this->level));
311
312 parent::insert(new ListElement($this->level, $tag2));
313 if ($text != '')
314 $this->last = & $this->last->insert(Factory_Inline( $text));
- 変更後
307 $this->tag = $tag;
308 $this->tag2 = $tag2;
309 $this->level = min(6, strspn($text, $head));
310 $text = ltrim(substr($text, $this->level));
311
312 parent::insert(new ListElement($this->level, $tag2));
313 if ($text != '')
314 $this->last = & $this->last->insert(Factory_Inline( $text));
- 変更箇所
- 変更前
426 parent::Element();
427
428 $head = substr($text, 0, 1);
429 $this->level = min(3, strspn($text, $head));
430 $text = ltrim(substr($text, $this->level));
- 変更後
426 parent::Element();
427
428 $head = substr($text, 0, 1);
429 $this->level = min(6, strspn($text, $head));
430 $text = ltrim(substr($text, $this->level));
- 変更箇所
- 変更前
864 // Horizontal Rule
865 if (substr($line, 0, 4) == '----') {
866 $this->insert(new HRule($this, $line));
867 continue;
868 }
- 変更後
864 // Horizontal Rule
865 if (preg_match('/^-{4,}\s*$/', $line)) {
866 $this->insert(new HRule($this, $line));
867 continue;
868 }
- 以下のファイルを編集, lib/html.php
- 変更箇所(2個所)
- 変更前
453 // Cut fixed-heading anchors
454 $id = '';
455 $matches = array();
456 if (preg_match('/^(\*{0,3})(.*?)\[#([A-Za-z][\w-]+)\](.*?)$/m', $str , $matches)) {
457 $str = $matches[2] . $matches[4];
458 $id = & $matches[3];
459 } else {
460 $str = preg_replace('/^\*{0,3}/', '', $str);
461 }
- 変更後
453 // Cut fixed-heading anchors
454 $id = '';
455 $matches = array();
456 if (preg_match('/^(\*{0,6})(.*?)\[#([A-Za-z][\w-]+)\](.*?)$/m', $str , $matches)) {
457 $str = $matches[2] . $matches[4];
458 $id = & $matches[3];
459 } else {
460 $str = preg_replace('/^\*{0,6}/', '', $str);
461 }
- 以下のファイルを編集, plugin/pcomment.inc.php
- vim plugin/pcomment.inc.php
- 変更箇所(2個所)
- 変更前
237 // Find the comment to reply
238 $level = 1;
239 $b_reply = FALSE;
240 if ($reply_hash != '') {
241 while ($end_position < $count) {
242 $matches = array();
243 if (preg_match('/^(\-{1,2})(?!\-)(.*)$/', $postdata[$end_position++], $matches)
244 && md5($matches[2]) === $reply_hash)
245 {
246 $b_reply = TRUE;
247 $level = strlen($matches[1]) + 1;
248
249 while ($end_position < $count) {
250 if (preg_match('/^(\-{1,3})(?!\-)/', $postdata[$end_position], $matches)
251 && strlen($matches[1]) < $level) break;
252 ++$end_position;
253 }
254 break;
255 }
256 }
257 }
- 変更後
237 // Find the comment to reply
238 $level = 1;
239 $b_reply = FALSE;
240 if ($reply_hash != '') {
241 while ($end_position < $count) {
242 $matches = array();
243 if (preg_match('/^(\-+)(.*)$/', $postdata[$end_position++], $matches)
244 && md5($matches[2]) === $reply_hash)
245 {
246 $b_reply = TRUE;
247 $level = strlen($matches[1]) + 1;
248
249 while ($end_position < $count) {
250 if (preg_match('/^(\-+)/', $postdata[$end_position], $matches)
251 && strlen($matches[1]) < $level) break;
252 ++$end_position;
253 }
254 break;
255 }
256 }
257 }
- 変更箇所
- 変更前
343 // Get latest N comments
344 $num = $cnt = 0;
345 $cmts = $matches = array();
346 if ($dir) $data = array_reverse($data);
347 foreach ($data as $line) {
348 if ($count > 0 && $dir && $cnt == $count) break;
349
350 if (preg_match('/^(\-{1,2})(?!\-)(.+)$/', $line, $matches)) {
351 if ($count > 0 && strlen($matches[1]) == 1 && ++$cnt > $count) break;
352
353 // Ready for radio-buttons
354 if ($reply) {
355 ++$num;
356 $cmts[] = $matches[1] . "\x01" . $num . "\x02" .
357 md5($matches[2]) . "\x03" . $matches[2] . "\n";
- 変更後
343 // Get latest N comments
344 $num = $cnt = 0;
345 $cmts = $matches = array();
346 if ($dir) $data = array_reverse($data);
347 foreach ($data as $line) {
348 if ($count > 0 && $dir && $cnt == $count) break;
349
350 if (preg_match('/^(\-+)(.+)$/', $line, $matches)) {
351 if ($count > 0 && strlen($matches[1]) == 1 && ++$cnt > $count) break;
352
353 // Ready for radio-buttons
354 if ($reply) {
355 ++$num;
356 $cmts[] = $matches[1] . "\x01" . $num . "\x02" .
357 md5($matches[2]) . "\x03" . $matches[2] . "\n";
テスト †
- テスト,a
- b
- c
- d
- e
- f
- + g
- ++ h
- テスト,A
- 水平線
- 見出し
test 1 †
test 2 †
test 3 †
test 4 †
test 5 †
test 6 †
* test 7 †
トラブル関連 †
pkwk_chown(): flock() failed 対応 †
- file.phpの598行目の$ffile = fopen($filename, 'r') orの'r'を'w+'に変更
pgid plugin,htaccess 記述内容 †
pukiwiki ユーザー認証有効後、ページロードが終わらない †
以下2つの機能を有効にするとページの読み込みが終わらなくなる †
- cache
- counter
- プラグインをリネーム
- plugin/counter.inc.php
|->plugin/counter.inc.php.bak
- pgid
エスケープ, 文字整形関連 †
行頭チルダのエスケープ(チルダを2つ書く) †
{ 及び } のエスケープ †
表内 | のエスケープ †
表内先頭 ~ のエスケープ †
- 空白を頭に付ける。|~abc| -> | ~abc|
表内の改行 †
タブを表示 †
&t;
Tips †
ページ内リンクは改行できない †
画像関連 †
ref †
- 書式
#ref(
ページ名/添付ファイル名|
添付ファイル名[,ページ名]|
URL
{,
[left|center|right],
[wrap|nowrap],
[around],
[noicon],
[noimg],
[nolink],
[zoom],
[999x999],
[999%]
}
[,タイトル]
)
&ref(
ページ名/添付ファイル名|
添付ファイル名[,ページ名]|
URL
{,
[noicon],
[noimg],
[nolink],
[zoom],
[999x999],
[999%]
}
[,タイトル]
);
- 概要
'#attach'でページに添付されたファイルを指定位置に展開します。添付ファイルが画像の場合は画像を表示し、それ以外の場合はダウンロード用のリンクを表示します。
- 引数
添付ファイル名にはページに添付したファイル名を指定します(省略時はエラーとなります)。別ページ名/添付ファイル名とする事で別ページの添付ファイルも指定できます。ページ名を相対指定する事が可能です。
ページ名にはファイルを添付したページをWikiNameかBracketNameで指定、または相対指定します。このオプションは最初(添付ファイル名の次)に記述してください。省略時は設置したページです。
パラメータにはファイルの展開方法を指定できます。
- left|center|right − 表示時の位置を指定します。省略時はleft(変更可)です。
- wrap|nowrap − テーブルタグで囲む/囲まないの指定を行います。省略時はnowrap(変更可)です。
- around − テキストの回り込みを可能とします。省略時は回り込みを行いません。
- noicon − ファイルが画像以外の場合に表示されるアイコンを表示しません。省略時は表示します。
- noimg − ファイルが画像の場合に画像を展開しないようにします。省略時は展開します。
- nolink − 元ファイルへのリンクを張らないようにします。省略時はリンクします。
- zoom − 縦横比を保持します。省略時はサイズ指定に従います。
- 999x999 − サイズを指定します(幅x高さ)。省略時は拡大率あるいは対象画像のサイズに従います。
- 999% − サイズを指定(拡大率)します。省略時は100%です、
- タイトル − 上記以外のパラメータは画像の代替文字列、リンクのタイトル属性として使用されます。ページ名やパラメータに見える文字列を使用するときは、#ref(hoge.png,,zoom)のようにタイトルの前にカンマを余分に入れます。
- プラグイン内設定
- PLUGIN_REF_USAGE 引数未指定時に表示されるヘルプ
- PLUGIN_REF_IMAGE マッチ時に指定ファイルを画像とみなす正規表現
- FILE_ICON アイコンイメージのファイル
- PLUGIN_REF_DEFAULT_ALIGN left,center,right省略時の表示位置
- PLUGIN_REF_WRAP_TABLE wrap,nowrap省略時にテーブルタグで囲むか
- PLUGIN_REF_URL_GET_IMAGE_SIZE URL指定時に画像サイズを取得するか
- PLUGIN_REF_DIRECT_ACCESS 添付ファイルの画像表示で UPLOAD_DIR のデータに直接アクセスするか
- 備考
PKWK_DISABLE_INLINE_IMAGE_FROM_URI が有効の場合、「URLであるかのように見えるURIによって、外部の画像をインライン表示させようとする行為」が無効化されます。
aroundで行った回り込み指定を解除するには clear?プラグイン、あるいはimg?プラグインを使用して下さい。
"ほげ"という別ページの添付ファイル"fuga.jpg"をインラインプラグイン形式で参照する場合、下記2通りの記述方法が存在します。
(1) &ref(ほげ/fuga.jpg);
(2) &ref(fuga.jpg,[[ほげ]]);
上記2通りの記述のうち、(2)の記述方式は旧バージョンと互換性を維持するために用意されたもので、推奨される記述方式は(1)です。
いずれの記述方法であっても一般的な動作は同じですが、いわゆるバナー画像のように表示した画像が別ページへのリンクとなるよう以下の指定をした場合、
(1) [[&ref(ほげ/fuga.jpg,nolink,ウェブ名);>ウェブのURL]]
(2) [[&ref(fuga.jpg,[[ほげ]],nolink,ウェブ名);>ウェブのURL]]
(1)の記述方法は期待通りの動作をしますが、(2)の記述方法ではうまくリンクされません。
また、ほげというページに添付された画像を、そのページ内でサイズ指定用パラメータを設定して(例えば半分の比率で)表示する場合、
(3) &ref(./fuga.jpg,50%);
(4) &ref(ほげ/fuga.jpg,50%);
(5) &ref(fuga.jpg,[[ほげ]],50%);
(6) &ref(fuga.jpg,50%);
(3)〜(5)は期待通りに同じ結果をしますが、(6)はエラーとなります。
これは(6)の書式が(2)の記述方式と同じであるため、添付ファイル名fuga.jpgの次の引数にページ名を期待するためです。
(7) &ref(fuga.jpg);
(7)は(6)と似た記述ですが、添付ファイル名の次の引数が省略されているため、エラーにはなりません。