Refactor method names/views for Articles
This commit is contained in:
parent
a3d1fec56d
commit
e320bec899
5 changed files with 7 additions and 7 deletions
|
|
@ -12,14 +12,14 @@ class ArticlesController extends Controller
|
||||||
*
|
*
|
||||||
* @return \Illuminate\View\Factory view
|
* @return \Illuminate\View\Factory view
|
||||||
*/
|
*/
|
||||||
public function showAllArticles($year = null, $month = null)
|
public function index($year = null, $month = null)
|
||||||
{
|
{
|
||||||
$articles = Article::where('published', '1')
|
$articles = Article::where('published', '1')
|
||||||
->date($year, $month)
|
->date($year, $month)
|
||||||
->orderBy('updated_at', 'desc')
|
->orderBy('updated_at', 'desc')
|
||||||
->simplePaginate(5);
|
->simplePaginate(5);
|
||||||
|
|
||||||
return view('articles', compact('articles'));
|
return view('articles.index', compact('articles'));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -27,14 +27,14 @@ class ArticlesController extends Controller
|
||||||
*
|
*
|
||||||
* @return \Illuminate\View\Factory view
|
* @return \Illuminate\View\Factory view
|
||||||
*/
|
*/
|
||||||
public function singleArticle($year, $month, $slug)
|
public function show($year, $month, $slug)
|
||||||
{
|
{
|
||||||
$article = Article::where('titleurl', $slug)->first();
|
$article = Article::where('titleurl', $slug)->first();
|
||||||
if ($article->updated_at->year != $year || $article->updated_at->month != $month) {
|
if ($article->updated_at->year != $year || $article->updated_at->month != $month) {
|
||||||
throw new \Exception;
|
throw new \Exception;
|
||||||
}
|
}
|
||||||
|
|
||||||
return view('article', compact('article'));
|
return view('articles.show', compact('article'));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -63,7 +63,7 @@ class ArticlesController extends Controller
|
||||||
$buildDate = $articles->first()->updated_at->toRssString();
|
$buildDate = $articles->first()->updated_at->toRssString();
|
||||||
|
|
||||||
return response()
|
return response()
|
||||||
->view('rss', compact('articles', 'buildDate'), 200)
|
->view('articles.rss', compact('articles', 'buildDate'), 200)
|
||||||
->header('Content-Type', 'application/rss+xml');
|
->header('Content-Type', 'application/rss+xml');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
36
resources/views/articles/index.blade.php
Normal file
36
resources/views/articles/index.blade.php
Normal file
|
|
@ -0,0 +1,36 @@
|
||||||
|
@extends('master')
|
||||||
|
|
||||||
|
@section('title')
|
||||||
|
Articles «
|
||||||
|
@stop
|
||||||
|
|
||||||
|
@section('content')
|
||||||
|
|
||||||
|
@if (count($articles) == 0)
|
||||||
|
<p>No articles exist for this time.</p>
|
||||||
|
@endif
|
||||||
|
|
||||||
|
@foreach ($articles as $article)
|
||||||
|
@if ($article->url != '')<article class="link h-entry">@else<article class="h-entry">@endif
|
||||||
|
<header>
|
||||||
|
<h1 class="p-name">
|
||||||
|
@if($article->url == '')
|
||||||
|
<a href="{{ $article->link }}">{{ $article->title }}</a>
|
||||||
|
@else
|
||||||
|
<a href="{{ $article->url }}">{{ $article->title }}</a>
|
||||||
|
@endif
|
||||||
|
</h1>
|
||||||
|
<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>
|
||||||
|
<div class="e-content">
|
||||||
|
{!! $article['main'] !!}
|
||||||
|
</div>
|
||||||
|
</article>
|
||||||
|
@endforeach
|
||||||
|
{{ $articles->links() }}
|
||||||
|
@stop
|
||||||
|
|
||||||
|
@section('scripts')
|
||||||
|
<script src="/assets/prism/prism.js"></script>
|
||||||
|
<link rel="stylesheet" href="/assets/prism/prism.css">
|
||||||
|
@stop
|
||||||
27
resources/views/articles/rss.blade.php
Normal file
27
resources/views/articles/rss.blade.php
Normal file
|
|
@ -0,0 +1,27 @@
|
||||||
|
<?xml version="1.0" encoding="UTF-8" ?>
|
||||||
|
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom">
|
||||||
|
<channel>
|
||||||
|
<title>{{ env('DISPLAY_NAME') }}</title>
|
||||||
|
<atom:link href="{{ config('app.url') }}/feed" rel="self" type="application/rss+xml" />
|
||||||
|
<description>An RSS feed of the blog posts found on {{ config('url.longurl') }}</description>
|
||||||
|
<link>{{ config('app.url') }}</link>
|
||||||
|
<lastBuildDate>{{ $buildDate }}</lastBuildDate>
|
||||||
|
<ttl>1800</ttl>
|
||||||
|
|
||||||
|
@foreach($articles as $article)
|
||||||
|
<item>
|
||||||
|
<title>{{ strip_tags($article->title) }}</title>
|
||||||
|
<description>
|
||||||
|
<![CDATA[
|
||||||
|
{{ $article->main }}
|
||||||
|
@if($article->url)<p><a href="{{ config('app.url') }}{{ $article->link }}">Permalink</a></p>@endif
|
||||||
|
]]>
|
||||||
|
</description>
|
||||||
|
<link>@if($article->url != ''){{ $article->url }}@else{{ config('app.url') }}{{ $article->link }}@endif</link>
|
||||||
|
<guid>{{ config('app.url') }}{{ $article->link }}</guid>
|
||||||
|
<pubDate>{{ $article->pubdate }}</pubDate>
|
||||||
|
</item>
|
||||||
|
@endforeach
|
||||||
|
|
||||||
|
</channel>
|
||||||
|
</rss>
|
||||||
24
resources/views/articles/show.blade.php
Normal file
24
resources/views/articles/show.blade.php
Normal file
|
|
@ -0,0 +1,24 @@
|
||||||
|
@extends('master')
|
||||||
|
|
||||||
|
@section('title')
|
||||||
|
{{ strip_tags($article->title) }} «
|
||||||
|
@stop
|
||||||
|
|
||||||
|
@section('content')
|
||||||
|
@if($article->url != '')<article class="link h-entry">@else<article class="h-entry">@endif
|
||||||
|
<header>
|
||||||
|
<h1 class="p-name">
|
||||||
|
<a href="@if($article->url == ''){{ $article->link }}@else{{ $article->url }}@endif">{{ $article->title }}</a>
|
||||||
|
</h1>
|
||||||
|
<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>
|
||||||
|
<div class="e-content">
|
||||||
|
{!! $article->main !!}
|
||||||
|
</div>
|
||||||
|
</article>
|
||||||
|
@stop
|
||||||
|
|
||||||
|
@section('scripts')
|
||||||
|
<script src="/assets/prism/prism.js"></script>
|
||||||
|
<link rel="stylesheet" href="/assets/prism/prism.css">
|
||||||
|
@stop
|
||||||
|
|
@ -84,8 +84,8 @@ Route::group(['domain' => config('url.longurl')], function () {
|
||||||
|
|
||||||
//Blog pages using ArticlesController
|
//Blog pages using ArticlesController
|
||||||
Route::get('blog/s/{id}', 'ArticlesController@onlyIdInURL');
|
Route::get('blog/s/{id}', 'ArticlesController@onlyIdInURL');
|
||||||
Route::get('blog/{year?}/{month?}', 'ArticlesController@showAllArticles');
|
Route::get('blog/{year?}/{month?}', 'ArticlesController@index');
|
||||||
Route::get('blog/{year}/{month}/{slug}', 'ArticlesController@singleArticle');
|
Route::get('blog/{year}/{month}/{slug}', 'ArticlesController@show');
|
||||||
|
|
||||||
//micropub new notes page
|
//micropub new notes page
|
||||||
//this needs to be first so `notes/new` doesn't match `notes/{id}`
|
//this needs to be first so `notes/new` doesn't match `notes/{id}`
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue