Skip to content

Commit def220d

Browse files
committed
Update profile, improve meta tags
1 parent 2609576 commit def220d

2 files changed

Lines changed: 72 additions & 1 deletion

File tree

app/Http/Controllers/ObjectController.php

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,13 @@ public function showProfile(Request $request, $username)
3535
return $this->activityPubResponse($profile->toActivityPub());
3636
}
3737

38-
return view('welcome');
38+
$profile = Profile::whereUsername($username)->first();
39+
40+
if (! $profile) {
41+
abort(404, 'Profile not found');
42+
}
43+
44+
return view('profile', compact('profile'));
3945
}
4046

4147
public function showVideo(Request $request, $hashId)

resources/views/profile.blade.php

Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
@php
2+
use App\Services\FrontendService;
3+
use App\Services\AccountService;
4+
5+
$appName = FrontendService::getAppName();
6+
$appDesc = FrontendService::getAppDescription();
7+
8+
$profileTitle = $profile ? "{$profile->name} (@{$profile->username}) | {$appName}" : $appName;
9+
10+
$descParts = [];
11+
if ($profile && $profile->bio) {
12+
$descParts[] = Str::limit($profile->bio, 26);
13+
}
14+
$likes = AccountService::getAccountLikesCount($profile->id);
15+
if ($profile) {
16+
$stats = [
17+
number_format($profile->video_count ?? 0) . ' videos',
18+
number_format($profile->followers ?? 0) . ' followers',
19+
number_format($likes ?? 0) . ' likes'
20+
];
21+
$descParts[] = implode(' · ', $stats);
22+
}
23+
24+
$profileDesc = !empty($descParts) ? implode(' | ', $descParts) : $appDesc;
25+
26+
$profileUrl = $profile ? url('/@' . $profile->username) : url('/');
27+
$profileAvatar = $profile && $profile->avatar ? $profile->avatar : url('/storage/avatars/default.jpg');
28+
@endphp
29+
<!DOCTYPE html>
30+
<html>
31+
<head>
32+
<meta charset="utf-8">
33+
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
34+
<title>{{ $profileTitle }}</title>
35+
<link rel="shortcut icon" type="image/png" href="{{ url('/favicon.png') }}"/>
36+
37+
<meta name="description" content="{{ $profileDesc }}">
38+
<meta property="og:title" content="{{ $profileTitle }}" />
39+
<meta property="og:description" content="{{ $profileDesc }}" />
40+
<meta property="og:type" content="profile" />
41+
<meta property="og:url" content="{{ $profileUrl }}" />
42+
<meta property="og:image" content="{{ $profileAvatar }}" />
43+
@if($profile)<meta property="profile:username" content="{{ $profile->username }}" />@endif
44+
45+
<meta name="twitter:card" content="summary" />
46+
<meta name="twitter:title" content="{{ $profileTitle }}" />
47+
<meta name="twitter:description" content="{{ $profileDesc }}" />
48+
<meta name="twitter:image" content="{{ $profileAvatar }}" />
49+
50+
@vite(['resources/js/app.js'])
51+
{!! FrontendService::getCustomCss() !!}
52+
53+
<script type="text/javascript">
54+
window.appConfig = {!! FrontendService::getAppData() !!};
55+
window._navi = {!! App\Services\PageService::getActiveSideLinks() !!};
56+
{!! FrontendService::getCaptchaData() !!}
57+
</script>
58+
</head>
59+
60+
<body class="bg-white dark:bg-slate-950">
61+
<main id="app">
62+
<router-view></router-view>
63+
</main>
64+
</body>
65+
</html>

0 commit comments

Comments
 (0)