#!/bin/sh # # mkdigest [-s] # # -s: return status: 1: error, 5: no change, 6: updated # # This script must be in Japanese EUC code # # $Id: mkdigest,v 1.19 1999/12/01 23:16:03 yasufu-i Exp itohy $ PATH=/usr/bin:/bin:/usr/pkg/bin:/usr/local/bin diaryURL=http://iy.hauN.org/itohy/diary/ diarypath=/home/itohy/public_html/diary digestdir=current digestfile=$digestdir/index.html digestfile_test=$digestdir/index-test.html digesttmp=$digestfile$$ digesttmp2=$digestfile$$-2 digestdays=14 mailaddr=itohy@netbsd.org signature='ITOH Yasufumi' J=' case "$m" in 01|1) j="睦月";; 02|2) j="如月";; 03|3) j="弥生";; 04|4) j="卯月";; 05|5) j="皐月";; 06|6) j="水無月";; 07|7) j="文月";; 08|8) j="葉月";; 09|9) j="長月";; 10) j="神無月";; 11) j="霜月";; 12) j="師走";; *) echo "$0: $m: illegal month number" >&2; exit 1;; esac' umask 22 # parse option retst=0 case "$1" in -t) digestfile=$digestfile_test;; -s) retst=1;; esac # check directory structure cd $diarypath if [ ! -d $digestdir ]; then case $retst in 0) echo "$digestdir: not found" >&2;; esac exit 1 fi # awk should be 8bit through if [ -f /usr/bin/gawk -o -f /usr/local/bin/gawk ]; then AWK=gawk else AWK=awk fi # latest three months diaryfiles="`find . -name '[01][0-9].html' -print | sort -r | head -3`" trap "rm -f $digesttmp $digesttmp2; exit 1" 1 2 3 13 15 rm -f $digesttmp $digesttmp2 # output the head # 注: ${dateline}行目にある空行は、このスクリプトの最後の方で使っている。 dateline=11 nkf << END > $digesttmp INFORMATION (Diary-current)

INFORMATION (日記ダイジェスト)

このページには、新しい方から、 ${digestdays}日分があるはず(汗)です。 内容に関してのリンクは、ここでなくて本体のページ(日付や先頭の o のリンクをたどったところ)へどうぞ。

RSS by しゃあるさん END # output the contents dd=$digestdays for file in $diaryfiles do year=`echo $file | sed 's/.*\/\([0-9]*\)\/[0-9]*.html$/\1/'` month=`echo $file | sed 's/.*\/\([0-9]*\)\.html$/\1/'` m=$month; eval $J nkf << END


日記の表紙日記の本体(${year}年$j)
END nkf -e $file | sed -n ' 1,/^
$/d /^$/d /
/q /
/q /^$/d s/^
0; i--) article[i] = article[i-1] article[0] = "" } { if (article[0]) article[0] = article[0] "\n" article[0] = article[0] $0 } END { for (i = 0; i < d; i++) { if (!article[i]) exit d-i print "\n
" print "&-`"'\"" print " accept-charset=\"ISO-2022-JP, EUC-JP\">" print "" print "
" } else print "

[next]" } exit 0 }' dd=$? echo '

' (exit $dd) && break done | nkf >> $digesttmp # link to the latest months latestmonths= for file in $diaryfiles do year=`echo $file | sed 's/.*\/\([0-9]*\)\/[0-9]*.html$/\1/'` month=`echo $file | sed 's/.*\/\([0-9]*\)\.html$/\1/'` m=$month; eval $J latestmonths="$latestmonths ${year}年$j" done nkf << END >> $digesttmp
latest months:$latestmonths END # output the tail nkf << END >> $digesttmp
$signature <${mailaddr}>
END # bury creation time if sed "${dateline}s/.*//" $digestfile 2>/dev/null | cmp -s - $digesttmp; then rm -f $digesttmp case $retst in 0) echo 'No change made';; 1) exit 5;; esac else sed "${dateline}s/^/Creation time: `date`/" $digesttmp > $digesttmp2 rm -f $digesttmp mv $digesttmp2 $digestfile case $retst in 0) echo 'Digest Updated';; 1) exit 6;; esac fi