Move webmention type logic into blade template
This commit is contained in:
parent
005685ed42
commit
8ec265f686
2 changed files with 19 additions and 33 deletions
|
@ -37,35 +37,9 @@ class NotesController extends Controller
|
|||
*/
|
||||
public function show($urlId)
|
||||
{
|
||||
$note = Note::nb60($urlId)->first();
|
||||
$replies = [];
|
||||
$reposts = [];
|
||||
$likes = [];
|
||||
foreach ($note->webmentions as $webmention) {
|
||||
$content['author'] = $webmention->author;
|
||||
$content['published'] = $webmention->published;
|
||||
$content['source'] = $webmention->source;
|
||||
switch ($webmention->type) {
|
||||
case 'in-reply-to':
|
||||
$content['reply'] = $webmention->reply;
|
||||
$microformats = json_decode($webmention->mf2, true);
|
||||
$content['reply'] = $this->filterHTML(
|
||||
$microformats['items'][0]['properties']['content'][0]['html']
|
||||
);
|
||||
$replies[] = $content;
|
||||
break;
|
||||
$note = Note::nb60($urlId)->with('webmentions')->first();
|
||||
|
||||
case 'repost-of':
|
||||
$reposts[] = $content;
|
||||
break;
|
||||
|
||||
case 'like-of':
|
||||
$likes[] = $content;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return view('notes.show', compact('note', 'replies', 'reposts', 'likes'));
|
||||
return view('notes.show', compact('note'));
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -7,7 +7,9 @@
|
|||
@section('content')
|
||||
<div class="h-entry">
|
||||
@include('templates.note', ['note' => $note])
|
||||
@foreach($replies as $reply)
|
||||
@foreach($note->webmentions->filter(function ($webmention) {
|
||||
return ($webmention->type == 'in-reply-to');
|
||||
}) as $reply)
|
||||
<div class="u-comment h-cite">
|
||||
<a class="u-author h-card mini-h-card" href="{{ $reply['author']['properties']['url'][0] }}">
|
||||
<img src="{{ $reply['author']['properties']['photo'][0] }}" alt="" class="photo u-photo logo"> <span class="fn">{{ $reply['author']['properties']['name'][0] }}</span>
|
||||
|
@ -17,16 +19,26 @@
|
|||
</div>
|
||||
</div>
|
||||
@endforeach
|
||||
@if(count($likes) > 0)<h1 class="notes-subtitle">Likes</h1>@endif
|
||||
@foreach($likes as $like)
|
||||
@if($note->webmentions->filter(function ($webmention) {
|
||||
return ($webmention->type == 'like-of');
|
||||
})->count() > 0)<h1 class="notes-subtitle">Likes</h1>
|
||||
@foreach($note->webmentions->filter(function ($webmention) {
|
||||
return ($webmention->type == 'like-of');
|
||||
}) as $like)
|
||||
<a href="{{ $like['author']['properties']['url'][0] }}"><img src="{{ $like['author']['properties']['photo'][0] }}" alt="profile picture of {{ $like['author']['properties']['name'][0] }}" class="like-photo"></a>
|
||||
@endforeach
|
||||
@if(count($reposts) > 0)<h1 class="notes-subtitle">Reposts</h1>@endif
|
||||
@foreach($reposts as $repost)
|
||||
@endif
|
||||
@if($note->webmentions->filter(function ($webmention) {
|
||||
return ($webmention->type == 'repost-of');
|
||||
})->count() > 0)<h1 class="notes-subtitle">Reposts</h1>
|
||||
@foreach($note->webmentions->filter(function ($webmention) {
|
||||
return ($webmention->type == 'repost-of');
|
||||
}) as $repost)
|
||||
<p><a class="h-card vcard mini-h-card p-author" href="{{ $repost['author']['properties']['url'][0] }}">
|
||||
<img src="{{ $repost['author']['properties']['photo'][0] }}" alt="profile picture of {{ $repost['author']['properties']['name'][0] }}" class="photo u-photo logo"> <span class="fn">{{ $repost['author']['properties']['name'][0] }}</span>
|
||||
</a> reposted this at <a href="{{ $repost['source'] }}">{{ $repost['published'] }}</a>.</p>
|
||||
@endforeach
|
||||
@endif
|
||||
<!-- these empty tags are for https://brid.gy’s publishing service -->
|
||||
<a href="https://brid.gy/publish/twitter"></a>
|
||||
<a href="https://brid.gy/publish/facebook"></a>
|
||||
|
|
Loading…
Add table
Reference in a new issue