commit d2c1874f0b5cc8d2f1431705753ef9702fc82187
parent d95406c4078e4cdc37862ebcb67688529720b48c
Author: St John Karp <stjohn@fuzzjunket.com>
Date: Sun, 19 Aug 2018 10:50:28 -0700
Implement reblogging
Implemented ability to reblog a status.
Diffstat:
4 files changed, 31 insertions(+), 3 deletions(-)
diff --git a/app/Http/Controllers/StatusController.php b/app/Http/Controllers/StatusController.php
@@ -13,7 +13,7 @@ class StatusController extends Controller
{
// The user has a session and may be here to favourite/unfavourite
// a status.
- if (session()->has('user'))
+ if (session()->has('user') && $request->has('action'))
{
$user = session('user');
if ($request->action === 'favourite')
@@ -28,6 +28,18 @@ class StatusController extends Controller
->token($user->token)
->post('/statuses/' . $status_id . '/unfavourite');
}
+ elseif ($request->action === 'reblog')
+ {
+ $status = Mastodon::domain(env('MASTODON_DOMAIN'))
+ ->token($user->token)
+ ->post('/statuses/' . $status_id . '/reblog');
+ }
+ elseif ($request->action === 'unreblog')
+ {
+ $status = Mastodon::domain(env('MASTODON_DOMAIN'))
+ ->token($user->token)
+ ->post('/statuses/' . $status_id . '/unreblog');
+ }
}
// If the status hasn't been returned from performing an action on it,
diff --git a/public/css/styles.css b/public/css/styles.css
@@ -67,6 +67,10 @@ div.actions span.favourited a {
color: goldenrod;
}
+div.actions span.reblogged a {
+ color: green;
+}
+
time {
font-size: smaller;
margin-left: 1em;
diff --git a/resources/views/show_status.blade.php b/resources/views/show_status.blade.php
@@ -12,6 +12,9 @@
<body>
<h1>{{ $mastodon_domain }} | Status</h1>
+ @component('navigation')
+ @endcomponent
+
@component('status', ['status' => $status])
@endcomponent
diff --git a/resources/views/status.blade.php b/resources/views/status.blade.php
@@ -38,13 +38,22 @@
<!-- Reblog -->
<span>
- ⇄ {{ $status['reblogs_count'] }}
+ @if ($status['reblogged'])
+ <span class="reblogged">
+ <a href="/status/{{ $status['id'] }}?action=unreblog">⇄</a>
+ </span>
+ @else
+ <a href="/status/{{ $status['id'] }}?action=reblog">⇄</a>
+ @endif
+ {{ $status['reblogs_count'] }}
</span>
<!-- Favourite -->
<span>
@if ($status['favourited'])
- <span class="favourited"><a href="/status/{{ $status['id'] }}?action=unfavourite">★</a></span>
+ <span class="favourited">
+ <a href="/status/{{ $status['id'] }}?action=unfavourite">★</a>
+ </span>
@else
<a href="/status/{{ $status['id'] }}?action=favourite">☆</a>
@endif