#!/bin/ksh db=~/db/img wroot=~/img ppp=15 cd $db html() { cat < 35.img $title p$curr_page

$title p$curr_page

rss : sect.html : 3.5

all $(cat db_alltags)


$(cat $posts) $(pager) eof } pager() { if [[ $pages -gt 1 ]]; then print "
" print "

" if [[ $curr_page -gt 1 && $curr_page != 2 ]]; then print "«" elif [[ $curr_page = 2 ]]; then print "«" fi if [[ $curr_page != $pages ]]; then print "»" fi print "

" for l in $(seq 1 $pages); do if (( curr_page == 1 && l == 1 )); then print "1" elif (( l == 1 )); then print "1" elif (( curr_page == l )); then print "$l" else print "$l" fi done print "
" fi } tag_maker() { for t in $tags; do print -n " $t" done } refresh() { :>tags rm db.* cat $db/db | sort -r | while read line; do date=$(print $line | cut -d"|" -f1) file=$(print $line | cut -d"|" -f2) tags=$(print $line | cut -d"|" -f3) desc=$(print $line | cut -d"|" -f4) echo $tags | tr " " "\n" >> tags cat <[img: $tags]

$file : $(tag_maker) $(if [[ $desc != "" ]]; then print ": $desc"; fi)

$date


eof desc="" done > db.all cat tags | sort | uniq > db_tags for t in $(cat db_tags); do cat db.all | grep ">$t<" > db.$t done } make() { pages=$(($(cat $1 |wc -l)/ppp)) pages_rem=$(($(cat $1 |wc -l)%ppp)) if (( pages_rem > 0 )); then ((pages++)); fi title=$(print $p | cut -d"." -f2) print $title pages: $pages curr_page=1 x=1 y=$ppp if (( pages == 1 )); then posts=$1 html > $wroot/$title.html else for w in $(seq 1 $pages); do cat $1 | sed -n "$x,$y p" > tmp posts=tmp if [[ $curr_page = 1 && $title = all ]]; then html > $wroot/index.html html > $wroot/all.html elif (( curr_page == 1 )); then html > $wroot/$title.html else html > $wroot/$title-$curr_page.html fi ((curr_page++));x=$((x+ppp));y=$((y+ppp)) done fi } new_post() { print $date|$file|$tags >> $db/db } if [[ $1 = -t ]]; then refresh for b in $(cat db_tags); do print " $b" done > db_alltags fi for p in $(ls db.*); do make $p done cgimg rss