diff --git a/CHANGELOG.md b/CHANGELOG.md index de2e283..1dc0412 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,10 @@ # Changelog +## 1.0.3 - 21th December 2023 +- Creating the export directory if not exist for EPUB creation +- Improving metadata for EPUB +- Table of Contents or EPUB + ## 1.0.2 - 21th December 2023 - Setting the content directory - Refactoring common code EPUB and PDF build @@ -7,13 +12,13 @@ ## 1.0.1 - 21th December 2023 -- Welcome to EPUB generation +- Welcome to the EPUB generation ## 1.0.0 - 17th December 2023 - upgrade and check with PHP 8.2 and PHP 8.3 - update support for Symfony 7 components -- upgrade code using new renderer of CommonMark +- upgrade code using the new renderer of CommonMark - upgrade GitHub Actions workflow - using Pint with PSR12 - added configuration for cover image (instead of using hard-coded cover.jpg, you can specify a new file name and format, for example, my-cover.png) diff --git a/src/Commands/BuildEpubCommand.php b/src/Commands/BuildEpubCommand.php index 05d27f5..868b6e5 100644 --- a/src/Commands/BuildEpubCommand.php +++ b/src/Commands/BuildEpubCommand.php @@ -10,6 +10,7 @@ use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Output\OutputInterface; use PHPePub\Core\EPub; +use PHPePub\Core\Structure\OPF\MetaValue; use Symfony\Component\Console\Input\InputOption; class BuildEpubCommand extends BaseBuildCommand @@ -52,7 +53,7 @@ public function execute(InputInterface $input, OutputInterface $output): int $this->preExecute($input, $output); - + $this->ensureExportDirectoryExists($this->currentPath); $this->config["breakLevel"] = 1; @@ -99,13 +100,14 @@ protected function buildEpub(Collection $chapters, array $config, string $curren $book->setAuthor(Ibis::author(), Ibis::author()); $book->setIdentifier(Ibis::title() . "&stamp=" . time(), EPub::IDENTIFIER_URI); $book->setLanguage("en"); + $book->addCSSFile("style.css", "css1", $this->getStyle($this->currentPath, "style")); $cssData = file_get_contents("https://cdnjs.cloudflare.com/ajax/libs/highlight.js/11.9.0/styles/github.css"); $book->addCSSFile("github.css", "css2", $cssData); - //$book->addChapter("Table of Contents", "TOC.xhtml", null, false, EPub::EXTERNAL_REF_IGNORE); + $book->addChapter("Table of Contents", "TOC.xhtml", null, false, EPub::EXTERNAL_REF_IGNORE); $cover = $content_start . "

" . Ibis::title() . "

\n"; if (Ibis::author()) { - $cover .= "

By: " . Ibis::author() . "e

\n"; + $cover .= "

By: " . Ibis::author() . "

\n"; } $content_end = ""; $cover .= $content_end; @@ -122,11 +124,24 @@ protected function buildEpub(Collection $chapters, array $config, string $curren } $book->addChapter("Notices", "Cover.html", $cover); - $book->buildTOC(); + $book->buildTOC(null, "toc", "Table of Contents", true, true); + //$book->buildTOC(); + /* + $book->addFileToMETAINF("com.apple.ibooks.display-options.xml", "\n\n \n \n \n \n \n"); + */ + $book->addCustomNamespace("dc", "http://purl.org/dc/elements/1.1/"); // StaticData::$namespaces["dc"]); + // This is to show how to use meta data, normally you'd use the $book->setAuthor + $metaValue = new MetaValue("dc:creator", Ibis::author()); + $metaValue->addOpfAttr("file-as", Ibis::author()); + $metaValue->addOpfAttr("role", "aut"); + $book->addCustomMetaValue($metaValue); + + foreach ($chapters as $key => $chapter) { $this->output->writeln('==> ❇️ ' . $chapter["mdfile"] . ' ...'); + $book->addChapter( - Arr::get($chapter, "frontmatter.title", "Chapter " . $key), + Arr::get($chapter, "frontmatter.title", "Chapter " . $key + 1), "Chapter" . $key . " .html", $content_start . $chapter["html"] . $content_end );