プログラムなどなど
をテンプレートにして作成
開始行:
#contents
*[[ショウジョウバエ研究会オンライン登録プログラム:http://...
ショウジョウバエ研究会第7回研究集会で使ったオンライン登...
松尾隆嗣さん(東京都立大学)の力を借り、都丸雅敏(京都工...
著作権は松尾と都丸にあります。GNU General Public License ...
*PukiWiki [#a359a032]
** 埋め込みツイートを表示させる 21 September 2020 [#i04d5...
PukiWiki公式ページの
[[欲しいプラグイン/417>https://pukiwiki.osdn.jp/?%E6%AC%B...
「twitterの特定のツイートを貼る(埋め込む)機能」のコメン...
ペナーさんが作成したもの+takayanさんの修正のプラグイン
tweet_inc.inc.php
を plugin ディレクトリにコピー
#tweet_inc(ツイートのURL);
でおっけい。実装は、例えば [[附属図書館のツイートで>tweet...
** レスポンシブデザインに対応する 23 January 2019 [#z2fc7...
基本的な部分は
[[PukiwikiレスポンシブSkin>http://reddog.s35.xrea.com/wik...
に従った。~
加えて、twitter bootstrap にも対応させた。
が、pukiwiki の skin をあまり触らないと bootstrap らしさ...
触ったのは skin と css
メニューをハンバーガー(≡)にするのは難易度が高くてできな...
*** skin [#ddb67b5c]
天下の Google さんの
[[モバイルフレンドリーテスト>https://search.google.com/te...
で不合格とされないために、~
<head> に
- viewport メタタグ
- Bootstrap CSS のおまじない
を追加~
これで、Google のモバイルフレンドリーテストでは合格になり...
が、これだけじゃ不足。<body> 部分も触る必要がある。
<head> 部分
<?php // 23 January 2019 ?>
<?php // from https://getbootstrap.com/docs/4.2/getting...
<meta name="viewport" content="width=device-width, initi...
<!-- Bootstrap CSS -->
<link rel="stylesheet" href="https://stackpath.bootstrap...
<?php // End of 23 January 2019 ?>
<body> 部分その1~
pukiwiki は <table> を利用してレイアウトされている...
<table> タグの部分を削除する。
Before
<?php if ($menu !== FALSE) { ?>
<table border="0" style="width:100%">
<div id="contents">
<tr>
<td class="menubar">
<div id="menubar"><?php echo $menu ?></div>
</td>
<td valign="top">
<div id="body"><?php echo $body ?></div>
</td>
</tr>
</table>
</div>
<?php } else { ?>
<div id="body"><?php echo $body ?></div>
<?php } ?>
After(コメントアウト)
<?php if ($menu !== FALSE) { ?>
<?php // 23 January 2019
// http://reddog.s35.xrea.com/wiki/PukiwikiレスポンシブS...
//<table border="0" style="width:100%">
?>
<div id="contents">
<?php // 23 January 2019
// <tr>
// <td class="menubar">
?>
<div id="menubar"><?php echo $menu ?></div>
<?php // 23 January 2019
// </td>
// <td valign="top">
?>
<div id="body"><?php echo $body ?></div>
<?php // 23 January 2019
// </td>
// </tr>
//</table>
?>
</div>
<?php // end of 23 January 2019 ?>
<?php } else { ?>
<div id="body"><?php echo $body ?></div>
<?php } ?>
After(削除後)
<?php if ($menu !== FALSE) { ?>
<div id="contents">
<div id="menubar"><?php echo $menu ?></div>
<div id="body"><?php echo $body ?></div>
</div>
<?php } else { ?>
<div id="body"><?php echo $body ?></div>
<?php } ?>
<body> 部分その2~
一番下に、bootstrap のおまじないを追加する
<?php // 23 January 2019 ?>
<?php from // https://getbootstrap.com/docs/4.2/getting-...
<!-- Optional JavaScript -->
<!-- jQuery first, then Popper.js, then Bootstrap JS --...
<script src="https://cdnjs.cloudflare.com/ajax/libs/pop...
<script src="https://stackpath.bootstrapcdn.com/bootstr...
<?php // End of 23 January 2019 ?>
*** css [#p182db2d]
幅によって表示が変わるように最後に追加
<?php // 23 January 2019 ?>
<?php // from reddog.s35.xrea.com/wiki/Pukiwikiレスポン...
@media (max-width: 480px)
{
div#contents
{
display:table;
table-layout:fixed;
width:100%;
}
div#menubar
{
display:table-footer-group;
width:100%;
}
div#body
{
display:table-row-group;
width:100%;
}
}
@media (min-width: 481px)
{
div#contents
{
display:table;
table-layout:fixed;
width:100%;
}
div#menubar
{
display:table-cell;
vertical-align:top;
width:120px;
}
div#body
{
display:table-cell;
}
}
@media (min-width: 800px)
{
div#contents
{
display:table;
table-layout:fixed;
width:100%;
}
div#menubar
{
display:table-cell;
vertical-align:top;
width:180px;
}
body
{
// max-width: 800px;
}
}
<?php // End of 23 January 2019 ?>
**自動生成される目次からのアンカーの位置を変更する 13 Feb...
#contents
によって自動的にそのページの目次が生成され、
目次の各項目をクリックすると、
小見出し(* や **、*** のところ)に飛ぶようになる。
しかし、そのリンク先のアンカーが小見出しの最後になってし...
小見出しが長く2行になってしまうようなときには、
「ここはどこ?」「ワタシはダレ」状態になってしまうことが...
そこで、アンカーを小見出しの前に設定するように変更する。
lib/convert_html.php の 947行目、Add heding のところを変...
// Add heding
return array($anchor . $text, $this->count > 1 ? "\n" ....
// return array($text . $anchor, $this->count > 1 ? "\n...
heding は、heading の綴りミスのような気がしないでもないけ...
元々こうなので。
なお、このページは変更はしていませんが、
[[別なページ>https://kyotofly.kit.jp/stocks/documents/]]...
動作確認済み。
** MathJax が使えるようにする 20 February 2015 [#p17c4f49]
参考 [[MathJaxの使い方 by くろきげん>http://genkuroki.web...
pukiwiki.skin.php の <head> と </head> の間に下のコード(...
<script type="text/javascript"
src="http://cdn.mathjax.org/mathjax/latest/MathJax.js?...
</script>
出力例:
コード
\(\sum_{n=1}^\infty \frac{1}{n^2} = \frac{\pi^2}{6}\)
出力~
\(\sum_{n=1}^\infty \frac{1}{n^2} = \frac{\pi^2}{6}\)
コード
\[
\sum_{n=1}^\infty \frac{1}{n^2} = \frac{\pi^2}{6}
\tag{3}
\]
出力~
\[
\sum_{n=1}^\infty \frac{1}{n^2} = \frac{\pi^2}{6}
\tag{3}
\]
くろきさんの、
デフォルトの設定では \( \) のみが使用できるが、このファ...
使えるようにしてある。$ $ がデフォルトの設定で使えないよ...
米語の文書に $ が頻出するからである。日本語で書く場合に...
だと思う。
のコード(下)をそのまま利用すると、地の文に $ が入ってい...
<script type="text/x-mathjax-config">
MathJax.Hub.Config({ tex2jax: { inlineMath: [['$','$']...
</script>
<script type="text/javascript"
src="http://cdn.mathjax.org/mathjax/latest/MathJax.js?...
</script>
<meta http-equiv="X-UA-Compatible" CONTENT="IE=EmulateIE...
**特定のIP addressからしか閲覧できないページを設定する 08...
某センターのサービスページで学内専用が必要と思い立った。~
某お役所が簡単に見たり、&ruby(ま){況};してや、
グーグルさんに提示されたりしたらあまりハッピーじゃない、
という秘密っぽいことが書けるようにしたいのです。
Natsuko's Homepage の
[[PukiWiki/アクセス制限>http://www.ioa.s.u-tokyo.ac.jp/~n...
を参考に設定しました。
ほぼそのままですが、一カ所修正しています。
pukiwiki.ini.php
// Read auth (0:Disable, 1:Enable)
$read_auth = 1;
$read_auth_pages = array(
// Regex Username
);
$read_auth を有効にしないと、IP address による制限ができ...
$read_auth_pages の中身を空にすると、誰でも閲覧可になる。
ので、$read_auth を有効にしても問題ない。
lib/auth.php
Basic authentication (function basic_auth) に追加(2ヶ所)
172行目に追加
Natsuko さんのは、in_array でページ名の一致を見ているコー...
プリフィクス KITdoc があるページは全て学内専用となるよう...
preg_match で判断させました。違いはここだけです。
// 08 June 2013 for access limit page by IP address
$auth_network = '/^133.16./';
$auth_network_pages = '/^KITdoc/';
if (preg_match($auth_network, $_SERVER['REMOTE_AD...
// End of 08 June 2013 for access limit page by IP address
挿入場所
global $auth_method_type, $auth_users, $_msg_auth;
<<ココ!>>
// Checked by:
$target_str = '';
if ($auth_method_type == 'pagename') {
198行目に追加
// 08 June 2013 for access limit page by IP address
} else {
$user_list = array();
$auth_flag = false;
}
// End of 08 June 2013 for access limit page by IP address
挿入場所
global $auth_method_type, $auth_users, $_msg_auth;
// Basic-auth with $_SERVER['HTTP_AUTHORIZATION']
list($_SERVER['PHP_AUTH_USER'], $_SERVER['PHP_AUTH_PW'...
explode(':', base64_decode($matches[1]));
}
<<ココ!>>
if (PKWK_READONLY ||
! isset($_SERVER['PHP_AUTH_USER']) ||
! in_array($_SERVER['PHP_AUTH_USER'], $user_list) ||
! isset($auth_users[$_SERVER['PHP_AUTH_USER']]) ||
pkwk_hash_compute(
どちらも消すものはありません。追加のみ。
真似して、diffの出力も貼り付けときます。
173,179d172
< // 08 June 2013 for access limit page by IP address
< $auth_network = '/^133.16./';
< $auth_network_pages = '/^KITdoc/';
<
< if (preg_match($auth_network, $_SERVER['REMOTE_...
< // End of 08 June 2013 for access limit page by IP add...
<
206,211d198
< // 08 June 2013 for access limit page by IP address
< } else {
< $user_list = array();
< $auth_flag = false;
< }
< // End of 08 June 2013 for access limit page by IP add...
**メニューバー内で単語が途中で改行されないようにする 05 J...
skin/pukiwiki.css.php の div#menubar(CSSの設定)の
word-break の値を break-all から normal に変える
div#menubar{
……略……
word-break:normal;
……略……
}
参考:[[generate_tagsプラグインによるタグを用いたページ分...
**PukiWikiで上付き文字下付き文字 02 August 2009 [#o8844bf0]
[[PukiWiki/1.4/ちょっと便利に/上付き下付き文字>http://puk...
return "<span style=\"font-size:80%;vertical-align:super...
または
return "<span style=\"font-size:80%;vertical-align:sub\"...
これで
Super&super{super}; & Sub&subsc{sub};
とすると右のようになる Super&super{super}; & Sub&subsc{s...
PukiWikiプラスなら、もとからプラグインがあったんですが、...
**WikiNameに自動的なリンクを生成させないようにする 22 Sep...
WikiNameのように大文字が2つ入った単語を、pukiwikiのデフォ...
WikiNameと認識して、リンクを作るようになっています。
そういう名前のページがないと、?がついて、クリックするとペ...
なります。~
ふだん、本文中で新しいWikiNameのページを作るような書き方...
この機能を停止させることにしました。
その結果、「McAfee」、「VirusScan」、「WinEyes」、「OneLo...
pukiwiki.ini.php
/////////////////////////////////////////////////
// _Disable_ WikiName auto-linking
$nowikiname = 1; // 22 September 2007 // 0; -> 1;
**pukiwikiで、静的ページhtmlに偽装する 22 September 2007 ...
pukiwikiの各ページは「index.php?ほにゃほにゃほにゃ」のよ...
いまひとつ。そこで、「ほにゃほにゃほにゃ.html」となるよう...
http://terai.xrea.jp/PukiWiki/RewriteEngine.html のとおり...
もっとワザを使う場合にはいろいろあるようですが、これが一...
これだけにしている。~
実際の設定は、01 July 2006
.htaccess(pukiwiki.ini.php のあるディレクトリのもの)に...
DirectoryIndex index.php
RewriteEngine on
RewriteBase /~tomaru/pukiwiki
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.*)\.html(#.*)?$ index.php?cmd=read&page=$...
※ 追記 2018年4月18日~
なんと、10年以上も書き忘れていました。.htaccess の設定だ...
実際の設定は、01 July 2006
/lib/make_link.php の修正(700行め位 1.4.6、750行め位 1.5...
return $al_left . '<a ' . 'href="' . $sc...
// 01 July 2006
// For Static URL
// http://terai.xrea.jp/PukiWiki/RewriteEngine.html
//
// return $al_left . '<a ' . 'href="' . $sc...
*** virtual host の https でも偽装する 26 April 2018 [#re...
virtual host の ssl のディレクティブ に(vhost-ssl.conf ...
AllowOverride All
などを入れておく。
All の代わりに FileInfo でもいいらしいのですが試していま...
ssl で override できるよう明示的に指示が必要。
80(s 抜き)で AllowOverride を書いておいても、s付きでは...
気付くのに何年も掛かってしまった……。
**PukiWikiで閲覧は誰でも可、編集・新規ページ作成は登録ユ...
pukiwiki.ini.phpの設定(抜粋)
1.$auth_usersを設定する
$auth_users = array(
'foo' => 'foo_passwd', // Cleartext
);
1−2. Authentication methodを変える(これをしないと不...
//$auth_method_type = 'contents'; // By Page contents
$auth_method_type = 'pagename'; // By Page name 02 Apri...
2.$edit_auth を有効にする
$edit_auth = 1;
3.Edit auth regex を設定する(正規表現!)
$edit_auth_pages = array(
'/^.*$/' => 'foo',
);
これで、編集・新規ページ作成のときにBasic認証(のような...
** pukiwiki のバージョンアップ 18 April 2018 [#nb2789ea]
[[https://pukiwiki.osdn.jp/?PukiWiki/Install/アップグレー...
*** 1.4.6 → 1.4.7 [#h597f3e4]
https://pukiwiki.osdn.jp/?PukiWiki/Download/1.4.7
*** 1.4.7 → 1.5.0 [#sa3dc893]
https://pukiwiki.osdn.jp/?PukiWiki/Install/Update/1.5.0
*** 1.5.0 → 1.5.1 [#v7583043]
https://pukiwiki.osdn.jp/?PukiWiki/Install/Update/1.5.1
*php: hypertext processor その2 [#q634042d]
**ファイルの「ダウンロードダイアログ」が常に開くようにす...
某センターの内部利用のウェブページにて、
テキストファイルを「ダウンロード」する必要がある。
必ずダウンロードしなければならないので、
右クリックさせるのはよくない設計。
ボタンをクリックしたらダイアログが開くのがよい。
テキストファイルは php が生成したものなので、php で作った。
が、しかし、その方法がわからず……
結論としては、
Content-Disposition: attachment; filename=fname.ext
だそうな。~
[[[HOWTO] 既知の MIME タイプに対し [ファイルのダウンロ...
で、実装は……、
<?php
$myfile = $_GET['file'];
$myid = $_GET['id'];
$mydate = date('Y-m-d');
header('Content-Disposition: attachment; (← 実際はココ...
filename="'.$mydate.'-'.$myfile.'-'.$myid.'.txt"');
readfile($myfile.'.txt');
exit;
?>
(↑これが全てです)
との php ファイルを form で呼び出す。
<form action="download.php?file=return&id=<?php echo $my...
<input type="submit" value="ファイルをダウンロードする">
</form>
(抜粋です)
ダウンロード用の php ファイルが呼び出されると、
サーバにあるテキストファイルを
「日付-名前-ID.txt」とのファイル名で
ダウンロードするダイアログが開く。
という具合です。
formの側で、名前と id を post 渡ししているので、
ちょっとだけ使い回しができています。
他に参考にしたもの
- [[phpの関数のマニュアル(header)>http://php.net/manual...
- [[エンジニアさんの「Tipsというかメモ」というページの記...
-[[KJさんのブログ PHPでファイルをDLさせる際のPHPコード...
*php: hypertext processor [#v5e8f85e]
ちょっとだけ、phpのコードがあります。ショウジョウバエ遺伝...
ショウジョウバエ遺伝資源センターでは、ユーザがのストック...
検索し、そのなかから複数の系統を一時的に記憶し、最後に確...
ストックリストは、リレーショナルデータベースの postgreSQL...
Under construction (ちょっと待って...
そのほかのことも。
1. ブラウザの判定:<button> </button> が使えるブラウザを...
$str = $HTTP_USER_AGENT;
$dgrc_browser;
if(eregi("MSIE", $str) || eregi("Netscape6", $str)) {
$dgrc_browser="IENN6";
} else {
$dgrc_browser="NN4";
}
*html tips [#g14f4de6]
html のちょっとしたこと(小技?)を
上のようにして、ストックを検索するページを作るときに、結...
1. 別なサイトから呼び出されたときに、フレームの中では開か...
<script language="JavaScript">
<!--
if(self != top){
top.location.href = self.location.href;
}
//-->
</script>
2. 文字セットをISO 8859-1(=Latin1)にする。下のコードを...
<meta http-equiv="Content-Type" content="text/html;...
3. ○秒後に別なページへ飛ぶ。下のコードを <head> </head> ...
<meta http-equiv="Refresh" content="3; URL=移動先の...
この例では3秒後に移動する。
4. プロポーショナルフォントを使わないようにする。 <tt> と...
<tt>non proportional</tt> ← プロポーショナルフォン...
proportional ← プロポーショナルフォントになる(tとi...
プロポーショナルフォントを使わないようにブラウザを設定し...
*shell script [#o8e5bf5b]
**htmlファイルを加工する 4th April 2008 [#d6e64187]
下のようなhtmlファイル(ファイル名:P001.html:具体的には...
|<html>|BGCOLOR(fuchsia):head.htmlと差し替え|
|<head>|BGCOLOR(fuchsia): |
|……|BGCOLOR(fuchsia): |
|<…… shift_jis ……>|BGCOLOR(fuchsia): |
|……|BGCOLOR(lime):残す(upper.html)|
|</head>|BGCOLOR(lime): |
|<body>|BGCOLOR(fuchsia):P001title.htmlと差し替え|
|……|BGCOLOR(lime):残す(lower.html)|
|</body>|BGCOLOR(fuchsia):tail.htmlと差し替え|
|</html>|BGCOLOR(fuchsia): |
-shell script
#!sh
grep -A 10000 "shift_jis" P001.html >temp01.html;
grep -v "shift_jis" temp01.html >temp1.html;
grep -B 10000 "<body" temp1.html > temp0.html;
grep -v "<body" temp0.html> upper.html;
grep -A 10000 "<body" temp1.html > temp2.html;
grep -v "<body" temp2.html > temp22.html;
grep -v "</body" temp22.html > temp23.html;
grep -v "</html" temp23.html > lower.html;
cat head.html upper.html P001title.html lower.html tail....
sed -e s/"str border=0"/"str border=1"/g temp3.html> tem...
nkf --utf8 -Lu temp4.html > P001.html
-grepを使って、必要部分を切り出す -> upper.html と lower....
grep -A num 文字列: 文字列とその下num行を表示
grep -v 文字列: 文字列を含まない行のみ表示
grep -B num 文字列: 文字列とその上num行を表示
-あらかじめ作っておいたファイル(head.html、P001title.htm...
-一部文字列を修正する(sed: s/文字列1/文字列2/g は、per...
-文字コードをutf-8に変更する
※ shell scriptを使う場合、パイプが働かないので注意
**拡張子追加 4th April 2008 [#wfe37afc]
ファイル名がPではじまるものに、拡張子「.txt」を追加
#!sh
for num in P*;
do
mv $num ${num}.txt;
done
* そのほか [#f2ee36da]
** ファイルを検索する 29th April 2016 [#p6c6a913]
スーパーユーザ権限を使って、マシンの全ディスク内にある st...
という名前を含むファイルをリストアップする
$ sudo find / -name "*struts*"
$ sudo find / -iname "*struts*" ← 大文字小文字を区別しない
*perl [#e81a8f91]
**URIのリストから、それへのリンク付きのリストのhtmlファイ...
こんな感じのリスト(下)をリンク付きのリストのhtmlファイ...
in.txt
http://www.kit.ac.jp/
http://www.yahoo.co.jp/
http://www.google.co.jp/
makelink.pl
#!perl
print "<html>\n";
print "<body>\n";
print "<ul>\n";
while(<>){
chop;
print "<li><a href=\"$_\" target=\"_blank\">$_</a>\n";
}
print "</ul>\n";
print "</html>\n";
print "</body>\n";
使い方
perl makelink.pl <in.txt >out.txt
メールに貼り付けて Thunderbird ででも受け取ればできちゃう...
**タブ区切りテキストからカラムを抜き出す 16th March 2009 ...
タブ区切りテキストの「2列目」と「5列目」を抜き出す
first2and5.pl
#!perl
while(<>){
chop;
split /[\t]/;
print "@_[1]\t@_[4]\n";
}
使い方
perl first2and5.pl <in.txt >out.txt
これで26めがのファイルから必要な部分が取り出せて、1めがに...
|Today:&counter(today);|Yesterday:&counter(yesterday);|To...
終了行:
#contents
*[[ショウジョウバエ研究会オンライン登録プログラム:http://...
ショウジョウバエ研究会第7回研究集会で使ったオンライン登...
松尾隆嗣さん(東京都立大学)の力を借り、都丸雅敏(京都工...
著作権は松尾と都丸にあります。GNU General Public License ...
*PukiWiki [#a359a032]
** 埋め込みツイートを表示させる 21 September 2020 [#i04d5...
PukiWiki公式ページの
[[欲しいプラグイン/417>https://pukiwiki.osdn.jp/?%E6%AC%B...
「twitterの特定のツイートを貼る(埋め込む)機能」のコメン...
ペナーさんが作成したもの+takayanさんの修正のプラグイン
tweet_inc.inc.php
を plugin ディレクトリにコピー
#tweet_inc(ツイートのURL);
でおっけい。実装は、例えば [[附属図書館のツイートで>tweet...
** レスポンシブデザインに対応する 23 January 2019 [#z2fc7...
基本的な部分は
[[PukiwikiレスポンシブSkin>http://reddog.s35.xrea.com/wik...
に従った。~
加えて、twitter bootstrap にも対応させた。
が、pukiwiki の skin をあまり触らないと bootstrap らしさ...
触ったのは skin と css
メニューをハンバーガー(≡)にするのは難易度が高くてできな...
*** skin [#ddb67b5c]
天下の Google さんの
[[モバイルフレンドリーテスト>https://search.google.com/te...
で不合格とされないために、~
<head> に
- viewport メタタグ
- Bootstrap CSS のおまじない
を追加~
これで、Google のモバイルフレンドリーテストでは合格になり...
が、これだけじゃ不足。<body> 部分も触る必要がある。
<head> 部分
<?php // 23 January 2019 ?>
<?php // from https://getbootstrap.com/docs/4.2/getting...
<meta name="viewport" content="width=device-width, initi...
<!-- Bootstrap CSS -->
<link rel="stylesheet" href="https://stackpath.bootstrap...
<?php // End of 23 January 2019 ?>
<body> 部分その1~
pukiwiki は <table> を利用してレイアウトされている...
<table> タグの部分を削除する。
Before
<?php if ($menu !== FALSE) { ?>
<table border="0" style="width:100%">
<div id="contents">
<tr>
<td class="menubar">
<div id="menubar"><?php echo $menu ?></div>
</td>
<td valign="top">
<div id="body"><?php echo $body ?></div>
</td>
</tr>
</table>
</div>
<?php } else { ?>
<div id="body"><?php echo $body ?></div>
<?php } ?>
After(コメントアウト)
<?php if ($menu !== FALSE) { ?>
<?php // 23 January 2019
// http://reddog.s35.xrea.com/wiki/PukiwikiレスポンシブS...
//<table border="0" style="width:100%">
?>
<div id="contents">
<?php // 23 January 2019
// <tr>
// <td class="menubar">
?>
<div id="menubar"><?php echo $menu ?></div>
<?php // 23 January 2019
// </td>
// <td valign="top">
?>
<div id="body"><?php echo $body ?></div>
<?php // 23 January 2019
// </td>
// </tr>
//</table>
?>
</div>
<?php // end of 23 January 2019 ?>
<?php } else { ?>
<div id="body"><?php echo $body ?></div>
<?php } ?>
After(削除後)
<?php if ($menu !== FALSE) { ?>
<div id="contents">
<div id="menubar"><?php echo $menu ?></div>
<div id="body"><?php echo $body ?></div>
</div>
<?php } else { ?>
<div id="body"><?php echo $body ?></div>
<?php } ?>
<body> 部分その2~
一番下に、bootstrap のおまじないを追加する
<?php // 23 January 2019 ?>
<?php from // https://getbootstrap.com/docs/4.2/getting-...
<!-- Optional JavaScript -->
<!-- jQuery first, then Popper.js, then Bootstrap JS --...
<script src="https://cdnjs.cloudflare.com/ajax/libs/pop...
<script src="https://stackpath.bootstrapcdn.com/bootstr...
<?php // End of 23 January 2019 ?>
*** css [#p182db2d]
幅によって表示が変わるように最後に追加
<?php // 23 January 2019 ?>
<?php // from reddog.s35.xrea.com/wiki/Pukiwikiレスポン...
@media (max-width: 480px)
{
div#contents
{
display:table;
table-layout:fixed;
width:100%;
}
div#menubar
{
display:table-footer-group;
width:100%;
}
div#body
{
display:table-row-group;
width:100%;
}
}
@media (min-width: 481px)
{
div#contents
{
display:table;
table-layout:fixed;
width:100%;
}
div#menubar
{
display:table-cell;
vertical-align:top;
width:120px;
}
div#body
{
display:table-cell;
}
}
@media (min-width: 800px)
{
div#contents
{
display:table;
table-layout:fixed;
width:100%;
}
div#menubar
{
display:table-cell;
vertical-align:top;
width:180px;
}
body
{
// max-width: 800px;
}
}
<?php // End of 23 January 2019 ?>
**自動生成される目次からのアンカーの位置を変更する 13 Feb...
#contents
によって自動的にそのページの目次が生成され、
目次の各項目をクリックすると、
小見出し(* や **、*** のところ)に飛ぶようになる。
しかし、そのリンク先のアンカーが小見出しの最後になってし...
小見出しが長く2行になってしまうようなときには、
「ここはどこ?」「ワタシはダレ」状態になってしまうことが...
そこで、アンカーを小見出しの前に設定するように変更する。
lib/convert_html.php の 947行目、Add heding のところを変...
// Add heding
return array($anchor . $text, $this->count > 1 ? "\n" ....
// return array($text . $anchor, $this->count > 1 ? "\n...
heding は、heading の綴りミスのような気がしないでもないけ...
元々こうなので。
なお、このページは変更はしていませんが、
[[別なページ>https://kyotofly.kit.jp/stocks/documents/]]...
動作確認済み。
** MathJax が使えるようにする 20 February 2015 [#p17c4f49]
参考 [[MathJaxの使い方 by くろきげん>http://genkuroki.web...
pukiwiki.skin.php の <head> と </head> の間に下のコード(...
<script type="text/javascript"
src="http://cdn.mathjax.org/mathjax/latest/MathJax.js?...
</script>
出力例:
コード
\(\sum_{n=1}^\infty \frac{1}{n^2} = \frac{\pi^2}{6}\)
出力~
\(\sum_{n=1}^\infty \frac{1}{n^2} = \frac{\pi^2}{6}\)
コード
\[
\sum_{n=1}^\infty \frac{1}{n^2} = \frac{\pi^2}{6}
\tag{3}
\]
出力~
\[
\sum_{n=1}^\infty \frac{1}{n^2} = \frac{\pi^2}{6}
\tag{3}
\]
くろきさんの、
デフォルトの設定では \( \) のみが使用できるが、このファ...
使えるようにしてある。$ $ がデフォルトの設定で使えないよ...
米語の文書に $ が頻出するからである。日本語で書く場合に...
だと思う。
のコード(下)をそのまま利用すると、地の文に $ が入ってい...
<script type="text/x-mathjax-config">
MathJax.Hub.Config({ tex2jax: { inlineMath: [['$','$']...
</script>
<script type="text/javascript"
src="http://cdn.mathjax.org/mathjax/latest/MathJax.js?...
</script>
<meta http-equiv="X-UA-Compatible" CONTENT="IE=EmulateIE...
**特定のIP addressからしか閲覧できないページを設定する 08...
某センターのサービスページで学内専用が必要と思い立った。~
某お役所が簡単に見たり、&ruby(ま){況};してや、
グーグルさんに提示されたりしたらあまりハッピーじゃない、
という秘密っぽいことが書けるようにしたいのです。
Natsuko's Homepage の
[[PukiWiki/アクセス制限>http://www.ioa.s.u-tokyo.ac.jp/~n...
を参考に設定しました。
ほぼそのままですが、一カ所修正しています。
pukiwiki.ini.php
// Read auth (0:Disable, 1:Enable)
$read_auth = 1;
$read_auth_pages = array(
// Regex Username
);
$read_auth を有効にしないと、IP address による制限ができ...
$read_auth_pages の中身を空にすると、誰でも閲覧可になる。
ので、$read_auth を有効にしても問題ない。
lib/auth.php
Basic authentication (function basic_auth) に追加(2ヶ所)
172行目に追加
Natsuko さんのは、in_array でページ名の一致を見ているコー...
プリフィクス KITdoc があるページは全て学内専用となるよう...
preg_match で判断させました。違いはここだけです。
// 08 June 2013 for access limit page by IP address
$auth_network = '/^133.16./';
$auth_network_pages = '/^KITdoc/';
if (preg_match($auth_network, $_SERVER['REMOTE_AD...
// End of 08 June 2013 for access limit page by IP address
挿入場所
global $auth_method_type, $auth_users, $_msg_auth;
<<ココ!>>
// Checked by:
$target_str = '';
if ($auth_method_type == 'pagename') {
198行目に追加
// 08 June 2013 for access limit page by IP address
} else {
$user_list = array();
$auth_flag = false;
}
// End of 08 June 2013 for access limit page by IP address
挿入場所
global $auth_method_type, $auth_users, $_msg_auth;
// Basic-auth with $_SERVER['HTTP_AUTHORIZATION']
list($_SERVER['PHP_AUTH_USER'], $_SERVER['PHP_AUTH_PW'...
explode(':', base64_decode($matches[1]));
}
<<ココ!>>
if (PKWK_READONLY ||
! isset($_SERVER['PHP_AUTH_USER']) ||
! in_array($_SERVER['PHP_AUTH_USER'], $user_list) ||
! isset($auth_users[$_SERVER['PHP_AUTH_USER']]) ||
pkwk_hash_compute(
どちらも消すものはありません。追加のみ。
真似して、diffの出力も貼り付けときます。
173,179d172
< // 08 June 2013 for access limit page by IP address
< $auth_network = '/^133.16./';
< $auth_network_pages = '/^KITdoc/';
<
< if (preg_match($auth_network, $_SERVER['REMOTE_...
< // End of 08 June 2013 for access limit page by IP add...
<
206,211d198
< // 08 June 2013 for access limit page by IP address
< } else {
< $user_list = array();
< $auth_flag = false;
< }
< // End of 08 June 2013 for access limit page by IP add...
**メニューバー内で単語が途中で改行されないようにする 05 J...
skin/pukiwiki.css.php の div#menubar(CSSの設定)の
word-break の値を break-all から normal に変える
div#menubar{
……略……
word-break:normal;
……略……
}
参考:[[generate_tagsプラグインによるタグを用いたページ分...
**PukiWikiで上付き文字下付き文字 02 August 2009 [#o8844bf0]
[[PukiWiki/1.4/ちょっと便利に/上付き下付き文字>http://puk...
return "<span style=\"font-size:80%;vertical-align:super...
または
return "<span style=\"font-size:80%;vertical-align:sub\"...
これで
Super&super{super}; & Sub&subsc{sub};
とすると右のようになる Super&super{super}; & Sub&subsc{s...
PukiWikiプラスなら、もとからプラグインがあったんですが、...
**WikiNameに自動的なリンクを生成させないようにする 22 Sep...
WikiNameのように大文字が2つ入った単語を、pukiwikiのデフォ...
WikiNameと認識して、リンクを作るようになっています。
そういう名前のページがないと、?がついて、クリックするとペ...
なります。~
ふだん、本文中で新しいWikiNameのページを作るような書き方...
この機能を停止させることにしました。
その結果、「McAfee」、「VirusScan」、「WinEyes」、「OneLo...
pukiwiki.ini.php
/////////////////////////////////////////////////
// _Disable_ WikiName auto-linking
$nowikiname = 1; // 22 September 2007 // 0; -> 1;
**pukiwikiで、静的ページhtmlに偽装する 22 September 2007 ...
pukiwikiの各ページは「index.php?ほにゃほにゃほにゃ」のよ...
いまひとつ。そこで、「ほにゃほにゃほにゃ.html」となるよう...
http://terai.xrea.jp/PukiWiki/RewriteEngine.html のとおり...
もっとワザを使う場合にはいろいろあるようですが、これが一...
これだけにしている。~
実際の設定は、01 July 2006
.htaccess(pukiwiki.ini.php のあるディレクトリのもの)に...
DirectoryIndex index.php
RewriteEngine on
RewriteBase /~tomaru/pukiwiki
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.*)\.html(#.*)?$ index.php?cmd=read&page=$...
※ 追記 2018年4月18日~
なんと、10年以上も書き忘れていました。.htaccess の設定だ...
実際の設定は、01 July 2006
/lib/make_link.php の修正(700行め位 1.4.6、750行め位 1.5...
return $al_left . '<a ' . 'href="' . $sc...
// 01 July 2006
// For Static URL
// http://terai.xrea.jp/PukiWiki/RewriteEngine.html
//
// return $al_left . '<a ' . 'href="' . $sc...
*** virtual host の https でも偽装する 26 April 2018 [#re...
virtual host の ssl のディレクティブ に(vhost-ssl.conf ...
AllowOverride All
などを入れておく。
All の代わりに FileInfo でもいいらしいのですが試していま...
ssl で override できるよう明示的に指示が必要。
80(s 抜き)で AllowOverride を書いておいても、s付きでは...
気付くのに何年も掛かってしまった……。
**PukiWikiで閲覧は誰でも可、編集・新規ページ作成は登録ユ...
pukiwiki.ini.phpの設定(抜粋)
1.$auth_usersを設定する
$auth_users = array(
'foo' => 'foo_passwd', // Cleartext
);
1−2. Authentication methodを変える(これをしないと不...
//$auth_method_type = 'contents'; // By Page contents
$auth_method_type = 'pagename'; // By Page name 02 Apri...
2.$edit_auth を有効にする
$edit_auth = 1;
3.Edit auth regex を設定する(正規表現!)
$edit_auth_pages = array(
'/^.*$/' => 'foo',
);
これで、編集・新規ページ作成のときにBasic認証(のような...
** pukiwiki のバージョンアップ 18 April 2018 [#nb2789ea]
[[https://pukiwiki.osdn.jp/?PukiWiki/Install/アップグレー...
*** 1.4.6 → 1.4.7 [#h597f3e4]
https://pukiwiki.osdn.jp/?PukiWiki/Download/1.4.7
*** 1.4.7 → 1.5.0 [#sa3dc893]
https://pukiwiki.osdn.jp/?PukiWiki/Install/Update/1.5.0
*** 1.5.0 → 1.5.1 [#v7583043]
https://pukiwiki.osdn.jp/?PukiWiki/Install/Update/1.5.1
*php: hypertext processor その2 [#q634042d]
**ファイルの「ダウンロードダイアログ」が常に開くようにす...
某センターの内部利用のウェブページにて、
テキストファイルを「ダウンロード」する必要がある。
必ずダウンロードしなければならないので、
右クリックさせるのはよくない設計。
ボタンをクリックしたらダイアログが開くのがよい。
テキストファイルは php が生成したものなので、php で作った。
が、しかし、その方法がわからず……
結論としては、
Content-Disposition: attachment; filename=fname.ext
だそうな。~
[[[HOWTO] 既知の MIME タイプに対し [ファイルのダウンロ...
で、実装は……、
<?php
$myfile = $_GET['file'];
$myid = $_GET['id'];
$mydate = date('Y-m-d');
header('Content-Disposition: attachment; (← 実際はココ...
filename="'.$mydate.'-'.$myfile.'-'.$myid.'.txt"');
readfile($myfile.'.txt');
exit;
?>
(↑これが全てです)
との php ファイルを form で呼び出す。
<form action="download.php?file=return&id=<?php echo $my...
<input type="submit" value="ファイルをダウンロードする">
</form>
(抜粋です)
ダウンロード用の php ファイルが呼び出されると、
サーバにあるテキストファイルを
「日付-名前-ID.txt」とのファイル名で
ダウンロードするダイアログが開く。
という具合です。
formの側で、名前と id を post 渡ししているので、
ちょっとだけ使い回しができています。
他に参考にしたもの
- [[phpの関数のマニュアル(header)>http://php.net/manual...
- [[エンジニアさんの「Tipsというかメモ」というページの記...
-[[KJさんのブログ PHPでファイルをDLさせる際のPHPコード...
*php: hypertext processor [#v5e8f85e]
ちょっとだけ、phpのコードがあります。ショウジョウバエ遺伝...
ショウジョウバエ遺伝資源センターでは、ユーザがのストック...
検索し、そのなかから複数の系統を一時的に記憶し、最後に確...
ストックリストは、リレーショナルデータベースの postgreSQL...
Under construction (ちょっと待って...
そのほかのことも。
1. ブラウザの判定:<button> </button> が使えるブラウザを...
$str = $HTTP_USER_AGENT;
$dgrc_browser;
if(eregi("MSIE", $str) || eregi("Netscape6", $str)) {
$dgrc_browser="IENN6";
} else {
$dgrc_browser="NN4";
}
*html tips [#g14f4de6]
html のちょっとしたこと(小技?)を
上のようにして、ストックを検索するページを作るときに、結...
1. 別なサイトから呼び出されたときに、フレームの中では開か...
<script language="JavaScript">
<!--
if(self != top){
top.location.href = self.location.href;
}
//-->
</script>
2. 文字セットをISO 8859-1(=Latin1)にする。下のコードを...
<meta http-equiv="Content-Type" content="text/html;...
3. ○秒後に別なページへ飛ぶ。下のコードを <head> </head> ...
<meta http-equiv="Refresh" content="3; URL=移動先の...
この例では3秒後に移動する。
4. プロポーショナルフォントを使わないようにする。 <tt> と...
<tt>non proportional</tt> ← プロポーショナルフォン...
proportional ← プロポーショナルフォントになる(tとi...
プロポーショナルフォントを使わないようにブラウザを設定し...
*shell script [#o8e5bf5b]
**htmlファイルを加工する 4th April 2008 [#d6e64187]
下のようなhtmlファイル(ファイル名:P001.html:具体的には...
|<html>|BGCOLOR(fuchsia):head.htmlと差し替え|
|<head>|BGCOLOR(fuchsia): |
|……|BGCOLOR(fuchsia): |
|<…… shift_jis ……>|BGCOLOR(fuchsia): |
|……|BGCOLOR(lime):残す(upper.html)|
|</head>|BGCOLOR(lime): |
|<body>|BGCOLOR(fuchsia):P001title.htmlと差し替え|
|……|BGCOLOR(lime):残す(lower.html)|
|</body>|BGCOLOR(fuchsia):tail.htmlと差し替え|
|</html>|BGCOLOR(fuchsia): |
-shell script
#!sh
grep -A 10000 "shift_jis" P001.html >temp01.html;
grep -v "shift_jis" temp01.html >temp1.html;
grep -B 10000 "<body" temp1.html > temp0.html;
grep -v "<body" temp0.html> upper.html;
grep -A 10000 "<body" temp1.html > temp2.html;
grep -v "<body" temp2.html > temp22.html;
grep -v "</body" temp22.html > temp23.html;
grep -v "</html" temp23.html > lower.html;
cat head.html upper.html P001title.html lower.html tail....
sed -e s/"str border=0"/"str border=1"/g temp3.html> tem...
nkf --utf8 -Lu temp4.html > P001.html
-grepを使って、必要部分を切り出す -> upper.html と lower....
grep -A num 文字列: 文字列とその下num行を表示
grep -v 文字列: 文字列を含まない行のみ表示
grep -B num 文字列: 文字列とその上num行を表示
-あらかじめ作っておいたファイル(head.html、P001title.htm...
-一部文字列を修正する(sed: s/文字列1/文字列2/g は、per...
-文字コードをutf-8に変更する
※ shell scriptを使う場合、パイプが働かないので注意
**拡張子追加 4th April 2008 [#wfe37afc]
ファイル名がPではじまるものに、拡張子「.txt」を追加
#!sh
for num in P*;
do
mv $num ${num}.txt;
done
* そのほか [#f2ee36da]
** ファイルを検索する 29th April 2016 [#p6c6a913]
スーパーユーザ権限を使って、マシンの全ディスク内にある st...
という名前を含むファイルをリストアップする
$ sudo find / -name "*struts*"
$ sudo find / -iname "*struts*" ← 大文字小文字を区別しない
*perl [#e81a8f91]
**URIのリストから、それへのリンク付きのリストのhtmlファイ...
こんな感じのリスト(下)をリンク付きのリストのhtmlファイ...
in.txt
http://www.kit.ac.jp/
http://www.yahoo.co.jp/
http://www.google.co.jp/
makelink.pl
#!perl
print "<html>\n";
print "<body>\n";
print "<ul>\n";
while(<>){
chop;
print "<li><a href=\"$_\" target=\"_blank\">$_</a>\n";
}
print "</ul>\n";
print "</html>\n";
print "</body>\n";
使い方
perl makelink.pl <in.txt >out.txt
メールに貼り付けて Thunderbird ででも受け取ればできちゃう...
**タブ区切りテキストからカラムを抜き出す 16th March 2009 ...
タブ区切りテキストの「2列目」と「5列目」を抜き出す
first2and5.pl
#!perl
while(<>){
chop;
split /[\t]/;
print "@_[1]\t@_[4]\n";
}
使い方
perl first2and5.pl <in.txt >out.txt
これで26めがのファイルから必要な部分が取り出せて、1めがに...
|Today:&counter(today);|Yesterday:&counter(yesterday);|To...
ページ名: