Implement status context page

Implemented a new page that shows a status context, though I'm
calling it a "thread" in the UI because I think that makes more
sense for users. Also moved the action element from the notification
into the event info component itself because I also want to use it
to indicate when a status is a reply.
This commit is contained in:
St John Karp 2018-08-26 13:37:55 -07:00
parent d8c1ed6884
commit 96cb4ffcc6
8 changed files with 107 additions and 43 deletions

View File

@ -58,4 +58,21 @@ class StatusController extends Controller
return view('show_status', $vars);
}
public function context(Request $request, string $status_id)
{
$status = Mastodon::domain(env('MASTODON_DOMAIN'))
->get('/statuses/' . $status_id);
$context = Mastodon::domain(env('MASTODON_DOMAIN'))
->get('/statuses/' . $status_id . '/context');
$vars = [
'status' => $status,
'context' => $context,
'mastodon_domain' => explode('//', env('MASTODON_DOMAIN'))[1]
];
return view('context', $vars);
}
}

View File

@ -71,7 +71,7 @@ div.actions span.reblogged a {
color: green;
}
time, span.action-notification {
time, span.event-action {
font-size: smaller;
margin-left: 1em;
}

View File

@ -1,19 +0,0 @@
<span title="{{ $account['acct'] }}">
<a href="{{ $account['url'] }}">
<img
src="{{ $account['avatar'] }}"
alt="{{ $account['acct'] }}"
class="avatar"
/>
{{ $account['display_name'] }}
</a>
</span>
<time datetime="{{ $created_at }}">
@php
$created_at_datetime = new Carbon\Carbon($created_at);
@endphp
@if (env('SHOW_BEATS') === true)
{{ '@' . $created_at_datetime->format('B') }} |
@endif
{{ $created_at_datetime->diffForHumans(null, false, true) }}
</time>

View File

@ -0,0 +1,31 @@
<!doctype html>
<html lang="{{ app()->getLocale() }}">
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>{{ $mastodon_domain }} | Thread</title>
<link rel="stylesheet" href="/css/styles.css" />
</head>
<body>
<h1>{{ $mastodon_domain }} | Thread</h1>
@component('navigation')
@endcomponent
@foreach ($context['ancestors'] as $ancestor)
@component('status', ['status' => $ancestor])
@endcomponent
@endforeach
@component('status', ['status' => $status])
@endcomponent
@foreach ($context['descendants'] as $descendant)
@component('status', ['status' => $descendant])
@endcomponent
@endforeach
</body>
</html>

View File

@ -0,0 +1,38 @@
<aside>
<span class="account" title="{{ $account['acct'] }}">
<a href="{{ $account['url'] }}">
<img
src="{{ $account['avatar'] }}"
alt="{{ $account['acct'] }}"
class="avatar"
/>
{{ $account['display_name'] }}
</a>
</span>
@if ($type !== null)
<span class="event-action">
@if ($type === 'mention')
mentioned
@elseif ($type === 'reblog')
reblogged
@elseif ($type === 'favourite')
favourited
@elseif ($type === 'follow')
followed you.
@elseif ($type === 'reply')
&#8624;
@endif
</span>
@endif
<time datetime="{{ $created_at }}">
@php
$created_at_datetime = new Carbon\Carbon($created_at);
@endphp
@if (env('SHOW_BEATS') === true)
{{ '@' . $created_at_datetime->format('B') }} |
@endif
{{ $created_at_datetime->diffForHumans(null, false, true) }}
</time>
</aside>

View File

@ -1,24 +1,13 @@
<article>
@component('account_time_info', [
'account' => $notification['account'],
'created_at' => $notification['created_at']
])
@component('event_info', [
'account' => $notification['account'],
'created_at' => $notification['created_at'],
'type' => $notification['type']
])
@endcomponent
<span class="action-notification">
@if ($notification['type'] === 'mention')
mentioned
@elseif ($notification['type'] === 'reblog')
reblogged
@elseif ($notification['type'] === 'favourite')
favourited
@elseif ($notification['type'] === 'follow')
followed you.
@endif
</span>
@if ($notification['status'] ?? null !== null)
@component('status', ['status' => $notification['status']])
@endcomponent
@component('status', ['status' => $notification['status']])
@endcomponent
@endif
</article>

View File

@ -1,8 +1,9 @@
<hr />
<article>
@component('account_time_info', [
@component('event_info', [
'account' => $status['account'],
'created_at' => $status['created_at']
'created_at' => $status['created_at'],
'type' => $status['in_reply_to_id'] === null ? null : 'reply'
])
@endcomponent
@ -19,13 +20,18 @@
@endif
<div class="actions">
<!-- Context -->
<span title="Expand thread">
<a href="/status/{{ $status['id'] }}/thread">&#10568;</a>
</span>
<!-- Reply -->
<span>
<span title="Reply">
<a href="/status/{{ $status['id'] }}">&#8629;</a>
</span>
<!-- Reblog -->
<span>
<span title="Reblog">
@if ($status['reblogged'])
<span class="reblogged">
<a href="/status/{{ $status['id'] }}?action=unreblog">&#8634;</a>
@ -37,7 +43,7 @@
</span>
<!-- Favourite -->
<span>
<span title="Favourite">
@if ($status['favourited'])
<span class="favourited">
<a href="/status/{{ $status['id'] }}?action=unfavourite">&#9733;</a>

View File

@ -35,6 +35,8 @@ Route::post('/timeline/home', 'TimelineController@post_status')
Route::get('/status/{status_id}', 'StatusController@show_status')
->name('status');
Route::get('/status/{status_id}/thread', 'StatusController@context');
Route::get('/notifications', 'NotificationsController@get_notifications')
->name('notifications')
->middleware('authorize');