Parsedownをプラグイン経由で使うようにした

This commit is contained in:
shibafu 2017-11-03 23:23:36 +09:00
parent d94c444b55
commit efea60fc81
4 changed files with 83 additions and 29 deletions

View File

@ -23,12 +23,9 @@ class InfoController extends Controller
public function show($id) public function show($id)
{ {
$information = Information::findOrFail($id); $information = Information::findOrFail($id);
$parser = new \Parsedown();
$compiledContent = $parser->text($information->content);
return view('info.show')->with([ return view('info.show')->with([
'info' => $information, 'info' => $information,
'category' => Information::CATEGORIES[$information->category], 'category' => Information::CATEGORIES[$information->category]
'compiledContent' => $compiledContent
]); ]);
} }
} }

View File

@ -6,9 +6,9 @@
"type": "project", "type": "project",
"require": { "require": {
"php": ">=7.0.0", "php": ">=7.0.0",
"erusev/parsedown": "^1.6",
"laravel/framework": "5.5.*", "laravel/framework": "5.5.*",
"laravel/tinker": "~1.0" "laravel/tinker": "~1.0",
"parsedown/laravel": "~1.0"
}, },
"require-dev": { "require-dev": {
"filp/whoops": "~2.0", "filp/whoops": "~2.0",

101
composer.lock generated
View File

@ -4,7 +4,7 @@
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#composer-lock-the-lock-file", "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#composer-lock-the-lock-file",
"This file is @generated automatically" "This file is @generated automatically"
], ],
"content-hash": "d5db680b40d4d68ebfb31b031548657a", "content-hash": "8fd656953b9909fbcbecf476db92f15c",
"packages": [ "packages": [
{ {
"name": "dnoegel/php-xdg-base-dir", "name": "dnoegel/php-xdg-base-dir",
@ -348,16 +348,16 @@
}, },
{ {
"name": "laravel/framework", "name": "laravel/framework",
"version": "v5.5.18", "version": "v5.5.19",
"source": { "source": {
"type": "git", "type": "git",
"url": "https://github.com/laravel/framework.git", "url": "https://github.com/laravel/framework.git",
"reference": "1cc21baac11551377734b8c17ead17db4c34fe21" "reference": "c678100e84934ec85c9f8bc26bd0a60222682719"
}, },
"dist": { "dist": {
"type": "zip", "type": "zip",
"url": "https://api.github.com/repos/laravel/framework/zipball/1cc21baac11551377734b8c17ead17db4c34fe21", "url": "https://api.github.com/repos/laravel/framework/zipball/c678100e84934ec85c9f8bc26bd0a60222682719",
"reference": "1cc21baac11551377734b8c17ead17db4c34fe21", "reference": "c678100e84934ec85c9f8bc26bd0a60222682719",
"shasum": "" "shasum": ""
}, },
"require": { "require": {
@ -475,7 +475,7 @@
"framework", "framework",
"laravel" "laravel"
], ],
"time": "2017-10-19T12:50:26+00:00" "time": "2017-10-25T19:10:45+00:00"
}, },
{ {
"name": "laravel/tinker", "name": "laravel/tinker",
@ -703,7 +703,7 @@
}, },
{ {
"name": "mtdowling/cron-expression", "name": "mtdowling/cron-expression",
"version": "v1.2.0", "version": "v1.2.1",
"source": { "source": {
"type": "git", "type": "git",
"url": "https://github.com/mtdowling/cron-expression.git", "url": "https://github.com/mtdowling/cron-expression.git",
@ -897,6 +897,63 @@
], ],
"time": "2017-09-27T21:40:39+00:00" "time": "2017-09-27T21:40:39+00:00"
}, },
{
"name": "parsedown/laravel",
"version": "1.0.0",
"source": {
"type": "git",
"url": "https://github.com/parsedown/laravel.git",
"reference": "d97b0b4ae21340ecbaa04f4f0a8fde9f33df0117"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/parsedown/laravel/zipball/d97b0b4ae21340ecbaa04f4f0a8fde9f33df0117",
"reference": "d97b0b4ae21340ecbaa04f4f0a8fde9f33df0117",
"shasum": ""
},
"require": {
"erusev/parsedown": "~1.6",
"php": ">=5.6"
},
"require-dev": {
"orchestra/testbench": "^3.4",
"php": ">=7.1",
"phpunit/phpunit": "^6.3"
},
"type": "library",
"extra": {
"laravel": {
"providers": [
"Parsedown\\Providers\\ParsedownServiceProvider"
]
}
},
"autoload": {
"files": [
"src/Support/helpers.php"
],
"psr-4": {
"Parsedown\\": "src/"
}
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"authors": [
{
"name": "Eduardo Agostini",
"email": "edu.agostini@gmail.com"
}
],
"description": "Official Laravel Wrapper of Parsedown.",
"homepage": "http://parsedown.org",
"keywords": [
"laravel",
"parsedown"
],
"time": "2017-08-23T02:26:10+00:00"
},
{ {
"name": "psr/container", "name": "psr/container",
"version": "1.0.0", "version": "1.0.0",
@ -2733,16 +2790,16 @@
}, },
{ {
"name": "phpunit/php-code-coverage", "name": "phpunit/php-code-coverage",
"version": "5.2.2", "version": "5.2.3",
"source": { "source": {
"type": "git", "type": "git",
"url": "https://github.com/sebastianbergmann/php-code-coverage.git", "url": "https://github.com/sebastianbergmann/php-code-coverage.git",
"reference": "8ed1902a57849e117b5651fc1a5c48110946c06b" "reference": "8e1d2397d8adf59a3f12b2878a3aaa66d1ab189d"
}, },
"dist": { "dist": {
"type": "zip", "type": "zip",
"url": "https://api.github.com/repos/sebastianbergmann/php-code-coverage/zipball/8ed1902a57849e117b5651fc1a5c48110946c06b", "url": "https://api.github.com/repos/sebastianbergmann/php-code-coverage/zipball/8e1d2397d8adf59a3f12b2878a3aaa66d1ab189d",
"reference": "8ed1902a57849e117b5651fc1a5c48110946c06b", "reference": "8e1d2397d8adf59a3f12b2878a3aaa66d1ab189d",
"shasum": "" "shasum": ""
}, },
"require": { "require": {
@ -2751,7 +2808,7 @@
"php": "^7.0", "php": "^7.0",
"phpunit/php-file-iterator": "^1.4.2", "phpunit/php-file-iterator": "^1.4.2",
"phpunit/php-text-template": "^1.2.1", "phpunit/php-text-template": "^1.2.1",
"phpunit/php-token-stream": "^1.4.11 || ^2.0", "phpunit/php-token-stream": "^2.0",
"sebastian/code-unit-reverse-lookup": "^1.0.1", "sebastian/code-unit-reverse-lookup": "^1.0.1",
"sebastian/environment": "^3.0", "sebastian/environment": "^3.0",
"sebastian/version": "^2.0.1", "sebastian/version": "^2.0.1",
@ -2793,7 +2850,7 @@
"testing", "testing",
"xunit" "xunit"
], ],
"time": "2017-08-03T12:40:43+00:00" "time": "2017-11-03T13:47:33+00:00"
}, },
{ {
"name": "phpunit/php-file-iterator", "name": "phpunit/php-file-iterator",
@ -3171,30 +3228,30 @@
}, },
{ {
"name": "sebastian/comparator", "name": "sebastian/comparator",
"version": "2.0.2", "version": "2.1.0",
"source": { "source": {
"type": "git", "type": "git",
"url": "https://github.com/sebastianbergmann/comparator.git", "url": "https://github.com/sebastianbergmann/comparator.git",
"reference": "ae068fede81d06e7bb9bb46a367210a3d3e1fe6a" "reference": "1174d9018191e93cb9d719edec01257fc05f8158"
}, },
"dist": { "dist": {
"type": "zip", "type": "zip",
"url": "https://api.github.com/repos/sebastianbergmann/comparator/zipball/ae068fede81d06e7bb9bb46a367210a3d3e1fe6a", "url": "https://api.github.com/repos/sebastianbergmann/comparator/zipball/1174d9018191e93cb9d719edec01257fc05f8158",
"reference": "ae068fede81d06e7bb9bb46a367210a3d3e1fe6a", "reference": "1174d9018191e93cb9d719edec01257fc05f8158",
"shasum": "" "shasum": ""
}, },
"require": { "require": {
"php": "^7.0", "php": "^7.0",
"sebastian/diff": "^2.0", "sebastian/diff": "^2.0",
"sebastian/exporter": "^3.0" "sebastian/exporter": "^3.1"
}, },
"require-dev": { "require-dev": {
"phpunit/phpunit": "^6.0" "phpunit/phpunit": "^6.4"
}, },
"type": "library", "type": "library",
"extra": { "extra": {
"branch-alias": { "branch-alias": {
"dev-master": "2.0.x-dev" "dev-master": "2.1.x-dev"
} }
}, },
"autoload": { "autoload": {
@ -3225,13 +3282,13 @@
} }
], ],
"description": "Provides the functionality to compare PHP values for equality", "description": "Provides the functionality to compare PHP values for equality",
"homepage": "http://www.github.com/sebastianbergmann/comparator", "homepage": "https://github.com/sebastianbergmann/comparator",
"keywords": [ "keywords": [
"comparator", "comparator",
"compare", "compare",
"equality" "equality"
], ],
"time": "2017-08-03T07:14:59+00:00" "time": "2017-11-03T07:16:52+00:00"
}, },
{ {
"name": "sebastian/diff", "name": "sebastian/diff",

View File

@ -10,6 +10,6 @@
</nav> </nav>
<h2><span class="badge {{ $category['class'] }}">{{ $category['label'] }}</span> {{ $info->title }}</h2> <h2><span class="badge {{ $category['class'] }}">{{ $category['label'] }}</span> {{ $info->title }}</h2>
<p class="text-secondary"><span class="oi oi-calendar"></span> {{ $info->created_at->format('Y年n月j日') }}</p> <p class="text-secondary"><span class="oi oi-calendar"></span> {{ $info->created_at->format('Y年n月j日') }}</p>
{!! $compiledContent !!} @parsedown($info->content)
</div> </div>
@endsection @endsection