#!/usr/bin/awk -f # # info2thumblink -- convert info to thumblinklist # # usage: info2thumblink galleries.info # # http://www.heikopurnhagen.net/software/info2thumblink # # This program is available under the terms of the GNU General Public # License (GPL). All usual disclaimers apply! # # Heiko Purnhagen (mail@heikopurnhagen.net) # HP 20080817 # HP 20080818 added missingidxcaption # HP 20090117 improved css for links (manual underline not required any longer) # HP 20090224 added optional key to DIRIDX # HP 20090913 remove all from title string in html header # HP 20090926 added style for "table.tll a" BEGIN { numinfo = 0; diridx = 0; } { if ($1 == "DIRIDX") { idxhepudir = $2; idxkey = $3; getline; idxtitle = $0; getline; idxcaption = $0; getline; idxyear = $0; getline; idxwebdir = $0; getline; idxthumb = $0; diridx = 1; } else if ($1 == "DIRKEY") { hepudir[numinfo] = $2; key[numinfo] = $3; getline; title[numinfo] = $0; getline; caption[numinfo] = $0; getline; srcdir[numinfo] = $0; getline; year[numinfo] = $0; getline; webdir[numinfo] = $0; getline; thumb[numinfo] = $0; numinfo++; } } END { print "INFO2THUMBLINK diridx=" diridx " numinfo=" numinfo > "/dev/stderr"; if (diridx) { idxs = idxhepudir idxkey ".idxs"; system ("rm -f " idxs); system ("touch " idxs); for (i=0; i "/dev/stderr"; exit; } print title[i] > idxs; print "index" key[i] ".html" > idxs; print "thumbs/" thumb[i] "_thumb.jpg" > idxs; print "" > idxs; } newindex = "index" idxkey "_info2thumblink.html"; indexhtml = "index" idxkey ".html"; print "\n\ \n\ \n\ \n\ " gensub("<[^>]*>","","g",idxtitle) "\n\ \n\ \n\ \n\
\n\

" idxtitle "

" > idxhepudir "/" newindex; if (idxcaption!="") { print "

" idxcaption "

" >> idxhepudir "/" newindex; } close(idxhepudir "/" newindex); system("( cd " idxhepudir " && thumblinklist ../" idxs " | sed 'sXtable borderXtable class=\"tll\" borderXg' >> " newindex " )"); print "

All photos copyright Heiko Purnhagen " idxyear "

\n\
\n\ \n\ " >> idxhepudir "/" newindex; close(idxhepudir "/" newindex); system("( cd " idxhepudir " && chainindex removeold=1 backlink=" indexhtml " ../" idxs" >> " newindex " )"); if (system("test -f " idxhepudir "/" indexhtml)) { system("mv " idxhepudir "/" newindex " " idxhepudir "/" indexhtml); } else { if (system("cmp -s " idxhepudir "/" newindex " " idxhepudir "/" indexhtml)) { "pwd" | getline pwd; print "\nINFO2THUMBLINK - UPDATE " indexhtml " MANUALLY:\nmv " pwd "/" idxhepudir "/" newindex " " pwd "/" idxhepudir "/" indexhtml "\n" > "/dev/stderr"; } else { system ("rm -f " idxhepudir "/" newindex); } } } } #--