diff --git a/scripts/deploy-ebook-to-www b/scripts/deploy-ebook-to-www
index b725df93..c9eed45f 100755
--- a/scripts/deploy-ebook-to-www
+++ b/scripts/deploy-ebook-to-www
@@ -339,9 +339,12 @@ do
workTitle=$(grep --only-matching --extended-regexp "(.+?)" "${workDir}"/src/epub/content.opf | sed --regexp-extended "s/<[^>]+?>//g")
find "${workDir}"/src/epub \( -type d -name .git -prune \) -o -type f -name "*.xhtml" -print0 | xargs -0 sed --in-place --regexp-extended "s|
|${workTitle} - |g"
- # Add the nav to each page
+ # Add the header nav to each page
find "${workDir}"/src/epub \( -type d -name .git -prune \) -o -type f -name "*.xhtml" -print0 | xargs -0 sed --in-place --regexp-extended "s%%%"
+ # Add a chapter navigation footer to each page
+ "${scriptsDir}"/inject-chapter-navigation-footer "${workDir}"/src/epub "${bookUrl}"
+
# Adjust sponsored links in the colophon
sed --in-place 's| ';
+ exit(1);
+}
+$epubDirectory = $argv[1];
+$bookUrl = $argv[2];
+
+// Parse the order of chapters from the table of contents.
+$doc = new DOMDocument();
+libxml_use_internal_errors(true); // Suppress warnings from output.
+$doc->loadHTMLFile($epubDirectory . '/toc.xhtml');
+libxml_clear_errors();
+$toc = $doc->getElementById('toc');
+if($toc){
+ $chapterLinks = array();
+ foreach($toc->getElementsByTagName('a') as $link){
+ $obj = new stdClass();
+ $obj->Path = $link->getAttribute('href');
+ $obj->Name = $link->textContent;
+
+ // Only include links pointing to actual files (e.g. skip href="text/chapter-7#panawes-story").
+ if(file_exists($epubDirectory . '/' . $obj->Path . '.xhtml')){
+ $chapterLinks[] = $obj;
+ }
+ }
+
+ for($i = 0; $i < count($chapterLinks); $i++){
+ $previousObj = $i > 0 ? $chapterLinks[$i - 1] : null;
+ $nextObj = $i < count($chapterLinks) - 1 ? $chapterLinks[$i + 1] : null;
+
+ $fileName = $epubDirectory . '/' . $chapterLinks[$i]->Path . '.xhtml';
+ $chapter = file_get_contents($fileName);
+ // Inject the navigation footer.
+ $previousLink = $previousObj ? sprintf('Previous: %s', $bookUrl . '/' . $previousObj->Path, htmlspecialchars($previousObj->Name)) : '';
+ $nextLink = $nextObj ? sprintf('Next: %s', $bookUrl . '/' . $nextObj->Path, htmlspecialchars($nextObj->Name)) : '';
+ $footer = sprintf('', $previousLink, $nextLink);
+ $chapter = str_replace('', $footer . '', $chapter);
+ file_put_contents($fileName, $chapter);
+ }
+}
+?>
diff --git a/www/css/web.css b/www/css/web.css
index 670aca0d..422ee3c8 100644
--- a/www/css/web.css
+++ b/www/css/web.css
@@ -1,5 +1,9 @@
@namespace epub "http://www.idpf.org/2007/ops";
+html{
+ position: relative;
+}
+
body{
font-family: "Georgia", serif;
font-size: 18px;
@@ -51,6 +55,28 @@ body > header li:first-child > a:hover{
transform: scale(1.025) rotate(1deg);
}
+body > footer{
+ position: absolute;
+ bottom: 0;
+ left: 0;
+ width: 100%;
+}
+
+body > footer ul{
+ display: flex;
+ justify-content: space-between;
+ margin: 0;
+ padding: 0.5em 1em;
+ list-style: none;
+}
+
+body > footer li{
+ max-width: 40%;
+ overflow: hidden;
+ text-overflow: ellipsis;
+ white-space: nowrap;
+}
+
body > section[epub|type~="titlepage"],
body > section[epub|type~="halftitlepage"]{
min-height: auto;