diff options
author | tcit <tcit@tcit.fr> | 2014-05-14 22:03:16 +0200 |
---|---|---|
committer | tcit <tcit@tcit.fr> | 2014-05-14 22:03:16 +0200 |
commit | f2b6b4e23064c40cde9e2ad5327499589dee503b (patch) | |
tree | 9dc8fbe034293dccece1bec996a67c942dee8fa5 /inc | |
parent | 6a3c5101577d08d65c22706dea61bba23cca782b (diff) | |
download | wallabag-f2b6b4e23064c40cde9e2ad5327499589dee503b.tar.gz wallabag-f2b6b4e23064c40cde9e2ad5327499589dee503b.tar.zst wallabag-f2b6b4e23064c40cde9e2ad5327499589dee503b.zip |
Fix bugs and improved epub rendering
Diffstat (limited to 'inc')
-rw-r--r-- | inc/3rdparty/libraries/PHPePub/EPub.php | 14 | ||||
-rwxr-xr-x | inc/poche/Poche.class.php | 40 |
2 files changed, 28 insertions, 26 deletions
diff --git a/inc/3rdparty/libraries/PHPePub/EPub.php b/inc/3rdparty/libraries/PHPePub/EPub.php index e120b341..f1f41bd5 100644 --- a/inc/3rdparty/libraries/PHPePub/EPub.php +++ b/inc/3rdparty/libraries/PHPePub/EPub.php | |||
@@ -574,7 +574,7 @@ class EPub { | |||
574 | * @param string $mimetype Image mimetype, such as "image/jpeg" or "image/png". | 574 | * @param string $mimetype Image mimetype, such as "image/jpeg" or "image/png". |
575 | * @return bool $success | 575 | * @return bool $success |
576 | */ | 576 | */ |
577 | function setCover($fileName, $imageData = NULL, $mimetype = NULL, $coverText=NULL) { | 577 | function setCoverImage($fileName, $imageData = NULL, $mimetype = NULL,$bookTitle) { |
578 | if ($this->isFinalized || $this->isCoverImageSet || array_key_exists("CoverPage.html", $this->fileList)) { | 578 | if ($this->isFinalized || $this->isCoverImageSet || array_key_exists("CoverPage.html", $this->fileList)) { |
579 | return FALSE; | 579 | return FALSE; |
580 | } | 580 | } |
@@ -621,13 +621,13 @@ class EPub { | |||
621 | . "<html xmlns=\"http://www.w3.org/1999/xhtml\" xmlns:epub=\"http://www.idpf.org/2007/ops\" xml:lang=\"en\">\n" | 621 | . "<html xmlns=\"http://www.w3.org/1999/xhtml\" xmlns:epub=\"http://www.idpf.org/2007/ops\" xml:lang=\"en\">\n" |
622 | . "\t<head>\n" | 622 | . "\t<head>\n" |
623 | . "\t\t<meta http-equiv=\"Content-Type\" content=\"text/html; charset=UTF-8\"/>\n" | 623 | . "\t\t<meta http-equiv=\"Content-Type\" content=\"text/html; charset=UTF-8\"/>\n" |
624 | . "\t\t<title>Cover</title>\n" | 624 | . "\t\t<title>Cover Image</title>\n" |
625 | . "\t\t<link type=\"text/css\" rel=\"stylesheet\" href=\"Styles/CoverPage.css\" />\n" | 625 | . "\t\t<link type=\"text/css\" rel=\"stylesheet\" href=\"Styles/CoverPage.css\" />\n" |
626 | . "\t</head>\n" | 626 | . "\t</head>\n" |
627 | . "\t<body>\n" | 627 | . "\t<body>\n" |
628 | . "\t\t" . $coverText . "\n" | 628 | . "\t" . $bookTitle . "\n" |
629 | . "\t\t<div>\n" | 629 | . "\t\t<div>\n" |
630 | . "\t\t\t<img src=\"" . $imgPath . "\" alt=\"Cover image\" style=\"height: 40%\"/>\n" | 630 | . "\t\t\t<img src=\"" . $imgPath . "\" alt=\"Cover image\" style=\"height: 100%\"/>\n" |
631 | . "\t\t</div>\n" | 631 | . "\t\t</div>\n" |
632 | . "\t</body>\n" | 632 | . "\t</body>\n" |
633 | . "</html>\n"; | 633 | . "</html>\n"; |
@@ -636,13 +636,13 @@ class EPub { | |||
636 | . "<html xmlns=\"http://www.w3.org/1999/xhtml\" xmlns:epub=\"http://www.idpf.org/2007/ops\">\n" | 636 | . "<html xmlns=\"http://www.w3.org/1999/xhtml\" xmlns:epub=\"http://www.idpf.org/2007/ops\">\n" |
637 | . "<head>" | 637 | . "<head>" |
638 | . "\t<meta http-equiv=\"Default-Style\" content=\"text/html; charset=utf-8\" />\n" | 638 | . "\t<meta http-equiv=\"Default-Style\" content=\"text/html; charset=utf-8\" />\n" |
639 | . "\t\t<title>Cover</title>\n" | 639 | . "\t\t<title>Cover Image</title>\n" |
640 | . "\t\t<link type=\"text/css\" rel=\"stylesheet\" href=\"Styles/CoverPage.css\" />\n" | 640 | . "\t\t<link type=\"text/css\" rel=\"stylesheet\" href=\"Styles/CoverPage.css\" />\n" |
641 | . "\t</head>\n" | 641 | . "\t</head>\n" |
642 | . "\t<body>\n" | 642 | . "\t<body>\n" |
643 | . "\t\t<section epub:type=\"cover\">\n" | 643 | . "\t\t<section epub:type=\"cover\">\n" |
644 | . "\t\t" . $coverText . "\n" | 644 | . "\t" . $bookTitle . "\n" |
645 | . "\t\t\t<img src=\"" . $imgPath . "\" alt=\"Cover image\" style=\"height: 40%\"/>\n" | 645 | . "\t\t\t<img src=\"" . $imgPath . "\" alt=\"Cover image\" style=\"height: 30%\"/>\n" |
646 | . "\t\t</section>\n" | 646 | . "\t\t</section>\n" |
647 | . "\t</body>\n" | 647 | . "\t</body>\n" |
648 | . "</html>\n"; | 648 | . "</html>\n"; |
diff --git a/inc/poche/Poche.class.php b/inc/poche/Poche.class.php index 85dd3848..99d2989b 100755 --- a/inc/poche/Poche.class.php +++ b/inc/poche/Poche.class.php | |||
@@ -1142,23 +1142,28 @@ class Poche | |||
1142 | $entryID = filter_var($_GET['id'],FILTER_SANITIZE_NUMBER_INT); | 1142 | $entryID = filter_var($_GET['id'],FILTER_SANITIZE_NUMBER_INT); |
1143 | $entry = $this->store->retrieveOneById($entryID, $this->user->getId()); | 1143 | $entry = $this->store->retrieveOneById($entryID, $this->user->getId()); |
1144 | $entries = array($entry); | 1144 | $entries = array($entry); |
1145 | $bookTitle = $entry['title']; | ||
1145 | break; | 1146 | break; |
1146 | case 'all': | 1147 | case 'all': |
1147 | $entries = $this->store->retrieveAll($this->user->getId()); | 1148 | $entries = $this->store->retrieveAll($this->user->getId()); |
1149 | $bookTitle = _('All my articles'); | ||
1148 | break; | 1150 | break; |
1149 | case 'tag': | 1151 | case 'tag': |
1150 | $tag = filter_var($_GET['tag'],FILTER_SANITIZE_STRING); | 1152 | $tag = filter_var($_GET['tag'],FILTER_SANITIZE_STRING); |
1151 | $tags_id = $this->store->retrieveAllTags($this->user->getId(),$tag); | 1153 | $tags_id = $this->store->retrieveAllTags($this->user->getId(),$tag); |
1152 | $tag_id = $tags_id[0]["id"]; // we take the first result, which is supposed to match perfectly. There must be a workaround. | 1154 | $tag_id = $tags_id[0]["id"]; // we take the first result, which is supposed to match perfectly. There must be a workaround. |
1153 | $entries = $this->store->retrieveEntriesByTag($tag_id,$this->user->getId()); | 1155 | $entries = $this->store->retrieveEntriesByTag($tag_id,$this->user->getId()); |
1156 | $bookTitle = sprintf(_('Articles related to %s'),$tag); | ||
1154 | break; | 1157 | break; |
1155 | case 'category': | 1158 | case 'category': |
1156 | $category = filter_var($_GET['category'],FILTER_SANITIZE_STRING); | 1159 | $category = filter_var($_GET['category'],FILTER_SANITIZE_STRING); |
1157 | $entries = $this->store->getEntriesByView($category,$this->user->getId()); | 1160 | $entries = $this->store->getEntriesByView($category,$this->user->getId()); |
1161 | $bookTitle = sprintf(_('All my articles in category %s'), $category); | ||
1158 | break; | 1162 | break; |
1159 | case 'search': | 1163 | case 'search': |
1160 | $search = filter_var($_GET['search'],FILTER_SANITIZE_STRING); | 1164 | $search = filter_var($_GET['search'],FILTER_SANITIZE_STRING); |
1161 | $entries = $this->store->search($search,$this->user->getId()); | 1165 | $entries = $this->store->search($search,$this->user->getId()); |
1166 | $bookTitle = sprintf(_('All my articles for search %s'), $search); | ||
1162 | break; | 1167 | break; |
1163 | case 'default': | 1168 | case 'default': |
1164 | die(_('Uh, there is a problem while generating epub.')); | 1169 | die(_('Uh, there is a problem while generating epub.')); |
@@ -1166,12 +1171,11 @@ class Poche | |||
1166 | } | 1171 | } |
1167 | 1172 | ||
1168 | $content_start = | 1173 | $content_start = |
1169 | "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n" | 1174 | "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n" |
1170 | . "<!DOCTYPE html>\n" | 1175 | . "<html xmlns=\"http://www.w3.org/1999/xhtml\" xmlns:epub=\"http://www.idpf.org/2007/ops\">\n" |
1171 | . "<html>\n" | 1176 | . "<head>" |
1172 | . "<head>\n" | 1177 | . "<meta http-equiv=\"Default-Style\" content=\"text/html; charset=utf-8\" />\n" |
1173 | . "<link rel=\"stylesheet\" type=\"text/css\" href=\"styles.css\" />\n" | 1178 | . "<title>wallabag articles book</title>\n" |
1174 | . "<title>wallabag article</title>\n" | ||
1175 | . "</head>\n" | 1179 | . "</head>\n" |
1176 | . "<body>\n"; | 1180 | . "<body>\n"; |
1177 | 1181 | ||
@@ -1205,23 +1209,22 @@ class Poche | |||
1205 | $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"; | 1209 | $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"; |
1206 | 1210 | ||
1207 | $log->logLine("Add Cover"); | 1211 | $log->logLine("Add Cover"); |
1208 | if (count($entries)>1){ | ||
1209 | $cover = sprintf(_('<h1>%s and %s other articles</h1>'), $entries[0]['title'], count($entries)); | ||
1210 | } else { | ||
1211 | $cover = sprintf(_('<h1>%s</h1>'), $entries[0]['title']); | ||
1212 | } | ||
1213 | $book->setCover("Cover.png", file_get_contents("themes/baggy/img/apple-touch-icon-152.png"), "image/png", $cover); | ||
1214 | 1212 | ||
1213 | $fullTitle = "<h1> " . $bookTitle . "</h1>\n"; | ||
1214 | |||
1215 | $book->setCoverImage("Cover.png", file_get_contents("themes/baggy/img/apple-touch-icon-152.png"), "image/png", $fullTitle); | ||
1215 | 1216 | ||
1216 | $book->setCover($cover); | 1217 | $cover = $content_start . _('<span style="text-align:center;display:block;">Produced by wallabag with PHPePub</span>') . $bookEnd; |
1217 | //$book->addChapter("Notices", "Cover.html", $cover); | 1218 | |
1218 | $book->buildTOC(NULL, "toc", _('Table of Contents'), TRUE, TRUE); | 1219 | //$book->addChapter("Table of Contents", "TOC.xhtml", NULL, false, EPub::EXTERNAL_REF_IGNORE); |
1219 | $subject = ""; | 1220 | $book->addChapter("Notices", "Cover2.html", $cover); |
1221 | |||
1222 | $book->buildTOC(); | ||
1220 | 1223 | ||
1221 | foreach ($entries as $entry) { | 1224 | foreach ($entries as $entry) { |
1222 | $tags = $this->store->retrieveTagsByEntry($entry['id']); | 1225 | $tags = $this->store->retrieveTagsByEntry($entry['id']); |
1223 | foreach ($tags as $tag) { | 1226 | foreach ($tags as $tag) { |
1224 | $subject =. $tag['value'] . ','; | 1227 | $book->setSubject($tag['value']); |
1225 | } | 1228 | } |
1226 | 1229 | ||
1227 | $log->logLine("Set up parameters"); | 1230 | $log->logLine("Set up parameters"); |
@@ -1229,8 +1232,7 @@ class Poche | |||
1229 | $chapter = $content_start . $entry['content'] . $bookEnd; | 1232 | $chapter = $content_start . $entry['content'] . $bookEnd; |
1230 | $book->addChapter($entry['title'], htmlspecialchars($entry['title']) . ".html", $chapter, true, EPub::EXTERNAL_REF_ADD); | 1233 | $book->addChapter($entry['title'], htmlspecialchars($entry['title']) . ".html", $chapter, true, EPub::EXTERNAL_REF_ADD); |
1231 | $log->logLine("Added chapter " . $entry['title']); | 1234 | $log->logLine("Added chapter " . $entry['title']); |
1232 | } | 1235 | } |
1233 | $book->setSubject($subject); | ||
1234 | 1236 | ||
1235 | if (DEBUG_POCHE) { | 1237 | if (DEBUG_POCHE) { |
1236 | $epuplog = $book->getLog(); | 1238 | $epuplog = $book->getLog(); |