Allow articles to be uploaded from a .md file
This commit is contained in:
parent
e8965c7a1b
commit
8cf3d05543
4 changed files with 6 additions and 6 deletions
|
@ -53,10 +53,10 @@ class Article extends Model
|
||||||
*
|
*
|
||||||
* @return string
|
* @return string
|
||||||
*/
|
*/
|
||||||
public function getMainAttribute($value)
|
public function getHtmlAttribute()
|
||||||
{
|
{
|
||||||
$markdown = new CommonMarkConverter();
|
$markdown = new CommonMarkConverter();
|
||||||
$html = $markdown->convertToHtml($value);
|
$html = $markdown->convertToHtml($this->main);
|
||||||
//change <pre><code>[lang] ~> <pre><code data-language="lang">
|
//change <pre><code>[lang] ~> <pre><code data-language="lang">
|
||||||
$match = '/<pre><code>\[(.*)\]\n/';
|
$match = '/<pre><code>\[(.*)\]\n/';
|
||||||
$replace = '<pre><code class="language-$1">';
|
$replace = '<pre><code class="language-$1">';
|
||||||
|
|
|
@ -8,7 +8,7 @@ Admin CP
|
||||||
<h1>Hello {{ $name }}!</h1>
|
<h1>Hello {{ $name }}!</h1>
|
||||||
|
|
||||||
<h2>Articles</h2>
|
<h2>Articles</h2>
|
||||||
<p>You can either <a href="/admin/articles/create">create</a> new blog posts, or <a href="/admin/articles/">edit</a> them.<p>
|
<p>You can either <a href="/admin/blog/create">create</a> new blog posts, or <a href="/admin/blog/">edit</a> them.<p>
|
||||||
|
|
||||||
<h2>Notes</h2>
|
<h2>Notes</h2>
|
||||||
<p>You can either <a href="/admin/notes/create">create</a> new notes, or <a href="/admin/notes/">edit</a> them.<p>
|
<p>You can either <a href="/admin/notes/create">create</a> new notes, or <a href="/admin/notes/">edit</a> them.<p>
|
||||||
|
|
|
@ -23,7 +23,7 @@ Articles «
|
||||||
<span class="post-info">Posted <time class="dt-published" title="{{ $article->tooltip_time }}" datetime="{{ $article->w3c_time }}">{{ $article->human_time }}</time> - <a title="Permalink" href="{{ $article->link }}">⚓</a></span>
|
<span class="post-info">Posted <time class="dt-published" title="{{ $article->tooltip_time }}" datetime="{{ $article->w3c_time }}">{{ $article->human_time }}</time> - <a title="Permalink" href="{{ $article->link }}">⚓</a></span>
|
||||||
</header>
|
</header>
|
||||||
<div class="e-content">
|
<div class="e-content">
|
||||||
{!! $article['main'] !!}
|
{!! $article->html !!}
|
||||||
</div>
|
</div>
|
||||||
</article>
|
</article>
|
||||||
@endforeach
|
@endforeach
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
@extends('master')
|
@extends('master')
|
||||||
|
|
||||||
@section('title')
|
@section('title')
|
||||||
{{ strip_tags($article->title) }} «
|
{{ strip_tags($article->title) }} «
|
||||||
@stop
|
@stop
|
||||||
|
|
||||||
@section('content')
|
@section('content')
|
||||||
|
@ -13,7 +13,7 @@
|
||||||
<span class="post-info">Posted <time class="dt-published" title="{{ $article->tooltip_time }}" datetime="{{ $article->w3c_time }}">{{ $article->human_time }}</time> - <a title="Permalink" href="{{ $article->link }}">⚓</a></span>
|
<span class="post-info">Posted <time class="dt-published" title="{{ $article->tooltip_time }}" datetime="{{ $article->w3c_time }}">{{ $article->human_time }}</time> - <a title="Permalink" href="{{ $article->link }}">⚓</a></span>
|
||||||
</header>
|
</header>
|
||||||
<div class="e-content">
|
<div class="e-content">
|
||||||
{!! $article->main !!}
|
{!! $article->html !!}
|
||||||
</div>
|
</div>
|
||||||
</article>
|
</article>
|
||||||
@stop
|
@stop
|
||||||
|
|
Loading…
Add table
Reference in a new issue