]> git.immae.eu Git - github/wallabag/wallabag.git/commitdiff
Many improvements to epub produced : better cover, better tags
authortcit <tcit@tcit.fr>
Wed, 7 May 2014 10:40:09 +0000 (12:40 +0200)
committertcit <tcit@tcit.fr>
Wed, 7 May 2014 10:40:09 +0000 (12:40 +0200)
inc/3rdparty/libraries/PHPePub/EPub.php
inc/poche/Poche.class.php

index 0260ce4f2adcfb7f2c145db70a80698422105271..e120b3413c344ce8c9da945ddf01d9d2150a296a 100644 (file)
@@ -574,7 +574,7 @@ class EPub {
      * @param string $mimetype Image mimetype, such as "image/jpeg" or "image/png".
      * @return bool $success
      */
-    function setCoverImage($fileName, $imageData = NULL, $mimetype = NULL) {
+    function setCover($fileName, $imageData = NULL, $mimetype = NULL, $coverText=NULL) {
         if ($this->isFinalized || $this->isCoverImageSet || array_key_exists("CoverPage.html", $this->fileList)) {
             return FALSE;
         }
@@ -621,12 +621,13 @@ class EPub {
                                . "<html xmlns=\"http://www.w3.org/1999/xhtml\" xmlns:epub=\"http://www.idpf.org/2007/ops\" xml:lang=\"en\">\n"
                                . "\t<head>\n"
                                . "\t\t<meta http-equiv=\"Content-Type\" content=\"text/html; charset=UTF-8\"/>\n"
-                               . "\t\t<title>Cover Image</title>\n"
+                               . "\t\t<title>Cover</title>\n"
                                . "\t\t<link type=\"text/css\" rel=\"stylesheet\" href=\"Styles/CoverPage.css\" />\n"
                                . "\t</head>\n"
                                . "\t<body>\n"
+                . "\t\t" . $coverText . "\n"
                                . "\t\t<div>\n"
-                               . "\t\t\t<img src=\"" . $imgPath . "\" alt=\"Cover image\" style=\"height: 100%\"/>\n"
+                               . "\t\t\t<img src=\"" . $imgPath . "\" alt=\"Cover image\" style=\"height: 40%\"/>\n"
                                . "\t\t</div>\n"
                                . "\t</body>\n"
                                . "</html>\n";
@@ -635,12 +636,13 @@ class EPub {
                                . "<html xmlns=\"http://www.w3.org/1999/xhtml\" xmlns:epub=\"http://www.idpf.org/2007/ops\">\n"
                                . "<head>"
                                . "\t<meta http-equiv=\"Default-Style\" content=\"text/html; charset=utf-8\" />\n"
-                               . "\t\t<title>Cover Image</title>\n"
+                               . "\t\t<title>Cover</title>\n"
                                . "\t\t<link type=\"text/css\" rel=\"stylesheet\" href=\"Styles/CoverPage.css\" />\n"
                                . "\t</head>\n"
                                . "\t<body>\n"
                                . "\t\t<section epub:type=\"cover\">\n"
-                               . "\t\t\t<img src=\"" . $imgPath . "\" alt=\"Cover image\" style=\"height: 100%\"/>\n"
+                . "\t\t" . $coverText . "\n"
+                               . "\t\t\t<img src=\"" . $imgPath . "\" alt=\"Cover image\" style=\"height: 40%\"/>\n"
                                . "\t\t</section>\n"
                                . "\t</body>\n"
                                . "</html>\n";
index c476df3efd868673a916ac858e6925b831b2d204..c99bfcba84aff909dbf33d12c9acdcd052727c38 100755 (executable)
@@ -1200,30 +1200,37 @@ class Poche
         $book->setSourceURL("http://$_SERVER[HTTP_HOST]");
         
         $book->addDublinCoreMetadata(DublinCore::CONTRIBUTOR, "PHP");
+        $book->addDublinCoreMetadata(DublinCore::CONTRIBUTOR, "wallabag");
         
         $cssData = "body {\n margin-left: .5em;\n margin-right: .5em;\n text-align: justify;\n}\n\np {\n font-family: serif;\n font-size: 10pt;\n text-align: justify;\n text-indent: 1em;\n margin-top: 0px;\n margin-bottom: 1ex;\n}\n\nh1, h2 {\n font-family: sans-serif;\n font-style: italic;\n text-align: center;\n background-color: #6b879c;\n color: white;\n width: 100%;\n}\n\nh1 {\n margin-bottom: 2px;\n}\n\nh2 {\n margin-top: -2px;\n margin-bottom: 2px;\n}\n";
         
-        $log->logLine("Add Cover Image");
-        $book->setCoverImage("Cover.png", file_get_contents("themes/baggy/img/apple-touch-icon-152.png"), "image/png");
+        $log->logLine("Add Cover");
+        if (count($entries)>1){
+            $cover = "<h1>" . $entries[0]['title'] . " and " . count($entries) . " other articles</h1>";
+        } else {
+            $cover = "<h1>" . $entries[0]['title'] . "</h1>";
+        }
+        $book->setCover("Cover.png", file_get_contents("themes/baggy/img/apple-touch-icon-152.png"), "image/png", $cover);
+        
         
-        $cover = $content_start . "<h1>My articles on wallabag</h1>\n<h2>As seen on : http://$_SERVER[HTTP_HOST]</h2>\n" . $bookEnd;
-        $book->addChapter("Notices", "Cover.html", $cover);
+        $book->setCover($cover);
+        //$book->addChapter("Notices", "Cover.html", $cover);
         $book->buildTOC(NULL, "toc", "Table of Contents", TRUE, TRUE);
+        $subject = "";
         
         foreach ($entries as $entry) {
             $tags = $this->store->retrieveTagsByEntry($entry['id']);
             foreach ($tags as $tag) {
-                $book->setSubject($tag['value']);
+                $subject =. $tag['value'] . ',';
             }
             
             $log->logLine("Set up parameters");
             
-            
-            
             $chapter = $content_start . $entry['content'] . $bookEnd;
             $book->addChapter($entry['title'], htmlspecialchars($entry['title']) . ".html", $chapter, true, EPub::EXTERNAL_REF_ADD);
+            $log->logLine("Added chapter " . $entry['title']);
         }    
-        
+        $book->setSubject($subject);
 
         if (DEBUG_POCHE) { 
         $epuplog = $book->getLog();