蔵書管理サービスのWebサイトとしては、何がいいでしょうか。
個人用、または、小さなオフィス用として。
http://hondana.org/ をアクセスすると、重くて。Ruby on Rails
で作っているからかあ。それとも単に手元のネットワークとの距離
が遠いだけか。
http://www.honjana.com/ は、「携帯専用」と書いてあるのがちょっ
と。これは、hondana.org をぱくった名前なのかなあ。
http://mediamarker.net/ は、軽そうです。
http://bookscope.net/ も、Ruby on Rails と書いてあるけれど軽いあ。
どうやって選んだらいいんでしょうね。ISBNが不明な本(古いもの
とか実は本ではないとか)に強いというのは、ありませんか。
コンピュータ系に強いというのもあれば欲しい。
この手のサイトは、Amazon へのリンクで利益を得て運営している
んですかね。
\\ 新城 靖 (しんじょう やすし) \\
\\ 筑波大学 電子・情報 \\
自分で見つけた話を少し追加します。
Ruby on Rails 関連で少しみてみたら、「蔵書管理サイトを自作す
る」という話がありました。
Web2.0サイトを自作する/第2回 Amazon WebAPIを使ってみる
増井 雄一郎 2007/07/27
http://itpro.nikkeibp.co.jp/article/COLUMN/20070719/277889/
うちの若いものへの演習としても手頃かもしれません。
「Web 2.0」ってキーワードは気に入らないんだけど。
#perl で自作しています。動くから、いいや‥‥ R.田中二郎
----------------------------------------------------------------
#!/usr/local/bin/perl
$file = '/path/to/book.lst';
$me = 'book.cgi';
$wc = '/usr/bin/wc';
print 'Content-Type: text/html
';
$[ = 1;
read(STDIN, $isbn, $ENV{'CONTENT_LENGTH'});
$isbn .= $ENV{'QUERY_STRING'};
if($isbn =~ /=/) {
for $in(split(/&/, $isbn)) {
$in{$`} = $' if($in =~ /=/);
}
$add = $in{'ADD'};
$isbn = $in{'ISBN'};
($key = $in{'KEY'}) =~ s/\+/ /g;
$key =~ s/%(..)/pack('c', hex($1))/ge;
($memo = $in{'MEMO'}) =~ s/\+/ /g;
$memo =~ s/%(..)/pack('c', hex($1))/ge;
}
if($add gt '') {
################
# 追加/変更
################
$add =~ s/%(..)/pack('c', hex($1))/ge;
open(IN, $file) or die "GET $file: $!";
while(<IN>) {
s/[\r\n]//g;
($n, $c) = split(/\t/, $_, 2);
$all{$n} = $c;
}
close(IN);
print "<HTML>
<HEAD><TITLE>追加/修正</TITLE></HEAD>
<BODY>
";
for(split(/\r\n/, $add)) {
s/[\r\n]//g;
$j = $_;
if(defined $all{$j}) {
print "<FONT color=\"Red\">$j\t$all{$j}</FONT>→$memo<BR>\n";
$all{$j} =~ s/\t.*/\t$memo/;
next;
}
s/^978//;
split(//);
$#_ = 9;
$c = 0;
for(1 .. 9) {
$c += $_[$_] * $_;
}
$c %= 11;
$c = 'X' if($c > 9);
$isbn = join('', @_) . $c;
$_ = `fetch -q -o - http://www.amazon.co.jp/exec/obidos/ASIN/$isbn | grep description`;
s/[\r\n]//g;
print "<!-- $isbn\t$_ -->\n";
$l = "$1" if(/content=\"Amazon.co.jp: (.*): 本/);
# $l = "$2,$1" if(/content=\"([^,]*),(.*),$isbn/);
# $l = $1 if(/:(.*):/);
while($l =~ /&\#x(..)(..);/) {
open(OUT, "| /usr/local/bin/iconv -f UTF-16 -t SJIS > $$");
print OUT pack('c', hex($1)), pack('c', hex($2));
close(OUT);
open(IN, "$$");
$t = <IN>;
close(IN);
unlink $$;
$l =~ s/&\#x....;/$t/;
}
$all{$j} = "$l\t$memo";
$result .= "$j\t$l\t\n";
undef $l;
}
rename $file, "$file.bak" or die "RENAME $file: $!";
open(OUT, ">$file") or die "WRITE $file: $!";
for(sort keys %all) {
print OUT "$_\t$all{$_}\r\n";
}
close(OUT);
# open(OUT, ">>$file") or die "ADD $file: $!";
# print OUT $result;
# close(OUT);
# `$sort -u +1 $file -o $file`;
$num = `$wc -l $file` - 0;
print "<PRE>\n$result</PRE>
<HR>追加しました。$num 冊。
</BODY>
</HTML>
";
exit;
}
if($isbn eq '') {
if($key eq '') {
################
# 画面表示
################
print "<HTML>
<HEAD><TITLE>書籍管理</TITLE></HEAD>
<BODY>
<FORM method=\"post\" action=\"$me\">
ISBN:<INPUT type=text name=ISBN size=20 istyle=4><BR>
単語:<INPUT type=text name=KEY size=20><BR>
<INPUT type=submit value=\"検索\"> <INPUT type=reset value=\"もういちど\"><HR>
<TEXTAREA name=ADD rows=3 cols=20 istyle=4></TEXTAREA><BR>
<INPUT type=submit value=\"追加\"><BR>
メモ:<INPUT type=text name=MEMO size=20>
</FORM>
</BODY>
</HTML>
";
exit;
} else {
################
# キーワード検索
################
open(IN, $file) or die "KEY $file: $!";
@l = grep(/\Q$key\E/, <IN>);
close(IN);
for(@l) {
s/[\r\n]//g;
split(/\t/, $_, 3);
$l .= "<A target=_blank href=\"$me?ISBN=$_[1]\">$_[1]</A>\t$_[2]\t<FONT color=magenta>$_[3]</FONT><BR>\n";
}
$l = $#l > 0 ? $l : '<FONT color="Red">みつかりませんでした。</FONT>';
print "<HTML>
<HEAD><TITLE>$key</TITLE></HEAD>
<BODY>
$l
</BODY>
</HTML>
";
exit;
}
}
################
# ISBN検索
################
$isbn =~ s/[^0-9]//g;
if($isbn =~ /978(\d{9})/) {
$isbn = $1;
}
split(//, $isbn);
$#_ = 9;
$c = 0;
for(1 .. 9) {
$c += $_[$_] * $_;
}
$c %= 11;
$c = 'X' if($c > 9);
$isbn = join('', @_) . $c;
$i2 = '-' if('40' le $isbn and $isbn lt '42');
$i3 = '-' if('42' le $isbn and $isbn lt '47');
$i4 = '-' if('47' le $isbn and $isbn lt '485');
split(//, $isbn);
$i = "ISBN$_[1]-$_[2]$_[3]" . $i2 . $_[4] . $i3 . $_[5] . $i4 . "$_[6]$_[7]$_[8]$_[9]-$_[10]";
unshift(@_, '8');
unshift(@_, '7');
unshift(@_, '9');
$c = 0;
for(1 .. 6) {
$c += $_[$_*2]*3 + $_[$_*2-1];
}
$_[13] = (-$c) % 10;
$isbn = join('', @_);
open(IN, $file) or die "ISBN $file: $!";
@f = grep(/$isbn/, <IN>);
close(IN);
$flag = $#f > 0 ? '<FONT color="Red">あり</FONT>' : '<FONT color="Blue">なし</FONT>';
($_, $l, $e) = split(/\t/, $f[1], 3);
if($l eq '') {
$_ = `fetch -q -o - http://www.amazon.co.jp/exec/obidos/ASIN/$isbn | grep description`;
s/[\r\n]//g;
$l = "$1" if(/content=\"Amazon.co.jp: (.*): 本/);
# $_ = `fetch -q -o - http://www.amazon.co.jp/exec/obidos/ASIN/$isbn | grep META | grep keywords`;
# s/[\r\n]//g;
# $l = "$1,$2" if(/content=\"(.*),\226\{,(.*),Amazon,/);
# $l = $1 if(/content="(.*)"/);
}
################
# メモ修正
################
if(defined($in{'TEXT'})) {
($text = $in{'TEXT'}) =~ s/\+/ /g;
$text =~ s/%(..)/pack('c', hex($1))/ge;
$text =~ s/[\0-\37]//g;
$text =~ s/&/&/g;
$text =~ s/</</g;
$text =~ s/>/>/g;
open(IN, $file) or die "READ $file: $!";
@all = <IN>;
close(IN);
for($a = 1; $a <= $#all && $e ne $text; $a ++) {
split(/\t/, $all[$a], 3);
if($_[1] eq $j) {
$all[$a] = "$_[1]\t$_[2]\t$text\n";
$e = $text;
}
}
rename $file, "$file.bak" or die "RENAME $file: $!";
open(OUT, ">$file") or die "WRITE $file: $!";
print OUT @all;
close(OUT);
}
print "<HTML>
<HEAD><TITLE>$j</TITLE></HEAD>
<BODY>
<A target=_blank href=\"http://www.bk1.jp/webap/user/SchBibList.do?keyword=$isbn&partnerid=p-bimyo67581\">$i</A><BR>
$flag<BR>
$l<BR>
<FORM method=post action=\"$me\">
<INPUT type=hidden name=ISBN value=\"$j\">
メモ:<INPUT name=TEXT size=80 value=\"$e\"><BR>
<INPUT type=submit value=\"OK\"> <INPUT type=reset value=\"RESET\">
</BODY>
</HTML>
";