From d8e75fe3fb1b7da5768ed09dc30415618119223d Mon Sep 17 00:00:00 2001 From: Oliver Davies Date: Wed, 25 Jul 2018 22:44:11 +0100 Subject: [PATCH] Add content:new:talk command --- app/SculpinKernel.php | 2 + composer.json | 3 +- composer.lock | 162 +++++++++++++++++++ src/WebsiteBundle/Command/NewTalkCommand.php | 55 +++++++ src/WebsiteBundle/Resources/stubs/talk.md | 16 ++ src/WebsiteBundle/SculpinWebsiteBundle.php | 9 ++ src/WebsiteBundle/composer.json | 5 + 7 files changed, 251 insertions(+), 1 deletion(-) create mode 100644 src/WebsiteBundle/Command/NewTalkCommand.php create mode 100644 src/WebsiteBundle/Resources/stubs/talk.md create mode 100644 src/WebsiteBundle/SculpinWebsiteBundle.php create mode 100644 src/WebsiteBundle/composer.json diff --git a/app/SculpinKernel.php b/app/SculpinKernel.php index 025e686f..d58b9e84 100644 --- a/app/SculpinKernel.php +++ b/app/SculpinKernel.php @@ -5,6 +5,7 @@ use Opdavies\Sculpin\Bundle\ContentGeneratorBundle\SculpinContentGeneratorBundle use Opdavies\Sculpin\Bundle\GistEmbedBundle\SculpinGistEmbedBundle; use Opdavies\Sculpin\Bundle\TwigMarkdownBundle\SculpinTwigMarkdownBundle; use Sculpin\Bundle\SculpinBundle\HttpKernel\AbstractKernel; +use WebsiteBundle\SculpinWebsiteBundle; class SculpinKernel extends AbstractKernel { @@ -19,6 +20,7 @@ class SculpinKernel extends AbstractKernel SculpinTwigMarkdownBundle::class, SculpinFormatTalksBundle::class, + SculpinWebsiteBundle::class, ]; } } diff --git a/composer.json b/composer.json index 2719acee..d2ef4210 100644 --- a/composer.json +++ b/composer.json @@ -23,7 +23,8 @@ }, "autoload": { "psr-4": { - "FormatTalksBundle\\": "src/FormatTalksBundle" + "FormatTalksBundle\\": "src/FormatTalksBundle", + "WebsiteBundle\\": "src/WebsiteBundle" }, "files": ["src/helpers.php"] }, diff --git a/composer.lock b/composer.lock index 1588a85f..b794af77 100644 --- a/composer.lock +++ b/composer.lock @@ -6,6 +6,56 @@ ], "content-hash": "077bd67921b19ca9f0e2dbb0b3389f85", "packages": [ + { + "name": "anahkiasen/underscore-php", + "version": "2.0.0", + "source": { + "type": "git", + "url": "https://github.com/Anahkiasen/underscore-php.git", + "reference": "48f97b295c82d99c1fe10d8b0684c43f051b5580" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/Anahkiasen/underscore-php/zipball/48f97b295c82d99c1fe10d8b0684c43f051b5580", + "reference": "48f97b295c82d99c1fe10d8b0684c43f051b5580", + "shasum": "" + }, + "require": { + "doctrine/inflector": "^1.0", + "patchwork/utf8": "^1.2", + "php": ">=5.4.0" + }, + "require-dev": { + "fabpot/php-cs-fixer": "2.0.*@dev", + "phpunit/phpunit": "^4.6" + }, + "type": "library", + "autoload": { + "psr-4": { + "Underscore\\": [ + "src", + "tests" + ] + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Maxime Fabre", + "email": "ehtnam6@gmail.com" + } + ], + "description": "A redacted port of Underscore.js for PHP", + "keywords": [ + "internals", + "laravel", + "toolkit" + ], + "time": "2015-05-16T19:24:58+00:00" + }, { "name": "composer/ca-bundle", "version": "1.0.7", @@ -1086,6 +1136,65 @@ ], "time": "2017-03-18T10:39:19+00:00" }, + { + "name": "patchwork/utf8", + "version": "v1.3.1", + "source": { + "type": "git", + "url": "https://github.com/tchwork/utf8.git", + "reference": "30ec6451aec7d2536f0af8fe535f70c764f2c47a" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/tchwork/utf8/zipball/30ec6451aec7d2536f0af8fe535f70c764f2c47a", + "reference": "30ec6451aec7d2536f0af8fe535f70c764f2c47a", + "shasum": "" + }, + "require": { + "lib-pcre": ">=7.3", + "php": ">=5.3.0" + }, + "suggest": { + "ext-iconv": "Use iconv for best performance", + "ext-intl": "Use Intl for best performance", + "ext-mbstring": "Use Mbstring for best performance", + "ext-wfio": "Use WFIO for UTF-8 filesystem access on Windows" + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "1.3-dev" + } + }, + "autoload": { + "psr-4": { + "Patchwork\\": "src/Patchwork/" + }, + "classmap": [ + "src/Normalizer.php" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "(Apache-2.0 or GPL-2.0)" + ], + "authors": [ + { + "name": "Nicolas Grekas", + "email": "p@tchwork.com" + } + ], + "description": "Portable and performant UTF-8, Unicode and Grapheme Clusters for PHP", + "homepage": "https://github.com/tchwork/utf8", + "keywords": [ + "grapheme", + "i18n", + "unicode", + "utf-8", + "utf8" + ], + "time": "2016-05-18T13:57:10+00:00" + }, { "name": "psr/http-message", "version": "1.0.1", @@ -1731,6 +1840,59 @@ ], "time": "2015-10-13T18:44:15+00:00" }, + { + "name": "spatie/string", + "version": "2.2.2", + "source": { + "type": "git", + "url": "https://github.com/spatie/string.git", + "reference": "28607b9925b4f0499d48570553ca419c6298e26b" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/spatie/string/zipball/28607b9925b4f0499d48570553ca419c6298e26b", + "reference": "28607b9925b4f0499d48570553ca419c6298e26b", + "shasum": "" + }, + "require": { + "anahkiasen/underscore-php": "^2.0", + "php": ">=5.6.0" + }, + "require-dev": { + "phpunit/phpunit": "5.*", + "scrutinizer/ocular": "~1.1" + }, + "type": "library", + "autoload": { + "files": [ + "src/string_functions.php" + ], + "psr-4": { + "Spatie\\String\\": "src" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Freek Van der Herten", + "email": "freek@spatie.be", + "homepage": "https://murze.be", + "role": "Developer" + } + ], + "description": "String handling evolved", + "homepage": "https://github.com/spatie/string", + "keywords": [ + "handling", + "handy", + "spatie", + "string" + ], + "time": "2017-11-08T14:28:57+00:00" + }, { "name": "symfony/config", "version": "v2.8.27", diff --git a/src/WebsiteBundle/Command/NewTalkCommand.php b/src/WebsiteBundle/Command/NewTalkCommand.php new file mode 100644 index 00000000..9e941e4a --- /dev/null +++ b/src/WebsiteBundle/Command/NewTalkCommand.php @@ -0,0 +1,55 @@ +setName('content:new:talk') + ->setDescription('Create a new talk') + ->addArgument( + 'title', + InputArgument::REQUIRED, + 'The title of the post' + ); + // ->addOption( + // 'filename', + // null, + // InputOption::VALUE_OPTIONAL, + // 'The name of the file to generate' + // ) + // ->addOption( + // 'force', + // 'f', + // InputOption::VALUE_NONE, + // 'Overwrite the file if it already exists' + // ) + ; + } + + /** + * {@inheritdoc} + */ + protected function execute(InputInterface $input, OutputInterface $output) + { + $title = $input->getArgument('title'); + + $contents = file_get_contents(__DIR__.'/../Resources/stubs/talk.md'); + + $contents = str_replace('{{ title }}', $title, $contents); + + file_put_contents(__DIR__.'/../../../source/_talks/' . string($title)->slugify() .'.md', $contents); + } +} diff --git a/src/WebsiteBundle/Resources/stubs/talk.md b/src/WebsiteBundle/Resources/stubs/talk.md new file mode 100644 index 00000000..8ff15dce --- /dev/null +++ b/src/WebsiteBundle/Resources/stubs/talk.md @@ -0,0 +1,16 @@ +--- +title: "{{ title }}" +speakerdeck: + id: ~ + ratio: ~ + url: ~ +youtube: + id: ~ +tags: [] +events: [] +--- +{% block excerpt %} +{% endblock %} + +{% block content %} +{% endblock %} diff --git a/src/WebsiteBundle/SculpinWebsiteBundle.php b/src/WebsiteBundle/SculpinWebsiteBundle.php new file mode 100644 index 00000000..ad53930d --- /dev/null +++ b/src/WebsiteBundle/SculpinWebsiteBundle.php @@ -0,0 +1,9 @@ +