planiverse

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

commit 7cd1d14d8a346209af217452239981e7f523bd8e
parent be9e3c3603d1958529c4261e359bce999aeec05b
Author: St John Karp <stjohn@fuzzjunket.com>
Date:   Mon, 13 Aug 2018 22:19:55 -0700

Implement reply functionality

Created a new status view that shows a single status and permits
replies if you're logged in.

Diffstat:
Aapp/Http/Controllers/StatusController.php | 25+++++++++++++++++++++++++
Mpublic/css/styles.css | 4++++
Aresources/views/show_status.blade.php | 28++++++++++++++++++++++++++++
Mresources/views/status.blade.php | 2+-
Mroutes/web.php | 2++
5 files changed, 60 insertions(+), 1 deletion(-)

diff --git a/app/Http/Controllers/StatusController.php b/app/Http/Controllers/StatusController.php @@ -0,0 +1,25 @@ +<?php + +namespace App\Http\Controllers; + +use App\Http\Controllers\Controller; +use Mastodon; +use GuzzleHttp\Psr7; +use Illuminate\Http\Request; + +class StatusController extends Controller +{ + public function show_status(Request $request, string $status_id) + { + $status = Mastodon::domain(env('MASTODON_DOMAIN')) + ->get('/statuses/' . $status_id); + + $vars = [ + 'status' => $status, + 'mastodon_domain' => explode('//', env('MASTODON_DOMAIN'))[1], + 'logged_in' => session()->has('user') + ]; + + return view('show_status', $vars); + } +} diff --git a/public/css/styles.css b/public/css/styles.css @@ -54,6 +54,10 @@ div.actions span { margin-right: 1em; } +div.actions a { + text-decoration: none; +} + time { font-size: smaller; margin-left: 1em; diff --git a/resources/views/show_status.blade.php b/resources/views/show_status.blade.php @@ -0,0 +1,28 @@ +<!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 }} | Status</title> + + <link rel="stylesheet" href="/css/styles.css" /> + </head> + <body> + <h1>{{ $mastodon_domain }} | Status</h1> + + @component('status', ['status' => $status]) + @endcomponent + + @if ($logged_in) + <form method="post" action="/timeline/home"> + <input type="text" name="spoiler_text" placeholder="Spoiler/Warning" /> + <textarea rows="4" name="status" placeholder="Reply" required autofocus></textarea> + <input type="submit" value="Post" /> + <input type="hidden" name="in_reply_to_id" value="{{ $status['id'] }}" /> + {{ csrf_field() }} + </form> + @endif + </body> +</html> diff --git a/resources/views/status.blade.php b/resources/views/status.blade.php @@ -43,7 +43,7 @@ <div class="actions"> <!-- Reply --> <span> - &#8629; + <a href="/status/{{ $status['id'] }}">&#8629;</a> </span> <!-- Reblog --> diff --git a/routes/web.php b/routes/web.php @@ -30,6 +30,8 @@ Route::get('/timeline/home', 'TimelineController@home_timeline') Route::post('/timeline/home', 'TimelineController@post_status'); +Route::get('/status/{status_id}', 'StatusController@show_status'); + Route::get('/login', 'LoginController@login') ->name('login');