#!/usr/bin/perl =head1 NAME make-publication-page - BibTeX データベースから業績一覧ページを生成する =head1 SYNOPSIS make-publication-page [your-bibtex-file] =head1 DESCRIPTION BibTeX データベースから業績一覧のウェブページを生成する非常に簡単なスク リプトです.データに応じて条件分岐させたりする改造を行って使うことを想 定しています. もっと多機能なツールが欲しい人は,RELATED TOOLS を参照してください. =head1 OPTIONS =over 4 =item --encoding 文字コード BibTeX データベースファイルで使っている文字コードを指定する.指定しなけ れば,EUC-JP を仮定. =back =head1 RELATED TOOLS =over 4 =item * http://sourceforge.net/projects/bib2html/ =item * http://www.lri.fr/~filliatr/bibtex2html/ =back =head1 AUTHOR =over 4 =item TSUCHIYA Masatoshi =back =head1 LICENSE This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 3, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; see the file COPYING. If not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. Last Update: $Date: 2009-11-14 03:56:43 $ =cut use Encode; use Getopt::Long; use HTML::Template; use Text::BibTeX; use strict; use utf8; use open qw/ :utf8 :std /; our $ENCODING = 'euc-jp'; &GetOptions( "encoding=s" => \$ENCODING ); &main( @ARGV ); sub main { my( $file ) = @_; my $bibfile = Text::BibTeX::File->new( $file ) or die "Cannot open $file: $!\n"; my @paper; my $i = 1; while( my $x = Text::BibTeX::Entry->new( $bibfile ) ){ next unless $x->parse_ok; push( @paper, { seq => $i++, key => $x->param('key'), title => $x->param('title'), author => $x->param('author'), source => $x->param('source'), year => $x->param('year') } ); } my $template = HTML::Template->new( filehandle => *DATA, default_escape => 'HTML' ); $template->param( papers => \@paper ); print $template->output; } sub Text::BibTeX::Entry::param { my $this = shift; unless( @_ ){ qw/ key title author journal booktitle volume number pages source year /; } else { my( $key ) = @_; if( $key eq 'key' ){ $this->key(); } elsif( $key eq 'source' ){ my $book = $this->param('journal') || $this->param('booktitle'); my @buf; if( my $vol = $this->param('volume') ){ push( @buf, sprintf( 'Vol.%s', $vol ) ); } if( my $num = $this->param('number') ){ push( @buf, sprintf( 'No.%s', $num ) ); } if( my $pages = $this->param('pages') ){ push( @buf, sprintf( 'pp.%s', $pages ) ); } join( ', ', $book, @buf ); } else { my $val = &decode( $ENCODING, $this->get( $key ) ); $val =~ s/[\$\{\}\\]//g; $val =~ s/---?/-/g; $val =~ s/\s+and\s+/, /g if $key eq 'author'; $val; } } } __DATA__ Publication List

Publication List

">[]

()