- 追加された行はこの色です。
- 削除された行はこの色です。
#author("2020-11-07T10:09:58+09:00","default:dramsukohome","dramsukohome")
#author("2022-03-06T14:07:25+09:00","default:dramsukohome","dramsukohome")
[[その他]]
#shadowheader(1,pukiwiki tips);
#contents
* 機能追加 [#wcaa318b]
** MenuBar を 右側にも表示 [#d962cf92]
- 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>
- 参考~
[[ページ右側にもMenuBarがほしいです。>http://pukiwiki.sourceforge.jp/dev/?BugTrack%2F430]]
** ボタンの追加 [#dfc33a62]
*** はてなブックマーク ボタン [#gc3ea820]
<!-- 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>
-参考
--[[はてなブックマークボタンの作成・設置について:http://b.hatena.ne.jp/guide/bbutton]]
*** Facebook like ボタン [#hcd2fedb]
<!-- 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>
-参考
--[[Open Graph Overview - Facebook開発者:https://developers.facebook.com/docs/reference/plugins/like/]]
*** Twitter 共有ボタン [#d3fbe67c]
<!-- 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>
-参考
--[[ツイートボタン:https://twitter.com/about/resources/buttons]]
*** google +1 ボタン [#o1263ecd]
<!-- 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>
-参考
-- [[+1 Button - Google+ Platform — Google Developers:https://developers.google.com/+/web/+1button/?hl=ja]]
*** 共有ボタンの追加 [#jf43aad4]
-参考リンク
-- [[jQuery.socialbutton プラグインでソーシャルリンクボタンを付ける:http://dexlab.net/pukiwiki/index.php?Memo%2FWiki]]
-- [[Pinterest/Google+1/Twitter/facebookいいね!/facebook Share/mixiチェック/mixiイイネ!/GREEいいね/Evernote/はてブのボタンを超カンタンに作れる jQuery.socialbutton プラグインを作ったよ:http://itra.jp/jquery_socialbutton_plugin/]]
<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 関連 [#p7e19573]
-[[PukiWiki bodycache改良版:http://jasmin.sakura.ne.jp/blog/PukiWiki/bodycache_kai]]
***patch コマンドによる適用 [#t4f4feb8]
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 [#h5db09a2]
+PukiWikiのpluginディレクトリにreload.inc.phpを格納
+「?cmd=reload&page=ページ名」にアクセス
+指定したページのキャッシュが再生成
** Pukiwiki全部からリンク切れリンクを探す [#s2769a5b]
[[index.php?plugin=yetlist>http://tar3.net/pukiwiki/index.php?plugin=yetlist]]
** Counter 関連 [#t7a72620]
Today : &counter(today);~
Yesterday : &counter(yesterday);~
Total : &counter(total);~
** 表全体を左側へ寄せる [#n73250cc]
- vim /skin/pukiwiki.css.php
.style_table {
padding:0px;
border:0px;
//margin:auto; ←を削る
margin:1em auto 1em 0; //←を追加
** google analytics [#xdd6c612]
-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 [#n3ea30ad]
-pgidというURLから?を抜き数字に置き換えるプラグインがあった。
-今は公式ページもなく動かない模様
** リスト, 見出し, 箇条書きの段数を増やす, 4段以上, 4つ以上, [#p1bf9671]
*** 参考サイト [#m2cf6d2e]
-[[見出しを5段まで、リスト階層を無制限に:https://pukiwiki.osdn.jp/dev/?PukiWiki/1.4/%E3%81%A1%E3%82%87%E3%81%A3%E3%81%A8%E4%BE%BF%E5%88%A9%E3%81%AB/%E8%A6%8B%E5%87%BA%E3%81%97%E3%81%A8%E3%83%AA%E3%82%B9%E3%83%88%E3%81%AE%E6%8B%A1%E5%BC%B5]]
*** 関連ファイルの変更 [#tc8f1f5f]
-やりたい事
-- 以下の例では6段までに変更
-- 水平線は「-を4つ以上並べ、行末まで空白以外の文字が現れない」にルール変更
+ 以下のファイルを編集, lib/convert_html.php
-- vim lib/convert_html.php
++ 変更箇所
--- 変更前~
237 function Heading(& $root, $text)~
238 {~
239 parent::Element();~
240~
&color(blue,){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~
&color(red,){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;~
&color(blue,){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;~
&color(red,){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 &color(blue,){$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 &color(red,){$this->level = min(''6'', strspn($text, $head));};~
430 $text = ltrim(substr($text, $this->level));~
++変更箇所
--- 変更前~
864 // Horizontal Rule~
865 &color(blue,){if (substr($line, 0, 4) == '----') {};~
866 $this->insert(new HRule($this, $line));~
867 continue;~
868 }~
--- 変更後~
864 // Horizontal Rule~
865 &color(blue,){if ''(preg_match('/^-{4,}\s*$/', $line)'') {};~
866 $this->insert(new HRule($this, $line));~
867 continue;~
868 }~
+ 以下のファイルを編集, lib/html.php
-- vim lib/html.php
++ 変更箇所(2個所)
--- 変更前~
453 // Cut fixed-heading anchors~
454 $id = '';~
455 $matches = array();~
456 &color(blue,){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 &color(blue,){$str = preg_replace('/^\*{0,''3''}/', '', $str);};~
461 }~
--- 変更後~
453 // Cut fixed-heading anchors~
454 $id = '';~
455 $matches = array();~
456 &color(red,){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 &color(red,){$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 &color(blue,){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 &color(blue,){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 &color(red,){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 &color(red,){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 &color(blue,){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 &color(red,){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";~
*** テスト [#o5f38dae]
+テスト,a
++ b
+++ c
++++ d
+++++ e
++++++ f
+++++++ g
++++++++ h
+テスト,A
-- B
--- C
---- D
----- E
------ F
------- G
-------- H
+水平線
----
+見出し
* test 1 [#da61f24f]
** test 2 [#uc1ee423]
*** test 3 [#z0b9f75a]
**** test 4 [#w0b4e4bc]
***** test 5 [#g4c90930]
****** test 6 [#g4c90930]
******* test 7 [#g4c90930]
* トラブル関連 [#f7874506]
** pkwk_chown(): flock() failed 対応 [#y292f39c]
- file.phpの598行目の$ffile = fopen($filename, 'r') orの'r'を'w+'に変更
** pgid plugin,htaccess 記述内容 [#p7f13259]
-ただし今はトラブルありで未使用(180930)
RewriteEngine on
RewriteRule ^([0-9]*)\.html$ index.php?plugin=pgid&id=$1
** pukiwiki ユーザー認証有効後、ページロードが終わらない [#oc49a572]
-「$edit_auth = 1;」を設定した後、pukiwikiページが表示されない
-認証方法を変更したら解決
$auth_type = AUTH_TYPE_BASIC;
** 以下2つの機能を有効にするとページの読み込みが終わらなくなる [#n351f8d4]
+cache
+counter
--プラグインをリネーム
---plugin/counter.inc.php~
|->plugin/counter.inc.php.bak
+pgid
* エスケープ, 文字整形関連 [#g1c4ff67]
** 行頭チルダのエスケープ(チルダを2つ書く) [#xd9db4b4]
- 例: ~~/.bashrc
** { 及び } のエスケープ [#o7624525]
- {
{
- }
}
** 表内 | のエスケープ [#ud8abda1]
- |
|
** 表内先頭 ~ のエスケープ [#ud8abda1]
- 空白を頭に付ける。|~abc| -> | ~abc|
** 表内の改行 [#cff5fd89]
-以下を使う。
&br;
** タブを表示 [#e0146e28]
&t;
* Tips [#d1b12a65]
** ページ内リンクは改行できない [#b87606a0]
- [[ ]]の中。
** 画像関連 [#id2a2ea7]
***ref [#pc9e417b]
-種別
--ブロック型プラグイン
--インライン型プラグイン
-書式
~''#ref(''
&color(blue){ページ名/添付ファイル名};|
&color(blue){添付ファイル名};[,&color(blue){ページ名};]|
&color(blue){URL};
{,
[&color(blue){left};|&color(blue){center};|&color(blue){right};],
[&color(blue){wrap};|&color(blue){nowrap};],
[&color(blue){around};],
[&color(blue){noicon};],
[&color(blue){noimg};],
[&color(blue){nolink};],
[&color(blue){zoom};],
[&color(blue){999x999};],
[&color(blue){999%};]
}
[,&color(blue){タイトル};]
'')''
~''&ref(''
&color(blue){ページ名/添付ファイル名};|
&color(blue){添付ファイル名};[,&color(blue){ページ名};]|
&color(blue){URL};
{,
[&color(blue){noicon};],
[&color(blue){noimg};],
[&color(blue){nolink};],
[&color(blue){zoom};],
[&color(blue){999x999};],
[&color(blue){999%};]
}
[,&color(blue){タイトル};]
'');''
:概要|
~'#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>../A-D#v515085f]]プラグイン、あるいは[[img>../H-K#v66d65c4]]プラグインを使用して下さい。
~"ほげ"という別ページの添付ファイル"fuga.jpg"をインラインプラグイン形式で参照する場合、下記2通りの記述方法が存在します。
(1) &ref(ほげ/fuga.jpg);
(2) &ref(fuga.jpg,[[ほげ]]);
~上記2通りの記述のうち、(2)の記述方式は旧バージョンと互換性を維持するために用意されたもので、推奨される記述方式は(1)です。&br;
いずれの記述方法であっても一般的な動作は同じですが、いわゆるバナー画像のように表示した画像が別ページへのリンクとなるよう以下の指定をした場合、
(1) [[&ref(ほげ/fuga.jpg,nolink,ウェブ名);>ウェブのURL]]
(2) [[&ref(fuga.jpg,[[ほげ]],nolink,ウェブ名);>ウェブのURL]]
(1)の記述方法は期待通りの動作をしますが、(2)の記述方法ではうまくリンクされません。&br;
また、ほげというページに添付された画像を、そのページ内でサイズ指定用パラメータを設定して(例えば半分の比率で)表示する場合、
(3) &ref(./fuga.jpg,50%);
(4) &ref(ほげ/fuga.jpg,50%);
(5) &ref(fuga.jpg,[[ほげ]],50%);
(6) &ref(fuga.jpg,50%);
(3)〜(5)は期待通りに同じ結果をしますが、(6)はエラーとなります。&br;
これは(6)の書式が(2)の記述方式と同じであるため、添付ファイル名fuga.jpgの次の引数にページ名を期待するためです。
(7) &ref(fuga.jpg);
(7)は(6)と似た記述ですが、添付ファイル名の次の引数が省略されているため、エラーにはなりません。