mirror of
https://github.com/pixelfed/pixelfed.git
synced 2025-01-25 22:10:47 +00:00
Update SiteController
This commit is contained in:
parent
c077f6625d
commit
451a65cc5b
1 changed files with 23 additions and 4 deletions
|
@ -2,9 +2,10 @@
|
||||||
|
|
||||||
namespace App\Http\Controllers;
|
namespace App\Http\Controllers;
|
||||||
|
|
||||||
use App, Auth;
|
use App, Auth, Cache;
|
||||||
use Illuminate\Http\Request;
|
use Illuminate\Http\Request;
|
||||||
use App\{Follower, Status, User};
|
use App\{Follower, Profile, Status, User};
|
||||||
|
use App\Util\Lexer\PrettyNumber;
|
||||||
|
|
||||||
class SiteController extends Controller
|
class SiteController extends Controller
|
||||||
{
|
{
|
||||||
|
@ -29,10 +30,12 @@ class SiteController extends Controller
|
||||||
$following = Follower::whereProfileId(Auth::user()->profile->id)->pluck('following_id');
|
$following = Follower::whereProfileId(Auth::user()->profile->id)->pluck('following_id');
|
||||||
$following->push(Auth::user()->profile->id);
|
$following->push(Auth::user()->profile->id);
|
||||||
$timeline = Status::whereIn('profile_id', $following)
|
$timeline = Status::whereIn('profile_id', $following)
|
||||||
|
->whereHas('media')
|
||||||
->orderBy('id','desc')
|
->orderBy('id','desc')
|
||||||
->withCount(['comments', 'likes', 'shares'])
|
->withCount(['comments', 'likes', 'shares'])
|
||||||
->simplePaginate(10);
|
->simplePaginate(20);
|
||||||
return view('timeline.template', compact('timeline'));
|
$type = 'personal';
|
||||||
|
return view('timeline.template', compact('timeline', 'type'));
|
||||||
}
|
}
|
||||||
|
|
||||||
public function changeLocale(Request $request, $locale)
|
public function changeLocale(Request $request, $locale)
|
||||||
|
@ -43,4 +46,20 @@ class SiteController extends Controller
|
||||||
App::setLocale($locale);
|
App::setLocale($locale);
|
||||||
return redirect()->back();
|
return redirect()->back();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function about()
|
||||||
|
{
|
||||||
|
$res = Cache::remember('site:page:about', 15, function() {
|
||||||
|
$statuses = Status::whereHas('media')
|
||||||
|
->whereNull('in_reply_to_id')
|
||||||
|
->whereNull('reblog_of_id')
|
||||||
|
->count();
|
||||||
|
$statusCount = PrettyNumber::convert($statuses);
|
||||||
|
$userCount = PrettyNumber::convert(User::count());
|
||||||
|
$remoteCount = PrettyNumber::convert(Profile::whereNotNull('remote_url')->count());
|
||||||
|
$adminContact = User::whereIsAdmin(true)->first();
|
||||||
|
return view('site.about')->with(compact('statusCount', 'userCount', 'remoteCount', 'adminContact'))->render();
|
||||||
|
});
|
||||||
|
return $res;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue