diff --git a/app/Http/Controllers/AccountController.php b/app/Http/Controllers/AccountController.php index b0d1c1c..250f85f 100644 --- a/app/Http/Controllers/AccountController.php +++ b/app/Http/Controllers/AccountController.php @@ -67,4 +67,43 @@ class AccountController extends Controller return redirect()->route('account', ['account_id' => $account_id]) ->with('relationship', $relationship); } + + public function show_search() + { + if (session()->has('accounts')) + { + // The user is coming here after peforming a search. + + $accounts = session('accounts'); + } + else + { + $accounts = []; + } + + $vars = [ + 'accounts' => $accounts, + 'mastodon_domain' => explode('//', env('MASTODON_DOMAIN'))[1] + ]; + + return view('search_accounts', $vars); + } + + public function search(Request $request) + { + $user = session('user'); + + # Verify we have an actual account to search for. + if (!$request->has('account')) + { + abort(400); + } + + $accounts = Mastodon::domain(env('MASTODON_DOMAIN')) + ->token($user->token) + ->get('/accounts/search', ['q' => $request->account]); + + return redirect()->route('show_search_accounts') + ->with('accounts', $accounts); + } } diff --git a/resources/views/navigation.blade.php b/resources/views/navigation.blade.php index e015814..a86891b 100644 --- a/resources/views/navigation.blade.php +++ b/resources/views/navigation.blade.php @@ -3,5 +3,6 @@
  • Timeline
  • Public Timeline
  • Notifications
  • + diff --git a/resources/views/search_accounts.blade.php b/resources/views/search_accounts.blade.php new file mode 100644 index 0000000..e41eaf0 --- /dev/null +++ b/resources/views/search_accounts.blade.php @@ -0,0 +1,43 @@ + + + + + + + + {{ $mastodon_domain }} | Search + + + + +

    {{ $mastodon_domain }} | Search

    + + @component('navigation') + @endcomponent + +
    + + + {{ csrf_field() }} +
    + + + + diff --git a/routes/web.php b/routes/web.php index ad798c7..aa15a25 100644 --- a/routes/web.php +++ b/routes/web.php @@ -71,6 +71,14 @@ Route::get('/account/{account_id}/unfollow', 'AccountController@unfollow_account ->name('unfollow') ->middleware('authorize'); +Route::get('/accounts/search', 'AccountController@show_search') + ->name('show_search_accounts') + ->middleware('authorize'); + +Route::post('/accounts/search', 'AccountController@search') + ->name('search_accounts') + ->middleware('authorize'); + Route::get('/login', 'LoginController@login') ->name('login');