1
0
mirror of https://github.com/themsaid/ibis.git synced 2025-01-16 21:18:35 +01:00

Merge branch 'master' into master

This commit is contained in:
Mohamed Said 2021-05-19 10:07:18 +02:00 committed by GitHub
commit 68633f4eea
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
7 changed files with 1208 additions and 25 deletions

34
.github/workflows/ci.yml vendored Normal file
View File

@ -0,0 +1,34 @@
name: CI for Ibis
on: [push, pull_request]
jobs:
php-cs-fixer:
runs-on: ubuntu-20.04
steps:
# This is required as this package does not support PHP 8 (yet)
- name: Setup PHP 7.4
uses: shivammathur/setup-php@v2
with:
php-version: '7.4'
- name: Checkout Code
uses: actions/checkout@v2
- name: Get Composer Cache Directory
id: composer-cache
run: |
echo "::set-output name=dir::$(composer config cache-files-dir)"
- name: Use Composer Cache
uses: actions/cache@v2
with:
path: ${{ steps.composer-cache.outputs.dir }}
key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }}
restore-keys: |
${{ runner.os }}-composer-
- name: Composer Install
run: "composer install --no-ansi --no-interaction --no-scripts --prefer-dist"
- name: Execute PHP CS Fixer review
run: composer run csfix-review

24
.php_cs
View File

@ -1,35 +1,35 @@
<?php
return PhpCsFixer\Config::create()
->setRules(array(
->setRules([
'@PSR2' => true,
'array_indentation' => true,
'array_syntax' => array('syntax' => 'short'),
'array_syntax' => ['syntax' => 'short'],
'combine_consecutive_unsets' => true,
'method_separation' => true,
'no_multiline_whitespace_before_semicolons' => true,
'single_quote' => true,
'binary_operator_spaces' => array(
'binary_operator_spaces' => [
'default' => 'single_space',
),
],
'blank_line_after_opening_tag' => true,
'braces' => array(
'braces' => [
'allow_single_line_closure' => true,
),
'concat_space' => array('spacing' => 'none'),
],
'concat_space' => ['spacing' => 'none'],
'declare_equal_normalize' => true,
'function_typehint_space' => true,
'hash_to_slash_comment' => true,
'include' => true,
'lowercase_cast' => true,
'no_extra_consecutive_blank_lines' => array(
'no_extra_consecutive_blank_lines' => [
'curly_brace_block',
'extra',
'parenthesis_brace_block',
'square_brace_block',
'throw',
'use',
),
],
'ordered_imports' => [
'sort_algorithm' => 'length'
],
@ -45,7 +45,5 @@ return PhpCsFixer\Config::create()
'unary_operator_spaces' => true,
'whitespace_after_comma_in_array' => true,
'not_operator_with_successor_space' => true,
))
//->setIndent("\t")
->setLineEnding("\n")
;
])
->setLineEnding("\n");

View File

@ -26,6 +26,7 @@
"spatie/commonmark-highlighter": "^2.1"
},
"require-dev": {
"friendsofphp/php-cs-fixer": "^2.18",
"symfony/var-dumper": "^5.0"
},
"autoload": {
@ -40,8 +41,15 @@
"scripts": {
"csfix": [
"php-cs-fixer fix src stubs --config=.php_cs"
],
"csfix-review": [
"php-cs-fixer fix src stubs --config=.php_cs --dry-run -v"
]
},
"scripts-descriptions": {
"csfix": "Runs PHP CS Fixer to fix project files.",
"csfix-review": "Runs PHP CS Fixer to show the details of which files are out of code standard."
},
"minimum-stability": "dev",
"prefer-stable": true
}

1137
composer.lock generated

File diff suppressed because it is too large Load Diff

View File

@ -13,7 +13,7 @@ This PHP tool helps you write eBooks in markdown. Run `ibis build` and an eBook
3. Code syntax highlighting.
4. Available in 2 themes. Light and dark.
Ibis was used to create [Laravel Queues in Action](https://learn-laravel-queues.com), an eBook I published in August 2020. [Click here](https://learn-laravel-queues.com/laravel-queues-in-action/laravel-queues-in-action.zip) for the sample.
Ibis was used to create [Laravel Queues in Action](https://learn-laravel-queues.com), an eBook I published in August 2020. [Click here](https://learn-laravel-queues.com/laravel-queues-in-action.zip) for the sample.
## Installation
@ -71,6 +71,10 @@ Images can be stored in the content folder and then brought in like this:
![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, just moit these files.
## Using Fonts
Edit your `/ibis.php` configuration files to define the font files to be loaded from the `/assets/fonts` directory. After that you may use the defined fonts in your themes (`/assets/theme-light.html` & `/assets/theme-dark.html`).
@ -99,6 +103,18 @@ ibis sample dark
This command will use the generated files from the `ibis build` command to generate samples from your PDF eBook. You can configure which pages to include in the sample by updating the `/ibis.php` file.
## Development
This project uses PHP CS Fixer with a code standard defined in `.php_cs`.
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`
## Credits
- [Mohamed Said](https://github.com/themsaid)

View File

@ -11,10 +11,10 @@ use League\CommonMark\Environment;
use Illuminate\Filesystem\Filesystem;
use Symfony\Component\Console\Command\Command;
use League\CommonMark\Block\Element\FencedCode;
use League\CommonMark\Extension\Table\TableExtension;
use Symfony\Component\Console\Input\InputArgument;
use Symfony\Component\Console\Input\InputInterface;
use Spatie\CommonMarkHighlighter\FencedCodeRenderer;
use League\CommonMark\Extension\Table\TableExtension;
use Symfony\Component\Console\Output\OutputInterface;
use League\CommonMark\GithubFlavoredMarkdownConverter;
@ -203,7 +203,7 @@ class BuildCommand extends Command
$pdf->SetMargins(400, 100, 12);
if ($this->disk->isFile($currentPath . '/assets/cover.jpg')) {
if ($this->disk->isFile($currentPath.'/assets/cover.jpg')) {
$this->output->writeln('<fg=yellow>==></> Adding Book Cover ...');
$coverPosition = $config['cover']['position'] ?? 'position: absolute; left:0; right: 0; top: -.2; bottom: 0;';
@ -218,7 +218,7 @@ HTML
);
$pdf->AddPage();
} elseif ($this->disk->isFile($currentPath . '/assets/cover.html')) {
} elseif ($this->disk->isFile($currentPath.'/assets/cover.html')) {
$this->output->writeln('<fg=yellow>==></> Adding Book Cover ...');
$cover = $this->disk->get($currentPath . '/assets/cover.html');

View File

@ -6,13 +6,11 @@ return [
*/
'title' => 'Laravel Queues in Action',
/**
* The author name.
*/
'author' => 'Mohamed Said',
/**
* The list of fonts to be used in the different themes.
*/
@ -21,7 +19,6 @@ return [
// 'times' => 'times-regular.ttf',
],
/**
* Document Dimensions.
*/
@ -41,7 +38,6 @@ return [
'H2' => 1,
],
/**
* Cover photo position and dimensions
*/
@ -50,7 +46,6 @@ return [
'dimensions' => 'width: 210mm; height: 297mm; margin: 0;',
],
/**
* Page ranges to be used with the sample command.
*/
@ -60,7 +55,6 @@ return [
[100, 103],
],
/**
* A notice printed at the final page of a generated sample.
*/