Skip to content

Commit 8a28c38

Browse files
committed
Update video, improve meta tags
1 parent b7be916 commit 8a28c38

3 files changed

Lines changed: 74 additions & 1 deletion

File tree

app/Http/Controllers/ObjectController.php

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
use App\Models\Video;
1010
use App\Services\ConfigService;
1111
use App\Services\HashidService;
12+
use App\Services\VideoService;
1213
use Illuminate\Http\Request;
1314

1415
class ObjectController extends Controller
@@ -85,7 +86,9 @@ public function showVideo(Request $request, $hashId)
8586
}
8687
}
8788

88-
return view('welcome');
89+
$videoData = VideoService::getMediaData($id);
90+
91+
return view('video', compact('videoData'));
8992
}
9093

9194
protected function renderVideoObject($video, $hashId)

resources/views/profile.blade.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
@php
22
use App\Services\FrontendService;
33
use App\Services\AccountService;
4+
use Illuminate\Support\Str;
45
56
$appName = FrontendService::getAppName();
67
$appDesc = FrontendService::getAppDescription();

resources/views/video.blade.php

Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
@php
2+
use App\Services\FrontendService;
3+
use Illuminate\Support\Str;
4+
5+
$appName = FrontendService::getAppName();
6+
$appDesc = FrontendService::getAppDescription();
7+
8+
$videoTitle = $videoData
9+
? ($videoData['caption'] ? Str::limit($videoData['caption'], 26) . " - @" . $videoData['account']['username'] . " | {$appName}" : "@{$videoData['account']['username']} | {$appName}")
10+
: $appName;
11+
12+
$videoDesc = $appDesc;
13+
$videoLikes = data_get($videoData, 'likes', 0);
14+
$videoComments = data_get($videoData, 'comments', 0);
15+
$videoUrl = data_get($videoData, 'url', url('/'));
16+
$videoThumbnail = data_get($videoData, 'media.thumbnail', url('/storage/avatars/default.jpg'));
17+
$authorName = data_get($videoData, 'account.name', '');
18+
$authorUsername = data_get($videoData, 'account.username', '');
19+
$authorAvatar = data_get($videoData, 'account.avatar', url('/storage/avatars/default.jpg'));
20+
21+
if ($videoData) {
22+
if (!empty($videoData['captionText'])) {
23+
$videoDesc = $videoData['captionText'];
24+
} elseif (!empty($videoData['caption'])) {
25+
$stats = "{$videoLikes} likes · {$videoComments} comments";
26+
$videoDesc = "{$videoData['caption']} • {$stats}";
27+
}
28+
}
29+
@endphp
30+
<!DOCTYPE html>
31+
<html>
32+
<head>
33+
<meta charset="utf-8">
34+
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
35+
<title>{{ $videoTitle }}</title>
36+
<link rel="shortcut icon" type="image/png" href="{{ url('/favicon.png') }}"/>
37+
38+
<meta name="description" content="{{ $videoDesc }}">
39+
<meta name="author" content="{{ $authorName }} ({{ '@' . $authorUsername }})">
40+
41+
<meta property="og:title" content="{{ $videoTitle }}" />
42+
<meta property="og:description" content="{{ $videoDesc }}" />
43+
<meta property="og:type" content="video.other" />
44+
<meta property="og:url" content="{{ $videoUrl }}" />
45+
<meta property="og:image" content="{{ $videoThumbnail }}" />
46+
<meta name="twitter:card" content="summary" />
47+
<meta name="twitter:title" content="{{ $videoTitle }}" />
48+
<meta name="twitter:description" content="{{ $videoDesc }}" />
49+
<meta name="twitter:image" content="{{ $videoThumbnail }}" />
50+
<meta property="video:release_date" content="{{ $videoData['created_at'] ?? '' }}" />
51+
52+
<meta property="article:author" content="{{ url('/@' . $authorUsername) }}" />
53+
54+
@vite(['resources/js/app.js'])
55+
{!! FrontendService::getCustomCss() !!}
56+
57+
<script type="text/javascript">
58+
window.appConfig = {!! FrontendService::getAppData() !!};
59+
window._navi = {!! App\Services\PageService::getActiveSideLinks() !!};
60+
{!! FrontendService::getCaptchaData() !!}
61+
</script>
62+
</head>
63+
64+
<body class="bg-white dark:bg-slate-950">
65+
<main id="app">
66+
<router-view></router-view>
67+
</main>
68+
</body>
69+
</html>

0 commit comments

Comments
 (0)