changeset 360:01ded8741361

Use server-side includes (with Apache XBitHack setting) in web. This means that we can have one main web page, dottes.html, for each book and include the intro and tunelist to make the page. This removes the separate header and footer components. Perhaps we should use a template engine instead to generate the output. That means choosing one. And preferably one that isn't aimed only at HTML so we could use it for the printed books. More research required.
author Jim Hague <jim.hague@acm.org>
date Wed, 21 Aug 2013 10:32:50 +0100
parents 2a7d03d6a89f
children 265539086836
files dottes.html dottes.html.footer dottes.html.header makeWeb.sh
diffstat 4 files changed, 65 insertions(+), 54 deletions(-) [+]
line wrap: on
line diff
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dottes.html	Wed Aug 21 10:32:50 2013 +0100
@@ -0,0 +1,49 @@
+<!DOCTYPE html>
+<html lang="en">
+<head>
+  <meta charset="utf-8" />
+  <title>Cry Havoc tunes - @TITLE@</title>
+  <link rel="stylesheet" href="../css/reset.css" />
+  <link rel="stylesheet" href="../css/text.css" />
+  <link rel="stylesheet" href="../css/960.css" />
+  <link rel="stylesheet" href="../css/dottes.css" />
+
+  <link href='http://fonts.googleapis.com/css?family=Pirata+One|Oswald'
+        rel='stylesheet' type='text/css'>
+</head>
+<body>
+  <div class="container_12">
+    <a href="/">
+      <div class="grid_12 header-strip banner">
+        <h1>Ye Crie Havock Booke of Dottes</h1>
+      </div>
+    </a>
+
+    <div class="grid_12 dottes-body">
+      <h1>@SUBTITLE@</h1>
+      <!--#include file="intro.html" -->
+      <p>@INTRO@
+      <p>You can download a PDF with a booklet of these tunes. There is an
+        <a href="@BOOK@-A5.pdf">A5 landscape book</a> with one
+        tune per page, a <a href="@BOOK@-Nook.pdf">4x5in portrait book</a>
+        suitable for use with an eReader like a Kindle, Nook, Kobo etc.,
+        and an <a href="@BOOK@-A4.pdf">A4 book</a> with two or
+        more tunes per page.
+      <p>If you have a printer that can do duplex (i.e. print on both sides
+        of the paper), you might like the
+        <a href="@BOOK@-A5bookletA4.pdf">A5 booklet</a>.
+        Print this onto A4 paper using both sides of the paper, and fold in half
+        to make an A5 booklet.
+      <p>When changes to this site are made, the issue number is incremented.
+        This is issue @BUILD@.
+    </div>
+
+    <div class="grid_12 dottes-body">
+      <h1>The tunes</h1>
+      <div class="dottes-tune-list">
+        <!--#include file="tunelist.html" -->
+      </div>
+    </div>
+  </div>
+</body>
+</html>
--- a/dottes.html.footer	Wed Aug 21 10:28:10 2013 +0100
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,4 +0,0 @@
-</div>
-</div>
-</body>
-</html>
--- a/dottes.html.header	Wed Aug 21 10:28:10 2013 +0100
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,42 +0,0 @@
-<!DOCTYPE html>
-<html lang="en">
-<head>
-  <meta charset="utf-8" />
-  <title>Cry Havoc tunes - @TITLE@</title>
-  <link rel="stylesheet" href="../css/reset.css" />
-  <link rel="stylesheet" href="../css/text.css" />
-  <link rel="stylesheet" href="../css/960.css" />
-  <link rel="stylesheet" href="../css/dottes.css" />
-
-  <link href='http://fonts.googleapis.com/css?family=Pirata+One|Oswald'
-        rel='stylesheet' type='text/css'>
-</head>
-<body>
-  <div class="container_12">
-    <a href="/">
-      <div class="grid_12 header-strip banner">
-        <h1>Ye Crie Havock Booke of Dottes</h1>
-      </div>
-    </a>
-
-    <div class="grid_12 dottes-body">
-      <h1>@SUBTITLE@</h1>
-      <p>@INTRO@
-      <p>You can download a PDF with a booklet of these tunes. There is an
-        <a href="@BOOK@-A5.pdf">A5 landscape book</a> with one
-        tune per page, a <a href="@BOOK@-Nook.pdf">4x5in portrait book</a>
-        suitable for use with an eReader like a Kindle, Nook, Kobo etc.,
-        and an <a href="@BOOK@-A4.pdf">A4 book</a> with two or
-        more tunes per page.
-      <p>If you have a printer that can do duplex (i.e. print on both sides
-        of the paper), you might like the
-        <a href="@BOOK@-A5bookletA4.pdf">A5 booklet</a>.
-        Print this onto A4 paper using both sides of the paper, and fold in half
-        to make an A5 booklet.
-      <p>When changes to this site are made, the issue number is incremented.
-        This is issue @BUILD@.
-    </div>
-
-    <div class="grid_12 dottes-body">
-      <h1>The tunes</h1>
-      <div class="dottes-tune-list">
--- a/makeWeb.sh	Wed Aug 21 10:28:10 2013 +0100
+++ b/makeWeb.sh	Wed Aug 21 10:32:50 2013 +0100
@@ -24,6 +24,7 @@
 webdir=$dir/web/$1
 graphicsdir=$dir/graphics/$1
 output=index.html
+tunelist=tunelist.html
 booke=$1
 masterbooke=$2
 title=$booke
@@ -37,9 +38,6 @@
 if [ -r $bookedir/subtitle.txt ]; then
     subtitle=`cat $bookedir/subtitle.txt`
 fi
-if [ -r $bookedir/intro.txt ]; then
-    intro=`txt2tags --no-headers --target=html --outfile=- $bookedir/intro.txt`
-fi
 
 if [ -n "$instrument" ]; then
     title="${title} ($instrument)"
@@ -49,8 +47,20 @@
 mkdir -p $webdir
 
 sed -e "s/@BUILD@/$buildno/" -e "s/@SUBTITLE@/$subtitle/" \
-    -e "s/@TITLE@/$title/" -e "s/@INTRO@/$intro/" \
-    -e "s/@BOOK@/$booke/" dottes.html.header > $webdir/$output
+    -e "s/@TITLE@/$title/" -e "s/@BOOK@/$booke/" dottes.html > $webdir/$output
+
+# Mark output as executable so it is scanned for server-side includes.
+chmod +x $webdir/$output
+
+for item in intro
+do
+    rm -f $webdir/$item.html
+    if [ -r $booke/$item.txt ]; then
+        txt2tags --no-headers --target=html --outfile=$webdir/$item.html $booke/$item.txt
+    else
+        touch $webdir/$item.html
+    fi
+done
 
 # Copy in the book PDFs. Like the graphics, Midi etc. these are assumed
 # to be already generated.
@@ -103,7 +113,5 @@
             -e "s/@TUNE@/${name}/" dottes.html.tune > $webdir/$tunepage
 
         sed -e "s/@TITLE@/${title//&/\&}/" \
-            -e "s/@TUNE@/${name}/" dottes.html.tuneindex >> $webdir/$output
+            -e "s/@TUNE@/${name}/" dottes.html.tuneindex >> $webdir/$tunelist
     done
-
-cat dottes.html.footer >> $webdir/$output