Merge pull request #369 from pixelfed/frontend-ui-refactor

Frontend ui refactor
This commit is contained in:
daniel 2018-08-13 18:19:13 -06:00 committed by GitHub
commit 44a0e1d1a0
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 31 additions and 9 deletions

View file

@ -48,6 +48,23 @@ class ProfileController extends Controller
return view('profile.show', compact('user', 'settings', 'owner', 'is_following', 'is_admin', 'timeline')); return view('profile.show', compact('user', 'settings', 'owner', 'is_following', 'is_admin', 'timeline'));
} }
public function permalinkRedirect(Request $request, $username)
{
$user = Profile::whereUsername($username)->firstOrFail();
$settings = User::whereUsername($username)->firstOrFail()->settings;
$mimes = [
'application/activity+json',
'application/ld+json; profile="https://www.w3.org/ns/activitystreams"'
];
if(in_array($request->header('accept'), $mimes) && config('pixelfed.activitypub_enabled')) {
return $this->showActivityPub($request, $user);
}
return redirect($user->url());
}
protected function privateProfileCheck(Profile $profile) protected function privateProfileCheck(Profile $profile)
{ {
if(Auth::check() === false) { if(Auth::check() === false) {

View file

@ -13,7 +13,7 @@ class ProfileOutbox extends Fractal\TransformerAbstract
$count = $profile->statuses()->count(); $count = $profile->statuses()->count();
$statuses = $profile->statuses()->has('media')->orderBy('id','desc')->take(20)->get()->map(function($i, $k) { $statuses = $profile->statuses()->has('media')->orderBy('id','desc')->take(20)->get()->map(function($i, $k) {
$item = [ $item = [
'id' => $i->url(), 'id' => $i->permalink(),
// TODO: handle other types // TODO: handle other types
'type' => 'Create', 'type' => 'Create',
'actor' => $i->profile->url(), 'actor' => $i->profile->url(),
@ -47,7 +47,7 @@ class ProfileOutbox extends Fractal\TransformerAbstract
// TODO: add cc's // TODO: add cc's
//"{$notice->getProfile()->getUrl()}/subscribers", //"{$notice->getProfile()->getUrl()}/subscribers",
], ],
'sensitive' => null, 'sensitive' => (bool) $i->is_nsfw,
'atomUri' => $i->url(), 'atomUri' => $i->url(),
'inReplyToAtomUri' => null, 'inReplyToAtomUri' => null,
'conversation' => $i->url(), 'conversation' => $i->url(),

View file

@ -11,7 +11,14 @@ class ProfileTransformer extends Fractal\TransformerAbstract
public function transform(Profile $profile) public function transform(Profile $profile)
{ {
return [ return [
'@context' => 'https://www.w3.org/ns/activitystreams', '@context' => [
'https://www.w3.org/ns/activitystreams',
'https://w3id.org/security/v1',
[
"manuallyApprovesFollowers" => "as:manuallyApprovesFollowers",
"featured" => 'https://pixelfed.org/ns/featured',
]
],
'id' => $profile->permalink(), 'id' => $profile->permalink(),
'type' => 'Person', 'type' => 'Person',
'following' => $profile->permalink('/following'), 'following' => $profile->permalink('/following'),
@ -23,9 +30,9 @@ class ProfileTransformer extends Fractal\TransformerAbstract
'name' => $profile->name, 'name' => $profile->name,
'summary' => $profile->bio, 'summary' => $profile->bio,
'url' => $profile->url(), 'url' => $profile->url(),
'manuallyApprovesFollowers' => $profile->is_private, 'manuallyApprovesFollowers' => (bool) $profile->is_private,
'follower_count' => $profile->followers()->count(), // 'follower_count' => $profile->followers()->count(),
'following_count' => $profile->following()->count(), // 'following_count' => $profile->following()->count(),
'publicKey' => [ 'publicKey' => [
'id' => $profile->permalink() . '#main-key', 'id' => $profile->permalink() . '#main-key',
'owner' => $profile->permalink(), 'owner' => $profile->permalink(),

View file

@ -123,9 +123,7 @@ Route::domain(config('pixelfed.domain.app'))->middleware('validemail')->group(fu
Route::redirect('/', '/'); Route::redirect('/', '/');
Route::get('{user}.atom', 'ProfileController@showAtomFeed'); Route::get('{user}.atom', 'ProfileController@showAtomFeed');
Route::get('{username}/outbox', 'FederationController@userOutbox'); Route::get('{username}/outbox', 'FederationController@userOutbox');
Route::get('{user}', function($user) { Route::get('{username}', 'ProfileController@permalinkRedirect');
return redirect('/'.$user);
});
}); });
Route::get('p/{username}/{id}/c/{cid}', 'CommentController@show'); Route::get('p/{username}/{id}/c/{cid}', 'CommentController@show');