###################### # embed vimeo movie # usage: {{vimeo('id','width','height')}} sub vimeo { my ($id,$width,$height) = @_; return qq(<object width="$width" height="$height"> <param name="allowfullscreen" value="true" /> <param name="allowscriptaccess" value="always" /> <param name="movie" value="http://vimeo.com/moogaloop.swf?clip_id=$id&server=vimeo.com&show_title=1&show_byline=1&show_portrait=0&fullscreen=1" /> <embed src="http://vimeo.com/moogaloop.swf?clip_id=$id&server=vimeo.com&show_title=1&show_byline=1&show_portrait=0&fullscreen=1" type="application/x-shockwave-flash" allowfullscreen="true" allowscriptaccess="always" width="$width" height="$height"> </embed> </object>); }
- Summary
いまさらながら、Google Mapsの埋め込みプラグインを作成。
- Source
### Google Mapsの埋め込み # usage: {{embed_google_maps('住所 (店名など)')}} sub embed_google_maps { my ($str) = @_; my $prefix = q(http://maps.google.co.jp/maps?q=); my $enc = URI::Escape::uri_escape(Jcode->new($str)->utf8); my $width = 600; my $height = 400; return qq(<iframe width="$width" height="$height" frameborder="0" scrolling="no" marginheight="0" marginwidth="0" src="$prefix$enc&output=embed"></iframe>); } sub embed_maps {embed_google_maps(@_)}
- Summary
「よかった探しリース」[2006-12-02-5]のためのchalowプラグイン
### よかった探しリース # usage: {{hyuki_wreath('id')}} sub hyuki_wreath { my ($id) = @_; my $prefix = 'http://www.hyuki.com/ring/ring.cgi'; my $left = $prefix.'?mycmd=left&myid='.$id; my $right = $prefix.'?mycmd=right&myid='.$id; return qq( <a href="$left">左手</a> <a href="$prefix">よかった探しリース</a> <a href="$right">右手</a> ); }
- Source
### Smarty # usage: {{smarty('検索語')}} sub smarty { my ($str) = @_; my $prefix = 'http://smarty.php.net/manual/en/search.php?query='; my $enc = url_encode($str); return qq(<a href="$prefix$enc">$str</a>); }
- Reference
[O] chalowでChangeLogのエントリを書いた時間をRSSフィードに反映するhack
http://overlasting.dyndns.org/2006-06-14-2.html
- via
読書記録ChangeLog - 2006-06-15
http://dkiroku.com/2006-06-15-19.html
- Summary
以下の記述で地図が挿入できる.
{{alps_map('東京都新宿区西新宿2-8-1')}} {{alps_map('35/41/10.574,139/41/41.787')}} {{alps_map('東京都新宿区西新宿2-8-1','LN')}}
| L | 480 x 360 |
| M | 320 x 240 (デフォルト) |
| S | 240 x 180 |
| D | 詳細 最大縮尺 (デフォルト) |
| N | 中域 (25000階層) |
| W | 広域 (250000階層) |
- Source
### キーボード # usage: {{keyboard('Ctrl','Alt','Del')}} sub keyboard { @result = map {'<kbd>'.$_.'</kbd>'} @_; return join('+',@result); }
kbd { color: #333333; background-color: white; text-align: center; border-left: 1px solid #cfcfcf; border-top: 1px solid #cfcfcf; border-right: 2px solid #666666; border-bottom: 2px solid #666666; -moz-border-radius: 4px 4px 4px 4px; padding-left: 2px; padding-top: 1px; padding-right: 3px; padding-bottom: 1px; margin-left: 2px; margin-right: 2px; margin-top: 1px; margin-bottom: 1px; vertical-align: middle; font-family: sans-serif; }
- Summary
紹介した店の最寄駅までの乗り換えを簡単に調べられるようにしたい.
駅前探検倶楽部の「下車駅」に引数を入力するプラグインを作成.
- Source
### 駅前探検倶楽部へのリンク # usage: {{ekitan('中板橋')}} sub ekitan { my ($str) = @_; my $prefix = q(http://www8.ekitan.com/norikae/Norikae1Servlet?ST=); my $enc = Jcode->new($str)->sjis; $enc =~ s/([^0-9a-z_ ])/'%'.unpack('H2', $1)/gei; $enc =~ s/\s/+/g; return qq(<a href="$prefix$enc" title="駅探検索 - $str着">$str</a>); } sub station {ekitan(@_)}
### Google 画像検索へのリンクプラグイン # usage: {{google_image('keyword')}} sub google_image { my ($str) = @_; my $prefix = q(http://images.google.com/images?q=); my $enc = Jcode->new($str)->utf8; $enc =~ s/([^0-9a-z_ ])/'%'.unpack('H2', $1)/gei; $enc =~ s/\s/+/g; return qq(<a href="$prefix$enc" title="Google Images - $str">Google 画像検索 - $str</a>); }
- Summary
地図サービスへのリンクの切り替えが面倒.
今回は MapionBB プラグインから Google Maps プラグインへの切り替え.
s/{{mapion/{{google_maps/g
- 解決方法
地図サービスへのリンクプラグインの名前をラッピングする.
mapを地図サービスへのリンクとして利用.
mapプラグイン内で実際の地図サービスプラグインを呼び出す.
sub maps {mapion(@_)}
sub maps {google_maps(@_)}
- Reference
### Google ローカルへのリンク # usage: {{google_map('東京都○○区○町00-0')}} sub google_map { my ($str) = @_; my $prefix = q(http://maps.google.co.jp); my $enc = Jcode->new($str)->utf8; $enc =~ s/([^0-9a-z_ ])/'%'.unpack('H2', $1)/gei; $enc =~ s/\s/+/g; return qq(<a href="$prefix/maps?q=$enc" title="Google ローカル - $str">$str</a>); }
- Summary
クリックしたらサムネイルの画像を拡大するようにした.
- 大きな画像をポップアップ [2005-09-28-5] のJavaScriptを popupImage.jsというファイルで保存して,各ページに<script>タグを埋め込む.
<script src="popupImage.js" type="text/javascript"></script>
sub get_link_str { my ($a, $b) = @_; if ($a =~ /\.(jpg|jpeg|png|gif)$/i) { # [[http://nais.to/|image/nais.jpg]] # return qq(<a href="$b"><img src="$a" alt="画像" /></a>); return qq(<img src="$a" alt="クリックして拡大" onclick="popupImage('$b')" /><a href="$b">.</a>); } elsif ($b =~ /\.(jpg|jpeg|png|gif)$/i) { # [[自画像|image/sp.jpg]] return qq(<img src="$b" alt="$a" />); } else { # [[トップページ|http://nais.to/]] return qq(<a href="$b">$a</a>); } }
- Source
### Google Local Plug-in # usage: {{google_local('what','where')}} sub google_local { my ($what,$where) = @_; my $prefix = q(http://local.google.co.jp); my $what_enc = q(); $what_enc = Jcode->new($what)->utf8; $what_enc =~ s/([^0-9a-z_ ])/'%'.unpack('H2', $1)/gei; $what_enc =~ s/\s/+/g; my $where_enc = q(); $where_enc = Jcode->new($where)->utf8; $where_enc =~ s/([^0-9a-z_ ])/'%'.unpack('H2', $1)/gei; $where_enc =~ s/\s/+/g; my $ret = qq(<a href="$prefix/local?q=$what_enc&near=$where_enc" title="Google Local - $where の $what">); $ret .= qq(Google Local - $where の $what); $ret .= qq(</a>); return $ret; }
- Summary
chalow から XML/SWF Charts[2005-03-10-6] を呼び出す Plug-in.
- Plug-in
### XML/SWF Charts Plug-in # usage: {{chart('XML File','width','height','bgcolor')}} sub chart { my ($xml,$width,$height,$bgcolor) = @_; my $charts = q(http://example.com/path/to/charts.swf); $ret = << "__CHARTHTML__" <object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,0,0" width="$width" height="$height" id="charts" align="" > <param name=movie value="$charts?xml_source=$xml"> <param name=quality value="high"> <param name=bgcolor value="$bgcolor"> <embed src="$charts?xml_source=$xml" quality="high" bgcolor="$bgcolor" width="$width" height="$height" name="charts" align="" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" > </embed> </object> __CHARTHTML__ ; return qq($ret); }
- Summary
chalow で Amazon の画像置換を利用してみる.
- amazon.js
function replaceImage(img) { if (img.width == '1' && img.src.match(/\.01\./)) { img.src = 'http://images-jp.amazon.com/images/G/09/x-locale/detail/thumb-no-image.gif'; img.width = 98; img.height = 140; } else if (img.width == '1') { img.src = img.src.replace('.09.','.01.'); } }
<script src="path/to/amazon.js" type="text/javascript"></script>
<img src="/path/to/image" onload="replaceImage(this)" />