feat: Initial commit.

This commit is contained in:
2026-04-16 12:58:54 +02:00
commit 6caad6ee97
29 changed files with 518 additions and 0 deletions
View File
View File
View File
View File
+38
View File
@@ -0,0 +1,38 @@
<?php
declare(strict_types=1);
namespace App;
use Nette\Bootstrap\Configurator;
class Bootstrap
{
public static function boot(): Configurator
{
$configurator = new Configurator;
$appDir = dirname(__DIR__);
$configurator->setDebugMode(true);
$configurator->enableTracy($appDir . '/_logs');
$configurator->setTimeZone('Europe/Prague');
$configurator->setTempDirectory($appDir . '/tmp');
$configurator->createRobotLoader()
->addDirectory(__DIR__)
->register();
$configurator->addConfig($appDir . '/app/config/common.neon');
$configurator->addConfig($appDir . '/app/config/services.neon');
$configurator->addConfig($appDir . '/app/config/local.neon');
// use ENV variables from PHP
/*$configurator->addDynamicParameters([
'env' => getenv(),
]);*/
return $configurator;
}
}
+34
View File
@@ -0,0 +1,34 @@
<?php
declare(strict_types=1);
namespace App\Presenters;
use Nette\Application\UI\Presenter;
use Predis\Client as PredisClient;
use Kdyby\Redis\RedisStorage;
use Kdyby\Redis\RedisClient;
use Nette\Caching\Cache;
class BasePresenter extends Presenter
{
// load shared functions
use SharedTrait;
// define properties
protected array $constants;
protected Cache $cache;
// DI constants from local.neon
public function __construct(array $constants, RedisStorage $cacheStorage) {
parent::__construct();
$this->constants = $constants;
$this->cache = new Cache($cacheStorage);
}
protected function getConstant(string $name) {
return $this->constants[$name] ?? null;
}
}
+13
View File
@@ -0,0 +1,13 @@
<?php
namespace App\Presenters;
use Nette\Application\UI\Presenter;
final class ErrorPresenter extends Presenter
{
public function renderDefault(): void
{
$this->template->message = "An error occurred.";
}
}
+24
View File
@@ -0,0 +1,24 @@
<?php
declare(strict_types=1);
namespace App\Presenters;
use Nette\Application\UI\Presenter;
final class HomepagePresenter extends BasePresenter
{
protected array $constants;
// load params from templates
/*public function __construct(array $constants, RedisStorage $cacheStorage)
{
parent::__construct($constants, $cacheStorage);
$this->constants = $constants;
}*/
// default content
public function actionDefault(): void
{
}
}
+46
View File
@@ -0,0 +1,46 @@
<?php
declare(strict_types=1);
namespace App\Presenters;
use Nette\Application\UI\Form;
trait SharedTrait {
// important for Bootstrap Forms visualisation
function makeBootstrap4(Form $form): void
{
$renderer = $form->getRenderer();
$renderer->wrappers['controls']['container'] = null;
$renderer->wrappers['pair']['container'] = 'div class="row form-group align-items-center justify-content-center py-2 login"';
$renderer->wrappers['pair']['.error'] = 'has-danger';
$renderer->wrappers['control']['container'] = 'div class=col-sm-9';
$renderer->wrappers['label']['container'] = 'div class="col-sm-3 col-form-label"';
$renderer->wrappers['control']['description'] = 'span class=form-text';
$renderer->wrappers['control']['errorcontainer'] = 'span class=form-control-feedback';
$renderer->wrappers['control']['.error'] = 'is-invalid';
foreach ($form->getControls() as $control) {
$type = $control->getOption('type');
if ($type === 'button') {
$control->getControlPrototype()->addClass(empty($usedPrimary) ? 'btn btn-primary' : 'btn btn-secondary');
$usedPrimary = true;
} elseif (in_array($type, ['text', 'textarea', 'select'], true)) {
$control->getControlPrototype()->addClass('form-control');
} elseif ($type === 'file') {
$control->getControlPrototype()->addClass('form-control-file');
} elseif (in_array($type, ['checkbox', 'radio'], true)) {
if ($control instanceof Nette\Forms\Controls\Checkbox) {
$control->getLabelPrototype()->addClass('form-check-label');
} else {
$control->getItemLabelPrototype()->addClass('form-check-label');
}
$control->getControlPrototype()->addClass('form-check-input');
$control->getSeparatorPrototype()->setName('div')->addClass('form-check');
}
}
}
}
@@ -0,0 +1 @@
HELLO
+21
View File
@@ -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;
}
}
+13
View File
@@ -0,0 +1,13 @@
parameters:
application:
errorPresenter: Error
mapping:
*: App\*Module\Presenters\*Presenter
session:
expiration: 60 minutes
debugger: true
di:
export:
parameters: no
tags: no
+11
View File
@@ -0,0 +1,11 @@
parameters:
constants:
DEBUG_MODE: true
DEBUG_FILE: 'debug.log'
ERROR_FILE: 'error.log'
LOGS_DIR: %appDir%/../_logs/
database:
dsn: 'mysql:host=db;dbname=${DB_DB};port=3306'
user: 'sslguard-skyger-cz'
password: 'gsjlqfdaldw08qpihrsax'
+20
View File
@@ -0,0 +1,20 @@
services:
redis.client:
factory: Kdyby\Redis\RedisClient('keydb', 6379)
cache.storage:
factory: Kdyby\Redis\RedisStorage(@redis.client)
basePresenter:
class: App\Presenters\BasePresenter
arguments:
- %constants%
- @cache.storage
homepagePresenter:
class: App\Presenters\HomepagePresenter
arguments:
- %constants%
- @cache.storage
- App\Router\RouterFactory::createRouter
View File
+37
View File
@@ -0,0 +1,37 @@
# Apache configuration file (see https://httpd.apache.org/docs/current/mod/quickreference.html)
Require all granted
# disable directory listing
<IfModule mod_autoindex.c>
Options -Indexes
</IfModule>
# enable cool URL
<IfModule mod_rewrite.c>
RewriteEngine On
#RewriteCond %{HTTPS} off
#RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI} [R=301,L]
# RewriteBase /
# prevents files starting with dot to be viewed by browser
RewriteCond %{REQUEST_FILENAME} -f
RewriteRule /\.|^\.(?!well-known/) - [F]
# front controller
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule !\.(pdf|js|mjs|ico|gif|jpg|jpeg|png|webp|svg|css|rar|zip|7z|tar\.gz|map|eot|ttf|otf|woff|woff2)$ index.php [L]
</IfModule>
# enable gzip compression
<IfModule mod_deflate.c>
<IfModule mod_filter.c>
AddOutputFilterByType DEFLATE text/html text/plain text/xml text/css application/javascript application/json application/xml image/svg+xml
</IfModule>
</IfModule>
# enable index files
<IfModule dir_module>
DirectoryIndex index.php index.html
</ifModule>
+10
View File
@@ -0,0 +1,10 @@
<?php
declare(strict_types=1);
require __DIR__ . '/../vendor/autoload.php';
$configurator = App\Bootstrap::boot();
$container = $configurator->createContainer();
$application = $container->getByType(Nette\Application\Application::class);
$application->run();
+2
View File
@@ -0,0 +1,2 @@
User-agent: *
Disallow: /