From a091fa72b08fee4bd92a9c1649c109e8c6eb695a Mon Sep 17 00:00:00 2001 From: Roberto Butti Date: Thu, 28 Dec 2023 17:58:26 +0100 Subject: [PATCH] More options - Adding the option for customizing the working path (the directory with the assets folder) - Adding the option for customizing the content path (the directory where you have your Markdown files) - Now you can organize your markdown files in subfolders - Eliminating most of the warnings during the EPUB generation process (thanks to the `epubcheck` tool) - Refactoring the configuration class --- CHANGELOG.md | 9 ++++ CONTRIBUTING.md | 19 ++++++- composer.json | 11 +++- readme.md | 87 ++++++++++++++++--------------- src/Commands/BaseBuildCommand.php | 39 ++++++-------- src/Commands/BuildEpubCommand.php | 78 ++++++++++++++++----------- src/Commands/BuildPdfCommand.php | 49 +++++++++++------ src/Commands/InitCommand.php | 6 +-- src/Config.php | 70 +++++++++++++++++++++++++ src/Ibis.php | 51 ------------------ 10 files changed, 249 insertions(+), 170 deletions(-) create mode 100644 src/Config.php delete mode 100644 src/Ibis.php diff --git a/CHANGELOG.md b/CHANGELOG.md index 1dc0412..0b18a4b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,14 @@ # Changelog +## 1.0.4 - WIP + +- Adding the option for customizing the working path (the directory with the assets folder) +- Adding the option for customizing the content path (the directory where you have your Markdown files) +- Now you can organize your markdown files in subfolders +- Eliminating most of the warnings during the EPUB generation process (thanks to the `epubcheck` tool) +- Refactoring the configuration class + + ## 1.0.3 - 21th December 2023 - Creating the export directory if not exist for EPUB creation - Improving metadata for EPUB diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 1b135c2..1f3297e 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -30,7 +30,21 @@ Before proposing or submitting new features, consider whether they are genuinely - Examine the codebase to prevent duplication of your proposed feature. - Check the pull requests to verify that another contributor hasn't already submitted the same feature or fix. -## Opening a Pull Request +### Follow the PER code style guide + +This project uses Laravel Pint to fix the code style according to `per` preset. +The `pint.json` file defines the Laravel Pint configuration. +Laravel Pint is built on top of the great tool PHP-CS-Fixer. + +To review code out of style, you can run the fix command as a dry run. Run the composer script like this: + +`composer run csfix-review` + +To fix the source code, run the following composer script: + +`composer run csfix` + +### Opening a Pull Request To maintain coding consistency, we adhere to the PER coding standard and use PHPStan for static code analysis (WIP). You can utilize the following command: @@ -40,7 +54,8 @@ composer all-check This command encompasses: - PER Coding Standard checks employing Laravel Pint. -- (WIP) PHPStan analysis at level 8. +- Executing some RectoryPHP checks, like the usage of PHP updated syntax (at least 8.1), the type declaration, early return, and dead code. For more info check the `rector.php` file in the root of the project. +- (WIP) PHPStan analysis. - (WIP) Execution of all tests from the `./tests/*` directory using PestPHP. We recommend running `composer all-check` before committing and creating a pull request. diff --git a/composer.json b/composer.json index 9f3b6e9..d13af0f 100644 --- a/composer.json +++ b/composer.json @@ -52,14 +52,23 @@ "csfix-review": [ "pint --test" ], + "refactor": [ + "rector process src" + ], + "refactor-review": [ + "rector process src --dry-run" + ], "all-check": [ + "@refactor-review", "@csfix" ] }, "scripts-descriptions": { "csfix": "Runs Pint to fix code style.", "csfix-review": "Runs Pint to show the code style review.", - "all-check": "Runs all checks needed." + "all-check": "Runs all checks needed.", + "refactor-review": "Runs Rector to show the code refactor review.", + "refactor": "Runs Rector and applies the refactor." }, "minimum-stability": "stable", "prefer-stable": true diff --git a/readme.md b/readme.md index 5543390..ab684e1 100644 --- a/readme.md +++ b/readme.md @@ -1,24 +1,23 @@

Ibis Next cover - -Artwork generated with Cover Wizard.

--- -This PHP tool helps you write eBooks in markdown. Run `ibis-next build` and an eBook will be generated with: +This PHP tool helps you write eBooks in markdown. You can automatically generate a PDF or an EPUB file. +Run `ibis-next build` or `ibis-next epub` and an eBook will be generated with: 1. A cover photo. 2. Clickable auto-generated table of contents. 3. Code syntax highlighting. -4. Available in 2 themes. Light and dark. +4. Available in 2 themes. Light and dark (the theme features is supported only for PDF). The Ibis project was created by Mohamed Said. The sources of the Ibis project are https://github.com/themsaid/ibis. We want to say thank you to Mohamed for creating this tool. Ibis was used to create [Laravel Queues in Action](https://learn-laravel-queues.com), an eBook Mohamed published in August 2020. [Click here](https://learn-laravel-queues.com/laravel-queues-in-action.zip) for the sample. -Why we forked the repository: to speed up the process of supporting PHP 8.2, PHP 8.3, Laravel 10, Symfony 7, Commonmark 2, and other dependencies upgrades. -Then we want to try to support also EPUB format, not only PDF. +Why we forked the repository: to speed up the process of supporting PHP 8.2, **PHP 8.3**, **Laravel 10**, **Symfony 7**, **Commonmark 2**, and other dependencies upgrades. +With *Ibis Next* we added also the **support for generating the EPUB format**. So with *Ibis Next* you can create your markdown files and then export them into PDF and EPUB for better compatibility with your devices and software. ## Installation @@ -30,39 +29,41 @@ You can decide if you want to install it locally for a specific project (eBook i If you want to start quickly to build your eBook you can: - create a new empty directory via the `mkdir` command, and then jump into the new directory via the `cd` command: -``` + +~~~shell mkdir my-first-ebook cd my-first-ebook -``` +~~~ + Now you are in the new empty directory, you can install Ibis Next: -``` +~~~shell composer require hi-folks/ibis-next -``` +~~~ Once the tool is installed, you will find the `vendor/` directory where you can find your new tool (`vendor/bin/ibis-next`). Now you can initialize properly the directory via the `init` command for automatically creating the configuration file, the assets folder, and the content folder (for creating your Markdown files). To launch the `init`` command: -``` +~~~shell ./vendor/bin/ibis-next init -``` +~~~ ### Installing ibis-next globally Instead, if you prefer to install the composer package globally you can add the `global` option while you are running the `composer require` command: -``` +~~~shell composer global require hi-folks/ibis-next -``` +~~~ Then, run this command inside an **empty directory**: -``` +~~~shell ibis-next init -``` +~~~ This will create the following files and directories: @@ -84,7 +85,7 @@ This sample content is taken from [Laravel Queues in Action](https://learn-larav Inside the `content` directory, you can write multiple `.md` files. Ibis uses the headings to divide the book into parts and chapters: -``` +~~~markdown # Part 1

tags define the start of a part. A separate PDF page will be generated to print the part title and any content below. @@ -96,39 +97,39 @@ Inside the `content` directory, you can write multiple `.md` files. Ibis uses th ### Starting with Ibis

tags define different titles inside a chapter. -``` +~~~ ### Adding different quotes Three different types of quotes can be added: `quote`, `warning`, and `notice`. -```md +~~~markdown >{quote} This is a quote. >{warning} This is a warning. >{notice} This is a notice. -``` +~~~ ### Using images Images can be stored in the content folder and then brought in like this: -``` +~~~markdown ![Screenshot 1](content/screenshot-1.png) -``` +~~~ ### Adding a cover image To use a cover image, add a `cover.jpg` in the `assets/` directory (or a `cover.html` file if you'd prefer a HTML-based cover page). If you don't want a cover image, delete these files. If your cover is in a PNG format you can store the file in the `assets/` directory and then in the `ibis.php` file you can adjust the `cover` configuration where you can set the cover file name, for example: -``` +~~~php 'cover' => [ 'position' => 'position: absolute; left:0; right: 0; top: -.2; bottom: 0;', 'dimensions' => 'width: 210mm; height: 297mm; margin: 0;', 'image' => 'cover.png', ], -``` +~~~ ### Setting the page headers @@ -136,17 +137,17 @@ You can set a page header for the pages. To add the header you need to set the `header` parameter in the `ibis.php` configuration file. For example, in the `ibis.php` file, you can set: -```php +~~~php /** * CSS inline style for the page header. * If you want to skip header, comment the line */ 'header' => 'font-style: italic; text-align: right; border-bottom: solid 1px #808080;', -``` +~~~ If you want to customize the page header for each section, in the markdown file, you can add in the frontmatter section the `title` parameter: -```markdown +~~~markdown --- title: My Title --- @@ -154,7 +155,7 @@ title: My Title ## My Section Title This is an example. -``` +~~~

Setting the Page Header @@ -167,17 +168,17 @@ Edit your `/ibis.php` configuration files to define the font files to be loaded ## Generating PDF eBook -``` +~~~shell ibis-next pdf -``` +~~~ Ibis will parse the files in alphabetical order and store the PDF file in the `export` directory. By default, for generating the PDF file, the light theme is used. To generate a PDF using the dark theme: -``` +~~~shell ibis-next pdf dark -``` +~~~ ### Using content from a different directory @@ -208,6 +209,16 @@ Ibis will parse the files in alphabetical order and store the EPUB file in the ` By default, for generating the EPUB file, the `assets/style.css` file is used. +If you are managing more than one book, you can use define the working directory. The working directory is the directory where your `assets` folder and `ibis.php` configuration file are located. You can define the path of the working directory via the `-w` option: + +``` +ibis-next epub -c ../your-dir-with-markdown-files -w ../myibisbook +``` + +You can combine the usage of the `-c` option for defining the content directory and the `-w` option for defining the working directory. + +> You can organize your Markdown files in your content directory in subfolders. + ## Generating A Sample ``` @@ -220,17 +231,7 @@ This command will use the generated files from the `ibis-next build` command to ## Development -This project uses Laravel Pint to fix the code style according to `per` preset. -The `pint.json` file defines the Laravel Pint configuration. -Laravel Pint is built on top of the great tool PHP-CS-Fixer. - -To review code out of style, you can run the fix command as a dry run. Run the composer script like this: - -`composer run csfix-review` - -To fix the source code, run the following composer script: - -`composer run csfix` +If you want to contribute to the development of this open-source project you can read the CONTRIBUTING.md file, at the root of the project. ## Credits diff --git a/src/Commands/BaseBuildCommand.php b/src/Commands/BaseBuildCommand.php index 945b277..982ba68 100644 --- a/src/Commands/BaseBuildCommand.php +++ b/src/Commands/BaseBuildCommand.php @@ -2,6 +2,7 @@ namespace Ibis\Commands; +use Ibis\Config; use SplFileInfo; use Illuminate\Filesystem\Filesystem; @@ -33,34 +34,28 @@ class BaseBuildCommand extends Command protected string $currentPath; - protected array $config; + protected Config $config; - protected function preExecute(InputInterface $input, OutputInterface $output) + protected function preExecute(InputInterface $input, OutputInterface $output): bool { $this->disk = new Filesystem(); $this->output = $output; - $this->currentPath = getcwd(); - - $this->contentDirectory = $input->getOption('content'); - if ($this->contentDirectory === "") { - $this->contentDirectory = getcwd() . DIRECTORY_SEPARATOR . "content"; - } - if (!$this->disk->isDirectory($this->contentDirectory)) { - $this->output->writeln('Error, check if ' . $this->contentDirectory . ' exists.'); - exit; + $this->config = Config::load($input->getOption('workingdir')); + $this->output->writeln('Loading config/assets from: ' . $this->config->workingPath . ''); + $this->output->writeln('Loading config file from: ' . $this->config->ibisConfigPath . ''); + if ($this->config->setContentPath($input->getOption('content')) === false) { + $this->output->writeln('Error, check if ' . $this->config->contentPath . ' exists.'); + return false; } - $this->output->writeln('Loading content from: ' . $this->contentDirectory . ''); + $this->output->writeln('Loading content from: ' . $this->config->contentPath . ''); - $configIbisFile = $this->currentPath . '/ibis.php'; - if (!$this->disk->isFile($configIbisFile)) { - $this->output->writeln('Error, check if ' . $configIbisFile . ' exists.'); - exit; + if (!$this->disk->isFile($this->config->ibisConfigPath)) { + $this->output->writeln('Error, check if ' . $this->config->ibisConfigPath . ' exists.'); + return false; } - - $this->config = require $configIbisFile; - + return true; } @@ -134,10 +129,8 @@ protected function prepareHtmlForEbook(string $html, $file, $breakLevel = 2): st '[break]' => '

' ]; - if ($file > 1) { - if ($breakLevel >= 1) { - $html = str_replace('

', '[break]

', $html); - } + if ($file > 1 && $breakLevel >= 1) { + $html = str_replace('

', '[break]

', $html); } if ($breakLevel >= 2) { $html = str_replace('

', '[break]

', $html); diff --git a/src/Commands/BuildEpubCommand.php b/src/Commands/BuildEpubCommand.php index 868b6e5..3e3a628 100644 --- a/src/Commands/BuildEpubCommand.php +++ b/src/Commands/BuildEpubCommand.php @@ -2,8 +2,6 @@ namespace Ibis\Commands; -use Ibis\Ibis; - use Illuminate\Support\Arr; use Illuminate\Support\Collection; @@ -11,6 +9,7 @@ use Symfony\Component\Console\Output\OutputInterface; use PHPePub\Core\EPub; use PHPePub\Core\Structure\OPF\MetaValue; +use Symfony\Component\Console\Command\Command; use Symfony\Component\Console\Input\InputOption; class BuildEpubCommand extends BaseBuildCommand @@ -32,6 +31,13 @@ protected function configure() 'The path of the content directory', '' ) + ->addOption( + 'workingdir', + 'd', + InputOption::VALUE_OPTIONAL, + 'The path of the working directory where `ibis.php` and `assets` directory are located', + '' + ) ->setDescription('Generate the book in EPUB format.'); } @@ -50,17 +56,19 @@ public function execute(InputInterface $input, OutputInterface $output): int $this->output->writeln('✨✨✨✨✨✨✨✨✨✨✨✨✨✨✨✨✨✨✨✨✨✨✨✨'); //return 0; - $this->preExecute($input, $output); + if (!$this->preExecute($input, $output)) { + return Command::INVALID; + } - $this->ensureExportDirectoryExists($this->currentPath); + $this->ensureExportDirectoryExists($this->config->workingPath); - $this->config["breakLevel"] = 1; + $this->config->config["breakLevel"] = 1; $result = $this->buildEpub( - $this->buildHtml($this->contentDirectory, $this->config), - $this->config, - $this->currentPath + $this->buildHtml($this->config->contentPath, $this->config->config), + $this->config->config, + $this->config->workingPath ); $this->output->writeln(''); @@ -72,7 +80,7 @@ public function execute(InputInterface $input, OutputInterface $output): int } - return 0; + return Command::SUCCESS; } @@ -92,47 +100,54 @@ protected function buildEpub(Collection $chapters, array $config, string $curren . "\n" . "\n" . "\n" - . "" . Ibis::title() . "\n" + . "" . $this->config->title() . "\n" . "\n" . "\n"; - $book = new EPub(); - $book->setTitle(Ibis::title()); - $book->setAuthor(Ibis::author(), Ibis::author()); - $book->setIdentifier(Ibis::title() . "&stamp=" . time(), EPub::IDENTIFIER_URI); - $book->setLanguage("en"); + $content_end = ""; - $book->addCSSFile("style.css", "css1", $this->getStyle($this->currentPath, "style")); + $book = new EPub(EPub::BOOK_VERSION_EPUB3, "en", EPub::DIRECTION_LEFT_TO_RIGHT); + $book->setIdentifier(md5($this->config->title() . " - " . $this->config->author()), EPub::IDENTIFIER_UUID); + $book->setLanguage("en"); + $book->setDescription($this->config->title() . " - " . $this->config->author()); + $book->setTitle($this->config->title()); + //$book->setPublisher("John and Jane Doe Publications", "http://JohnJaneDoePublications.com/"); + $book->setAuthor($this->config->author(), $this->config->author()); + $book->setIdentifier($this->config->title() . "&stamp=" . time(), EPub::IDENTIFIER_URI); + //$book->setLanguage("en"); + + $book->addCSSFile("style.css", "css1", $this->getStyle($this->config->workingPath, "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); - $cover = $content_start . "

" . Ibis::title() . "

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

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

\n"; + // + $cover = $content_start . "

" . $this->config->title() . "

\n"; + if ($this->config->author()) { + $cover .= "

By: " . $this->config->author() . "

\n"; } - $content_end = ""; + $cover .= $content_end; $coverImage = "cover.jpg"; if (array_key_exists("image", $config['cover'])) { $coverImage = $config['cover']['image']; } - if ($this->disk->isFile($currentPath . '/assets/' . $coverImage)) { - $this->output->writeln('==> Adding Book Cover ...'); + $pathCoverImage = $currentPath . '/assets/' . $coverImage; + if ($this->disk->isFile($pathCoverImage)) { + $this->output->writeln('==> Adding Book Cover ' . $pathCoverImage . ' ...'); $coverPosition = $config['cover']['position'] ?? 'position: absolute; left:0; right: 0; top: -.2; bottom: 0;'; $coverDimensions = $config['cover']['dimensions'] ?? 'width: 210mm; height: 297mm; margin: 0;'; - $book->setCoverImage("Cover.jpg", file_get_contents("assets/{$coverImage}"), "image/jpeg"); + $book->setCoverImage($coverImage, file_get_contents($pathCoverImage), mime_content_type($pathCoverImage)); } - - $book->addChapter("Notices", "Cover.html", $cover); $book->buildTOC(null, "toc", "Table of Contents", true, true); + $book->addChapter("Notices", "Cover.html", $cover); + //$book->addChapter("Table of Contents", "TOC.html", null, false, EPub::EXTERNAL_REF_IGNORE); //$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"]); + //$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 = new MetaValue("dc:creator", $this->config->author()); + $metaValue->addOpfAttr("file-as", $this->config->author()); $metaValue->addOpfAttr("role", "aut"); $book->addCustomMetaValue($metaValue); @@ -142,7 +157,7 @@ protected function buildEpub(Collection $chapters, array $config, string $curren $book->addChapter( Arr::get($chapter, "frontmatter.title", "Chapter " . $key + 1), - "Chapter" . $key . " .html", + "Chapter" . $key . ".html", $content_start . $chapter["html"] . $content_end ); //file_put_contents('export/' . "Chapter" . $key . " .html", $content_start . $chapter["html"] . $content_end); @@ -151,7 +166,8 @@ protected function buildEpub(Collection $chapters, array $config, string $curren $book->finalize(); - $epubFilename = 'export/' . Ibis::outputFileName() . '.epub'; + + $epubFilename = $currentPath . '/export/' . $this->config->outputFileName() . '.epub'; $book->saveBook($epubFilename); diff --git a/src/Commands/BuildPdfCommand.php b/src/Commands/BuildPdfCommand.php index e64e18d..dd939b8 100644 --- a/src/Commands/BuildPdfCommand.php +++ b/src/Commands/BuildPdfCommand.php @@ -2,7 +2,6 @@ namespace Ibis\Commands; -use Ibis\Ibis; use Mpdf\Mpdf; use Mpdf\Config\FontVariables; @@ -11,8 +10,7 @@ use Illuminate\Support\Arr; use Illuminate\Support\Collection; - - +use Symfony\Component\Console\Command\Command; use Symfony\Component\Console\Input\InputArgument; use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Output\OutputInterface; @@ -48,6 +46,13 @@ protected function configure() 'The path of the content directory', '' ) + ->addOption( + 'workingdir', + 'd', + InputOption::VALUE_OPTIONAL, + 'The path of the working directory where `ibis.php` and `assets` directory are located', + '' + ) ->setDescription('Generate the book in PDF format.'); } @@ -60,24 +65,28 @@ protected function configure() public function execute(InputInterface $input, OutputInterface $output): int { - $this->preExecute($input, $output); + + if (!$this->preExecute($input, $output)) { + return Command::INVALID; + } + $this->themeName = $input->getArgument('theme'); - $this->ensureExportDirectoryExists($this->currentPath); + $this->ensureExportDirectoryExists($this->config->workingPath); - $theme = $this->getTheme($this->currentPath, $this->themeName); + $theme = $this->getTheme($this->config->workingPath, $this->themeName); $this->buildPdf( - $this->buildHtml($this->contentDirectory, $this->config), - $this->config, - $this->currentPath, + $this->buildHtml($this->config->contentPath, $this->config->config), + $this->config->config, + $this->config->workingPath, $theme ); $this->output->writeln(''); $this->output->writeln('Book Built Successfully!'); - return 0; + return Command::SUCCESS; } @@ -89,7 +98,7 @@ public function execute(InputInterface $input, OutputInterface $output): int * @throws \Illuminate\Contracts\Filesystem\FileNotFoundException * @throws \Mpdf\MpdfException */ - protected function buildPdf(Collection $chapters, array $config, string $currentPath, string $theme) + protected function buildPdf(Collection $chapters, array $config, string $currentPath, string $theme): bool { $defaultConfig = (new ConfigVariables())->getDefaults(); $fontDirs = $defaultConfig['fontDir']; @@ -108,9 +117,9 @@ protected function buildPdf(Collection $chapters, array $config, string $current 'fontdata' => $this->fonts($config, $fontData), ]); - $pdf->SetTitle(Ibis::title()); - $pdf->SetAuthor(Ibis::author()); - $pdf->SetCreator(Ibis::author()); + $pdf->SetTitle($this->config->title()); + $pdf->SetAuthor($this->config->author()); + $pdf->SetCreator($this->config->author()); $pdf->setAutoTopMargin = 'pad'; @@ -135,7 +144,7 @@ protected function buildPdf(Collection $chapters, array $config, string $current $pdf->WriteHTML( << - + HTML ); @@ -182,9 +191,17 @@ protected function buildPdf(Collection $chapters, array $config, string $current $this->output->writeln(''); $this->output->writeln('✨✨ ' . $pdf->page . ' PDF pages ✨✨'); + $pdfFilename = $currentPath . '/export/' . $this->config->outputFileName() . '-' . $this->themeName . '.pdf'; + + + + $pdf->Output( - $currentPath . '/export/' . Ibis::outputFileName() . '-' . $this->themeName . '.pdf' + $pdfFilename ); + + $this->output->writeln('==> PDF file ' . $pdfFilename . ' created'); + return true; } /** diff --git a/src/Commands/InitCommand.php b/src/Commands/InitCommand.php index f7413c2..cddc2f5 100644 --- a/src/Commands/InitCommand.php +++ b/src/Commands/InitCommand.php @@ -40,9 +40,9 @@ public function execute(InputInterface $input, OutputInterface $output): int if ($this->disk->isDirectory($currentPath . '/assets')) { $this->output->writeln(''); - $this->output->writeln('Project already initialised!'); + $this->output->writeln('Project already initialised!'); - return 0; + return Command::INVALID; } $this->disk->makeDirectory( @@ -90,6 +90,6 @@ public function execute(InputInterface $input, OutputInterface $output): int $this->output->writeln(''); $this->output->writeln('Done!'); - return 0; + return Command::SUCCESS; } } diff --git a/src/Config.php b/src/Config.php new file mode 100644 index 0000000..2e5e2a8 --- /dev/null +++ b/src/Config.php @@ -0,0 +1,70 @@ +workingPath = "./"; + } elseif (!is_dir($workingPath)) { + $this->workingPath = "./"; + } + $this->ibisConfigPath = $this->workingPath . '/ibis.php'; + $this->config = require $this->ibisConfigPath; + } + + public static function load($directory = ""): self + { + return new self($directory); + } + + public function setContentPath($directory = ""): bool + { + $this->contentPath = $directory; + if ($this->contentPath === "") { + $this->contentPath = $this->workingPath . DIRECTORY_SEPARATOR . "content"; + } + return is_dir($this->contentPath); + + } + + /** + * + */ + public function title() + { + return $this->config['title']; + } + + /** + * + */ + public function outputFileName() + { + return Str::slug($this->title()); + } + + /** + * + */ + public function author() + { + return $this->config['author']; + } + +} diff --git a/src/Ibis.php b/src/Ibis.php deleted file mode 100644 index c3e153f..0000000 --- a/src/Ibis.php +++ /dev/null @@ -1,51 +0,0 @@ -