changing how we add covers to EPUBs to fix errors reported by validators
authorJonathan Blake <jonathan.blake@projectaon.org>
Wed, 31 Jul 2013 20:00:04 +0000 (20:00 +0000)
committerJonathan Blake <jonathan.blake@projectaon.org>
Wed, 31 Jul 2013 20:00:04 +0000 (20:00 +0000)
git-svn-id: https://projectaon.org/data/trunk@2250 f6f3e2d7-ff33-0410-aaf5-b4bee2cdac11

common/epub/Makefile
common/epub/Makefile.common
common/scripts/gbtoepub.pl
common/xsl/epub-coverpage.xsl
common/xsl/epub-opf-metadata.xsl
common/xsl/epub-opf-spine.xsl
en/.publisher/style/epub/main.csst

index b8f6201..959bfd6 100644 (file)
@@ -4,10 +4,10 @@
 # GS #1 to #4
 ENGLISH_DIRS := 01fftd 02fotw 03tcok 04tcod 05sots 06tkot 07cd 08tjoh \
        09tcof 10tdot 11tpot 12tmod 13tplor 14tcok 15tdc 16tlov 17tdoi \
-       18dotd 19wb 20tcon 21votm 22tbos 23mh 24rw  25totw \
+       18dotd 19wb 20tcon 21votm 22tbos 23mh 24rw  25totw 26tfobm \
        01gstw  02tfc  03btng  04wotw 
 # Unpublished (english) books:
-# 26tfobm 27v 28thos
+# 27v 28thos
 
 # LS #1 to #12  (Spanish)
 SPANISH_DIRS := 01hdlo 02fsea 03lcdk 04eam 05eddls 06lpdlc 07meec \
index 73e205a..8a61c48 100644 (file)
@@ -11,6 +11,7 @@ RELSCRIPT := $(AONROOTDIR)/common/scripts
 # Relative location of the xsl files
 RELXSLDIR := $(AONROOTDIR)/common/xsl
 EPUBSCRIPT := $(RELSCRIPT)/gbtoepub.pl
+COVERIMAGE := $(AONROOTDIR)/$(BLANG)/jpeg/$(SERIES)/$(BASENAME)/skins/ebook/cover.jpg
 
 EPUB=$(BASENAME).epub
 MOBI=$(BASENAME).mobi
@@ -43,8 +44,8 @@ $(AONROOTDIR)/$(BLANG)/epub/$(SERIES)/$(BASENAME)/$(EPUB): $(XMLFILE) $(EPUBSCRI
 
 $(EPUB): $(AONROOTDIR)/$(BLANG)/epub/$(SERIES)/$(BASENAME)/$(EPUB)
        cp -p $(AONROOTDIR)/$(BLANG)/epub/$(SERIES)/$(BASENAME)/$(EPUB) .
-# Regenerate to include the covers properly within the Ebook
-       ebook-convert $(EPUB) regen_$(EPUB)
+# Regenerate to include the covers properly within the Ebook and fix the EPUB
+       ebook-convert $(EPUB) regen_$(EPUB) --cover $(COVERIMAGE)
        mv regen_$(EPUB) $(EPUB)
        -rm -f cover.jpg $(BASENAME).opf  
 
index cd25611..810b5e6 100755 (executable)
@@ -10,16 +10,26 @@ my $USAGE           = "$PROGRAM_NAME [options] book-code\n\t--meta=[metadata fil
 
 my $FILENAME_SEPARATOR = '/';
 
-my $RXP        = '/usr/bin/rxp';
-my $CP         = '/bin/cp';
-my $MV         = '/bin/mv';
-my $TAR        = '/bin/tar';
-my $ZIP        = '/usr/bin/zip';
-my $BZIP2      = '/bin/bzip2';
-my $JAVA       = '/usr/bin/java';
+my $RXP        = qx{which rxp};
+my $CP         = qx{which cp};
+my $MV         = qx{which mv};
+my $TAR        = qx{which tar};
+my $ZIP        = qx{which zip};
+my $BZIP2      = qx{which bzip2};
+my $JAVA       = qx{which java};
 my $XALAN_JAR  = '/usr/share/java/xalan2.jar';
-my $RM         = '/bin/rm';
-my $CHMOD      = '/bin/chmod';
+my $RM         = qx{which rm};
+my $CHMOD      = qx{which chmod};
+
+chomp $RXP;
+chomp $CP;
+chomp $MV;
+chomp $TAR;
+chomp $ZIP;
+chomp $BZIP2;
+chomp $JAVA;
+chomp $RM;
+chomp $CHMOD;
 
 # Check that all the binaries are were want them
 
@@ -54,7 +64,6 @@ my $ncxXSL       = 'common/xsl/epub-ncx.xsl';
 my $epubXSL      = 'common/xsl/epub-xhtml.xsl';
 my $metadataXSL  = 'common/xsl/epub-opf-metadata.xsl';
 my $spineXSL     = 'common/xsl/epub-opf-spine.xsl';
-my $coverXSL     = 'common/xsl/epub-coverpage.xsl';
 my $fontFiles    = "$ENV{'HOME'}${FILENAME_SEPARATOR}souvenir";
 my $language     = 'en';
 
@@ -249,70 +258,6 @@ print MIMETYPE $EPUB_MIMETYPE;
 close MIMETYPE;
 
 
-## write coverpage 
-
-# Generate the cover image. This can be done in two ways:
-# 1.- A file is available under the directory of JPEG files for the book
-# 2.- A file is generated using imagemagick
-
-# Cover filename
-my $coverImage = $outPath{'oebps'} . $FILENAME_SEPARATOR . "cover.jpg"; 
-# Cover filename generated by Project Aon
-my $pa_coverImage = $rulesHash{'language'} . $FILENAME_SEPARATOR . "jpeg" . $FILENAME_SEPARATOR .$rulesHash{'book-series'}. $FILENAME_SEPARATOR .$bookCode . $FILENAME_SEPARATOR . "cover.jpg";
-
-if ( -e  "$pa_coverImage") {
-    # Copy the file here
-    print STDERR "DEBUG: Using cover from $pa_coverImage\n" if $verbose;
-    system "cp $pa_coverImage $coverImage";
-} else {
-
-# Use Imagemagick if available
-    if ( -x "/usr/bin/convert" ) {
-
-        print STDERR "DEBUG: Will generate cover with ImageMagick\n" if $verbose;
-        my $TITLE = quote_shell(find_title($bookXML));
-        my $AUTHOR = quote_shell(find_author($bookXML));
-        my $ILLUSTRATOR = quote_shell(find_illustrator($bookXML));
-        my $convert_cmd = "";
-
-        if ( -e "$fontFiles/SouvenirStd-Demi.otf" && -e "$fontFiles/SouvenirStd-Light.otf" ) { 
-            $convert_cmd="convert -size 600x800 -background white  -font $fontFiles/SouvenirStd-Demi.otf -pointsize 32 -fill '#006633' -gravity north caption:\"\" -annotate +0+218 \"$TITLE\"  -font $fontFiles/SouvenirStd-Light.otf -pointsize 22 -fill black -annotate +0+304 '$AUTHOR' -annotate +0+333 '$ILLUSTRATOR' $coverImage"
-        } else {
-            print STDERR "WARN: Fontfiles not found, using standard font\n";
-            $convert_cmd="convert -size 600x800 -background white -pointsize 32 -fill '#006633' -gravity north caption:\"\" -annotate +0+218 \"$TITLE\"  -pointsize 22 -fill black -annotate +0+304 '$AUTHOR' -annotate +0+333 '$ILLUSTRATOR' $coverImage";
-        }
-
-        print STDERR "DEBUG: Will run '$convert_cmd'\n" if $verbose;
-        system $convert_cmd;
-    }
-}
-
-# If there is no coverImage then we will change the XSL output
-my $addCover = "yes"; 
-$addCover = "no" if ! -e $coverImage;
-
-
-#
-#  TODO: The coverpage seems to be stripped by Calibre since it 
-#  expects an image file for the coverpage. Alternatively, create
-#  a jpeg file based on the HTML (using html2ps for example) 
-#  and use that for the OPF description of the book
-
-my $coverFileName = "coverpage.html";
-my $coverFile = "$outPath{'oebps'}$FILENAME_SEPARATOR$coverFileName";
-open( COVER, '>', $coverFile ) or
-    die "$PROGRAM_NAME: unable to open OPF file for writing " .
-        "\"$coverFile\"\n";
-
-my $cover  = qx{$JAVA -classpath "$XALAN_JAR" org.apache.xalan.xslt.Process -IN "$bookXML" -XSL "$coverXSL" -PARAM opf-id "$uniqueID" -PARAM unique-identifier "$bookUniqueURI" -PARAM language "$rulesHash{'language'}" -PARAM book_series "$SERIES" -PARAM book_series_index "$SERIES_NUMBER" -PARAM addcover "$addCover"}; #" comment to unconfuse VIM syntax hilighting
-
-
-print COVER "$cover";
-
-close COVER;
-
-check_file($coverFileName);
-
 ### write OPF Root file
 # All content files must be created prior to creating the OPF root file
 # with its manifest of content files.
@@ -333,7 +278,7 @@ END_OPF_HEADER
 
 ## write metadata
 
-my $metadata = qx{$JAVA -classpath "$XALAN_JAR" org.apache.xalan.xslt.Process -IN "$bookXML" -XSL "$metadataXSL" -PARAM opf-id "$uniqueID" -PARAM unique-identifier "$bookUniqueURI" -PARAM language "$rulesHash{'language'}" -PARAM book_series "$SERIES" -PARAM book_series_index "$SERIES_NUMBER" -PARAM addcover "$addCover"}; #" comment to unconfuse VIM syntax hilighting
+my $metadata = qx{$JAVA -classpath "$XALAN_JAR" org.apache.xalan.xslt.Process -IN "$bookXML" -XSL "$metadataXSL" -PARAM opf-id "$uniqueID" -PARAM unique-identifier "$bookUniqueURI" -PARAM language "$rulesHash{'language'}" -PARAM book_series "$SERIES" -PARAM book_series_index "$SERIES_NUMBER"}; #" comment to unconfuse VIM syntax hilighting
 $metadata = " $metadata";
 $metadata =~ s|(<dc:)|\n  $1|g;
 $metadata =~ s|(</metadata>)|\n $1|g;
@@ -367,8 +312,7 @@ print OPF " </manifest>\n\n";
 ## write spine data
 
 my $ncxID = make_id( $NCX_FILE );
-#print OPF qx{$JAVA -classpath "$XALAN_JAR" org.apache.xalan.xslt.Process -IN "$bookXML" -XSL "$spineXSL" -PARAM toc-id "$ncxID"};
-my $spine = qx{$JAVA -classpath "$XALAN_JAR" org.apache.xalan.xslt.Process -IN "$bookXML" -XSL "$spineXSL" -PARAM toc-id "$ncxID" -PARAM addcover "$addCover"};
+my $spine = qx{$JAVA -classpath "$XALAN_JAR" org.apache.xalan.xslt.Process -IN "$bookXML" -XSL "$spineXSL" -PARAM toc-id "$ncxID"};
 
 $spine =~ s/idref="([^"]*)"/idref="$1.$XHTML_EXT"/g;
 $spine = " $spine";
index 02cc852..1b7c875 100644 (file)
@@ -25,7 +25,6 @@
 <xsl:param name="language"><xsl:text>en</xsl:text></xsl:param>
 <xsl:param name="book_series"><xsl:text>Lone Wolf</xsl:text></xsl:param>
 <xsl:param name="book_series_index" />
-<xsl:param name="addcover" />
  
 <!-- ======================= variables ========================== -->
 
     </head>
     <body>
 
-       <xsl:choose>
-               <xsl:when test="$addcover='yes'">
-                    <div>
-                    <img src="cover.jpg" alt="cover" style="height: 100%"/>
-                    </div>
-                </xsl:when>
-                <xsl:otherwise>
-
-                <div>
-                    <h1><xsl:value-of select="$book_series" /><xsl:choose><xsl:when test="$book_series_index"> - <xsl:value-of select="$book_series_index"/></xsl:when></xsl:choose> - <xsl:apply-templates select="title[1]" /></h1>
-               </div>
-               <div>
-                    <p><xsl:apply-templates select="creator[@class='author']"/></p>
-               </div>
-               <div>
-                    <p><xsl:apply-templates select="creator[@class='illustrator']"/></p>
-              </div>
-            </xsl:otherwise>
-        </xsl:choose>
+
+        <div>
+            <h1><xsl:value-of select="$book_series" /><xsl:choose><xsl:when test="$book_series_index"> - <xsl:value-of select="$book_series_index"/></xsl:when></xsl:choose> - <xsl:apply-templates select="title[1]" /></h1>
+       </div>
+       <div>
+            <p><xsl:apply-templates select="creator[@class='author']"/></p>
+       </div>
+       <div>
+            <p><xsl:apply-templates select="creator[@class='illustrator']"/></p>
+      </div>
 
         <div>
             <p><xsl:apply-templates select="rights[@class='copyrights']"/></p>
index ea9aaa6..1427d8b 100644 (file)
@@ -34,8 +34,6 @@
 -->
 <xsl:param name="book_series"><xsl:text>Lone Wolf</xsl:text></xsl:param>
 <xsl:param name="book_series_index" />
-<xsl:param name="addcover" />
-
  
 <!-- ======================= variables ========================== -->
 
   </xsl:when>
   </xsl:choose>
  </metadata>
-
-  <guide>
-  <xsl:choose>
-    <xsl:when test="$addcover='yes'">
-     <reference href="cover.jpg" type="cover" title="Cover"/>
-    </xsl:when>
-    <xsl:otherwise>
-     <reference href="coverpage.html" type="cover" title="Cover"/>
-    </xsl:otherwise>
-  </xsl:choose>
-  </guide>
-
-
 </xsl:template>
 <!--
 <xsl:template match="title">
index aec41cb..0387ce6 100644 (file)
@@ -11,7 +11,6 @@
  <!-- ====================== parameters ========================== -->
 
  <xsl:param name="toc-id"><xsl:text>toc.ncx</xsl:text></xsl:param>
- <xsl:param name="addcover" />
   
  <!-- ======================== Templates ========================= -->
 
@@ -35,7 +34,6 @@
  <xsl:template match="/gamebook/section[@id='title']">
   <itemref idref="title" media-type="application/xhtml+xml"/>
   <itemref idref="toc"   media-type="application/xhtml+xml"/>
-  <itemref idref="coverpage" media-type="application/xhtml+xml"/>
 
   <xsl:apply-templates select="data/section"/>
  </xsl:template>
index 1c73fc0..20a067c 100644 (file)
  src: url("SouvenirStd-DemiItalic.otf") format("opentype");
 }
 
-#page-header { 
- display: oeb-page-head
-}
-
 html, body {
  font-family: "Souvenir Light", serif;
 }