Skip to content

Commit

Permalink
added copy of Web Project 3.0 https://github.com/nette/web-project
Browse files Browse the repository at this point in the history
  • Loading branch information
dg committed Apr 12, 2019
1 parent e447872 commit 6bdfb12
Show file tree
Hide file tree
Showing 25 changed files with 433 additions and 0 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
app/config/local.neon
1 change: 1 addition & 0 deletions .htaccess
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Require all denied
31 changes: 31 additions & 0 deletions app/Booting.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
<?php

declare(strict_types=1);

namespace App;

use Nette\Configurator;


class Bootstrap
{
public static function boot(): Configurator
{
$configurator = new Configurator;

//$configurator->setDebugMode('23.75.345.200'); // enable for your remote IP
$configurator->enableTracy(__DIR__ . '/../log');

$configurator->setTimeZone('Europe/Prague');
$configurator->setTempDirectory(__DIR__ . '/../temp');

$configurator->createRobotLoader()
->addDirectory(__DIR__)
->register();

$configurator->addConfig(__DIR__ . '/config/common.neon');
$configurator->addConfig(__DIR__ . '/config/local.neon');

return $configurator;
}
}
15 changes: 15 additions & 0 deletions app/config/common.neon
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
parameters:


application:
errorPresenter: Error
mapping:
*: App\*Module\Presenters\*Presenter


session:
expiration: 14 days


services:
router: App\Router\RouterFactory::createRouter
27 changes: 27 additions & 0 deletions app/presenters/Error4xxPresenter.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
<?php

declare(strict_types=1);

namespace App\Presenters;

use Nette;


final class Error4xxPresenter extends Nette\Application\UI\Presenter
{
public function startup(): void
{
parent::startup();
if (!$this->getRequest()->isMethod(Nette\Application\Request::FORWARD)) {
$this->error();
}
}


public function renderDefault(Nette\Application\BadRequestException $exception): void
{
// load template 403.latte or 404.latte or ... 4xx.latte
$file = __DIR__ . "/templates/Error/{$exception->getCode()}.latte";
$this->template->setFile(is_file($file) ? $file : __DIR__ . '/templates/Error/4xx.latte');
}
}
43 changes: 43 additions & 0 deletions app/presenters/ErrorPresenter.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
<?php

declare(strict_types=1);

namespace App\Presenters;

use Nette;
use Nette\Application\Responses;
use Nette\Http;
use Tracy\ILogger;


final class ErrorPresenter implements Nette\Application\IPresenter
{
use Nette\SmartObject;

/** @var ILogger */
private $logger;


public function __construct(ILogger $logger)
{
$this->logger = $logger;
}


public function run(Nette\Application\Request $request): Nette\Application\IResponse
{
$exception = $request->getParameter('exception');

if ($exception instanceof Nette\Application\BadRequestException) {
[$module, , $sep] = Nette\Application\Helpers::splitName($request->getPresenterName());
return new Responses\ForwardResponse($request->setPresenterName($module . $sep . 'Error4xx'));
}

$this->logger->log($exception, ILogger::EXCEPTION);
return new Responses\CallbackResponse(function (Http\IRequest $httpRequest, Http\IResponse $httpResponse): void {
if (preg_match('#^text/html(?:;|$)#', (string) $httpResponse->getHeader('Content-Type'))) {
require __DIR__ . '/templates/Error/500.phtml';
}
});
}
}
12 changes: 12 additions & 0 deletions app/presenters/HomepagePresenter.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
<?php

declare(strict_types=1);

namespace App\Presenters;

use Nette;


final class HomepagePresenter extends Nette\Application\UI\Presenter
{
}
19 changes: 19 additions & 0 deletions app/presenters/templates/@layout.latte
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width">

<title>{ifset title}{include title|stripHtml} | {/ifset}Nette Web</title>
</head>

<body>
<div n:foreach="$flashes as $flash" n:class="flash, $flash->type">{$flash->message}</div>

{include content}

{block scripts}
<script src="https://nette.github.io/resources/js/3/netteForms.min.js"></script>
{/block}
</body>
</html>
7 changes: 7 additions & 0 deletions app/presenters/templates/Error/403.latte
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{block content}
<h1 n:block=title>Access Denied</h1>

<p>You do not have permission to view this page. Please try contact the web
site administrator if you believe you should be able to view this page.</p>

<p><small>error 403</small></p>
8 changes: 8 additions & 0 deletions app/presenters/templates/Error/404.latte
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{block content}
<h1 n:block=title>Page Not Found</h1>

<p>The page you requested could not be found. It is possible that the address is
incorrect, or that the page no longer exists. Please use a search engine to find
what you are looking for.</p>

<p><small>error 404</small></p>
6 changes: 6 additions & 0 deletions app/presenters/templates/Error/405.latte
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{block content}
<h1 n:block=title>Method Not Allowed</h1>

<p>The requested method is not allowed for the URL.</p>

<p><small>error 405</small></p>
6 changes: 6 additions & 0 deletions app/presenters/templates/Error/410.latte
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{block content}
<h1 n:block=title>Page Not Found</h1>

<p>The page you requested has been taken off the site. We apologize for the inconvenience.</p>

<p><small>error 410</small></p>
4 changes: 4 additions & 0 deletions app/presenters/templates/Error/4xx.latte
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{block content}
<h1 n:block=title>Oops...</h1>

<p>Your browser sent a request that this server could not understand or process.</p>
27 changes: 27 additions & 0 deletions app/presenters/templates/Error/500.phtml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
<!DOCTYPE html><!-- "' --></textarea></script></style></pre></xmp></a></audio></button></canvas></datalist></details></dialog></iframe></listing></meter></noembed></noframes></noscript></optgroup></option></progress></rp></select></table></template></title></video>
<meta charset="utf-8">
<meta name="robots" content="noindex">
<title>Server Error</title>

<style>
#nette-error { all: initial; position: absolute; top: 0; left: 0; right: 0; height: 70vh; min-height: 400px; display: flex; align-items: center; justify-content: center; z-index: 1000 }
#nette-error div { all: initial; max-width: 550px; background: white; color: #333; display: block }
#nette-error h1 { all: initial; font: bold 50px/1.1 sans-serif; display: block; margin: 40px }
#nette-error p { all: initial; font: 20px/1.4 sans-serif; margin: 40px; display: block }
#nette-error small { color: gray }
</style>

<div id=nette-error>
<div>
<h1>Server Error</h1>

<p>We're sorry! The server encountered an internal error and
was unable to complete your request. Please try again later.</p>

<p><small>error 500</small></p>
</div>
</div>

<script>
document.body.insertBefore(document.getElementById('nette-error'), document.body.firstChild);
</script>
24 changes: 24 additions & 0 deletions app/presenters/templates/Error/503.phtml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
<?php

declare(strict_types=1);

header('HTTP/1.1 503 Service Unavailable');
header('Retry-After: 300'); // 5 minutes in seconds

?>
<!DOCTYPE html>
<meta charset="utf-8">
<meta name="robots" content="noindex">
<meta name="generator" content="Nette Framework">

<style>
body { color: #333; background: white; width: 500px; margin: 100px auto }
h1 { font: bold 47px/1.5 sans-serif; margin: .6em 0 }
p { font: 21px/1.5 Georgia,serif; margin: 1.5em 0 }
</style>

<title>Site is temporarily down for maintenance</title>

<h1>We're Sorry</h1>

<p>The site is temporarily down for maintenance. Please try again in a few minutes.</p>
38 changes: 38 additions & 0 deletions app/presenters/templates/Homepage/default.latte
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
{* This is the welcome page, you can delete it *}

{block content}
<div id="banner">
<h1 n:block=title>Congratulations!</h1>
</div>

<div id="content">
<h2>You have successfully created your <a href="https://nette.org">Nette</a> Web project.</h2>

<p><img src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAEYAAABVCAYAAAD0bJKxAAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAACudJREFUeNrMXG1sFMcZfvfu7ECw7+xDaQL+AApE1B+EJLapSNs4QIhtVWpSVTJNVIkqatX+II1apf8SoTZSq/KHiv5oqRolVaUS5UfgD04qtRAcUGipSrDdjxjHxDa0xOIcDBiMOU9nZj9udndmZ2Y/zjen0d7uzs7u+8z7Pu87H7sGCFLvrqfWGABbwMyBqfW5C5BrvhFYBkFFpiMvP3HlQ94JgwPI43izD+du1dpbn8XArLlRmaLLW+Qiznte3n7lPS4wPU/uyuHN6zg/rXpPwzAvb+kfhSzWGJTMg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nZFtRPUIgw4ASJHBKsB+UvfcAjvCybH/gxGD2Fz3gpphjwNn3BbcZibmkJMdk/1MKZhekMSigpXn/FxXKiupzmVIqwP5l/KLDRTJiB0WegSBuAL33TET7XI+k6p1AAigEAGAodM2C3mlBgmMywlbZAjjrqtSTobEvKwsaGgMhQFPd56b/CzAArAe2YDJd4I4AAAAASUVORK5CYII=" alt="">
If you are exploring Nette for the first time, you should read the
<a href="https://doc.nette.org/quickstart">Quick Start</a>, <a href="https://doc.nette.org">documentation</a>,
<a href="https://pla.nette.org">tutorials</a> and <a href="https://forum.nette.org">forum</a>.</p>

<h2>We hope you enjoy Nette!</h2>
</div>

<style>
html { font: normal 18px/1.3 Georgia, "New York CE", utopia, serif; color: #666; -webkit-text-stroke: 1px rgba(0,0,0,0); overflow-y: scroll; }
body { background: #3484d2; color: #333; margin: 2em auto; padding: 0 .5em; max-width: 600px; min-width: 320px; }
a { color: #006aeb; padding: 3px 1px; }
a:hover, a:active, a:focus { background-color: #006aeb; text-decoration: none; color: white; }
#banner { border-radius: 12px 12px 0 0; background-image: url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAB5CAMAAADPursXAAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAAAGBQTFRFD1CRDkqFDTlmDkF1D06NDT1tDTNZDk2KEFWaDTZgDkiCDTtpDT5wDkZ/DTBVEFacEFOWD1KUDTRcDTFWDkV9DkR7DkN4DkByDTVeDC9TDThjDTxrDkeADkuIDTRbDC9SbsUaggAAAEdJREFUeNqkwYURgAAQA7DH3d3335LSKyxAYpf9vWCpnYbf01qcOdFVXc14w4BznNTjkQfsscAdU3b4wIh9fDVYc4zV8xZgAAYaCMI6vPgLAAAAAElFTkSuQmCC); }
h1 { font: inherit; color: white; font-size: 50px; line-height: 121px; margin: 0; padding-left: 4%; background: url(https://files.nette.org/images/[email protected]) no-repeat 95%; background-size: 130px auto; text-shadow: 1px 1px 0 rgba(0, 0, 0, .9); }
@media (max-width: 600px) {
h1 { background: none; font-size: 40px; }
}
#content { background: white; border: 1px solid #eff4f7; border-radius: 0 0 12px 12px; padding: 10px 4%; overflow: hidden; }
h2 { font: inherit; padding: 1.2em 0; margin: 0; }
img { border: none; float: right; margin: 0 0 1em 3em; }
</style>
21 changes: 21 additions & 0 deletions app/router/RouterFactory.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
<?php

declare(strict_types=1);

namespace App\Router;

use Nette;
use Nette\Application\Routers\RouteList;


final class RouterFactory
{
use Nette\StaticClass;

public static function createRouter(): RouteList
{
$router = new RouteList;
$router->addRoute('<presenter>/<action>[/<id>]', 'Homepage:default');
return $router;
}
}
36 changes: 36 additions & 0 deletions composer.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
{
"name": "nette/web-project",
"description": "Nette: Standard Web Project",
"keywords": ["nette"],
"type": "project",
"license": ["MIT", "BSD-3-Clause", "GPL-2.0", "GPL-3.0"],
"require": {
"php": ">= 7.1",
"nette/application": "^3.0",
"nette/bootstrap": "^3.0",
"nette/caching": "^3.0",
"nette/database": "^3.0",
"nette/di": "^3.0",
"nette/finder": "^2.5",
"nette/forms": "^3.0",
"nette/http": "^3.0",
"nette/mail": "^3.0",
"nette/robot-loader": "^3.0",
"nette/security": "^3.0",
"nette/utils": "^3.0",
"latte/latte": "^2.5",
"tracy/tracy": "^2.6"
},
"require-dev": {
"nette/tester": "^2.0"
},
"autoload": {
"classmap": ["app/Bootstrap.php"]
},
"minimum-stability": "dev",
"config": {
"platform": {
"php": "7.1"
}
}
}
2 changes: 2 additions & 0 deletions log/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
*
!.gitignore
Loading

0 comments on commit 6bdfb12

Please sign in to comment.