1
0
Fork 0
pixelfed/app/Http/Controllers/SiteController.php

68 lines
1.6 KiB
PHP
Raw Normal View History

2018-06-01 03:12:06 +00:00
<?php
namespace App\Http\Controllers;
2018-08-28 03:07:36 +00:00
use Illuminate\Http\Request;
2019-02-05 20:58:48 +00:00
use App, Auth, Cache, View;
use App\Util\Lexer\PrettyNumber;
use App\{Follower, Page, Profile, Status, User, UserFilter};
2019-02-28 03:15:18 +00:00
use App\Util\Localization\Localization;
2018-06-01 03:12:06 +00:00
class SiteController extends Controller
{
2018-07-12 16:37:31 +00:00
public function home()
{
2018-08-28 03:07:36 +00:00
if (Auth::check()) {
return $this->homeTimeline();
2018-07-12 16:37:31 +00:00
} else {
2018-08-28 03:07:36 +00:00
return $this->homeGuest();
2018-07-12 16:37:31 +00:00
}
}
public function homeGuest()
{
2018-08-20 01:22:54 +00:00
return view('site.index');
2018-07-12 16:37:31 +00:00
}
public function homeTimeline()
{
2018-12-11 03:41:41 +00:00
return view('timeline.home');
2018-07-12 16:37:31 +00:00
}
2018-06-05 07:49:05 +00:00
public function changeLocale(Request $request, $locale)
{
2018-11-16 03:52:36 +00:00
// todo: add other locales after pushing new l10n strings
2019-02-28 03:15:18 +00:00
$locales = Localization::languages();
2018-11-16 03:52:36 +00:00
if(in_array($locale, $locales)) {
session()->put('locale', $locale);
2018-06-05 07:49:05 +00:00
}
2018-08-28 03:07:36 +00:00
2019-02-28 04:52:47 +00:00
return redirect(route('site.language'));
2018-06-05 07:49:05 +00:00
}
2018-08-10 03:18:56 +00:00
public function about()
{
2019-03-14 02:05:29 +00:00
$stats = Cache::remember('site:about', now()->addMinutes(120), function() {
return [
'posts' => Status::whereLocal(true)->count(),
'users' => User::count(),
'admin' => User::whereIsAdmin(true)->first()
];
});
2019-03-14 02:05:29 +00:00
return view('site.about', compact('stats'));
2018-11-16 03:52:36 +00:00
}
2018-08-28 03:07:36 +00:00
2018-11-16 03:52:36 +00:00
public function language()
{
return view('site.language');
2018-08-10 03:18:56 +00:00
}
2019-02-05 20:58:48 +00:00
public function communityGuidelines(Request $request)
{
$slug = '/site/kb/community-guidelines';
$page = Page::whereSlug($slug)->whereActive(true)->first();
return view('site.help.community-guidelines', compact('page'));
}
2018-06-01 03:12:06 +00:00
}