2019-05-09 18:54:39 +12:00
|
|
|
<?php
|
2019-09-07 05:10:41 +12:00
|
|
|
|
2023-05-02 03:43:32 +12:00
|
|
|
use Appwrite\Utopia\Request;
|
2022-05-27 01:23:49 +12:00
|
|
|
use Appwrite\Utopia\Response;
|
2020-06-29 05:31:21 +12:00
|
|
|
use Utopia\App;
|
2019-05-09 18:54:39 +12:00
|
|
|
|
2023-06-02 23:18:34 +12:00
|
|
|
App::get('/console/*')
|
2022-10-31 23:50:19 +13:00
|
|
|
->alias('/')
|
2023-06-03 09:22:28 +12:00
|
|
|
->alias('auth/*')
|
2022-10-31 21:53:36 +13:00
|
|
|
->alias('/invite')
|
|
|
|
->alias('/login')
|
2023-07-11 09:20:24 +12:00
|
|
|
->alias('/card/*')
|
2022-10-31 21:53:36 +13:00
|
|
|
->alias('/recover')
|
2023-06-03 09:22:28 +12:00
|
|
|
->alias('/register/*')
|
2022-10-12 03:36:39 +13:00
|
|
|
->groups(['web'])
|
2019-05-09 18:54:39 +12:00
|
|
|
->label('permission', 'public')
|
|
|
|
->label('scope', 'home')
|
2023-05-02 03:43:32 +12:00
|
|
|
->inject('request')
|
2022-06-22 22:51:49 +12:00
|
|
|
->inject('response')
|
2023-05-02 03:43:32 +12:00
|
|
|
->action(function (Request $request, Response $response) {
|
2022-10-31 21:53:36 +13:00
|
|
|
$fallback = file_get_contents(__DIR__ . '/../../../console/index.html');
|
2023-05-02 03:43:32 +12:00
|
|
|
|
|
|
|
// Card SSR
|
|
|
|
if (\str_starts_with($request->getURI(), '/card')) {
|
|
|
|
$urlCunks = \explode('/', $request->getURI());
|
|
|
|
$userId = $urlCunks[\count($urlCunks) - 1] ?? '';
|
|
|
|
|
|
|
|
$domain = $request->getProtocol() . '://' . $request->getHostname();
|
|
|
|
|
|
|
|
if (!empty($userId)) {
|
|
|
|
$ogImageUrl = $domain . '/v1/cards/cloud-og?userId=' . $userId;
|
|
|
|
} else {
|
|
|
|
$ogImageUrl = $domain . '/v1/cards/cloud-og?mock=normal';
|
|
|
|
}
|
|
|
|
|
|
|
|
$ogTags = [
|
2023-05-02 04:51:36 +12:00
|
|
|
'<title>Appwrite Cloud Card</title>',
|
2023-05-02 03:43:32 +12:00
|
|
|
'<meta name="description" content="Appwrite Cloud is now LIVE! Share your Cloud card for a chance to win an exclusive Cloud hoodie!">',
|
2023-05-02 04:50:35 +12:00
|
|
|
'<meta property="og:url" content="' . $domain . $request->getURI() . '">',
|
2023-05-02 04:38:22 +12:00
|
|
|
'<meta name="og:image:type" content="image/png">',
|
|
|
|
'<meta name="og:image:width" content="1008">',
|
|
|
|
'<meta name="og:image:height" content="1008">',
|
2023-05-02 03:43:32 +12:00
|
|
|
'<meta property="og:type" content="website">',
|
2023-05-02 04:51:36 +12:00
|
|
|
'<meta property="og:title" content="Appwrite Cloud Card">',
|
2023-05-02 03:43:32 +12:00
|
|
|
'<meta property="og:description" content="Appwrite Cloud is now LIVE! Share your Cloud card for a chance to win an exclusive Cloud hoodie!">',
|
|
|
|
'<meta property="og:image" content="' . $ogImageUrl . '">',
|
|
|
|
'<meta name="twitter:card" content="summary_large_image">',
|
|
|
|
'<meta property="twitter:domain" content="' . $request->getHostname() . '">',
|
2023-05-02 04:50:35 +12:00
|
|
|
'<meta property="twitter:url" content="' . $domain . $request->getURI() . '">',
|
2023-05-02 04:51:36 +12:00
|
|
|
'<meta name="twitter:title" content="Appwrite Cloud Card">',
|
2023-05-02 04:38:22 +12:00
|
|
|
'<meta name="twitter:image:type" content="image/png">',
|
|
|
|
'<meta name="twitter:image:width" content="1008">',
|
|
|
|
'<meta name="twitter:image:height" content="1008">',
|
2023-05-02 03:43:32 +12:00
|
|
|
'<meta name="twitter:description" content="Appwrite Cloud is now LIVE! Share your Cloud card for a chance to win an exclusive Cloud hoodie!">',
|
|
|
|
'<meta name="twitter:image" content="' . $ogImageUrl . '">',
|
|
|
|
];
|
|
|
|
|
|
|
|
$fallback = \str_replace('<!-- {{CLOUD_OG}} -->', \implode('', $ogTags), $fallback);
|
|
|
|
}
|
|
|
|
|
2022-10-31 21:53:36 +13:00
|
|
|
$response->html($fallback);
|
|
|
|
});
|