planiverse

A minimalist, no-JS front-end for Mastodon.
git clone https://git.stjo.hn/planiverse
Log | Files | Refs | README | LICENSE

commit 96cb4ffcc6131eedba82a4546149a5d528b33e8b
parent d8c1ed68840b5caf6c94d890a2e10a2ceac45345
Author: St John Karp <stjohn@fuzzjunket.com>
Date:   Sun, 26 Aug 2018 13:37:55 -0700

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.

Diffstat:
Mapp/Http/Controllers/StatusController.php | 17+++++++++++++++++
Mpublic/css/styles.css | 2+-
Dresources/views/account_time_info.blade.php | 19-------------------
Aresources/views/context.blade.php | 31+++++++++++++++++++++++++++++++
Aresources/views/event_info.blade.php | 38++++++++++++++++++++++++++++++++++++++
Mresources/views/notification.blade.php | 25+++++++------------------
Mresources/views/status.blade.php | 16+++++++++++-----
Mroutes/web.php | 2++
8 files changed, 107 insertions(+), 43 deletions(-)

diff --git a/app/Http/Controllers/StatusController.php b/app/Http/Controllers/StatusController.php @@ -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); + } } diff --git a/public/css/styles.css b/public/css/styles.css @@ -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; } diff --git a/resources/views/account_time_info.blade.php b/resources/views/account_time_info.blade.php @@ -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> diff --git a/resources/views/context.blade.php b/resources/views/context.blade.php @@ -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> diff --git a/resources/views/event_info.blade.php b/resources/views/event_info.blade.php @@ -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> diff --git a/resources/views/notification.blade.php b/resources/views/notification.blade.php @@ -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> diff --git a/resources/views/status.blade.php b/resources/views/status.blade.php @@ -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> diff --git a/routes/web.php b/routes/web.php @@ -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');