mirror of
https://github.com/pixelfed/pixelfed.git
synced 2024-11-27 00:33:17 +00:00
Merge pull request #774 from pixelfed/frontend-ui-refactor
Frontend ui refactor
This commit is contained in:
commit
81097fae18
3 changed files with 59 additions and 3 deletions
|
@ -9,7 +9,7 @@ use App\Media;
|
||||||
use App\Profile;
|
use App\Profile;
|
||||||
use App\Status;
|
use App\Status;
|
||||||
use App\Transformer\ActivityPub\StatusTransformer;
|
use App\Transformer\ActivityPub\StatusTransformer;
|
||||||
use App\Transformer\ActivityPub\Verb\CreateNote;
|
use App\Transformer\ActivityPub\Verb\Note;
|
||||||
use App\User;
|
use App\User;
|
||||||
use Auth;
|
use Auth;
|
||||||
use Cache;
|
use Cache;
|
||||||
|
@ -250,7 +250,7 @@ class StatusController extends Controller
|
||||||
public function showActivityPub(Request $request, $status)
|
public function showActivityPub(Request $request, $status)
|
||||||
{
|
{
|
||||||
$fractal = new Fractal\Manager();
|
$fractal = new Fractal\Manager();
|
||||||
$resource = new Fractal\Resource\Item($status, new CreateNote());
|
$resource = new Fractal\Resource\Item($status, new Note());
|
||||||
$res = $fractal->createData($resource)->toArray();
|
$res = $fractal->createData($resource)->toArray();
|
||||||
|
|
||||||
return response(json_encode($res['data']))->header('Content-Type', 'application/activity+json');
|
return response(json_encode($res['data']))->header('Content-Type', 'application/activity+json');
|
||||||
|
|
56
app/Transformer/ActivityPub/Verb/Note.php
Normal file
56
app/Transformer/ActivityPub/Verb/Note.php
Normal file
|
@ -0,0 +1,56 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Transformer\ActivityPub\Verb;
|
||||||
|
|
||||||
|
use App\Status;
|
||||||
|
use League\Fractal;
|
||||||
|
|
||||||
|
class Note extends Fractal\TransformerAbstract
|
||||||
|
{
|
||||||
|
public function transform(Status $status)
|
||||||
|
{
|
||||||
|
|
||||||
|
$mentions = $status->mentions->map(function ($mention) {
|
||||||
|
return [
|
||||||
|
'type' => 'Mention',
|
||||||
|
'href' => $mention->permalink(),
|
||||||
|
'name' => $mention->emailUrl()
|
||||||
|
];
|
||||||
|
})->toArray();
|
||||||
|
$hashtags = $status->hashtags->map(function ($hashtag) {
|
||||||
|
return [
|
||||||
|
'type' => 'Hashtag',
|
||||||
|
'href' => $hashtag->url(),
|
||||||
|
'name' => "#{$hashtag->name}",
|
||||||
|
];
|
||||||
|
})->toArray();
|
||||||
|
$tags = array_merge($mentions, $hashtags);
|
||||||
|
|
||||||
|
return [
|
||||||
|
'@context' => [
|
||||||
|
'https://www.w3.org/ns/activitystreams',
|
||||||
|
'https://w3id.org/security/v1',
|
||||||
|
],
|
||||||
|
'id' => $status->url(),
|
||||||
|
'type' => 'Note',
|
||||||
|
'summary' => null,
|
||||||
|
'content' => $status->rendered ?? $status->caption,
|
||||||
|
'inReplyTo' => $status->in_reply_to_id ? $status->parent()->url() : null,
|
||||||
|
'published' => $status->created_at->toAtomString(),
|
||||||
|
'url' => $status->url(),
|
||||||
|
'attributedTo' => $status->profile->permalink(),
|
||||||
|
'to' => $status->scopeToAudience('to'),
|
||||||
|
'cc' => $status->scopeToAudience('cc'),
|
||||||
|
'sensitive' => (bool) $status->is_nsfw,
|
||||||
|
'attachment' => $status->media->map(function ($media) {
|
||||||
|
return [
|
||||||
|
'type' => $media->activityVerb(),
|
||||||
|
'mediaType' => $media->mime,
|
||||||
|
'url' => $media->url(),
|
||||||
|
'name' => null,
|
||||||
|
];
|
||||||
|
})->toArray(),
|
||||||
|
'tag' => $tags,
|
||||||
|
];
|
||||||
|
}
|
||||||
|
}
|
|
@ -23,7 +23,7 @@ return [
|
||||||
| This value is the version of your PixelFed instance.
|
| This value is the version of your PixelFed instance.
|
||||||
|
|
|
|
||||||
*/
|
*/
|
||||||
'version' => '0.7.9',
|
'version' => '0.7.10',
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|--------------------------------------------------------------------------
|
|--------------------------------------------------------------------------
|
||||||
|
|
Loading…
Reference in a new issue