Squashed commit of the following:

commit a01812b0d709e556af060a393168acc471aca774
Author: Jonny Barnes <jonny@jonnybarnes.uk>
Date:   Thu Apr 12 18:15:25 2018 +0100

    Improve JSON feed generation to better match the spec

commit 72ad2c629738ef73ccaf984ed3ad9b726956dd71
Author: Jonny Barnes <jonny@jonnybarnes.uk>
Date:   Sun Apr 8 13:07:48 2018 +0100

    Add a test for null title entries
This commit is contained in:
Jonny Barnes 2018-04-12 18:15:42 +01:00
parent 97a6b771f8
commit 3d1ae20afb
3 changed files with 56 additions and 2 deletions

View file

@ -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 .= '<img src="' . $media->url . '" alt="">';
}
if ($media->type == 'audio' ){
$note .= '<audio src="' . $media->url . '">';
}
if ($media->type == 'video') {
$note .= '<video src="' . $media->url . '">';
}
}
if ($note === null) {
// when would $note still be blank?
$note = 'A blank note';
}
return $note;
}
/**
* Generate the NewBase60 ID from primary ID.
*