URL を短く表示するプラグインを作りました。
cl.conf にコピーしてご利用ください。
使い方:以下の様に書くと、
ref. 「perl: 文字列中の http URL と ftp URL をリンクにし、URL が長
すぎる場合は省略表示する」
<http://sonic64.hp.infoseek.co.jp/2004-01-07.html#2004-01-07-1>
cl.conf にコピーしてご利用ください。
### URL を短くして表示
# usage: {{shorten_url(URL, LEN_MAX)}}
# Ex.: {{shorten_url('http://example.com/abc/def/00101033/
# 0123456/aaaaaaaaaaaa/aaaaaaaaaaaa/index.html')}}
sub shorten_url {
my ($url, $max) = @_;
$max = 60 if not defined $max;
$url =~ s/\s+//gsm;
my $urlstr = $url;
$urlstr =~ s/^(.{$max}).+$/$1 .../;
return qq(<a href="$url">$urlstr</a>);
}
使い方:以下の様に書くと、
参考:{{shorten_url('http://example.com/0123456789/0123456789/
0123456789/0123456789/0123456789/0123456789-a.html',54)}}
{{shorten_url('http://example.com/0123456789/0123456789/
0123456789/0123456789/0123456789/0123456789-b.html')}}
こうなります:参考:http://example.com/0123456789/0123456789/0123456789/01 ...
http://example.com/0123456789/0123456789/0123456789/01234567 ...
ref. 「perl: 文字列中の http URL と ftp URL をリンクにし、URL が長
すぎる場合は省略表示する」
<http://sonic64.hp.infoseek.co.jp/2004-01-07.html#2004-01-07-1>
