From 3d1ae20afb93f7d5e959194988cd99f045649ad2 Mon Sep 17 00:00:00 2001 From: Jonny Barnes Date: Thu, 12 Apr 2018 18:15:42 +0100 Subject: [PATCH] Squashed commit of the following: commit a01812b0d709e556af060a393168acc471aca774 Author: Jonny Barnes Date: Thu Apr 12 18:15:25 2018 +0100 Improve JSON feed generation to better match the spec commit 72ad2c629738ef73ccaf984ed3ad9b726956dd71 Author: Jonny Barnes Date: Sun Apr 8 13:07:48 2018 +0100 Add a test for null title entries --- app/Http/Controllers/FeedsController.php | 3 +-- app/Models/Note.php | 31 ++++++++++++++++++++++++ tests/Feature/FeedsTest.php | 24 ++++++++++++++++++ 3 files changed, 56 insertions(+), 2 deletions(-) diff --git a/app/Http/Controllers/FeedsController.php b/app/Http/Controllers/FeedsController.php index 3ffb99f8..e7602230 100644 --- a/app/Http/Controllers/FeedsController.php +++ b/app/Http/Controllers/FeedsController.php @@ -121,9 +121,8 @@ class FeedsController extends Controller foreach ($notes as $key => $note) { $data['items'][$key] = [ 'id' => $note->longurl, - 'title' => $note->getOriginal('note'), 'url' => $note->longurl, - 'content_html' => $note->note, + 'content_html' => $note->content, 'date_published' => $note->created_at->tz('UTC')->toRfc3339String(), 'date_modified' => $note->updated_at->tz('UTC')->toRfc3339String(), 'author' => [ diff --git a/app/Models/Note.php b/app/Models/Note.php index cbbc5335..fc652c90 100644 --- a/app/Models/Note.php +++ b/app/Models/Note.php @@ -176,6 +176,37 @@ class Note extends Model return $modified; } + /** + * Provide the content_html for JSON feed. + * + * In particular we want to include media links such as images. + * + * @return string + */ + public function getContentAttribute(): string + { + $note = $this->note; + + foreach ($this->media as $media) { + if ($media->type == 'image') { + $note .= ''; + } + if ($media->type == 'audio' ){ + $note .= '