A stab at ePub

This commit is contained in:
cruft 2009-11-18 20:45:24 -07:00
parent ccabcc6d28
commit 54e26d66c4
14 changed files with 165 additions and 29 deletions

View File

@ -5,6 +5,10 @@ SUPPORT = chapauth.sty praise.tex
STORIES = stories/*.tex STORIES = stories/*.tex
ART = art/* ART = art/*
all: pdf epub
pdf: horrors2-book.pdf
epub: book.epub
horrors2-book.pdf: horrors2-book.ps horrors2-book.pdf: horrors2-book.ps
ps2pdf $< $@ ps2pdf $< $@
@ -18,8 +22,22 @@ horrors2.pdf: horrors2.ltx $(SUPPORT) $(STORIES) $(ART)
pdflatex $< pdflatex $<
pdflatex $< pdflatex $<
horrors2.mdwn: horrors2.ltx $(STORIES)
./toxhtml.py > $@
horrors2.xhtml: horrors2.mdwn head.xhtml foot.xhtml
cat head.xhtml > $@
markdown $< >> $@
cat foot.xhtml >> $@
book.epub: horrors2.xhtml
./mkepub
publish: horrors2.pdf publish: horrors2.pdf
cp horrors2.pdf horrors2.$(shell TZ=UTC date "+%Y-%m-%dT%H:%M:%SZ").pdf cp horrors2.pdf horrors2.$(shell TZ=UTC date "+%Y-%m-%dT%H:%M:%SZ").pdf
clean: clean:
rm -f *aux *dvi *log rm -f *aux *dvi *log
rm -f horrors2.xhtml horrors2.mdwn book.epub
rm -f epub/art/*

Binary file not shown.

Binary file not shown.

Binary file not shown.

View File

@ -0,0 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<container xmlns="urn:oasis:names:tc:opendocument:xmlns:container"
version="1.0">
<rootfiles>
<rootfile full-path="content.opf" media-type="application/oebps-package+xml" />
</rootfiles>
</container>

29
epub/book.ncx Normal file
View File

@ -0,0 +1,29 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE ncx PUBLIC "-//NISO//DTD ncx 2005-1//EN"
"http://www.daisy.org/z3986/2005/ncx-2005-1.dtd">
<ncx version="2005-1" xml:lang="en"
xmlns="http://www.daisy.org/z3986/2005/ncx/">
<head>
<!-- The following four metadata items are required for all NCX documents,
including those conforming to the relaxed constraints of OPS 2.0 -->
<meta name="dtb:uid" content="horrors2"/> <!-- same as in .opf -->
<meta name="dtb:depth" content="1"/> <!-- 1 or higher -->
<meta name="dtb:totalPageCount" content="0"/> <!-- must be 0 -->
<meta name="dtb:maxPageNumber" content="0"/> <!-- must be 0 -->
</head>
<docTitle>
<text>Horrors 2</text>
</docTitle>
<navMap>
<navPoint class="chapter" id="chapter1" playOrder="1">
<navLabel><text>Chapter 1</text></navLabel>
<content src="book.xhtml"/>
</navPoint>
</navMap>
</ncx>

2
foot.xhtml Normal file
View File

@ -0,0 +1,2 @@
</body>
</html>

11
head.xhtml Normal file
View File

@ -0,0 +1,11 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html PUBLIC
"-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>Horrors 2</title>
<link rel="stylesheet" href="style.css" type="text/css" />
</head>
<body>

73
mkepub Executable file
View File

@ -0,0 +1,73 @@
#! /bin/sh
cat horrors2.xhtml > epub/book.xhtml
rm -rf epub/art
mkdir epub/art
cp art/*.png art/*.jpg epub/art
cp style.css epub/
cd epub
echo -n application/epub+zip > mimetype
cat >MANIFEST <<EOF
mimetype
META-INF/container.xml
content.opf
EOF
cat > content.opf <<EOF
<?xml version="1.0"?>
<package version="2.0" xmlns="http://www.idpf.org/2007/opf" unique-identifier="BookId">
<metadata xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:opf="http://www.idpf.org/2007/opf">
<dc:title>Horrors 2</dc:title>
<dc:language>en</dc:language>
<dc:identifier id="BookId" opf:scheme="title">Horrors2</dc:identifier>
<dc:creator opf:file-as="Something Awful Forums" opf:role="aut">The Something Awful Forums</dc:creator>
</metadata>
<manifest>
EOF
find . -type f | sed 's#./##' | while read fn; do
b=$(basename $fn)
id=thing$count
count=$(expr $count + 1)
case "$b" in
META-INF/*|MANIFEST|mimetype|content.opf)
continue
;;
book.xhtml)
id=book
type=application/xhtml+xml
;;
*.css)
type=image/css
;;
book.ncx)
id=ncx
;;
*.png)
type=image/png
;;
*.jpg)
type=image/jpeg
;;
*.svg)
type=image/svg+xml
;;
*.otf)
type=application/octet-stream
;;
esac
echo "<item id=\"$id\" href=\"$fn\" media-type=\"$type\"/>" >> content.opf
echo $fn >> MANIFEST
done
cat >> content.opf <<EOF
</manifest>
<spine toc="ncx">
<itemref idref="book" />
</spine>
</package>
EOF
xargs zip -Xr9D ../book.epub < MANIFEST

View File

@ -22,27 +22,27 @@ address book.
{\em ABE {\em ABE}
CYNTHIA {\em CYNTHIA}
MOM {\em MOM}
PIZZA HUT {\em PIZZA HUT}
DIRECTORIES {\em DIRECTORIES}
INFO HOTLINE} {\em INFO HOTLINE}

View File

@ -128,11 +128,7 @@ Awesome!
{\em But confetti doesn't wear its hair in a blond, barretted {\em But confetti doesn't wear its hair in a blond, barretted
ponytail. ponytail. Good Christ--} (he thought)
Good Christ--} (he thought)

View File

@ -180,4 +180,4 @@ Red lights whirled closer. Suddenly, I was sobbing.
\illustration{lucifer chikken}{Gun / Warehouse}{art/lucifer_chickken-gun_warehouse.png} \illustration{lucifer chikken}{Gun / Warehouse}{art/lucifer_chikken-gun_warehouse.png}

View File

@ -1,3 +1,20 @@
@font-face {
font-family: "Antykwa Torunska";
src: url(AntykwaTorunska-Regular.otf);
}
@font-face {
font-family: "Antykwa Torunska";
font-style: italic;
src: url(AntykwaTorunska-Italic.otf);
}
@font-face {
font-family: "Antykwa Torunska";
font-weight: bold;
src: url(AntykwaTorunska-Bold.otf);
}
body { body {
max-width: 40em; max-width: 40em;
font-family: Antykwa Torunska; font-family: Antykwa Torunska;

View File

@ -199,22 +199,5 @@ for l in f:
if l.startswith('\\begin{document'): if l.startswith('\\begin{document'):
break break
print('''<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html PUBLIC
"-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>Horrors 2</title>
<link rel="stylesheet" href="style.css" type="text/css" />
</head>
<body>
''')
for l in f: for l in f:
outline(l) outline(l)
print('''</body>
</html>
''')