1
0
Fork 0
mirror of synced 2024-09-29 08:51:28 +13:00

fix: remove layout

This commit is contained in:
Torsten Dittmann 2022-11-17 13:37:59 +01:00
parent e7189efcff
commit 8d3903cd37
4 changed files with 51 additions and 115 deletions

View file

@ -394,11 +394,10 @@ App::error()
->inject('utopia')
->inject('request')
->inject('response')
->inject('layout')
->inject('project')
->inject('logger')
->inject('loggerBreadcrumbs')
->action(function (Throwable $error, App $utopia, Request $request, Response $response, View $layout, Document $project, ?Logger $logger, array $loggerBreadcrumbs) {
->action(function (Throwable $error, App $utopia, Request $request, Response $response, Document $project, ?Logger $logger, array $loggerBreadcrumbs) {
$version = App::getEnv('_APP_VERSION', 'UNKNOWN');
$route = $utopia->match($request);
@ -538,9 +537,10 @@ App::error()
$template = ($route) ? $route->getLabel('error', null) : null;
if ($template) {
$comp = new View($template);
$layout = new View($template);
$comp
$layout
->setParam('title', $project->getAttribute('name') . ' - Error')
->setParam('development', App::isDevelopment())
->setParam('projectName', $project->getAttribute('name'))
->setParam('projectURL', $project->getAttribute('url'))
@ -549,14 +549,6 @@ App::error()
->setParam('trace', $trace)
;
$layout
->setParam('title', $project->getAttribute('name') . ' - Error')
->setParam('description', 'No Description')
->setParam('body', $comp)
->setParam('version', $version)
->setParam('litespeed', false)
;
$response->html($layout->render());
}
@ -637,7 +629,6 @@ App::get('/.well-known/acme-challenge')
});
include_once __DIR__ . '/shared/api.php';
include_once __DIR__ . '/shared/web.php';
foreach (Config::getParam('services', []) as $service) {
include_once $service['controller'];

View file

@ -1,64 +0,0 @@
<?php
use Utopia\App;
use Utopia\Config\Config;
use Appwrite\Utopia\Response;
use Appwrite\Utopia\Request;
use Appwrite\Utopia\View;
App::init()
->groups(['web'])
->inject('utopia')
->inject('request')
->inject('response')
->inject('layout')
->action(function (App $utopia, Request $request, Response $response, View $layout) {
/* AJAX check */
if (!empty($request->getQuery('version', ''))) {
$layout->setPath(__DIR__ . '/../../views/layouts/empty.phtml');
}
$port = $request->getPort();
$protocol = $request->getProtocol();
$domain = $request->getHostname();
$layout
->setParam('title', APP_NAME)
->setParam('protocol', $protocol)
->setParam('domain', $domain)
->setParam('endpoint', $protocol . '://' . $domain . ($port != 80 && $port != 443 ? ':' . $port : ''))
->setParam('home', App::getEnv('_APP_HOME'))
->setParam('setup', App::getEnv('_APP_SETUP'))
->setParam('class', 'unknown')
->setParam('icon', '/images/favicon.png')
->setParam('roles', [
['type' => 'owner', 'label' => 'Owner'],
['type' => 'developer', 'label' => 'Developer'],
['type' => 'admin', 'label' => 'Admin'],
])
->setParam('runtimes', Config::getParam('runtimes'))
->setParam('mode', App::getMode())
;
$time = (60 * 60 * 24 * 45); // 45 days cache
$response
->addHeader('Cache-Control', 'public, max-age=' . $time)
->addHeader('Expires', \date('D, d M Y H:i:s', \time() + $time) . ' GMT') // 45 days cache
->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
;
$route = $utopia->match($request);
$route->label('error', __DIR__ . '/../../views/general/error.phtml');
$scope = $route->getLabel('scope', '');
$layout
->setParam('version', App::getEnv('_APP_VERSION', 'UNKNOWN'))
->setParam('isDev', App::isDevelopment())
->setParam('class', $scope)
;
});

View file

@ -730,13 +730,6 @@ App::setResource('loggerBreadcrumbs', function () {
App::setResource('register', fn() => $register);
App::setResource('layout', function ($locale) {
$layout = new View(__DIR__ . '/views/layouts/default.phtml');
$layout->setParam('locale', $locale);
return $layout;
}, ['locale']);
App::setResource('locale', fn() => new Locale(App::getEnv('_APP_LOCALE', 'en')));
// Queues

View file

@ -6,44 +6,60 @@ $message = $this->getParam('message', '');
$trace = $this->getParam('trace', []);
$projectName = $this->getParam('projectName', '');
$projectURL = $this->getParam('projectURL', '');
$title = $this->getParam('title', '')
?>
<section class="zone large margin-top padding">
<h1 class="margin-bottom">Error <?php echo $code; ?></h1>
<!DOCTYPE html>
<html lang="en">
<p><?php echo $message; ?></p>
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title><?php echo $title; ?></title>
</head>
<small>Error ID: <?php echo $errorID; ?></small>
<body>
<?php if (!empty($projectURL)): ?>
<hr class="margin-top margin-bottom" />
<section>
<h1>Error <?php echo $code; ?></h1>
<p><a href="<?php echo $this->escape($projectURL); ?>" rel="noopener">Back to <?php echo $projectName; ?></a></p>
<?php endif; ?>
<p><?php echo $message; ?></p>
<?php if ($development): ?>
<div class="margin-top-xl">
<h2 class="margin-bottom-large">Error Trace</h2>
<small>Error ID: <?php echo $errorID; ?></small>
<?php if (!empty($projectURL)) : ?>
<hr />
<p><a href="<?php echo $this->escape($projectURL); ?>" rel="noopener">Back to <?php echo $projectName; ?></a></p>
<?php endif; ?>
<?php if ($development) : ?>
<div>
<h2>Error Trace</h2>
<?php foreach ($trace as $log) : ?>
<table>
<?php foreach ($log as $key => $value) : ?>
<tr>
<td style="width: 120px"><?php echo $key; ?></td>
<td>
<?php if (is_array($value)) : ?>
<?php var_dump($value); ?>
<?php else : ?>
<?php echo $value; ?>
<?php endif; ?>
</td>
</tr>
<?php foreach($trace as $log): ?>
<table class="margin-bottom-xl">
<?php foreach($log as $key => $value): ?>
<tr>
<td style="width: 120px"><?php echo $key; ?></td>
<td>
<?php if (is_array($value)): ?>
<?php var_dump($value); ?>
<?php else: ?>
<?php echo $value; ?>
<?php endif; ?>
</td>
</tr>
<?php endforeach; ?>
</table>
<?php endforeach; ?>
</div>
<?php endif; ?>
</table>
<?php endforeach; ?>
</div>
<?php endif; ?>
</section>
</section>
</body>
</html>