mirror of
https://github.com/pixelfed/pixelfed.git
synced 2024-11-26 16:23:16 +00:00
Merge pull request #348 from pixelfed/frontend-ui-refactor
Frontend UI Refactor
This commit is contained in:
commit
c6947acd98
7 changed files with 441 additions and 500 deletions
71
app/Http/Controllers/Api/BaseApiController.php
Normal file
71
app/Http/Controllers/Api/BaseApiController.php
Normal file
|
@ -0,0 +1,71 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Http\Controllers\Api;
|
||||||
|
|
||||||
|
use Auth;
|
||||||
|
use App\{Like, Profile, Status};
|
||||||
|
use League\Fractal;
|
||||||
|
use Illuminate\Http\Request;
|
||||||
|
use App\Http\Controllers\Controller;
|
||||||
|
use App\Util\Webfinger\Webfinger;
|
||||||
|
use App\Transformer\Api\{
|
||||||
|
AccountTransformer,
|
||||||
|
StatusTransformer
|
||||||
|
};
|
||||||
|
use League\Fractal\Serializer\ArraySerializer;
|
||||||
|
|
||||||
|
class BaseApiController extends Controller
|
||||||
|
{
|
||||||
|
protected $fractal;
|
||||||
|
|
||||||
|
public function __construct()
|
||||||
|
{
|
||||||
|
$this->middleware('auth');
|
||||||
|
$this->fractal = new Fractal\Manager();
|
||||||
|
$this->fractal->setSerializer(new ArraySerializer());
|
||||||
|
}
|
||||||
|
|
||||||
|
public function accounts(Request $request, $id)
|
||||||
|
{
|
||||||
|
$profile = Profile::findOrFail($id);
|
||||||
|
$resource = new Fractal\Resource\Item($profile, new AccountTransformer);
|
||||||
|
$res = $this->fractal->createData($resource)->toArray();
|
||||||
|
return response()->json($res, 200, [], JSON_PRETTY_PRINT);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function accountFollowers(Request $request, $id)
|
||||||
|
{
|
||||||
|
$profile = Profile::findOrFail($id);
|
||||||
|
$followers = $profile->followers;
|
||||||
|
$resource = new Fractal\Resource\Collection($followers, new AccountTransformer);
|
||||||
|
$res = $this->fractal->createData($resource)->toArray();
|
||||||
|
return response()->json($res, 200, [], JSON_PRETTY_PRINT);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function accountFollowing(Request $request, $id)
|
||||||
|
{
|
||||||
|
$profile = Profile::findOrFail($id);
|
||||||
|
$following = $profile->following;
|
||||||
|
$resource = new Fractal\Resource\Collection($following, new AccountTransformer);
|
||||||
|
$res = $this->fractal->createData($resource)->toArray();
|
||||||
|
return response()->json($res, 200, [], JSON_PRETTY_PRINT);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function accountStatuses(Request $request, $id)
|
||||||
|
{
|
||||||
|
$profile = Profile::findOrFail($id);
|
||||||
|
$statuses = $profile->statuses()->orderBy('id', 'desc')->paginate(20);
|
||||||
|
$resource = new Fractal\Resource\Collection($statuses, new StatusTransformer);
|
||||||
|
$res = $this->fractal->createData($resource)->toArray();
|
||||||
|
return response()->json($res, 200, [], JSON_PRETTY_PRINT);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public function followSuggestions(Request $request)
|
||||||
|
{
|
||||||
|
$followers = Auth::user()->profile->recommendFollowers();
|
||||||
|
$resource = new Fractal\Resource\Collection($followers, new AccountTransformer);
|
||||||
|
$res = $this->fractal->createData($resource)->toArray();
|
||||||
|
return response()->json($res);
|
||||||
|
}
|
||||||
|
}
|
|
@ -26,6 +26,10 @@ class BookmarkController extends Controller
|
||||||
['status_id' => $status->id], ['profile_id' => $profile->id]
|
['status_id' => $status->id], ['profile_id' => $profile->id]
|
||||||
);
|
);
|
||||||
|
|
||||||
|
if(!$bookmark->wasRecentlyCreated) {
|
||||||
|
$bookmark->delete();
|
||||||
|
}
|
||||||
|
|
||||||
if($request->ajax()) {
|
if($request->ajax()) {
|
||||||
$response = ['code' => 200, 'msg' => 'Bookmark saved!'];
|
$response = ['code' => 200, 'msg' => 'Bookmark saved!'];
|
||||||
} else {
|
} else {
|
||||||
|
|
|
@ -109,11 +109,12 @@ class ProfileController extends Controller
|
||||||
abort(403);
|
abort(403);
|
||||||
}
|
}
|
||||||
$user = Auth::user()->profile;
|
$user = Auth::user()->profile;
|
||||||
|
$settings = User::whereUsername($username)->firstOrFail()->settings;
|
||||||
$owner = true;
|
$owner = true;
|
||||||
$following = false;
|
$following = false;
|
||||||
$timeline = $user->bookmarks()->withCount(['likes','comments'])->orderBy('created_at','desc')->simplePaginate(10);
|
$timeline = $user->bookmarks()->withCount(['likes','comments'])->orderBy('created_at','desc')->simplePaginate(10);
|
||||||
$is_following = ($owner == false && Auth::check()) ? $user->followedBy(Auth::user()->profile) : false;
|
$is_following = ($owner == false && Auth::check()) ? $user->followedBy(Auth::user()->profile) : false;
|
||||||
$is_admin = is_null($user->domain) ? $user->user->is_admin : false;
|
$is_admin = is_null($user->domain) ? $user->user->is_admin : false;
|
||||||
return view('profile.show', compact('user', 'owner', 'following', 'timeline', 'is_following', 'is_admin'));
|
return view('profile.show', compact('user', 'settings', 'owner', 'following', 'timeline', 'is_following', 'is_admin'));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -118,6 +118,7 @@ class RestrictedNames {
|
||||||
|
|
||||||
// Static Assets
|
// Static Assets
|
||||||
"assets",
|
"assets",
|
||||||
|
"storage",
|
||||||
|
|
||||||
// Laravel Horizon
|
// Laravel Horizon
|
||||||
"horizon",
|
"horizon",
|
||||||
|
@ -127,14 +128,19 @@ class RestrictedNames {
|
||||||
"api",
|
"api",
|
||||||
"auth",
|
"auth",
|
||||||
"i",
|
"i",
|
||||||
|
"dashboard",
|
||||||
"discover",
|
"discover",
|
||||||
|
"docs",
|
||||||
"home",
|
"home",
|
||||||
"login",
|
"login",
|
||||||
"logout",
|
"logout",
|
||||||
|
"media",
|
||||||
"p",
|
"p",
|
||||||
"password",
|
"password",
|
||||||
|
"reports",
|
||||||
"search",
|
"search",
|
||||||
"settings",
|
"settings",
|
||||||
|
"statuses",
|
||||||
"site",
|
"site",
|
||||||
"timeline",
|
"timeline",
|
||||||
"user",
|
"user",
|
||||||
|
|
|
@ -31,13 +31,9 @@ class Webfinger {
|
||||||
|
|
||||||
public function generateAliases()
|
public function generateAliases()
|
||||||
{
|
{
|
||||||
$host = parse_url(config('app.url'), PHP_URL_HOST);
|
|
||||||
$username = $this->user->username;
|
|
||||||
$url = $this->user->url();
|
|
||||||
|
|
||||||
$this->aliases = [
|
$this->aliases = [
|
||||||
'acct:'.$username.'@'.$host,
|
$this->user->url(),
|
||||||
$url
|
$this->user->permalink()
|
||||||
];
|
];
|
||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
|
@ -55,24 +51,12 @@ class Webfinger {
|
||||||
[
|
[
|
||||||
'rel' => 'http://schemas.google.com/g/2010#updates-from',
|
'rel' => 'http://schemas.google.com/g/2010#updates-from',
|
||||||
'type' => 'application/atom+xml',
|
'type' => 'application/atom+xml',
|
||||||
'href' => url("/users/{$user->username}.atom")
|
'href' => $user->permalink('.atom')
|
||||||
],
|
],
|
||||||
[
|
[
|
||||||
'rel' => 'self',
|
'rel' => 'self',
|
||||||
'type' => 'application/activity+json',
|
'type' => 'application/activity+json',
|
||||||
'href' => $user->permalink()
|
'href' => $user->permalink()
|
||||||
],
|
|
||||||
[
|
|
||||||
'rel' => 'magic-public-key',
|
|
||||||
'href' => null//$user->public_key
|
|
||||||
],
|
|
||||||
[
|
|
||||||
'rel' => 'salmon',
|
|
||||||
'href' => $user->permalink('/salmon')
|
|
||||||
],
|
|
||||||
[
|
|
||||||
'rel' => 'http://ostatus.org/schema/1.0/subscribe',
|
|
||||||
'href' => url('/main/ostatussub?profile={uri}')
|
|
||||||
]
|
]
|
||||||
];
|
];
|
||||||
return $this;
|
return $this;
|
||||||
|
|
|
@ -12,7 +12,7 @@
|
||||||
"fideloper/proxy": "^4.0",
|
"fideloper/proxy": "^4.0",
|
||||||
"greggilbert/recaptcha": "dev-master",
|
"greggilbert/recaptcha": "dev-master",
|
||||||
"intervention/image": "^2.4",
|
"intervention/image": "^2.4",
|
||||||
"kitetail/zttp": "^0.3.0",
|
"pixelfed/zttp": "^0.4",
|
||||||
"laravel/framework": "5.6.*",
|
"laravel/framework": "5.6.*",
|
||||||
"laravel/horizon": "^1.2",
|
"laravel/horizon": "^1.2",
|
||||||
"laravel/passport": "^6.0",
|
"laravel/passport": "^6.0",
|
||||||
|
|
821
composer.lock
generated
821
composer.lock
generated
File diff suppressed because it is too large
Load diff
Loading…
Reference in a new issue