diff --git a/app/Http/Controllers/FeedsController.php b/app/Http/Controllers/FeedsController.php
index 9aeb4abb..a30c89dc 100644
--- a/app/Http/Controllers/FeedsController.php
+++ b/app/Http/Controllers/FeedsController.php
@@ -7,13 +7,66 @@ namespace App\Http\Controllers;
use App\Models\Article;
use App\Models\Note;
use Illuminate\Http\JsonResponse;
+use Illuminate\Http\Response;
class FeedsController extends Controller
{
+ /**
+ * Returns the blog RSS feed.
+ */
+ public function blogRss(): Response
+ {
+ $articles = Article::where('published', '1')->latest('updated_at')->take(20)->get();
+ $buildDate = $articles->first()->updated_at->toRssString();
+
+ return response()
+ ->view('articles.rss', compact('articles', 'buildDate'))
+ ->header('Content-Type', 'application/rss+xml; charset=utf-8');
+ }
+
+ /**
+ * Returns the blog Atom feed.
+ */
+ public function blogAtom(): Response
+ {
+ $articles = Article::where('published', '1')->latest('updated_at')->take(20)->get();
+
+ return response()
+ ->view('articles.atom', compact('articles'))
+ ->header('Content-Type', 'application/atom+xml; charset=utf-8');
+ }
+
+ /**
+ * Returns the notes RSS feed.
+ */
+ public function notesRss(): Response
+ {
+ $notes = Note::latest()->take(20)->get();
+ $buildDate = $notes->first()->updated_at->toRssString();
+
+ return response()
+ ->view('notes.rss', compact('notes', 'buildDate'))
+ ->header('Content-Type', 'application/rss+xml; charset=utf-8');
+ }
+
+ /**
+ * Returns the notes Atom feed.
+ */
+ public function notesAtom(): Response
+ {
+ $notes = Note::latest()->take(20)->get();
+
+ return response()
+ ->view('notes.atom', compact('notes'))
+ ->header('Content-Type', 'application/atom+xml; charset=utf-8');
+ }
+
+ /** @todo sort out return type for json responses */
+
/**
* Returns the blog JSON feed.
*/
- public function blogJson(): JsonResponse
+ public function blogJson(): array
{
$articles = Article::where('published', '1')->latest('updated_at')->take(20)->get();
$data = [
@@ -41,15 +94,13 @@ class FeedsController extends Controller
];
}
- return response()->json($data, 200, [
- 'Content-Type' => 'application/feed+json',
- ]);
+ return $data;
}
/**
* Returns the notes JSON feed.
*/
- public function notesJson(): JsonResponse
+ public function notesJson(): array
{
$notes = Note::latest()->with('media', 'place', 'tags')->take(20)->get();
$data = [
@@ -79,9 +130,7 @@ class FeedsController extends Controller
}
}
- return response()->json($data, 200, [
- 'Content-Type' => 'application/feed+json',
- ]);
+ return $data;
}
/**
diff --git a/resources/views/articles/atom.blade.php b/resources/views/articles/atom.blade.php
new file mode 100644
index 00000000..9892bcfb
--- /dev/null
+++ b/resources/views/articles/atom.blade.php
@@ -0,0 +1,20 @@
+
+
+ Atom feed for {{ config('user.display_name') }}’s blog
+
+ {{ config('app.url')}}/blog
+ {{ $articles[0]->updated_at->toAtomString() }}
+
+@foreach($articles as $article)
+
+ {{ $article->title }}
+
+ {{ config('app.url') }}{{ $article->link }}
+ {{ $article->updated_at->toAtomString() }}
+ {{ $article->main }}
+
+ {{ config('user.display_name') }}
+
+
+@endforeach
+
diff --git a/resources/views/articles/rss.blade.php b/resources/views/articles/rss.blade.php
new file mode 100644
index 00000000..00268681
--- /dev/null
+++ b/resources/views/articles/rss.blade.php
@@ -0,0 +1,26 @@
+
+
+
+ {{ config('user.display_name') }}
+
+ An RSS feed of the blog posts found on {{ config('app.url') }}
+ {{ config('app.url') }}/blog
+ {{ $buildDate }}
+ 1800
+
+@foreach($articles as $article)
+ -
+ {{ strip_tags($article->title) }}
+
+ main }}
+ @if($article->url)
Permalink
@endif
+ ]]>
+
+ @if($article->url != ''){{ $article->url }}@else{{ config('app.url') }}{{ $article->link }}@endif
+ {{ config('app.url') }}{{ $article->link }}
+ {{ $article->pubdate }}
+
+@endforeach
+
+
diff --git a/resources/views/icons/json-feed.blade.php b/resources/views/icons/json-feed.blade.php
deleted file mode 100644
index 7b8df856..00000000
--- a/resources/views/icons/json-feed.blade.php
+++ /dev/null
@@ -1,11 +0,0 @@
-@php
-if (isset($title)) {
- $uniqueId = bin2hex(random_bytes(6));
-}
-@endphp
-
diff --git a/resources/views/master.blade.php b/resources/views/master.blade.php
index 3c82845b..2e5c6b5a 100644
--- a/resources/views/master.blade.php
+++ b/resources/views/master.blade.php
@@ -7,9 +7,13 @@
@yield('title'){{ config('app.name') }}
-
+
+
+
-
+
+
+
@@ -36,7 +40,7 @@
Likes
Contacts
Projects
-
+