More user page tweaks

This commit is contained in:
Timothy Warren 2023-05-18 16:25:50 -04:00
parent b678a3401e
commit f2b7f61030
9 changed files with 37 additions and 39 deletions

View File

@ -16,7 +16,9 @@ use Aviat\AnimeClient\Kitsu;
<aside class="info">
<table class="media-details invisible">
<tr>
<td><?= $helper->img($data['avatar'], ['alt' => '']); ?></td>
<?php if($data['avatar'] !== null): ?>
<td><?= $helper->img($data['avatar'], ['alt' => '', 'width' => '225']); ?></td>
<?php endif ?>
<td><?= $escape->html($data['about']) ?></td>
</tr>
</table>
@ -25,6 +27,7 @@ use Aviat\AnimeClient\Kitsu;
<?php foreach ([
'joinDate' => 'Joined',
'birthday' => 'Birthday',
'gender' => 'Gender',
'location' => 'Location'
] as $key => $label): ?>
<?php if ($data[$key] !== null): ?>
@ -42,7 +45,7 @@ use Aviat\AnimeClient\Kitsu;
</tr>
<?php endif ?>
<?php if ( ! empty($data['waifu'])): ?>
<?php if ($data['waifu']['character'] !== null): ?>
<tr>
<td><?= $escape->html($data['waifu']['label']) ?></td>
<td>

View File

@ -1,15 +0,0 @@
{
"name": "Anilist Schema",
"schemaPath": "schema.graphql",
"extensions": {
"endpoints": {
"Anilist": {
"url": "https://graphql.anilist.co",
"headers": {
"user-agent": "JS GraphQL"
},
"introspect": true
}
}
}
}

View File

@ -0,0 +1,8 @@
schema: schema.graphql
extensions:
endpoints:
Anilist:
url: https://graphql.anilist.co
headers:
user-agent: JS GraphQL
introspect: true

View File

@ -1,15 +0,0 @@
{
"name": "Kitsu Schema",
"schemaPath": "schema.graphql",
"extensions": {
"endpoints": {
"Kitsu": {
"url": "https://kitsu.io/api/graphql",
"headers": {
"user-agent": "JS GraphQL"
},
"introspect": true
}
}
}
}

View File

@ -21,6 +21,7 @@ query ($slug: String!) {
createdAt
id
location
gender
name
proMessage
proTier

View File

@ -39,17 +39,18 @@ final class UserTransformer extends AbstractTransformer
] : [];
return User::from([
'about' => $base['about'],
'avatar' => $base['avatarImage']['original']['url'],
'birthday' => Kitsu::formatDate($base['birthday']) . ' (' . Kitsu::friendlyTime(Kitsu::getDateDiff($base['birthday']), 'year') . ')',
'joinDate' => Kitsu::formatDate($base['createdAt']) . ' (' . Kitsu::friendlyTime(Kitsu::getDateDiff($base['createdAt']), 'day') . ')',
'about' => $base['about'] ?? '',
'avatar' => $base['avatarImage']['original']['url'] ?? null,
'birthday' => $base['birthday'] !== null ? Kitsu::formatDate($base['birthday']) . ' (' . Kitsu::friendlyTime(Kitsu::getDateDiff($base['birthday']), 'year') . ')' : null,
'joinDate' => Kitsu::formatDate($base['createdAt']) . ' (' . Kitsu::friendlyTime(Kitsu::getDateDiff($base['createdAt']), 'day') . ' ago)',
'gender' => $base['gender'],
'favorites' => $this->organizeFavorites($favorites),
'location' => $base['location'],
'name' => $base['name'],
'slug' => $base['slug'],
'stats' => $this->organizeStats($stats),
'waifu' => $waifu,
'website' => $base['siteLinks']['nodes'][0]['url'],
'website' => $base['siteLinks']['nodes'][0]['url'] ?? null,
]);
}

View File

@ -0,0 +1,8 @@
schema: schema.graphql
extensions:
endpoints:
Kitsu:
url: https://kitsu.io/api/graphql
headers:
user-agent: JS GraphQL
introspect: true

View File

@ -69,6 +69,12 @@ final class User extends BaseController
: $username;
$rawData = $this->kitsuModel->getUserData($username);
if ($rawData['data']['findProfileBySlug'] === null)
{
$this->notFound('Sorry, user not found', "The user '$username' does not seem to exist.");
return;
}
$data = (new UserTransformer())->transform($rawData)->toArray();
$this->outputHTML('user/details', [

View File

@ -22,12 +22,13 @@ final class User extends AbstractType
public ?string $about;
public ?string $avatar;
public ?string $birthday;
public ?string $joinDate;
public string $joinDate;
public ?string $gender;
public ?array $favorites;
public ?string $location;
public ?string $name;
public ?string $slug;
public ?array $stats;
public ?array $waifu;
public array $waifu;
public ?string $website;
}