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 @@
- -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
@@ -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('