Add content🆕talk command
This commit is contained in:
parent
6083b78a7c
commit
d8e75fe3fb
7 changed files with 251 additions and 1 deletions
55
src/WebsiteBundle/Command/NewTalkCommand.php
Normal file
55
src/WebsiteBundle/Command/NewTalkCommand.php
Normal file
|
@ -0,0 +1,55 @@
|
|||
<?php
|
||||
|
||||
namespace WebsiteBundle\Command;
|
||||
|
||||
use Sculpin\Core\Console\Command\ContainerAwareCommand;
|
||||
use Symfony\Component\Console\Input\InputArgument;
|
||||
use Symfony\Component\Console\Input\InputInterface;
|
||||
use Symfony\Component\Console\Input\InputOption;
|
||||
use Symfony\Component\Console\Output\OutputInterface;
|
||||
use Symfony\Component\Console\Style\SymfonyStyle;
|
||||
|
||||
class NewTalkCommand extends ContainerAwareCommand
|
||||
{
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
protected function configure()
|
||||
{
|
||||
$this
|
||||
->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);
|
||||
}
|
||||
}
|
16
src/WebsiteBundle/Resources/stubs/talk.md
Normal file
16
src/WebsiteBundle/Resources/stubs/talk.md
Normal file
|
@ -0,0 +1,16 @@
|
|||
---
|
||||
title: "{{ title }}"
|
||||
speakerdeck:
|
||||
id: ~
|
||||
ratio: ~
|
||||
url: ~
|
||||
youtube:
|
||||
id: ~
|
||||
tags: []
|
||||
events: []
|
||||
---
|
||||
{% block excerpt %}
|
||||
{% endblock %}
|
||||
|
||||
{% block content %}
|
||||
{% endblock %}
|
9
src/WebsiteBundle/SculpinWebsiteBundle.php
Normal file
9
src/WebsiteBundle/SculpinWebsiteBundle.php
Normal file
|
@ -0,0 +1,9 @@
|
|||
<?php
|
||||
|
||||
namespace WebsiteBundle;
|
||||
|
||||
use Symfony\Component\HttpKernel\Bundle\Bundle;
|
||||
|
||||
class SculpinWebsiteBundle extends Bundle
|
||||
{
|
||||
}
|
5
src/WebsiteBundle/composer.json
Normal file
5
src/WebsiteBundle/composer.json
Normal file
|
@ -0,0 +1,5 @@
|
|||
{
|
||||
"require": {
|
||||
"spatie/string": "^2.2"
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue