1
0
Fork 0
forked from mirror/pixelfed
pixelfed/app/Http/Controllers/SiteController.php

83 lines
2.3 KiB
PHP
Raw Normal View History

2018-05-31 21:12:06 -06:00
<?php
namespace App\Http\Controllers;
2018-08-28 03:07:36 +00:00
use Illuminate\Http\Request;
2019-02-05 13:58:48 -07:00
use App, Auth, Cache, View;
use App\Util\Lexer\PrettyNumber;
use App\{Follower, Page, Profile, Status, User, UserFilter};
2018-05-31 21:12:06 -06:00
class SiteController extends Controller
{
2018-07-12 10:37:31 -06:00
public function home()
{
2018-08-28 03:07:36 +00:00
if (Auth::check()) {
return $this->homeTimeline();
2018-07-12 10:37:31 -06:00
} else {
2018-08-28 03:07:36 +00:00
return $this->homeGuest();
2018-07-12 10:37:31 -06:00
}
}
public function homeGuest()
{
2018-08-19 19:22:54 -06:00
return view('site.index');
2018-07-12 10:37:31 -06:00
}
public function homeTimeline()
{
2018-12-10 20:41:41 -07:00
return view('timeline.home');
2018-07-12 10:37:31 -06:00
}
2018-06-05 01:49:05 -06:00
public function changeLocale(Request $request, $locale)
{
2018-11-15 20:52:36 -07:00
// todo: add other locales after pushing new l10n strings
$locales = ['en'];
if(in_array($locale, $locales)) {
session()->put('locale', $locale);
2018-06-05 01:49:05 -06:00
}
2018-08-28 03:07:36 +00:00
2018-06-05 01:49:05 -06:00
return redirect()->back();
}
2018-08-09 21:18:56 -06:00
public function about()
{
2019-02-05 13:58:48 -07:00
$res = Cache::remember('site:about', 120, function() {
$custom = Page::whereSlug('/site/about')->whereActive(true)->exists();
if($custom) {
$stats = Cache::remember('site:about:stats', 60, function() {
return [
'posts' => Status::whereLocal(true)->count(),
'users' => User::count(),
'admin' => User::whereIsAdmin(true)->first()
];
});
return View::make('site.about')->with('stats', $stats)->render();
} else {
$stats = Cache::remember('site:about:stats', 60, function() {
return [
'posts' => Status::whereLocal(true)->count(),
'users' => User::count(),
'admin' => User::whereIsAdmin(true)->first()
];
});
//return view('site.about', compact('stats'));
return View::make('site.about')->with('stats', $stats)->render();
}
});
2019-02-05 13:58:48 -07:00
return $res;
2018-11-15 20:52:36 -07:00
}
2018-08-28 03:07:36 +00:00
2018-11-15 20:52:36 -07:00
public function language()
{
return view('site.language');
2018-08-09 21:18:56 -06:00
}
2019-02-05 13:58:48 -07: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-05-31 21:12:06 -06:00
}