1
0
Fork 0
mirror of synced 2024-07-07 23:46:11 +12:00
appwrite/app/controllers/web/console.php

76 lines
3.4 KiB
PHP
Raw Normal View History

2019-05-09 18:54:39 +12:00
<?php
2023-08-12 01:34:57 +12:00
use Appwrite\Extend\Exception;
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
2022-11-23 10:14:38 +13:00
App::init()
->groups(['web'])
->inject('request')
->inject('response')
->action(function (Request $request, Response $response) {
$response
->addHeader('X-Frame-Options', 'SAMEORIGIN') // Avoid console and homepage from showing in iframes
->addHeader('X-XSS-Protection', '1; mode=block; report=/v1/xss?url=' . \urlencode($request->getURI()))
->addHeader('X-UA-Compatible', 'IE=Edge') // Deny IE browsers from going into quirks mode
;
});
2023-06-02 23:18:34 +12:00
App::get('/console/*')
2022-10-31 23:50:19 +13:00
->alias('/')
->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')
->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')
Database layer (#3338) * database response model * database collection config * new database scopes * database service update * database execption codes * remove read write permission from database model * updating tests and fixing some bugs * server side tests are now passing * databases api * tests for database endpoint * composer update * fix error * formatting * formatting fixes * get database test * more updates to events and usage * more usage updates * fix delete type * fix test * delete database * more fixes * databaseId in attributes and indexes * more fixes * fix issues * fix index subquery * fix console scope and index query * updating tests as required * fix phpcs errors and warnings * updates to review suggestions * UI progress * ui updates and cleaning up * fix type * rework database events * update tests * update types * event generation fixed * events config updated * updating context to support multiple * realtime updates * fix ids * update context * validator updates * fix naming conflict * fix tests * fix lint errors * fix wprler and realtime tests * fix webhooks test * fix event validator and other tests * formatting fixes * removing leftover var_dumps * remove leftover comment * update usage params * usage metrics updates * update database usage * fix usage * specs update * updates to usage * fix UI and usage * fix lints * internal id fixes * fixes for internal Id * renaming services and related files * rename tests * rename doc link * rename readme * fix test name * tests: fixes for 0.15.x sync Co-authored-by: Torsten Dittmann <torsten.dittmann@googlemail.com>
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);
});