#!/bin/bash

# convert to html ==============================================================
asciidoctor site/*adoc

# manual modifications to html created by asciidoctor ==========================

#   make it clear where corpus is (English home)
sed -i -e 's/"#_outputs">Outputs<\/a>/"#_outputs">Corpus \&amp; Outputs<\/a>/' site/en.html

#   shorten title for Publications section
sed -i -e 's/href="#_publications_and_contributions_to_conferences">Publications and contributions to conferences</#_publications_and_contributions_to_conferences">Publications</g' site/en.html
sed -i -e 's/href="#_publications_et_communications">Publications et communications</#_publications_et_communications">Publications</g' site/index.html

#   add home link to top entry in ToC
for pname in index en ; do
  sed -i -e 's/"toctitle">Navigation<\/div>/"toctitle"><a href="https:\/\/methal.pages.unistra.fr">Navigation<\/a><\/div>/' site/${pname}.html
  sed -i -e 's/"toctitle">Navigation<\/div>/"toctitle"><a href="https:\/\/methal.pages.unistra.fr">Navigation<\/a><\/div>/' site/${pname}.html
  sed -i -e 's/"toctitle">Navigation<\/div>/"toctitle"><a href="https:\/\/methal.pages.unistra.fr">Navigation<\/a><\/div>/' site/read/${pname}.html
  sed -i -e 's/"toctitle">Navigation<\/div>/"toctitle"><a href="https:\/\/methal.pages.unistra.fr">Navigation<\/a><\/div>/' site/read/${pname}.html
done

# read-section
plays_done=$(ls site/read/tei/*xml | wc -l)
sed -i -e "s/##nbrPieces/${plays_done}/g" read/*html
sed -i -e "s/##nbrPieces/${plays_done}/g" site/*html


# copy to public repo ==========================================================
cp -r site/*html public
cp -r site/{img,styles,docs,read} public/.
