From 736399cf15e40622a7d3c5d46124ad769b21859b Mon Sep 17 00:00:00 2001 From: Jeroen De Meerleer Date: Tue, 6 Apr 2021 22:44:39 +0200 Subject: [PATCH] Cleanup the folder --- .env | 18 ------------------ .gitignore | 4 ++-- lib/Framework/Controller.php | 8 ++++++++ lib/Framework/Kernel.php | 8 +++++++- .htaccess => public/.htaccess | 0 {css => public/css}/site.css | 0 {images => public/images}/ajax-loader.gif | Bin index.php => public/index.php | 1 - {js => public/js}/site.js | 0 templates/addjob.html.twig | 2 +- templates/base.html.twig | 4 ++-- templates/editjob.html.twig | 2 +- templates/overview.html.twig | 2 +- templates/security/login.html.twig | 6 +++--- addjob.php => webcron.old/addjob.php | 0 bootstrap.php => webcron.old/bootstrap.php | 0 composer.json => webcron.old/composer.json | 0 composer.lock => webcron.old/composer.lock | 0 .../config.inc.sample.php | 0 config.php => webcron.old/config.php | 0 database.sql => webcron.old/database.sql | 0 editjob.php => webcron.old/editjob.php | 0 .../include}/finalize.inc.php | 0 .../include}/functions.php | 0 index_old.php => webcron.old/index.php | 0 overview.php => webcron.old/overview.php | 0 runnow.php => webcron.old/runnow.php | 0 runs.php => webcron.old/runs.php | 0 webcron.php => webcron.old/webcron.php | 0 29 files changed, 25 insertions(+), 30 deletions(-) delete mode 100644 .env rename .htaccess => public/.htaccess (100%) rename {css => public/css}/site.css (100%) rename {images => public/images}/ajax-loader.gif (100%) rename index.php => public/index.php (70%) rename {js => public/js}/site.js (100%) rename addjob.php => webcron.old/addjob.php (100%) rename bootstrap.php => webcron.old/bootstrap.php (100%) rename composer.json => webcron.old/composer.json (100%) rename composer.lock => webcron.old/composer.lock (100%) rename config.inc.sample.php => webcron.old/config.inc.sample.php (100%) rename config.php => webcron.old/config.php (100%) rename database.sql => webcron.old/database.sql (100%) rename editjob.php => webcron.old/editjob.php (100%) rename {include => webcron.old/include}/finalize.inc.php (100%) rename {include => webcron.old/include}/functions.php (100%) rename index_old.php => webcron.old/index.php (100%) rename overview.php => webcron.old/overview.php (100%) rename runnow.php => webcron.old/runnow.php (100%) rename runs.php => webcron.old/runs.php (100%) rename webcron.php => webcron.old/webcron.php (100%) diff --git a/.env b/.env deleted file mode 100644 index 8e6b572..0000000 --- a/.env +++ /dev/null @@ -1,18 +0,0 @@ -################ -### DATABASE ### -################ -## Look at the url below to create a database URL -## https://www.doctrine-project.org/projects/doctrine-dbal/en/latest/reference/configuration.html#connecting-using-a-url - -## Mysql sample -DATABASE="mysql://root:letmein@localhost:3306/webcron?charset=UTF8" -## Sqlite sample -DATABASE="sqlite://storage/database.sqlite" - -############### -### SECRETS ### -############### - -## This secret value is used to encrypt secret values (eg. ssh-keys, http-auth passwords, etc) -## You should consider your already stored secret values lost when changing this value. -SECRET=ImNotThatSecretSoPleaseChangeMe0123456789 \ No newline at end of file diff --git a/.gitignore b/.gitignore index 712a153..61433bc 100644 --- a/.gitignore +++ b/.gitignore @@ -1,6 +1,6 @@ cache/* !cache/.gitkeep -nbproject/private/ vendor/ -config.inc.php +webcron.old/config.inc.php \.idea/ +.env \ No newline at end of file diff --git a/lib/Framework/Controller.php b/lib/Framework/Controller.php index e8f3b3a..457c5b2 100644 --- a/lib/Framework/Controller.php +++ b/lib/Framework/Controller.php @@ -3,6 +3,7 @@ namespace JeroenED\Framework; +use Doctrine\DBAL\Connection; use http\Env\Request; use Symfony\Component\HttpFoundation\Response; use Twig\Environment; @@ -12,14 +13,21 @@ abstract class Controller { private $twig; private $request; + private $database; + private $kernel; public function __construct(Request $request, Kernel $kernel) { $loader = new FilesystemLoader([$kernel->getTemplateDir()]); $this->twig = new Environment($loader); $this->request = $request; + $this->kernel = $kernel; } + public function getDbCon(): Connection + { + return $this->kernel->getDbCon(); + } /** * @return Request */ diff --git a/lib/Framework/Kernel.php b/lib/Framework/Kernel.php index c01b12d..3245a4b 100644 --- a/lib/Framework/Kernel.php +++ b/lib/Framework/Kernel.php @@ -4,11 +4,12 @@ namespace JeroenED\Framework; +use Doctrine\DBAL\Connection; +use Doctrine\DBAL\DriverManager; use http\Exception\InvalidArgumentException; use Symfony\Component\HttpFoundation\Request; use Symfony\Component\HttpFoundation\Response; use Symfony\Component\Routing\RouteCollection; -use Symfony\Component\Yaml\Yaml; class Kernel { @@ -87,6 +88,11 @@ class Kernel return Request::createFromGlobals(); } + public function getDbCon(): Connection + { + $db = DriverManager::getConnection(['url' => $_ENV['DATABASE']]); + } + private function createResponse($request, $routes): Response { $requestContext = RequestContext::fromUri($request->getUri()); diff --git a/.htaccess b/public/.htaccess similarity index 100% rename from .htaccess rename to public/.htaccess diff --git a/css/site.css b/public/css/site.css similarity index 100% rename from css/site.css rename to public/css/site.css diff --git a/images/ajax-loader.gif b/public/images/ajax-loader.gif similarity index 100% rename from images/ajax-loader.gif rename to public/images/ajax-loader.gif diff --git a/index.php b/public/index.php similarity index 70% rename from index.php rename to public/index.php index 9abb4cc..353f5ad 100644 --- a/index.php +++ b/public/index.php @@ -9,5 +9,4 @@ $kernel->setProjectDir(__DIR__); $kernel->setConfigDir(__DIR__ . '/config/'); $kernel->setTemplateDir(__DIR__ . '/templates/'); -$db = DriverManager::getConnection(['url' => $_ENV['DATABASE']]); $kernel->handle()->send(); \ No newline at end of file diff --git a/js/site.js b/public/js/site.js similarity index 100% rename from js/site.js rename to public/js/site.js diff --git a/templates/addjob.html.twig b/templates/addjob.html.twig index 34e754b..7ab325b 100644 --- a/templates/addjob.html.twig +++ b/templates/addjob.html.twig @@ -1,7 +1,7 @@ {% extends "base.html.twig" %} {% block title %}Add job{% endblock %} {% block content %} -
+ {% if not error == "" %}
× diff --git a/templates/base.html.twig b/templates/base.html.twig index 6b0e4b6..eb069de 100644 --- a/templates/base.html.twig +++ b/templates/base.html.twig @@ -8,13 +8,13 @@ - + - + diff --git a/templates/editjob.html.twig b/templates/editjob.html.twig index 978a93e..631646c 100644 --- a/templates/editjob.html.twig +++ b/templates/editjob.html.twig @@ -1,7 +1,7 @@ {% extends "base.html.twig" %} {% block title %}Edit job {{ name }}{% endblock %} {% block content %} - + {% if not error == "" %}
× diff --git a/templates/overview.html.twig b/templates/overview.html.twig index 638a0da..4907f6a 100644 --- a/templates/overview.html.twig +++ b/templates/overview.html.twig @@ -47,6 +47,6 @@
{% endblock %} diff --git a/templates/security/login.html.twig b/templates/security/login.html.twig index 419bdb9..5f2f430 100644 --- a/templates/security/login.html.twig +++ b/templates/security/login.html.twig @@ -7,17 +7,17 @@ - + - +

Webcron management

- + {% if not error == "" %}
× diff --git a/addjob.php b/webcron.old/addjob.php similarity index 100% rename from addjob.php rename to webcron.old/addjob.php diff --git a/bootstrap.php b/webcron.old/bootstrap.php similarity index 100% rename from bootstrap.php rename to webcron.old/bootstrap.php diff --git a/composer.json b/webcron.old/composer.json similarity index 100% rename from composer.json rename to webcron.old/composer.json diff --git a/composer.lock b/webcron.old/composer.lock similarity index 100% rename from composer.lock rename to webcron.old/composer.lock diff --git a/config.inc.sample.php b/webcron.old/config.inc.sample.php similarity index 100% rename from config.inc.sample.php rename to webcron.old/config.inc.sample.php diff --git a/config.php b/webcron.old/config.php similarity index 100% rename from config.php rename to webcron.old/config.php diff --git a/database.sql b/webcron.old/database.sql similarity index 100% rename from database.sql rename to webcron.old/database.sql diff --git a/editjob.php b/webcron.old/editjob.php similarity index 100% rename from editjob.php rename to webcron.old/editjob.php diff --git a/include/finalize.inc.php b/webcron.old/include/finalize.inc.php similarity index 100% rename from include/finalize.inc.php rename to webcron.old/include/finalize.inc.php diff --git a/include/functions.php b/webcron.old/include/functions.php similarity index 100% rename from include/functions.php rename to webcron.old/include/functions.php diff --git a/index_old.php b/webcron.old/index.php similarity index 100% rename from index_old.php rename to webcron.old/index.php diff --git a/overview.php b/webcron.old/overview.php similarity index 100% rename from overview.php rename to webcron.old/overview.php diff --git a/runnow.php b/webcron.old/runnow.php similarity index 100% rename from runnow.php rename to webcron.old/runnow.php diff --git a/runs.php b/webcron.old/runs.php similarity index 100% rename from runs.php rename to webcron.old/runs.php diff --git a/webcron.php b/webcron.old/webcron.php similarity index 100% rename from webcron.php rename to webcron.old/webcron.php