From d7679f5b8d9ac900229a91d59099974cb82568e1 Mon Sep 17 00:00:00 2001 From: Caen De Silva Date: Wed, 23 Mar 2022 19:29:52 +0100 Subject: [PATCH 1/5] Implement the Authors backend feature --- composer.json | 4 +- composer.lock | 1145 +++++++++++++++++++++ src/Actions/CreatesDefaultDirectories.php | 3 +- src/Models/Author.php | 48 + src/Services/AuthorService.php | 106 ++ 5 files changed, 1304 insertions(+), 2 deletions(-) create mode 100644 composer.lock create mode 100644 src/Models/Author.php create mode 100644 src/Services/AuthorService.php diff --git a/composer.json b/composer.json index 799f2120..61fa8158 100644 --- a/composer.json +++ b/composer.json @@ -14,7 +14,9 @@ } ], "require": { - "php": "^8.0" + "php": "^8.0", + "illuminate/support": "^9.5", + "symfony/yaml": "^6.0" }, "suggest": { "hyde/hyde" : "The Framework package contains the Hyde Core. To create your site you should use the Hyde/Hyde project." diff --git a/composer.lock b/composer.lock new file mode 100644 index 00000000..487740cc --- /dev/null +++ b/composer.lock @@ -0,0 +1,1145 @@ +{ + "_readme": [ + "This file locks the dependencies of your project to a known state", + "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", + "This file is @generated automatically" + ], + "content-hash": "e50e4e61233e28ba38d8c9b2eada8018", + "packages": [ + { + "name": "doctrine/inflector", + "version": "2.0.4", + "source": { + "type": "git", + "url": "https://github.com/doctrine/inflector.git", + "reference": "8b7ff3e4b7de6b2c84da85637b59fd2880ecaa89" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/doctrine/inflector/zipball/8b7ff3e4b7de6b2c84da85637b59fd2880ecaa89", + "reference": "8b7ff3e4b7de6b2c84da85637b59fd2880ecaa89", + "shasum": "" + }, + "require": { + "php": "^7.2 || ^8.0" + }, + "require-dev": { + "doctrine/coding-standard": "^8.2", + "phpstan/phpstan": "^0.12", + "phpstan/phpstan-phpunit": "^0.12", + "phpstan/phpstan-strict-rules": "^0.12", + "phpunit/phpunit": "^7.0 || ^8.0 || ^9.0", + "vimeo/psalm": "^4.10" + }, + "type": "library", + "autoload": { + "psr-4": { + "Doctrine\\Inflector\\": "lib/Doctrine/Inflector" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Guilherme Blanco", + "email": "guilhermeblanco@gmail.com" + }, + { + "name": "Roman Borschel", + "email": "roman@code-factory.org" + }, + { + "name": "Benjamin Eberlei", + "email": "kontakt@beberlei.de" + }, + { + "name": "Jonathan Wage", + "email": "jonwage@gmail.com" + }, + { + "name": "Johannes Schmitt", + "email": "schmittjoh@gmail.com" + } + ], + "description": "PHP Doctrine Inflector is a small library that can perform string manipulations with regard to upper/lowercase and singular/plural forms of words.", + "homepage": "https://www.doctrine-project.org/projects/inflector.html", + "keywords": [ + "inflection", + "inflector", + "lowercase", + "manipulation", + "php", + "plural", + "singular", + "strings", + "uppercase", + "words" + ], + "support": { + "issues": "https://github.com/doctrine/inflector/issues", + "source": "https://github.com/doctrine/inflector/tree/2.0.4" + }, + "funding": [ + { + "url": "https://www.doctrine-project.org/sponsorship.html", + "type": "custom" + }, + { + "url": "https://www.patreon.com/phpdoctrine", + "type": "patreon" + }, + { + "url": "https://tidelift.com/funding/github/packagist/doctrine%2Finflector", + "type": "tidelift" + } + ], + "time": "2021-10-22T20:16:43+00:00" + }, + { + "name": "illuminate/collections", + "version": "v9.5.1", + "source": { + "type": "git", + "url": "https://github.com/illuminate/collections.git", + "reference": "3cc51aa2a03a4c3bd4995e64e00ca795f65cb9c2" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/illuminate/collections/zipball/3cc51aa2a03a4c3bd4995e64e00ca795f65cb9c2", + "reference": "3cc51aa2a03a4c3bd4995e64e00ca795f65cb9c2", + "shasum": "" + }, + "require": { + "illuminate/conditionable": "^9.0", + "illuminate/contracts": "^9.0", + "illuminate/macroable": "^9.0", + "php": "^8.0.2" + }, + "suggest": { + "symfony/var-dumper": "Required to use the dump method (^6.0)." + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "9.x-dev" + } + }, + "autoload": { + "files": [ + "helpers.php" + ], + "psr-4": { + "Illuminate\\Support\\": "" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Taylor Otwell", + "email": "taylor@laravel.com" + } + ], + "description": "The Illuminate Collections package.", + "homepage": "https://laravel.com", + "support": { + "issues": "https://github.com/laravel/framework/issues", + "source": "https://github.com/laravel/framework" + }, + "time": "2022-03-15T13:34:43+00:00" + }, + { + "name": "illuminate/conditionable", + "version": "v9.5.1", + "source": { + "type": "git", + "url": "https://github.com/illuminate/conditionable.git", + "reference": "56b4ba1166c264064bf63896f498a2bee320d16a" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/illuminate/conditionable/zipball/56b4ba1166c264064bf63896f498a2bee320d16a", + "reference": "56b4ba1166c264064bf63896f498a2bee320d16a", + "shasum": "" + }, + "require": { + "php": "^8.0.2" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "9.x-dev" + } + }, + "autoload": { + "psr-4": { + "Illuminate\\Support\\": "" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Taylor Otwell", + "email": "taylor@laravel.com" + } + ], + "description": "The Illuminate Conditionable package.", + "homepage": "https://laravel.com", + "support": { + "issues": "https://github.com/laravel/framework/issues", + "source": "https://github.com/laravel/framework" + }, + "time": "2022-02-28T16:37:46+00:00" + }, + { + "name": "illuminate/contracts", + "version": "v9.5.1", + "source": { + "type": "git", + "url": "https://github.com/illuminate/contracts.git", + "reference": "7ef269f27f8ac0e1d0217a28ff5544ea8bbd0fee" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/illuminate/contracts/zipball/7ef269f27f8ac0e1d0217a28ff5544ea8bbd0fee", + "reference": "7ef269f27f8ac0e1d0217a28ff5544ea8bbd0fee", + "shasum": "" + }, + "require": { + "php": "^8.0.2", + "psr/container": "^1.1.1|^2.0.1", + "psr/simple-cache": "^1.0|^2.0|^3.0" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "9.x-dev" + } + }, + "autoload": { + "psr-4": { + "Illuminate\\Contracts\\": "" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Taylor Otwell", + "email": "taylor@laravel.com" + } + ], + "description": "The Illuminate Contracts package.", + "homepage": "https://laravel.com", + "support": { + "issues": "https://github.com/laravel/framework/issues", + "source": "https://github.com/laravel/framework" + }, + "time": "2022-03-12T17:02:05+00:00" + }, + { + "name": "illuminate/macroable", + "version": "v9.5.1", + "source": { + "type": "git", + "url": "https://github.com/illuminate/macroable.git", + "reference": "25a2c6dac2b7541ecbadef952702e84ae15f5354" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/illuminate/macroable/zipball/25a2c6dac2b7541ecbadef952702e84ae15f5354", + "reference": "25a2c6dac2b7541ecbadef952702e84ae15f5354", + "shasum": "" + }, + "require": { + "php": "^8.0.2" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "9.x-dev" + } + }, + "autoload": { + "psr-4": { + "Illuminate\\Support\\": "" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Taylor Otwell", + "email": "taylor@laravel.com" + } + ], + "description": "The Illuminate Macroable package.", + "homepage": "https://laravel.com", + "support": { + "issues": "https://github.com/laravel/framework/issues", + "source": "https://github.com/laravel/framework" + }, + "time": "2022-02-01T14:44:21+00:00" + }, + { + "name": "illuminate/support", + "version": "v9.5.1", + "source": { + "type": "git", + "url": "https://github.com/illuminate/support.git", + "reference": "fe167872090bd70ec8f9c26ebd81979dc44da167" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/illuminate/support/zipball/fe167872090bd70ec8f9c26ebd81979dc44da167", + "reference": "fe167872090bd70ec8f9c26ebd81979dc44da167", + "shasum": "" + }, + "require": { + "doctrine/inflector": "^2.0", + "ext-json": "*", + "ext-mbstring": "*", + "illuminate/collections": "^9.0", + "illuminate/conditionable": "^9.0", + "illuminate/contracts": "^9.0", + "illuminate/macroable": "^9.0", + "nesbot/carbon": "^2.53.1", + "php": "^8.0.2", + "voku/portable-ascii": "^2.0" + }, + "conflict": { + "tightenco/collect": "<5.5.33" + }, + "suggest": { + "illuminate/filesystem": "Required to use the composer class (^9.0).", + "league/commonmark": "Required to use Str::markdown() and Stringable::markdown() (^2.0.2).", + "ramsey/uuid": "Required to use Str::uuid() (^4.2.2).", + "symfony/process": "Required to use the composer class (^6.0).", + "symfony/var-dumper": "Required to use the dd function (^6.0).", + "vlucas/phpdotenv": "Required to use the Env class and env helper (^5.4.1)." + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "9.x-dev" + } + }, + "autoload": { + "files": [ + "helpers.php" + ], + "psr-4": { + "Illuminate\\Support\\": "" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Taylor Otwell", + "email": "taylor@laravel.com" + } + ], + "description": "The Illuminate Support package.", + "homepage": "https://laravel.com", + "support": { + "issues": "https://github.com/laravel/framework/issues", + "source": "https://github.com/laravel/framework" + }, + "time": "2022-03-13T14:56:16+00:00" + }, + { + "name": "nesbot/carbon", + "version": "2.57.0", + "source": { + "type": "git", + "url": "https://github.com/briannesbitt/Carbon.git", + "reference": "4a54375c21eea4811dbd1149fe6b246517554e78" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/briannesbitt/Carbon/zipball/4a54375c21eea4811dbd1149fe6b246517554e78", + "reference": "4a54375c21eea4811dbd1149fe6b246517554e78", + "shasum": "" + }, + "require": { + "ext-json": "*", + "php": "^7.1.8 || ^8.0", + "symfony/polyfill-mbstring": "^1.0", + "symfony/polyfill-php80": "^1.16", + "symfony/translation": "^3.4 || ^4.0 || ^5.0 || ^6.0" + }, + "require-dev": { + "doctrine/dbal": "^2.0 || ^3.0", + "doctrine/orm": "^2.7", + "friendsofphp/php-cs-fixer": "^3.0", + "kylekatarnls/multi-tester": "^2.0", + "phpmd/phpmd": "^2.9", + "phpstan/extension-installer": "^1.0", + "phpstan/phpstan": "^0.12.54 || ^1.0", + "phpunit/phpunit": "^7.5.20 || ^8.5.14", + "squizlabs/php_codesniffer": "^3.4" + }, + "bin": [ + "bin/carbon" + ], + "type": "library", + "extra": { + "branch-alias": { + "dev-3.x": "3.x-dev", + "dev-master": "2.x-dev" + }, + "laravel": { + "providers": [ + "Carbon\\Laravel\\ServiceProvider" + ] + }, + "phpstan": { + "includes": [ + "extension.neon" + ] + } + }, + "autoload": { + "psr-4": { + "Carbon\\": "src/Carbon/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Brian Nesbitt", + "email": "brian@nesbot.com", + "homepage": "https://markido.com" + }, + { + "name": "kylekatarnls", + "homepage": "https://github.com/kylekatarnls" + } + ], + "description": "An API extension for DateTime that supports 281 different languages.", + "homepage": "https://carbon.nesbot.com", + "keywords": [ + "date", + "datetime", + "time" + ], + "support": { + "docs": "https://carbon.nesbot.com/docs", + "issues": "https://github.com/briannesbitt/Carbon/issues", + "source": "https://github.com/briannesbitt/Carbon" + }, + "funding": [ + { + "url": "https://opencollective.com/Carbon", + "type": "open_collective" + }, + { + "url": "https://tidelift.com/funding/github/packagist/nesbot/carbon", + "type": "tidelift" + } + ], + "time": "2022-02-13T18:13:33+00:00" + }, + { + "name": "psr/container", + "version": "2.0.2", + "source": { + "type": "git", + "url": "https://github.com/php-fig/container.git", + "reference": "c71ecc56dfe541dbd90c5360474fbc405f8d5963" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/php-fig/container/zipball/c71ecc56dfe541dbd90c5360474fbc405f8d5963", + "reference": "c71ecc56dfe541dbd90c5360474fbc405f8d5963", + "shasum": "" + }, + "require": { + "php": ">=7.4.0" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "2.0.x-dev" + } + }, + "autoload": { + "psr-4": { + "Psr\\Container\\": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "PHP-FIG", + "homepage": "https://www.php-fig.org/" + } + ], + "description": "Common Container Interface (PHP FIG PSR-11)", + "homepage": "https://github.com/php-fig/container", + "keywords": [ + "PSR-11", + "container", + "container-interface", + "container-interop", + "psr" + ], + "support": { + "issues": "https://github.com/php-fig/container/issues", + "source": "https://github.com/php-fig/container/tree/2.0.2" + }, + "time": "2021-11-05T16:47:00+00:00" + }, + { + "name": "psr/simple-cache", + "version": "3.0.0", + "source": { + "type": "git", + "url": "https://github.com/php-fig/simple-cache.git", + "reference": "764e0b3939f5ca87cb904f570ef9be2d78a07865" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/php-fig/simple-cache/zipball/764e0b3939f5ca87cb904f570ef9be2d78a07865", + "reference": "764e0b3939f5ca87cb904f570ef9be2d78a07865", + "shasum": "" + }, + "require": { + "php": ">=8.0.0" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "3.0.x-dev" + } + }, + "autoload": { + "psr-4": { + "Psr\\SimpleCache\\": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "PHP-FIG", + "homepage": "https://www.php-fig.org/" + } + ], + "description": "Common interfaces for simple caching", + "keywords": [ + "cache", + "caching", + "psr", + "psr-16", + "simple-cache" + ], + "support": { + "source": "https://github.com/php-fig/simple-cache/tree/3.0.0" + }, + "time": "2021-10-29T13:26:27+00:00" + }, + { + "name": "symfony/polyfill-ctype", + "version": "v1.25.0", + "source": { + "type": "git", + "url": "https://github.com/symfony/polyfill-ctype.git", + "reference": "30885182c981ab175d4d034db0f6f469898070ab" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/symfony/polyfill-ctype/zipball/30885182c981ab175d4d034db0f6f469898070ab", + "reference": "30885182c981ab175d4d034db0f6f469898070ab", + "shasum": "" + }, + "require": { + "php": ">=7.1" + }, + "provide": { + "ext-ctype": "*" + }, + "suggest": { + "ext-ctype": "For best performance" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-main": "1.23-dev" + }, + "thanks": { + "name": "symfony/polyfill", + "url": "https://github.com/symfony/polyfill" + } + }, + "autoload": { + "files": [ + "bootstrap.php" + ], + "psr-4": { + "Symfony\\Polyfill\\Ctype\\": "" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Gert de Pagter", + "email": "BackEndTea@gmail.com" + }, + { + "name": "Symfony Community", + "homepage": "https://symfony.com/contributors" + } + ], + "description": "Symfony polyfill for ctype functions", + "homepage": "https://symfony.com", + "keywords": [ + "compatibility", + "ctype", + "polyfill", + "portable" + ], + "support": { + "source": "https://github.com/symfony/polyfill-ctype/tree/v1.25.0" + }, + "funding": [ + { + "url": "https://symfony.com/sponsor", + "type": "custom" + }, + { + "url": "https://github.com/fabpot", + "type": "github" + }, + { + "url": "https://tidelift.com/funding/github/packagist/symfony/symfony", + "type": "tidelift" + } + ], + "time": "2021-10-20T20:35:02+00:00" + }, + { + "name": "symfony/polyfill-mbstring", + "version": "v1.25.0", + "source": { + "type": "git", + "url": "https://github.com/symfony/polyfill-mbstring.git", + "reference": "0abb51d2f102e00a4eefcf46ba7fec406d245825" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/symfony/polyfill-mbstring/zipball/0abb51d2f102e00a4eefcf46ba7fec406d245825", + "reference": "0abb51d2f102e00a4eefcf46ba7fec406d245825", + "shasum": "" + }, + "require": { + "php": ">=7.1" + }, + "provide": { + "ext-mbstring": "*" + }, + "suggest": { + "ext-mbstring": "For best performance" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-main": "1.23-dev" + }, + "thanks": { + "name": "symfony/polyfill", + "url": "https://github.com/symfony/polyfill" + } + }, + "autoload": { + "files": [ + "bootstrap.php" + ], + "psr-4": { + "Symfony\\Polyfill\\Mbstring\\": "" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Nicolas Grekas", + "email": "p@tchwork.com" + }, + { + "name": "Symfony Community", + "homepage": "https://symfony.com/contributors" + } + ], + "description": "Symfony polyfill for the Mbstring extension", + "homepage": "https://symfony.com", + "keywords": [ + "compatibility", + "mbstring", + "polyfill", + "portable", + "shim" + ], + "support": { + "source": "https://github.com/symfony/polyfill-mbstring/tree/v1.25.0" + }, + "funding": [ + { + "url": "https://symfony.com/sponsor", + "type": "custom" + }, + { + "url": "https://github.com/fabpot", + "type": "github" + }, + { + "url": "https://tidelift.com/funding/github/packagist/symfony/symfony", + "type": "tidelift" + } + ], + "time": "2021-11-30T18:21:41+00:00" + }, + { + "name": "symfony/polyfill-php80", + "version": "v1.25.0", + "source": { + "type": "git", + "url": "https://github.com/symfony/polyfill-php80.git", + "reference": "4407588e0d3f1f52efb65fbe92babe41f37fe50c" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/symfony/polyfill-php80/zipball/4407588e0d3f1f52efb65fbe92babe41f37fe50c", + "reference": "4407588e0d3f1f52efb65fbe92babe41f37fe50c", + "shasum": "" + }, + "require": { + "php": ">=7.1" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-main": "1.23-dev" + }, + "thanks": { + "name": "symfony/polyfill", + "url": "https://github.com/symfony/polyfill" + } + }, + "autoload": { + "files": [ + "bootstrap.php" + ], + "psr-4": { + "Symfony\\Polyfill\\Php80\\": "" + }, + "classmap": [ + "Resources/stubs" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Ion Bazan", + "email": "ion.bazan@gmail.com" + }, + { + "name": "Nicolas Grekas", + "email": "p@tchwork.com" + }, + { + "name": "Symfony Community", + "homepage": "https://symfony.com/contributors" + } + ], + "description": "Symfony polyfill backporting some PHP 8.0+ features to lower PHP versions", + "homepage": "https://symfony.com", + "keywords": [ + "compatibility", + "polyfill", + "portable", + "shim" + ], + "support": { + "source": "https://github.com/symfony/polyfill-php80/tree/v1.25.0" + }, + "funding": [ + { + "url": "https://symfony.com/sponsor", + "type": "custom" + }, + { + "url": "https://github.com/fabpot", + "type": "github" + }, + { + "url": "https://tidelift.com/funding/github/packagist/symfony/symfony", + "type": "tidelift" + } + ], + "time": "2022-03-04T08:16:47+00:00" + }, + { + "name": "symfony/translation", + "version": "v6.0.6", + "source": { + "type": "git", + "url": "https://github.com/symfony/translation.git", + "reference": "f6639cb9b5e0c57fe31e3263b900a77eedb0c908" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/symfony/translation/zipball/f6639cb9b5e0c57fe31e3263b900a77eedb0c908", + "reference": "f6639cb9b5e0c57fe31e3263b900a77eedb0c908", + "shasum": "" + }, + "require": { + "php": ">=8.0.2", + "symfony/polyfill-mbstring": "~1.0", + "symfony/translation-contracts": "^2.3|^3.0" + }, + "conflict": { + "symfony/config": "<5.4", + "symfony/console": "<5.4", + "symfony/dependency-injection": "<5.4", + "symfony/http-kernel": "<5.4", + "symfony/twig-bundle": "<5.4", + "symfony/yaml": "<5.4" + }, + "provide": { + "symfony/translation-implementation": "2.3|3.0" + }, + "require-dev": { + "psr/log": "^1|^2|^3", + "symfony/config": "^5.4|^6.0", + "symfony/console": "^5.4|^6.0", + "symfony/dependency-injection": "^5.4|^6.0", + "symfony/finder": "^5.4|^6.0", + "symfony/http-client-contracts": "^1.1|^2.0|^3.0", + "symfony/http-kernel": "^5.4|^6.0", + "symfony/intl": "^5.4|^6.0", + "symfony/polyfill-intl-icu": "^1.21", + "symfony/service-contracts": "^1.1.2|^2|^3", + "symfony/yaml": "^5.4|^6.0" + }, + "suggest": { + "psr/log-implementation": "To use logging capability in translator", + "symfony/config": "", + "symfony/yaml": "" + }, + "type": "library", + "autoload": { + "files": [ + "Resources/functions.php" + ], + "psr-4": { + "Symfony\\Component\\Translation\\": "" + }, + "exclude-from-classmap": [ + "/Tests/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Fabien Potencier", + "email": "fabien@symfony.com" + }, + { + "name": "Symfony Community", + "homepage": "https://symfony.com/contributors" + } + ], + "description": "Provides tools to internationalize your application", + "homepage": "https://symfony.com", + "support": { + "source": "https://github.com/symfony/translation/tree/v6.0.6" + }, + "funding": [ + { + "url": "https://symfony.com/sponsor", + "type": "custom" + }, + { + "url": "https://github.com/fabpot", + "type": "github" + }, + { + "url": "https://tidelift.com/funding/github/packagist/symfony/symfony", + "type": "tidelift" + } + ], + "time": "2022-03-02T12:58:14+00:00" + }, + { + "name": "symfony/translation-contracts", + "version": "v3.0.0", + "source": { + "type": "git", + "url": "https://github.com/symfony/translation-contracts.git", + "reference": "1b6ea5a7442af5a12dba3dbd6d71034b5b234e77" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/symfony/translation-contracts/zipball/1b6ea5a7442af5a12dba3dbd6d71034b5b234e77", + "reference": "1b6ea5a7442af5a12dba3dbd6d71034b5b234e77", + "shasum": "" + }, + "require": { + "php": ">=8.0.2" + }, + "suggest": { + "symfony/translation-implementation": "" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-main": "3.0-dev" + }, + "thanks": { + "name": "symfony/contracts", + "url": "https://github.com/symfony/contracts" + } + }, + "autoload": { + "psr-4": { + "Symfony\\Contracts\\Translation\\": "" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Nicolas Grekas", + "email": "p@tchwork.com" + }, + { + "name": "Symfony Community", + "homepage": "https://symfony.com/contributors" + } + ], + "description": "Generic abstractions related to translation", + "homepage": "https://symfony.com", + "keywords": [ + "abstractions", + "contracts", + "decoupling", + "interfaces", + "interoperability", + "standards" + ], + "support": { + "source": "https://github.com/symfony/translation-contracts/tree/v3.0.0" + }, + "funding": [ + { + "url": "https://symfony.com/sponsor", + "type": "custom" + }, + { + "url": "https://github.com/fabpot", + "type": "github" + }, + { + "url": "https://tidelift.com/funding/github/packagist/symfony/symfony", + "type": "tidelift" + } + ], + "time": "2021-09-07T12:43:40+00:00" + }, + { + "name": "symfony/yaml", + "version": "v6.0.3", + "source": { + "type": "git", + "url": "https://github.com/symfony/yaml.git", + "reference": "e77f3ea0b21141d771d4a5655faa54f692b34af5" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/symfony/yaml/zipball/e77f3ea0b21141d771d4a5655faa54f692b34af5", + "reference": "e77f3ea0b21141d771d4a5655faa54f692b34af5", + "shasum": "" + }, + "require": { + "php": ">=8.0.2", + "symfony/polyfill-ctype": "^1.8" + }, + "conflict": { + "symfony/console": "<5.4" + }, + "require-dev": { + "symfony/console": "^5.4|^6.0" + }, + "suggest": { + "symfony/console": "For validating YAML files using the lint command" + }, + "bin": [ + "Resources/bin/yaml-lint" + ], + "type": "library", + "autoload": { + "psr-4": { + "Symfony\\Component\\Yaml\\": "" + }, + "exclude-from-classmap": [ + "/Tests/" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Fabien Potencier", + "email": "fabien@symfony.com" + }, + { + "name": "Symfony Community", + "homepage": "https://symfony.com/contributors" + } + ], + "description": "Loads and dumps YAML files", + "homepage": "https://symfony.com", + "support": { + "source": "https://github.com/symfony/yaml/tree/v6.0.3" + }, + "funding": [ + { + "url": "https://symfony.com/sponsor", + "type": "custom" + }, + { + "url": "https://github.com/fabpot", + "type": "github" + }, + { + "url": "https://tidelift.com/funding/github/packagist/symfony/symfony", + "type": "tidelift" + } + ], + "time": "2022-01-26T17:23:29+00:00" + }, + { + "name": "voku/portable-ascii", + "version": "2.0.1", + "source": { + "type": "git", + "url": "https://github.com/voku/portable-ascii.git", + "reference": "b56450eed252f6801410d810c8e1727224ae0743" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/voku/portable-ascii/zipball/b56450eed252f6801410d810c8e1727224ae0743", + "reference": "b56450eed252f6801410d810c8e1727224ae0743", + "shasum": "" + }, + "require": { + "php": ">=7.0.0" + }, + "require-dev": { + "phpunit/phpunit": "~6.0 || ~7.0 || ~9.0" + }, + "suggest": { + "ext-intl": "Use Intl for transliterator_transliterate() support" + }, + "type": "library", + "autoload": { + "psr-4": { + "voku\\": "src/voku/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Lars Moelleken", + "homepage": "http://www.moelleken.org/" + } + ], + "description": "Portable ASCII library - performance optimized (ascii) string functions for php.", + "homepage": "https://github.com/voku/portable-ascii", + "keywords": [ + "ascii", + "clean", + "php" + ], + "support": { + "issues": "https://github.com/voku/portable-ascii/issues", + "source": "https://github.com/voku/portable-ascii/tree/2.0.1" + }, + "funding": [ + { + "url": "https://www.paypal.me/moelleken", + "type": "custom" + }, + { + "url": "https://github.com/voku", + "type": "github" + }, + { + "url": "https://opencollective.com/portable-ascii", + "type": "open_collective" + }, + { + "url": "https://www.patreon.com/voku", + "type": "patreon" + }, + { + "url": "https://tidelift.com/funding/github/packagist/voku/portable-ascii", + "type": "tidelift" + } + ], + "time": "2022-03-08T17:03:00+00:00" + } + ], + "packages-dev": [], + "aliases": [], + "minimum-stability": "stable", + "stability-flags": [], + "prefer-stable": false, + "prefer-lowest": false, + "platform": { + "php": "^8.0" + }, + "platform-dev": [], + "plugin-api-version": "2.1.0" +} diff --git a/src/Actions/CreatesDefaultDirectories.php b/src/Actions/CreatesDefaultDirectories.php index 7602ff42..4ddc4207 100644 --- a/src/Actions/CreatesDefaultDirectories.php +++ b/src/Actions/CreatesDefaultDirectories.php @@ -12,8 +12,9 @@ class CreatesDefaultDirectories '_pages', '_posts', '_media', - '_site', '_docs', + '_data', + '_site', '_site/posts', '_site/media', '_site/docs', diff --git a/src/Models/Author.php b/src/Models/Author.php new file mode 100644 index 00000000..65fb174f --- /dev/null +++ b/src/Models/Author.php @@ -0,0 +1,48 @@ +username = $username; + if (isset($data['name'])) { + $this->name = $data['name']; + } + if (isset($data['website'])) { + $this->website = $data['website']; + } + } +} \ No newline at end of file diff --git a/src/Services/AuthorService.php b/src/Services/AuthorService.php new file mode 100644 index 00000000..387caf28 --- /dev/null +++ b/src/Services/AuthorService.php @@ -0,0 +1,106 @@ +filepath = $this->getFilepath(); + $this->yaml = $this->getYaml(); + $this->authors = $this->getAuthors(); + } + + /** + * Returns the filepath of the Yaml file. + * + * If the file does not exist, it will be created. + * + * @return string + */ + public function getFilepath(): string + { + $filepath = Hyde::path('_data/authors.yml'); + + if (!file_exists($filepath)) { + file_put_contents($filepath, <<<'EOF' +# In this file you can declare custom authors. + +# In the default example, `mr_hyde` is the username. +# When setting the author to mr_hyde in a blog post, +# the data in the array will automatically be added. + +authors: + mr_hyde: + name: Mr Hyde + website: https://github.com/hydephp/hyde +EOF +); + } + + return $filepath; + } + + /** + * Parse the Yaml file. + * + * If the Yaml cannot be parsed, it will back up the file and regenerate it. + * + * @return array + */ + public function getYaml(): array + { + $yaml = Yaml::parse(file_get_contents($this->filepath)); + + if (!isset($yaml['authors'])) { + copy($this->filepath, $this->filepath . '.corrupted'); + unlink($this->filepath); + $this->getFilepath(); + return $this->getYaml(); + } + + return $yaml; + } + + /** + * Use the Yaml array to parse and collect the Authors + * + * @return Collection + */ + public function getAuthors(): Collection + { + $collection = new Collection(); + + foreach ($this->yaml['authors'] as $username => $data) { + $collection->push(new Author($username, $data)); + } + + return $collection; + } + + /** + * Find and retrieve an Author by their username. + * + * @param string $username + * @return Author|false + */ + public static function find(string $username): Author|false + { + $service = new self; + return $service->authors->firstWhere('username', $username) ?? false; + } +} \ No newline at end of file From edae77bf7282e0dbfcfd7b9caad35149fdfde424 Mon Sep 17 00:00:00 2001 From: Caen De Silva Date: Wed, 23 Mar 2022 20:14:38 +0100 Subject: [PATCH 2/5] Add a fuzzy search to attempt to convert names to usernames --- src/Services/AuthorService.php | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/src/Services/AuthorService.php b/src/Services/AuthorService.php index 387caf28..2ae873b4 100644 --- a/src/Services/AuthorService.php +++ b/src/Services/AuthorService.php @@ -5,6 +5,7 @@ use Hyde\Framework\Hyde; use Hyde\Framework\Models\Author; use Illuminate\Support\Collection; +use Illuminate\Support\Str; use Symfony\Component\Yaml\Yaml; /** @@ -95,12 +96,16 @@ public function getAuthors(): Collection /** * Find and retrieve an Author by their username. * - * @param string $username + * @param string $username of the Author to search for + * @param bool $forgiving should the search be fuzzy? * @return Author|false */ - public static function find(string $username): Author|false + public static function find(string $username, bool $forgiving = true): Author|false { $service = new self; + if ($forgiving) { + $username = Str::snake($username); + } return $service->authors->firstWhere('username', $username) ?? false; } } \ No newline at end of file From e061316bbe340d5dcad6b31cc63735df50fcab75 Mon Sep 17 00:00:00 2001 From: Caen De Silva Date: Wed, 23 Mar 2022 20:21:12 +0100 Subject: [PATCH 3/5] Add stubs to aid in testing --- config/commands.php | 1 + src/Commands/PublishStubsCommand.php | 72 +++++++++++++++++++++++ tests/stubs/_data/authors.yml | 13 ++++ tests/stubs/_posts/alice-in-wonderland.md | 22 +++++++ tests/stubs/_posts/my-new-post.md | 10 ++++ 5 files changed, 118 insertions(+) create mode 100644 src/Commands/PublishStubsCommand.php create mode 100644 tests/stubs/_data/authors.yml create mode 100644 tests/stubs/_posts/alice-in-wonderland.md create mode 100644 tests/stubs/_posts/my-new-post.md diff --git a/config/commands.php b/config/commands.php index 0b2542ce..10c72e70 100644 --- a/config/commands.php +++ b/config/commands.php @@ -70,6 +70,7 @@ Illuminate\Console\Scheduling\ScheduleFinishCommand::class, LaravelZero\Framework\Commands\StubPublishCommand::class, Hyde\Framework\Commands\MakeValidatorCommand::class, + Hyde\Framework\Commands\PublishStubsCommand::class, Hyde\Framework\Commands\Debug::class, ], diff --git a/src/Commands/PublishStubsCommand.php b/src/Commands/PublishStubsCommand.php new file mode 100644 index 00000000..97420da8 --- /dev/null +++ b/src/Commands/PublishStubsCommand.php @@ -0,0 +1,72 @@ +option('clean')) { + if ((config('app.env', 'production') === 'development') || $this->option('force')) { + $this->error('Purging files, I hope you know what you are doing.'); + $this->purge(); + } else { + $this->error('This command cannot be run in production unless the force flag is set.'); + return 403; + } + } + + $this->info('Publishing test stubs'); + + File::copyDirectory(Hyde::path('vendor/hyde/framework/tests/stubs/_posts'), Hyde::path('_posts')); + File::copyDirectory(Hyde::path('vendor/hyde/framework/tests/stubs/_data'), Hyde::path('_data')); + + $this->info('Done!'); + } + + + public function purge() + { + $this->warn('Removing all _content directories.'); + + File::deleteDirectory(Hyde::path('_data')); + File::deleteDirectory(Hyde::path('_docs')); + File::deleteDirectory(Hyde::path('_drafts')); + File::deleteDirectory(Hyde::path('_media')); + File::deleteDirectory(Hyde::path('_pages')); + File::deleteDirectory(Hyde::path('_posts')); + File::deleteDirectory(Hyde::path('_site')); + + $this->line(' > Directories purged'); + + $this->line(' > Recreating directories'); + (new CreatesDefaultDirectories)->__invoke(); + + $this->line(''); + } +} diff --git a/tests/stubs/_data/authors.yml b/tests/stubs/_data/authors.yml new file mode 100644 index 00000000..f8dd77f4 --- /dev/null +++ b/tests/stubs/_data/authors.yml @@ -0,0 +1,13 @@ +# In this file you can declare custom authors. + +# In the default example, `mr_hyde` is the username. +# When setting the author to mr_hyde in a blog post, +# the data in the array will automatically be added. + +authors: + mr_hyde: + name: Mr Hyde + website: https://github.com/hydephp/hyde + lewis_carroll: + name: Lewis Carroll + \ No newline at end of file diff --git a/tests/stubs/_posts/alice-in-wonderland.md b/tests/stubs/_posts/alice-in-wonderland.md new file mode 100644 index 00000000..36a445b8 --- /dev/null +++ b/tests/stubs/_posts/alice-in-wonderland.md @@ -0,0 +1,22 @@ +--- +title: Alice's Adventures in Wonderland +description: All in the golden afternoon ⁠Full leisurely we glide; For both our oars, with little skill, ⁠By little arms are plied, While little hands make vain pretence ⁠Our wanderings to guide. +category: novels +author: Lewis Carroll +date: 1865-11-18 18:52 +--- + +## CHAPTER I. DOWN THE RABBIT-HOLE. + +> This piece of work is in the public domain and was made available through [Wikisource](https://en.wikisource.org/wiki/Alice%27s_Adventures_in_Wonderland_(1866)). + + +Alice was beginning to get very tired of sitting by her sister on the bank, and of having nothing to do: once or twice she had peeped into the book her sister was reading, but it had no pictures or conversations in it, "and what is the use of a book," thought Alice, "without pictures or conversations?" + +![Illustration d'origine (1865), par John Tenniel](https://upload.wikimedia.org/wikipedia/commons/6/63/Alice_par_John_Tenniel_04.png) + +So she was considering in her own mind, (as well as she could, for the hot day made her feel very sleepy and stupid,) whether the pleasure of making a daisy-chain would be worth the trouble of getting up and picking the daisies, when suddenly a white rabbit with pink eyes ran close by her. + +There was nothing so very remarkable in that; nor did Alice think it so very much out of the way to hear the Rabbit say to itself, "Oh dear! Oh dear! I shall be too late!" (when she thought it over afterwards, it occurred to her that she ought to have wondered at this, but at the time it all seemed quite natural;) but when the Rabbit actually took a watch out of its waistcoat-pocket, and looked at it, and then hurried on, Alice started to her feet, for it flashed across her mind that she had never before seen a rabbit with either a waistcoat-pocket, or a watch to take out of it, and, burning with curiosity, she ran across the field after it, and was just in time to see it pop down a large rabbit-hole under the hedge. + +In another moment down went Alice after it, never once considering how in the world she was to get out again. \ No newline at end of file diff --git a/tests/stubs/_posts/my-new-post.md b/tests/stubs/_posts/my-new-post.md new file mode 100644 index 00000000..02855d21 --- /dev/null +++ b/tests/stubs/_posts/my-new-post.md @@ -0,0 +1,10 @@ +--- +title: My New Post +description: A short description used in previews and SEO +category: blog +author: Mr. Hyde +date: 2022-03-23 18:40 +--- + +## Write something awesome. + From f1827e65c05a3c957bbdd7cac58ae5868c7fe6d1 Mon Sep 17 00:00:00 2001 From: Caen De Silva Date: Wed, 23 Mar 2022 20:41:50 +0100 Subject: [PATCH 4/5] Fix trailing carrige return bug on Windows --- src/MarkdownPostParser.php | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/MarkdownPostParser.php b/src/MarkdownPostParser.php index 0feae9e2..ffec890c 100644 --- a/src/MarkdownPostParser.php +++ b/src/MarkdownPostParser.php @@ -144,6 +144,8 @@ public function parseFrontMatter(array $lines): array // Trim trailing whitespace $value = trim($value, ' '); + // Trim trailing return character + $value = trim($value, "\r"); $matter[$key] = $value; } From 16936d7f8a865aefe62636cb5e7a90f97498f11b Mon Sep 17 00:00:00 2001 From: Caen De Silva Date: Wed, 23 Mar 2022 20:42:09 +0100 Subject: [PATCH 5/5] Add the Author data --- resources/views/components/post/author.blade.php | 12 ++++++++++-- tests/stubs/_data/authors.yml | 2 +- tests/stubs/_posts/my-new-post.md | 2 +- 3 files changed, 12 insertions(+), 4 deletions(-) diff --git a/resources/views/components/post/author.blade.php b/resources/views/components/post/author.blade.php index 7d8c6b21..647593c5 100644 --- a/resources/views/components/post/author.blade.php +++ b/resources/views/components/post/author.blade.php @@ -1,5 +1,13 @@ +@php + $authorObject = Hyde\Framework\Services\AuthorService::find($author); +@endphp by author
- {{ $author }} - {{-- @todo Add more properties such as social media links --}} + @if($authorObject && $authorObject->website) + + @endif
diff --git a/tests/stubs/_data/authors.yml b/tests/stubs/_data/authors.yml index f8dd77f4..944d8a13 100644 --- a/tests/stubs/_data/authors.yml +++ b/tests/stubs/_data/authors.yml @@ -6,7 +6,7 @@ authors: mr_hyde: - name: Mr Hyde + name: Mr. Hyde website: https://github.com/hydephp/hyde lewis_carroll: name: Lewis Carroll diff --git a/tests/stubs/_posts/my-new-post.md b/tests/stubs/_posts/my-new-post.md index 02855d21..86f86373 100644 --- a/tests/stubs/_posts/my-new-post.md +++ b/tests/stubs/_posts/my-new-post.md @@ -2,7 +2,7 @@ title: My New Post description: A short description used in previews and SEO category: blog -author: Mr. Hyde +author: mr_hyde date: 2022-03-23 18:40 ---