Skip to content

Instantly share code, notes, and snippets.

@tofi86
Created February 11, 2015 16:51
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tofi86/41dca82db8d92fbf2f84 to your computer and use it in GitHub Desktop.
Save tofi86/41dca82db8d92fbf2f84 to your computer and use it in GitHub Desktop.
Mac Shell-Skript für epubMinFlow (http://datenverdrahten.de/epubMinFlow/)
#!/bin/sh
# Bash-Build-Konsolenskript go.sh zum Projekt epubMinFlow
# by Tobias Fischer - http://www.pagina-online.de - 02/2015
# (1) - - - - - - - - - - V o r b e r e i t u n g - - - - - - - - - -
# Ausgangsdokumente (XML bzw. XSLT):
xmlfile="buch.xml"
xslfile="epub.xsl"
# Programmpfade zu ZIP-Tool, XSLT-Prozessor, EPUB-Checktools
# [Aufrufparameter ggf. unter (2) anpassen]:
ziptool="/Pfad_zu/Info-ZIP/zip"
xsltprz="/Pfad_zu/Saxon/saxon9he.jar"
epcheck="/Pfad_zu/EpubCheck/epubcheck-3.0.jar"
# Anpassbare Datei- und Pfadvorgaben für Ausgabestruktur
# (Verzeichnisse bilder, fonts und style liegen statisch vor):
epubdir="epub"
epubfile="buch"
metadir="META-INF"
opsdir="OPS"
cssdir="style"
htmldir="html"
imgdir="bilder"
fontdir="fonts"
# (2) - - - - - - - - - - V e r a r b e i t u n g - - - - - - - - - -
echo "EPUB-Build-Prozess gestartet ..."
echo ""
echo "* Vorbereitung ..."
echo ""
# EPUB-Struktur erzeugen (ggf. alte Version entfernen):
if [[ -d ${epubdir} ]] ; then
rm -rf ${epubdir}
fi
if [[ -f ${epubfile}.epub ]]; then
rm ${epubfile}.epub
fi
mkdir ${epubdir}
mkdir ${epubdir}/${metadir}
mkdir ${epubdir}/${opsdir}
mkdir ${epubdir}/${opsdir}/${cssdir}
cp -r ${cssdir} ${epubdir}/${opsdir}/
mkdir ${epubdir}/${opsdir}/${imgdir}
cp -r ${imgdir} ${epubdir}/${opsdir}/
mkdir ${epubdir}/${opsdir}/${fontdir}
cp -r ${fontdir} ${epubdir}/${opsdir}/
mkdir ${epubdir}/${opsdir}/${htmldir}
echo -n "application/epub+zip" > ${epubdir}/mimetype
# EPUB-Inhalte mittels XSLT 2.0-Job aus XML-Buchdokument erzeugen
# (container.xml, content.opf, toc.ncx, einzelne XHTML-Dokumente):
echo ""
echo "* XSLT-Prozess ..."
java -jar ${xsltprz} -s:${xmlfile} -xsl:${xslfile}
# Erzeugten Verzeichnisinhalt in *.epub packen:
echo ""
echo "* Kompression ..."
echo ""
cd ${epubdir}
find . -name *.DS_Store -type f -exec rm {} \;
${ziptool} -0X ../${epubfile}.epub mimetype
${ziptool} -9XDr ../${epubfile}.epub ${metadir} ${opsdir}
cd ..
# Formale Statusmeldung zur Erstellung:
echo ""
if [[ -f ${epubfile}.epub ]] ; then
echo "... EPUB (${epubfile}.epub) wurde erzeugt."
else
echo "... EPUB (${epubfile}.epub) konnte nicht erzeugt werden."
fi
# Abschlieflende EPUB-Konformitätstests ausführen
# (Erfolg bei Meldung: No errors or warnings detected):
echo ""
echo "* EPUB-Tests ..."
echo ""
if [[ -f ${epubfile}.epub ]] ; then
java -jar ${epcheck} ${epubfile}.epub
fi
echo ""
@tofi86
Copy link
Author

tofi86 commented Feb 11, 2015

epubpreflight habe ich rausgelassen - ist nicht mehr aktuell

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment