#!/bin/bash

###############################################################################
## generate HTML bibliography


## whole bibliography with abstracts
## * output: pubs.binc, pubs_bib.binc
## * temp:   pubs.tmp, pubs_bib.tmp

bibtex2html --revkeys --nodoc --no-header --style abbrv_web.bst --style-sheet gph.css --file-suffix .tmp --output pubs pubs.bib

# post process: translate links, remove footer
sed 's:href="pubs_bib.html#:href="papers_bib.shtml#:
     /<hr>/ {
         s:<hr>.*::
         q
     }' pubs.tmp > pubs.binc

# post process: remove headline, remove footer
sed 's:<h1>.*</h1>::
     /<hr>/ {
         s:<hr>.*::
         q
     }' pubs_bib.tmp > pubs_bib.binc

# del tmp files
rm -f pubs.tmp pubs_bib.tmp



## bibliography section 'implementation'
## * output: pubs_impl.binc
## * temp:   pubs_impl.tmp pubs_impl_abstracts.tmp pubs_impl_bib.tmp, pubs_impl_keys.tmp

bib2bib -oc pubs_impl_keys.tmp -ob /dev/null -c 'keywords : "\(^\|,\)[ ]*implementation[ ]*\(,\|$\)"' pubs.bib
bibtex2html --both --revkeys --nodoc --no-header --no-keys --style abbrv_web.bst --style-sheet gph.css --file-suffix .tmp --output pubs_impl --citefile pubs_impl_keys.tmp pubs.bib

# post process: translate links, remove footer
sed 's:href="pubs_impl_abstracts.html#:href="papers_abs.shtml#:
     s:href="pubs_impl_bib.html#:href="papers_bib.shtml#:
     /<hr>/ {
         s:<hr>.*::
         q
     }' pubs_impl.tmp > pubs_impl.binc

# del tmp files
rm -f pubs_impl.tmp pubs_impl_abstracts.tmp pubs_impl_bib.tmp pubs_impl_keys.tmp


## bibliography section 'semantics'
## * output: pubs_sem.binc
## * temp:   pubs_sem.tmp pubs_sem_abstracts.tmp pubs_sem_bib.tmp, pubs_sem_keys.tmp

bib2bib -oc pubs_sem_keys.tmp -ob /dev/null -c 'keywords : "\(^\|,\)[ ]*semantics[ ]*\(,\|$\)"' pubs.bib
bibtex2html --both --revkeys --nodoc --no-header --no-keys --style abbrv_web.bst --style-sheet gph.css --file-suffix .tmp --output pubs_sem --citefile pubs_sem_keys.tmp pubs.bib

# post process: translate links, remove footer
sed 's:href="pubs_sem_abstracts.html#:href="papers_abs.shtml#:
     s:href="pubs_sem_bib.html#:href="papers_bib.shtml#:
     /<hr>/ {
         s:<hr>.*::
         q
     }' pubs_sem.tmp > pubs_sem.binc

# del tmp files
rm -f pubs_sem.tmp pubs_sem_abstracts.tmp pubs_sem_bib.tmp pubs_sem_keys.tmp



## bibliography section 'models of parallelism'
## * output: pubs_models.binc
## * temp:   pubs_models.tmp pubs_models_abstracts.tmp pubs_models_bib.tmp, pubs_models_keys.tmp

bib2bib -oc pubs_models_keys.tmp -ob /dev/null -c 'keywords : "\(^\|,\)[ ]*models[ ]+of[ ]+parallelism[ ]*\(,\|$\)"' pubs.bib
bibtex2html --both --revkeys --nodoc --no-header --no-keys --style abbrv_web.bst --style-sheet gph.css --file-suffix .tmp --output pubs_models --citefile pubs_models_keys.tmp pubs.bib

# post process: translate links, remove footer
sed 's:href="pubs_models_abstracts.html#:href="papers_abs.shtml#:
     s:href="pubs_models_bib.html#:href="papers_bib.shtml#:
     /<hr>/ {
         s:<hr>.*::
         q
     }' pubs_models.tmp > pubs_models.binc

# del tmp files
rm -f pubs_models.tmp pubs_models_abstracts.tmp pubs_models_bib.tmp pubs_models_keys.tmp



## bibliography section 'tools'
## * output: pubs_tools.binc
## * temp:   pubs_tools.tmp pubs_tools_abstracts.tmp pubs_tools_bib.tmp, pubs_tools_keys.tmp

bib2bib -oc pubs_tools_keys.tmp -ob /dev/null -c 'keywords : "\(^\|,\)[ ]*tools[ ]*\(,\|$\)"' pubs.bib
bibtex2html --both --revkeys --nodoc --no-header --no-keys --style abbrv_web.bst --style-sheet gph.css --file-suffix .tmp --output pubs_tools --citefile pubs_tools_keys.tmp pubs.bib

# post process: translate links, remove footer
sed 's:href="pubs_tools_abstracts.html#:href="papers_abs.shtml#:
     s:href="pubs_tools_bib.html#:href="papers_bib.shtml#:
     /<hr>/ {
         s:<hr>.*::
         q
     }' pubs_tools.tmp > pubs_tools.binc

# del tmp files
rm -f pubs_tools.tmp pubs_tools_abstracts.tmp pubs_tools_bib.tmp pubs_tools_keys.tmp



## bibliography section 'parallel applications'
## * output: pubs_apps.binc
## * temp:   pubs_apps.tmp pubs_apps_abstracts.tmp pubs_apps_bib.tmp, pubs_apps_keys.tmp

bib2bib -oc pubs_apps_keys.tmp -ob /dev/null -c 'keywords : "\(^\|,\)[ ]*parallel[ ]+applications[ ]*\(,\|$\)"' pubs.bib
bibtex2html --both --revkeys --nodoc --no-header --no-keys --style abbrv_web.bst --style-sheet gph.css --file-suffix .tmp --output pubs_apps --citefile pubs_apps_keys.tmp pubs.bib

# post process: translate links, remove footer
sed 's:href="pubs_apps_abstracts.html#:href="papers_abs.shtml#:
     s:href="pubs_apps_bib.html#:href="papers_bib.shtml#:
     /<hr>/ {
         s:<hr>.*::
         q
     }' pubs_apps.tmp > pubs_apps.binc

# del tmp files
rm -f pubs_apps.tmp pubs_apps_abstracts.tmp pubs_apps_bib.tmp pubs_apps_keys.tmp
