Add Markdown support for posts
This commit is contained in:
parent
9a4030f19a
commit
3ae6392aae
@ -13,7 +13,7 @@ class AppServiceProvider extends ServiceProvider
|
|||||||
*/
|
*/
|
||||||
public function register()
|
public function register()
|
||||||
{
|
{
|
||||||
//
|
$this->app->singleton(Parsedown::class);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -9,7 +9,9 @@
|
|||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"require": {
|
"require": {
|
||||||
"php": "^7.2",
|
"php": "^7.2",
|
||||||
|
"davidbadura/faker-markdown-generator": "^1.0",
|
||||||
"fideloper/proxy": "^4.0",
|
"fideloper/proxy": "^4.0",
|
||||||
|
"graham-campbell/markdown": "^12.0",
|
||||||
"laravel/framework": "^7.0",
|
"laravel/framework": "^7.0",
|
||||||
"laravel/tinker": "^2.0"
|
"laravel/tinker": "^2.0"
|
||||||
},
|
},
|
||||||
|
257
composer.lock
generated
257
composer.lock
generated
@ -4,8 +4,96 @@
|
|||||||
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies",
|
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies",
|
||||||
"This file is @generated automatically"
|
"This file is @generated automatically"
|
||||||
],
|
],
|
||||||
"content-hash": "fc98d6ceedf442855112995ab62ccccd",
|
"content-hash": "d61ae394179317854afc58130475daaf",
|
||||||
"packages": [
|
"packages": [
|
||||||
|
{
|
||||||
|
"name": "davidbadura/faker-markdown-generator",
|
||||||
|
"version": "1.0.0",
|
||||||
|
"source": {
|
||||||
|
"type": "git",
|
||||||
|
"url": "https://github.com/DavidBadura/FakerMarkdownGenerator.git",
|
||||||
|
"reference": "acfeeedb3d3f2bd9092823818c65733360d71b5d"
|
||||||
|
},
|
||||||
|
"dist": {
|
||||||
|
"type": "zip",
|
||||||
|
"url": "https://api.github.com/repos/DavidBadura/FakerMarkdownGenerator/zipball/acfeeedb3d3f2bd9092823818c65733360d71b5d",
|
||||||
|
"reference": "acfeeedb3d3f2bd9092823818c65733360d71b5d",
|
||||||
|
"shasum": ""
|
||||||
|
},
|
||||||
|
"require": {
|
||||||
|
"davidbadura/markdown-builder": "^1.0",
|
||||||
|
"fzaninotto/faker": "^1.6",
|
||||||
|
"php": ">=5.4.0"
|
||||||
|
},
|
||||||
|
"type": "library",
|
||||||
|
"autoload": {
|
||||||
|
"psr-4": {
|
||||||
|
"DavidBadura\\FakerMarkdownGenerator\\": "src/"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"notification-url": "https://packagist.org/downloads/",
|
||||||
|
"license": [
|
||||||
|
"MIT"
|
||||||
|
],
|
||||||
|
"authors": [
|
||||||
|
{
|
||||||
|
"name": "DavidBadura",
|
||||||
|
"email": "d.badura@gmx.de"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"description": "Faker Markdown Generator",
|
||||||
|
"keywords": [
|
||||||
|
"faker",
|
||||||
|
"generator",
|
||||||
|
"markdown"
|
||||||
|
],
|
||||||
|
"time": "2016-06-28T18:33:06+00:00"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "davidbadura/markdown-builder",
|
||||||
|
"version": "1.0.4",
|
||||||
|
"source": {
|
||||||
|
"type": "git",
|
||||||
|
"url": "https://github.com/DavidBadura/markdown-builder.git",
|
||||||
|
"reference": "7e5a9106522d513dcd138afad714da1188556a0d"
|
||||||
|
},
|
||||||
|
"dist": {
|
||||||
|
"type": "zip",
|
||||||
|
"url": "https://api.github.com/repos/DavidBadura/markdown-builder/zipball/7e5a9106522d513dcd138afad714da1188556a0d",
|
||||||
|
"reference": "7e5a9106522d513dcd138afad714da1188556a0d",
|
||||||
|
"shasum": ""
|
||||||
|
},
|
||||||
|
"require": {
|
||||||
|
"php": ">=5.4.0"
|
||||||
|
},
|
||||||
|
"require-dev": {
|
||||||
|
"phpunit/phpunit": "~4.4"
|
||||||
|
},
|
||||||
|
"type": "library",
|
||||||
|
"autoload": {
|
||||||
|
"psr-4": {
|
||||||
|
"DavidBadura\\MarkdownBuilder\\": "src/"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"notification-url": "https://packagist.org/downloads/",
|
||||||
|
"license": [
|
||||||
|
"MIT"
|
||||||
|
],
|
||||||
|
"authors": [
|
||||||
|
{
|
||||||
|
"name": "DavidBadura",
|
||||||
|
"email": "d.badura@gmx.de"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"description": "Markdown Builder",
|
||||||
|
"keywords": [
|
||||||
|
"builder",
|
||||||
|
"markdown",
|
||||||
|
"render",
|
||||||
|
"writer"
|
||||||
|
],
|
||||||
|
"time": "2018-05-21T09:17:46+00:00"
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"name": "dnoegel/php-xdg-base-dir",
|
"name": "dnoegel/php-xdg-base-dir",
|
||||||
"version": "v0.1.1",
|
"version": "v0.1.1",
|
||||||
@ -334,6 +422,123 @@
|
|||||||
],
|
],
|
||||||
"time": "2020-02-22T01:51:47+00:00"
|
"time": "2020-02-22T01:51:47+00:00"
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
"name": "fzaninotto/faker",
|
||||||
|
"version": "v1.9.1",
|
||||||
|
"source": {
|
||||||
|
"type": "git",
|
||||||
|
"url": "https://github.com/fzaninotto/Faker.git",
|
||||||
|
"reference": "fc10d778e4b84d5bd315dad194661e091d307c6f"
|
||||||
|
},
|
||||||
|
"dist": {
|
||||||
|
"type": "zip",
|
||||||
|
"url": "https://api.github.com/repos/fzaninotto/Faker/zipball/fc10d778e4b84d5bd315dad194661e091d307c6f",
|
||||||
|
"reference": "fc10d778e4b84d5bd315dad194661e091d307c6f",
|
||||||
|
"shasum": ""
|
||||||
|
},
|
||||||
|
"require": {
|
||||||
|
"php": "^5.3.3 || ^7.0"
|
||||||
|
},
|
||||||
|
"require-dev": {
|
||||||
|
"ext-intl": "*",
|
||||||
|
"phpunit/phpunit": "^4.8.35 || ^5.7",
|
||||||
|
"squizlabs/php_codesniffer": "^2.9.2"
|
||||||
|
},
|
||||||
|
"type": "library",
|
||||||
|
"extra": {
|
||||||
|
"branch-alias": {
|
||||||
|
"dev-master": "1.9-dev"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"autoload": {
|
||||||
|
"psr-4": {
|
||||||
|
"Faker\\": "src/Faker/"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"notification-url": "https://packagist.org/downloads/",
|
||||||
|
"license": [
|
||||||
|
"MIT"
|
||||||
|
],
|
||||||
|
"authors": [
|
||||||
|
{
|
||||||
|
"name": "François Zaninotto"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"description": "Faker is a PHP library that generates fake data for you.",
|
||||||
|
"keywords": [
|
||||||
|
"data",
|
||||||
|
"faker",
|
||||||
|
"fixtures"
|
||||||
|
],
|
||||||
|
"time": "2019-12-12T13:22:17+00:00"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "graham-campbell/markdown",
|
||||||
|
"version": "v12.0.0",
|
||||||
|
"source": {
|
||||||
|
"type": "git",
|
||||||
|
"url": "https://github.com/GrahamCampbell/Laravel-Markdown.git",
|
||||||
|
"reference": "1566129f213adf7f508e0bebc2399102c4c78cd6"
|
||||||
|
},
|
||||||
|
"dist": {
|
||||||
|
"type": "zip",
|
||||||
|
"url": "https://api.github.com/repos/GrahamCampbell/Laravel-Markdown/zipball/1566129f213adf7f508e0bebc2399102c4c78cd6",
|
||||||
|
"reference": "1566129f213adf7f508e0bebc2399102c4c78cd6",
|
||||||
|
"shasum": ""
|
||||||
|
},
|
||||||
|
"require": {
|
||||||
|
"illuminate/contracts": "^6.0|^7.0",
|
||||||
|
"illuminate/support": "^6.0|^7.0",
|
||||||
|
"illuminate/view": "^6.0|^7.0",
|
||||||
|
"league/commonmark": "^1.3",
|
||||||
|
"php": "^7.2.5"
|
||||||
|
},
|
||||||
|
"require-dev": {
|
||||||
|
"graham-campbell/analyzer": "^3.0",
|
||||||
|
"graham-campbell/testbench": "^5.4",
|
||||||
|
"mockery/mockery": "^1.3.1",
|
||||||
|
"phpunit/phpunit": "^8.5|^9.0"
|
||||||
|
},
|
||||||
|
"type": "library",
|
||||||
|
"extra": {
|
||||||
|
"branch-alias": {
|
||||||
|
"dev-master": "12.0-dev"
|
||||||
|
},
|
||||||
|
"laravel": {
|
||||||
|
"providers": [
|
||||||
|
"GrahamCampbell\\Markdown\\MarkdownServiceProvider"
|
||||||
|
]
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"autoload": {
|
||||||
|
"psr-4": {
|
||||||
|
"GrahamCampbell\\Markdown\\": "src/"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"notification-url": "https://packagist.org/downloads/",
|
||||||
|
"license": [
|
||||||
|
"MIT"
|
||||||
|
],
|
||||||
|
"authors": [
|
||||||
|
{
|
||||||
|
"name": "Graham Campbell",
|
||||||
|
"email": "graham@alt-three.com"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"description": "Markdown Is A CommonMark Wrapper For Laravel",
|
||||||
|
"keywords": [
|
||||||
|
"Graham Campbell",
|
||||||
|
"GrahamCampbell",
|
||||||
|
"Laravel Markdown",
|
||||||
|
"Laravel-Markdown",
|
||||||
|
"common mark",
|
||||||
|
"commonmark",
|
||||||
|
"framework",
|
||||||
|
"laravel",
|
||||||
|
"markdown"
|
||||||
|
],
|
||||||
|
"time": "2020-03-01T11:40:45+00:00"
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"name": "jakub-onderka/php-console-color",
|
"name": "jakub-onderka/php-console-color",
|
||||||
"version": "v0.2",
|
"version": "v0.2",
|
||||||
@ -3334,56 +3539,6 @@
|
|||||||
],
|
],
|
||||||
"time": "2020-01-15T10:00:00+00:00"
|
"time": "2020-01-15T10:00:00+00:00"
|
||||||
},
|
},
|
||||||
{
|
|
||||||
"name": "fzaninotto/faker",
|
|
||||||
"version": "v1.9.1",
|
|
||||||
"source": {
|
|
||||||
"type": "git",
|
|
||||||
"url": "https://github.com/fzaninotto/Faker.git",
|
|
||||||
"reference": "fc10d778e4b84d5bd315dad194661e091d307c6f"
|
|
||||||
},
|
|
||||||
"dist": {
|
|
||||||
"type": "zip",
|
|
||||||
"url": "https://api.github.com/repos/fzaninotto/Faker/zipball/fc10d778e4b84d5bd315dad194661e091d307c6f",
|
|
||||||
"reference": "fc10d778e4b84d5bd315dad194661e091d307c6f",
|
|
||||||
"shasum": ""
|
|
||||||
},
|
|
||||||
"require": {
|
|
||||||
"php": "^5.3.3 || ^7.0"
|
|
||||||
},
|
|
||||||
"require-dev": {
|
|
||||||
"ext-intl": "*",
|
|
||||||
"phpunit/phpunit": "^4.8.35 || ^5.7",
|
|
||||||
"squizlabs/php_codesniffer": "^2.9.2"
|
|
||||||
},
|
|
||||||
"type": "library",
|
|
||||||
"extra": {
|
|
||||||
"branch-alias": {
|
|
||||||
"dev-master": "1.9-dev"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"autoload": {
|
|
||||||
"psr-4": {
|
|
||||||
"Faker\\": "src/Faker/"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"notification-url": "https://packagist.org/downloads/",
|
|
||||||
"license": [
|
|
||||||
"MIT"
|
|
||||||
],
|
|
||||||
"authors": [
|
|
||||||
{
|
|
||||||
"name": "François Zaninotto"
|
|
||||||
}
|
|
||||||
],
|
|
||||||
"description": "Faker is a PHP library that generates fake data for you.",
|
|
||||||
"keywords": [
|
|
||||||
"data",
|
|
||||||
"faker",
|
|
||||||
"fixtures"
|
|
||||||
],
|
|
||||||
"time": "2019-12-12T13:22:17+00:00"
|
|
||||||
},
|
|
||||||
{
|
{
|
||||||
"name": "hamcrest/hamcrest-php",
|
"name": "hamcrest/hamcrest-php",
|
||||||
"version": "v2.0.0",
|
"version": "v2.0.0",
|
||||||
|
@ -226,6 +226,11 @@ return [
|
|||||||
'Validator' => Illuminate\Support\Facades\Validator::class,
|
'Validator' => Illuminate\Support\Facades\Validator::class,
|
||||||
'View' => Illuminate\Support\Facades\View::class,
|
'View' => Illuminate\Support\Facades\View::class,
|
||||||
|
|
||||||
|
// Custom facades
|
||||||
|
/**
|
||||||
|
* Laravel Markdown: https://github.com/GrahamCampbell/Laravel-Markdown
|
||||||
|
*/
|
||||||
|
'Markdown' => GrahamCampbell\Markdown\Facades\Markdown::class,
|
||||||
],
|
],
|
||||||
|
|
||||||
];
|
];
|
||||||
|
158
config/markdown.php
Normal file
158
config/markdown.php
Normal file
@ -0,0 +1,158 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
declare(strict_types=1);
|
||||||
|
|
||||||
|
/*
|
||||||
|
* This file is part of Laravel Markdown.
|
||||||
|
*
|
||||||
|
* (c) Graham Campbell <graham@alt-three.com>
|
||||||
|
*
|
||||||
|
* For the full copyright and license information, please view the LICENSE
|
||||||
|
* file that was distributed with this source code.
|
||||||
|
*/
|
||||||
|
|
||||||
|
return [
|
||||||
|
|
||||||
|
/*
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
| Enable View Integration
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
|
|
||||||
|
| This option specifies if the view integration is enabled so you can write
|
||||||
|
| markdown views and have them rendered as html. The following extensions
|
||||||
|
| are currently supported: ".md", ".md.php", and ".md.blade.php". You may
|
||||||
|
| disable this integration if it is conflicting with another package.
|
||||||
|
|
|
||||||
|
| Default: true
|
||||||
|
|
|
||||||
|
*/
|
||||||
|
|
||||||
|
'views' => true,
|
||||||
|
|
||||||
|
/*
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
| CommonMark Extensions
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
|
|
||||||
|
| This option specifies what extensions will be automatically enabled.
|
||||||
|
| Simply provide your extension class names here.
|
||||||
|
|
|
||||||
|
| Default: []
|
||||||
|
|
|
||||||
|
*/
|
||||||
|
|
||||||
|
'extensions' => [],
|
||||||
|
|
||||||
|
/*
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
| Renderer Configuration
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
|
|
||||||
|
| This option specifies an array of options for rendering HTML.
|
||||||
|
|
|
||||||
|
| Default: [
|
||||||
|
| 'block_separator' => "\n",
|
||||||
|
| 'inner_separator' => "\n",
|
||||||
|
| 'soft_break' => "\n",
|
||||||
|
| ]
|
||||||
|
|
|
||||||
|
*/
|
||||||
|
|
||||||
|
'renderer' => [
|
||||||
|
'block_separator' => "\n",
|
||||||
|
'inner_separator' => "\n",
|
||||||
|
'soft_break' => "\n",
|
||||||
|
],
|
||||||
|
|
||||||
|
/*
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
| Enable Em Tag Parsing
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
|
|
||||||
|
| This option specifies if `<em>` parsing is enabled.
|
||||||
|
|
|
||||||
|
| Default: true
|
||||||
|
|
|
||||||
|
*/
|
||||||
|
|
||||||
|
'enable_em' => true,
|
||||||
|
|
||||||
|
/*
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
| Enable Strong Tag Parsing
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
|
|
||||||
|
| This option specifies if `<strong>` parsing is enabled.
|
||||||
|
|
|
||||||
|
| Default: true
|
||||||
|
|
|
||||||
|
*/
|
||||||
|
|
||||||
|
'enable_strong' => true,
|
||||||
|
|
||||||
|
/*
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
| Enable Asterisk Parsing
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
|
|
||||||
|
| This option specifies if `*` should be parsed for emphasis.
|
||||||
|
|
|
||||||
|
| Default: true
|
||||||
|
|
|
||||||
|
*/
|
||||||
|
|
||||||
|
'use_asterisk' => true,
|
||||||
|
|
||||||
|
/*
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
| Enable Underscore Parsing
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
|
|
||||||
|
| This option specifies if `_` should be parsed for emphasis.
|
||||||
|
|
|
||||||
|
| Default: true
|
||||||
|
|
|
||||||
|
*/
|
||||||
|
|
||||||
|
'use_underscore' => true,
|
||||||
|
|
||||||
|
/*
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
| HTML Input
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
|
|
||||||
|
| This option specifies how to handle untrusted HTML input.
|
||||||
|
|
|
||||||
|
| Default: 'strip'
|
||||||
|
|
|
||||||
|
*/
|
||||||
|
|
||||||
|
'html_input' => 'strip',
|
||||||
|
|
||||||
|
/*
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
| Allow Unsafe Links
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
|
|
||||||
|
| This option specifies whether to allow risky image URLs and links.
|
||||||
|
|
|
||||||
|
| Default: true
|
||||||
|
|
|
||||||
|
*/
|
||||||
|
|
||||||
|
'allow_unsafe_links' => true,
|
||||||
|
|
||||||
|
/*
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
| Maximum Nesting Level
|
||||||
|
|--------------------------------------------------------------------------
|
||||||
|
|
|
||||||
|
| This option specifies the maximum permitted block nesting level.
|
||||||
|
|
|
||||||
|
| Default: INF
|
||||||
|
|
|
||||||
|
*/
|
||||||
|
|
||||||
|
'max_nesting_level' => INF,
|
||||||
|
|
||||||
|
];
|
@ -4,10 +4,14 @@
|
|||||||
|
|
||||||
use App\BlogPost;
|
use App\BlogPost;
|
||||||
use Faker\Generator as Faker;
|
use Faker\Generator as Faker;
|
||||||
|
use DavidBadura\FakerMarkdownGenerator\FakerProvider as FakerMarkdownProvider;
|
||||||
|
|
||||||
$factory->define(BlogPost::class, function (Faker $faker) {
|
$factory->define(BlogPost::class, function (Faker $faker) {
|
||||||
|
$mdProvider = new FakerMarkdownProvider($faker);
|
||||||
|
$faker->addProvider($mdProvider);
|
||||||
|
|
||||||
return [
|
return [
|
||||||
'title' => $faker->sentence(5),
|
'title' => $faker->realText(80),
|
||||||
'body' => $faker->paragraph(4),
|
'body' => $faker->markdown(),
|
||||||
];
|
];
|
||||||
});
|
});
|
||||||
|
@ -9,10 +9,10 @@
|
|||||||
@else
|
@else
|
||||||
@foreach ($user->posts as $post)
|
@foreach ($user->posts as $post)
|
||||||
<div class="jumbotron">
|
<div class="jumbotron">
|
||||||
<h3>{{ $post->title }}</h3>
|
<h1 class="user-post-heading">{{ $post->title }}</h1>
|
||||||
<p>
|
<div class="user-post-body">
|
||||||
{{ nl2br($post->body) }}
|
@markdown($post->body)
|
||||||
</p>
|
</div>
|
||||||
<p class="text-muted">
|
<p class="text-muted">
|
||||||
Created: {{ $post->created_at }}
|
Created: {{ $post->created_at }}
|
||||||
@if ($post->created_at->diffInSeconds($post->updated_at) > 1)
|
@if ($post->created_at->diffInSeconds($post->updated_at) > 1)
|
||||||
|
Loading…
Reference in New Issue
Block a user