Jun 04, 2006
[Blosxom] SimpleAPI その1. にチャレンジ(2)
SimpleAPI その1. 用の Blosxom プラグインを作成してみた。 %BLOSXOM_HOME%/plugins/siteimg に保存して、Story 内で [[siteimg:<URL>]] と記述するだけ。
SimpleAPI その1. 用 Blosxom プラグイン
プラグインのソースは下記の通り。
ZIP アーカイブでダウンロードする場合は
こちら。
# Blosxom Plugin: siteimg
# Author: in-vitro.jp
# Version: 1.0.0
# License: GPL
# Autoattach
#
# Usage Examples:
# [[siteimg:http://www.in-vitro.jp]]
package siteimg;
###############################################################
# Configuration Section
$simpleapi1_url = "http://img.simpleapi.net/small/";
###############################################################
sub start {
1;
}
sub story {
my ($pkg, $path, $filename, $story_ref, $title_ref, $body_ref) = @_;
$$body_ref =~ s/\[\[siteimg:(.+)\]\]/ <a href="$1\"><img src="$simpleapi1_url$1" width="128" height="128" border="0"><br>$1<\/a>/gs;
1;
}
1;
こんな感じで表示される。
http://www.in-vitro.jp/blog/index.cgi
Mar 10, 2006
[Blosxom] Bloxsom のエントリーを一覧表示する
Blosxom のエントリー一覧を確認したくなることが結構あるので、簡単なスクリプトを作成してみた。 このスクリプトは Blosxom starter kit 環境下で、エントリーファイルの一覧を HTML で表示する。 Blosxom starter kit の設定ファイルを参照している都合で、ノーマルの Blosxom 環境下では動作しないかもしれない(未確認)。
Blosxom エントリー一覧表示スクリプト
$BLOG_HOME 直下に適当な名前でスクリプトを設置し、パーミッションを 755 にすると動作する。
#!/usr/bin/perl
package blosxom;
eval { require './config.cgi'; };
die "Failed to load configuration file.\n$@" if $@;
use vars qw! $datadir $url $depth $file_extension %files !;
use strict;
use FileHandle;
use File::Find;
use File::stat;
use Time::localtime;
use Time::Local;
use CGI qw/:standard :netscape/;
use CGI::Carp;
my $fh = new FileHandle;
# Use the stated preferred URL or figure it out automatically
$url ||= url();
$url =~ s/^included:/http:/; # Fix for Server Side Includes (SSI)
$url =~ s!/$!!;
# Drop ending any / from dir settings
$datadir =~ s!/$!!;
# Fix depth to take into account datadir's path
$depth and $depth += ($datadir =~ tr[/][]) - 1;
# find entry files
my @files;
find(
sub {
my $d;
my $curr_depth = $File::Find::dir =~ tr[/][];
return if $depth and $curr_depth > $depth;
my $file = $File::Find::name;
if($file =~ m/(.)*\.$file_extension$/i) {
push(@files, $file);
}
}, $datadir
);
# soft entry files
@files = sort {
$a =~ /.*\/(.+)/;
my $filename_a = $1;
$b =~ /.*\/(.+)/;
my $filename_b = $1;
$filename_b cmp $filename_a;
} @files;
# print results;
print "Content-type: text/html\n\n";
print "<html>";
print "<head><title>";
print "list entries in ";
print $datadir;
print "</title></head>";
print "<body>";
print "list entries in ";
print $datadir;
print "<ol>";
foreach my $file (@files) {
$file =~ /.*\/(.+)/;
my $filename = $1;
my $fileurl = $file;
$fileurl =~ s/$datadir//g;
$fileurl =~ s/\.$file_extension/\.html/g;
$fileurl = $url . $fileurl;
print "<li>";
print "<a href=\"";
print $fileurl;
print "\">";
print $filename;
print "</a>";
print " <span style=\"font-size: x-small;\">(";
print $file;
print ")</span>";
print "</li>";
}
print "</ol>";
print "</body></html>";
Aug 09, 2005
[Blosxom] Bloxsom Autoattach plugin
autoimg を参考に添付ファイル用の plugin を作成してみた。
ダウンロード
インストール方法
bloxsom の plugin ディレクトリ内に解凍
使用方法
entry 内に "[" + 添付ファイル名 + "]" を記述する。添付ファイルは zip, lzh, gz を指定可能。
添付ファイルは以下の通り設置する。
bloxsom_home └entries ・・・ bloxsom の entry 設置用ディレクトリ ├myentry.txt ・・・ ファイルを添付される entry └myentry ・・・ entry と同一の名前でディレクトリを作成 └attach.zip ・・・ 添付ファイルはここに設置



