mirror of
https://github.com/pixelfed/pixelfed.git
synced 2024-11-18 20:41:27 +00:00
Merge pull request #643 from pixelfed/frontend-ui-refactor
Frontend ui refactor
This commit is contained in:
commit
564998732d
9 changed files with 40 additions and 79 deletions
|
@ -167,7 +167,7 @@ XML;
|
|||
|
||||
public function userInbox(Request $request, $username)
|
||||
{
|
||||
// todo
|
||||
return;
|
||||
}
|
||||
|
||||
public function userFollowing(Request $request, $username)
|
||||
|
@ -175,7 +175,10 @@ XML;
|
|||
if (config('pixelfed.activitypub_enabled') == false) {
|
||||
abort(403);
|
||||
}
|
||||
$profile = Profile::whereNull('remote_url')->whereUsername($username)->firstOrFail();
|
||||
$profile = Profile::whereNull('remote_url')
|
||||
->whereUsername($username)
|
||||
->whereIsPrivate(false)
|
||||
->firstOrFail();
|
||||
$obj = [
|
||||
'@context' => 'https://www.w3.org/ns/activitystreams',
|
||||
'id' => $request->getUri(),
|
||||
|
@ -193,7 +196,10 @@ XML;
|
|||
if (config('pixelfed.activitypub_enabled') == false) {
|
||||
abort(403);
|
||||
}
|
||||
$profile = Profile::whereNull('remote_url')->whereUsername($username)->firstOrFail();
|
||||
$profile = Profile::whereNull('remote_url')
|
||||
->whereUsername($username)
|
||||
->whereIsPrivate(false)
|
||||
->firstOrFail();
|
||||
$obj = [
|
||||
'@context' => 'https://www.w3.org/ns/activitystreams',
|
||||
'id' => $request->getUri(),
|
||||
|
|
|
@ -46,7 +46,12 @@ class Media extends Model
|
|||
{
|
||||
$verb = 'Image';
|
||||
switch ($this->mimeType()) {
|
||||
case 'audio':
|
||||
$verb = 'Audio';
|
||||
break;
|
||||
|
||||
case 'image':
|
||||
$verb = 'Image';
|
||||
break;
|
||||
|
||||
case 'video':
|
||||
|
|
|
@ -22,6 +22,7 @@ class Status extends Model
|
|||
protected $fillable = ['profile_id', 'visibility', 'in_reply_to_id', 'reblog_of_id'];
|
||||
|
||||
const STATUS_TYPES = [
|
||||
'text',
|
||||
'photo',
|
||||
'photo:album',
|
||||
'video',
|
||||
|
|
|
@ -4,74 +4,33 @@ namespace App\Transformer\ActivityPub;
|
|||
|
||||
use App\Profile;
|
||||
use League\Fractal;
|
||||
use App\Transformer\ActivityPub\Verb\CreateNote;
|
||||
|
||||
class ProfileOutbox extends Fractal\TransformerAbstract
|
||||
{
|
||||
protected $defaultIncludes = ['orderedItems'];
|
||||
|
||||
public function transform(Profile $profile)
|
||||
{
|
||||
$count = $profile->statuses()->count();
|
||||
$statuses = $profile->statuses()->has('media')->orderBy('id', 'desc')->take(20)->get()->map(function ($i, $k) {
|
||||
$item = [
|
||||
'id' => $i->permalink(),
|
||||
// TODO: handle other types
|
||||
'type' => 'Create',
|
||||
'actor' => $i->profile->url(),
|
||||
'published' => $i->created_at->toISO8601String(),
|
||||
'to' => [
|
||||
'https://www.w3.org/ns/activitystreams#Public',
|
||||
],
|
||||
'cc' => [
|
||||
$i->profile->permalink('/followers'),
|
||||
],
|
||||
'object' => [
|
||||
'id' => $i->url(),
|
||||
|
||||
// TODO: handle other types
|
||||
'type' => 'Note',
|
||||
|
||||
// XXX: CW Title
|
||||
'summary' => null,
|
||||
'content' => $i->rendered ?? $i->caption,
|
||||
'inReplyTo' => null,
|
||||
|
||||
// TODO: fix date format
|
||||
'published' => $i->created_at->toAtomString(),
|
||||
'url' => $i->url(),
|
||||
'attributedTo' => $i->profile->permalink(),
|
||||
'to' => [
|
||||
// TODO: handle proper scope
|
||||
'https://www.w3.org/ns/activitystreams#Public',
|
||||
],
|
||||
'cc' => [
|
||||
// TODO: add cc's
|
||||
//"{$notice->getProfile()->getUrl()}/subscribers",
|
||||
],
|
||||
'sensitive' => (bool) $i->is_nsfw,
|
||||
'atomUri' => $i->url(),
|
||||
'inReplyToAtomUri' => null,
|
||||
'attachment' => [
|
||||
|
||||
// TODO: support more than 1 attachment
|
||||
[
|
||||
'type' => 'Document',
|
||||
'mediaType' => $i->firstMedia()->mime,
|
||||
'url' => $i->firstMedia()->url(),
|
||||
'name' => null,
|
||||
],
|
||||
],
|
||||
'tag' => [],
|
||||
],
|
||||
];
|
||||
|
||||
return $item;
|
||||
});
|
||||
$count = $profile->statuses()->whereHas('media')->count();
|
||||
|
||||
return [
|
||||
'@context' => 'https://www.w3.org/ns/activitystreams',
|
||||
'id' => $profile->permalink('/outbox'),
|
||||
'type' => 'OrderedCollection',
|
||||
'totalItems' => $count,
|
||||
'orderedItems' => $statuses,
|
||||
];
|
||||
}
|
||||
|
||||
public function includeOrderedItems(Profile $profile)
|
||||
{
|
||||
$statuses = $profile
|
||||
->statuses()
|
||||
->with('media')
|
||||
->whereVisibility('public')
|
||||
->orderBy('created_at', 'desc')
|
||||
->paginate(10);
|
||||
|
||||
return $this->collection($statuses, new CreateNote);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -15,9 +15,6 @@ class ProfileTransformer extends Fractal\TransformerAbstract
|
|||
'https://w3id.org/security/v1',
|
||||
[
|
||||
'manuallyApprovesFollowers' => 'as:manuallyApprovesFollowers',
|
||||
'featured' => [
|
||||
'https://pixelfed.org/ns#featured' => ['@type' => '@id'],
|
||||
],
|
||||
],
|
||||
],
|
||||
'id' => $profile->permalink(),
|
||||
|
@ -26,7 +23,7 @@ class ProfileTransformer extends Fractal\TransformerAbstract
|
|||
'followers' => $profile->permalink('/followers'),
|
||||
'inbox' => $profile->permalink('/inbox'),
|
||||
'outbox' => $profile->permalink('/outbox'),
|
||||
'featured' => $profile->permalink('/collections/featured'),
|
||||
//'featured' => $profile->permalink('/collections/featured'),
|
||||
'preferredUsername' => $profile->username,
|
||||
'name' => $profile->name,
|
||||
'summary' => $profile->bio,
|
||||
|
|
|
@ -30,12 +30,6 @@ class CreateNote extends Fractal\TransformerAbstract
|
|||
'@context' => [
|
||||
'https://www.w3.org/ns/activitystreams',
|
||||
'https://w3id.org/security/v1',
|
||||
[
|
||||
'manuallyApprovesFollowers' => 'as:manuallyApprovesFollowers',
|
||||
'featured' => [
|
||||
'https://pixelfed.org/ns#featured' => ['@type' => '@id'],
|
||||
],
|
||||
],
|
||||
],
|
||||
'id' => $status->permalink(),
|
||||
'type' => 'Create',
|
||||
|
@ -57,7 +51,7 @@ class CreateNote extends Fractal\TransformerAbstract
|
|||
'sensitive' => (bool) $status->is_nsfw,
|
||||
'attachment' => $status->media->map(function ($media) {
|
||||
return [
|
||||
'type' => 'Document',
|
||||
'type' => $media->activityVerb(),
|
||||
'mediaType' => $media->mime,
|
||||
'url' => $media->url(),
|
||||
'name' => null,
|
||||
|
|
|
@ -23,7 +23,7 @@ return [
|
|||
| This value is the version of your PixelFed instance.
|
||||
|
|
||||
*/
|
||||
'version' => '0.5.4',
|
||||
'version' => '0.5.5',
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
|
@ -3,7 +3,6 @@
|
|||
font-size: 14px;
|
||||
}
|
||||
.comment-text {
|
||||
word-break: break-all;
|
||||
}
|
||||
.comment-text p {
|
||||
display: inline;
|
||||
|
@ -33,7 +32,7 @@
|
|||
</template>
|
||||
<b-dropdown-item class="font-weight-bold" v-on:click="reply(comment)">Reply</b-dropdown-item>
|
||||
<b-dropdown-item class="font-weight-bold" :href="comment.url">Permalink</b-dropdown-item>
|
||||
<b-dropdown-item class="font-weight-bold" v-on:click="embed(comment)">Embed</b-dropdown-item>
|
||||
<!-- <b-dropdown-item class="font-weight-bold" v-on:click="embed(comment)">Embed</b-dropdown-item> -->
|
||||
<b-dropdown-item class="font-weight-bold" :href="comment.account.url">Profile</b-dropdown-item>
|
||||
<b-dropdown-divider></b-dropdown-divider>
|
||||
<b-dropdown-item class="font-weight-bold" :href="'/i/report?type=post&id='+comment.id">Report</b-dropdown-item>
|
||||
|
|
|
@ -41,13 +41,13 @@
|
|||
<p class="mb-0 lead font-weight-bold">{{ status.spoiler_text ? status.spoiler_text : 'CW / NSFW / Hidden Media'}}</p>
|
||||
<p class="font-weight-light">(click to show)</p>
|
||||
</summary>
|
||||
<a class="max-hide-overflow" :href="status.url">
|
||||
<a class="max-hide-overflow" :href="status.url" :class="status.media_attachments[0].filter_class">
|
||||
<img class="card-img-top" :src="status.media_attachments[0].url">
|
||||
</a>
|
||||
</details>
|
||||
</div>
|
||||
<div v-else>
|
||||
<div>
|
||||
<div :class="status.media_attachments[0].filter_class">
|
||||
<img class="card-img-top" :src="status.media_attachments[0].url">
|
||||
</div>
|
||||
</div>
|
||||
|
@ -74,7 +74,7 @@
|
|||
</div>
|
||||
</div>
|
||||
|
||||
<div v-else-if="status.pf_type === 'photo:album'">
|
||||
<div v-else-if="status.pf_type === 'photo:album'" class="w-100">
|
||||
<div v-if="status.sensitive == true">
|
||||
<details class="details-animated">
|
||||
<summary>
|
||||
|
@ -251,7 +251,7 @@
|
|||
<div class="card-body contents d-none">
|
||||
<div class="media d-flex align-items-center">
|
||||
<a :href="profile.url">
|
||||
<img class="mr-3 rounded-circle box-shadow" :src="profile.avatar || '/storage/avatars/default.png'" alt="avatar" width="64px">
|
||||
<img class="mr-3 rounded-circle box-shadow" :src="profile.avatar || '/storage/avatars/default.png'" alt="avatar" width="64px" height="64px">
|
||||
</a>
|
||||
<div class="media-body">
|
||||
<p class="mb-0 px-0 font-weight-bold"><a :href="profile.url" class="text-dark">@{{profile.username}}</a></p>
|
||||
|
@ -291,7 +291,7 @@
|
|||
</div>
|
||||
<div class="card-body pt-2 contents" style="max-height: 300px; overflow-y: scroll;">
|
||||
<div class="media mb-3 align-items-center" v-for="(n, index) in notifications">
|
||||
<img class="mr-2 rounded-circle img-thumbnail" :src="n.account.avatar" alt="" width="32px">
|
||||
<img class="mr-2 rounded-circle img-thumbnail" :src="n.account.avatar" alt="" width="32px" height="32px">
|
||||
<div class="media-body font-weight-light small">
|
||||
<div v-if="n.type == 'favourite'">
|
||||
<p class="my-0">
|
||||
|
|
Loading…
Reference in a new issue