2024.12.01 16:10:44

This commit is contained in:
Christian Moser 2024-12-01 16:10:44 +01:00
parent d3385bfb05
commit b3b3327905
14 changed files with 132 additions and 139 deletions

View File

@ -109,6 +109,29 @@
--font-style-em: italic;
}
html {
padding:0px;
margin:0px;
}
body {
padding:0px;
margin:0px;
background-color: var(--color-background);
color: var(--color-text);
font-family: var(--font-family);
font-size: 16px;
}
.header {
margin:0px;
/*padding:10px;*/
}
main {
padding:0px 10px 0px 10px;
}
h6 {
font-family: var(--font-family);
font-weight: bold;
@ -198,12 +221,6 @@ a:visited {
color: var(--color-link-visited);
}
body {
background-color: var(--color-background);
color: var(--color-text);
font-family: var(--font-family);
font-size: 20px;
}
.left {
text-align: left;
@ -212,6 +229,8 @@ body {
.center {
text-align: center;
align-self: center;
align-items:center;
}
.right {

View File

@ -0,0 +1,6 @@
_ _ _
_ __ ___ _ _ __| | _____ _____| | __ _| |_
| '_ ` _ \| | | |/ _` |/ _ \ \ / / _ \ | / _` | __|
| | | | | | |_| | (_| | __/\ V / __/ || (_| | |_
|_| |_| |_|\__, |\__,_|\___| \_/ \___|_(_)__,_|\__|
|___/

View File

@ -22,6 +22,7 @@ security:
enable_csrf: true
logout:
path: app_logout
target: app_login
# where to redirect after logout
# target: app_any_route
# where to redirect after logout

View File

@ -1,86 +0,0 @@
<?php
declare(strict_types=1);
namespace DoctrineMigrations;
use Doctrine\DBAL\Schema\Schema;
use Doctrine\Migrations\AbstractMigration;
/**
* Auto-generated Migration: Please modify to your needs!
*/
final class Version20241201012357 extends AbstractMigration
{
public function getDescription(): string
{
return '';
}
public function up(Schema $schema): void
{
// this up() migration is auto-generated, please modify it to your needs
$this->addSql('CREATE TABLE mydevel_webroot_file (
id INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL,
owner_id INTEGER NOT NULL,
url CLOB NOT NULL,
abspath CLOB NOT NULL,
description CLOB DEFAULT NULL,
CONSTRAINT FK_A7B135127E3C61F9 FOREIGN KEY (owner_id) REFERENCES mydevel_webroot_user (id) NOT DEFERRABLE INITIALLY IMMEDIATE
)');
$this->addSql('CREATE UNIQUE INDEX UNIQ_A7B135127E3C61F9 ON mydevel_webroot_file (owner_id)');
$this->addSql('CREATE TABLE mydevel_webroot_file_permission (
id INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL,
role_id INTEGER NOT NULL,
webroot_file_id INTEGER NOT NULL,
is_readable BOOLEAN DEFAULT 1 NOT NULL,
is_writeable BOOLEAN DEFAULT 0 NOT NULL,
is_deleteable BOOLEAN DEFAULT 0 NOT NULL,
CONSTRAINT FK_4D56CEFD60322AC FOREIGN KEY (role_id) REFERENCES mydevel_webroot_role (id) NOT DEFERRABLE INITIALLY IMMEDIATE,
CONSTRAINT FK_4D56CEF2800AFC9 FOREIGN KEY (webroot_file_id) REFERENCES mydevel_webroot_file (id) NOT DEFERRABLE INITIALLY IMMEDIATE
)');
$this->addSql('CREATE UNIQUE INDEX UNIQ_4D56CEFD60322AC ON mydevel_webroot_file_permission (role_id)');
$this->addSql('CREATE INDEX IDX_4D56CEF2800AFC9 ON mydevel_webroot_file_permission (webroot_file_id)');
$this->addSql('CREATE TABLE mydevel_webroot_role (
id INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL,
role VARCHAR(255) NOT NULL,
name VARCHAR(255) NOT NULL,
description VARCHAR(1023) DEFAULT NULL
)');
$this->addSql('CREATE TABLE mydevel_webroot_user (
id INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL,
username VARCHAR(180) NOT NULL,
roles CLOB NOT NULL --(DC2Type:json)
,
password VARCHAR(255) NOT NULL,
email VARCHAR(255) NOT NULL,
is_admin BOOLEAN DEFAULT 0 NOT NULL
)');
$this->addSql('CREATE UNIQUE INDEX UNIQ_A6BDD54BE7927C74 ON mydevel_webroot_user (email)');
$this->addSql('CREATE UNIQUE INDEX UNIQ_IDENTIFIER_USERNAME ON mydevel_webroot_user (username)');
$this->addSql('CREATE TABLE messenger_messages (
id INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL,
body CLOB NOT NULL,
headers CLOB NOT NULL,
queue_name VARCHAR(190) NOT NULL,
created_at DATETIME NOT NULL --(DC2Type:datetime_immutable)
,
available_at DATETIME NOT NULL --(DC2Type:datetime_immutable)
,
delivered_at DATETIME DEFAULT NULL --(DC2Type:datetime_immutable)
)');
$this->addSql('CREATE INDEX IDX_75EA56E0FB7336F0 ON messenger_messages (queue_name)');
$this->addSql('CREATE INDEX IDX_75EA56E0E3BD61CE ON messenger_messages (available_at)');
$this->addSql('CREATE INDEX IDX_75EA56E016BA31DB ON messenger_messages (delivered_at)');
}
public function down(Schema $schema): void
{
// this down() migration is auto-generated, please modify it to your needs
$this->addSql('DROP TABLE mydevel_webroot_file');
$this->addSql('DROP TABLE mydevel_webroot_file_permission');
$this->addSql('DROP TABLE mydevel_webroot_role');
$this->addSql('DROP TABLE mydevel_webroot_user');
$this->addSql('DROP TABLE messenger_messages');
}
}

View File

@ -10,7 +10,7 @@ use Doctrine\Migrations\AbstractMigration;
/**
* Auto-generated Migration: Please modify to your needs!
*/
final class Version20241201011651 extends AbstractMigration
final class Version20241201030110 extends AbstractMigration
{
public function getDescription(): string
{

View File

@ -6,23 +6,25 @@ use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\Routing\Attribute\Route;
use Symfony\Component\HttpKernel\KernelInterface;
//use MyDevel\Webroot\Controller\WebrootMainController;
use App\Controller\WebrootController;
class MainController extends AbstractController //WebrootMainController
class MainController extends WebrootController
{
#[Route('/', name: 'app_main')]
public function index(KernelInterface $kernel): Response
{
$project_root = $kernel->getProjectDir();
$dotenvlocal_file = join(DIRECTORY_SEPARATOR,[$project_root,'.env.local']);
if (!file_exists($dotenvlocal_file)) {
$dotenvlocal = join(DIRECTORY_SEPARATOR,[$kernel->getProjectDir(),".env.local"]);
if (!file_exists($dotenvlocal)) {
return $this->redirectToRoute('webroot.setup');
}
$user = $this->getUser();
if (!$user) {
return $this->redirectToRoute("app_login");
}
return $this->render('main/index.html.twig', [
'controller_name' => $kernel->getProjectDir(),
'user' => $user,
]);
}
}

View File

@ -135,7 +135,7 @@ class SetupController extends WebrootSetupController
$this->runCreateDatabase();
} catch (\Throwable $ex) {
$status = "FAILED";
$status_message = $this->translate("command.failed",domain:"mydevel.webroot.setup");
$status_message = $this->trans("command.failed",domain:"mydevel.webroot.setup");
}
} elseif ($commands[$step] === "make-migrations") {
$output = $this->trans("command.makemigrations",domain:"mydevel.webroot.setup");
@ -143,31 +143,32 @@ class SetupController extends WebrootSetupController
$this->runMakeMigration();
} catch (\Throwable $ex) {
$status = "FAILED";
$status_message = $this->translate("command.failed",domain:"mydevel.webroot.setup");
$status_message = $this->trans("command.success",domain:"mydevel.webroot.setup");
}
} elseif ($commands[$step] === "migrate") {
$output = $this->trans("command.migrate",domain:"mydevel.webroot.setup");
try {
$this->runMigrate();
} catch (\Throwable $ex) {
$status_message = $this->translate("command.failed",domain:"mydevel.webroot.setup");
$status_message = $this->trans("command.failed",domain:"mydevel.webroot.setup");
$status = "FAILED";
}
} elseif ($commands[$step] === "populate-database") {
$output = $this->trans("command.populatedb",domain:"mydevel.webroot.setup");
//try {
try {
$this->addRoles();
$this->addAdministrator($data);
$this->addRootDir($data);
$status = "SUCCESS";
$status_message = $this->trans("command.success",domain:"mydevel.webroot.setup");
// } catch (\Throwable $ex) {
// $status = "FAILED";
// $status_message = $this->translate("command.failed",domain:"mydevel.webroot.setup");
// }
} catch (\Throwable $ex) {
$status = "FAILED";
$status_message = $this->translate("command.failed",domain:"mydevel.webroot.setup");
}
} else {
$output = "Unknown command \"" . $commands[$step] . "\"";
$status = "FAILED";
$status_message = $status_message = $this->translate("command.failed",domain:"mydevel.webroot.setup");
$status_message = $status_message = $this->trans("command.failed",domain:"mydevel.webroot.setup");
}
return $this->render('setup/initial-setup.run.html.twig', [

View File

@ -423,7 +423,7 @@ abstract class WebrootSetupController extends AbstractController
public function setSetupFormFromData(Form $form,array $values)
{
if (array_key_exists("env", values)) {
if (array_key_exists("env", $values)) {
$form->get("env")->setData($values["env"]);
}
if (array_key_exists("locale",$values)) {
@ -441,7 +441,7 @@ abstract class WebrootSetupController extends AbstractController
$form->get("site_email")->setData($site["email"]);
}
if (array_key_exists("rootdir", $site)) {
$form->set("site_rootdir")->setData($site["rootdir"]);
$form->get("site_rootdir")->setData($site["rootdir"]);
}
}
if (array_key_exists("database",$values)) {
@ -523,13 +523,13 @@ abstract class WebrootSetupController extends AbstractController
$form->get("tempdir")->setData(join(DIRECTORY_SEPARATOR,[$this->project_dir,"temp"]));
}
if (getenv("CONTACT_EMAIL") && strlen(getenv("CONTACT_EMAIL"))) {
form->get('site_email')->setData(getenv("CONTACT_EMAIL"));
$form->get('site_email')->setData(getenv("CONTACT_EMAIL"));
}
if (getenv("SITE_NAME") && strlen(getenv("SITE_NAME"))) {
$form->get("site_name")->setData(getenv("SITE_NAME"));
}
if (getenv("SITE_ROOTDIR") && strlen("SITE_ROOTDIR")) {
form->set("site_rootdir")->setData(getenv("SITE_ROOTDIR"));
$form->get("site_rootdir")->setData(getenv("SITE_ROOTDIR"));
}
if (getenv("DATABASE_URL") && strlen("DATABASE_URL")) {
$form->get("db_url")->setData(getenv("DATABASE_URL"));
@ -689,9 +689,9 @@ abstract class WebrootSetupController extends AbstractController
$ret="";
for ($i=0; $i< $length; ++$i) {
$ret .= x[rand() % $x_len];
$ret .= $x[rand() % $x_len];
}
return ret;
return $ret;
}
protected function setInitialSetupDataCookie(Request $request,Form $form,Response $response)
@ -750,7 +750,7 @@ abstract class WebrootSetupController extends AbstractController
}
}
public function writeDotEnvLocal(array $data,bool $generate_app_secret=true) {
$file = fopen(join(DIRECTORY_SEPARATOR,[$this->project_dir,".env.local"]));
$file = fopen(join(DIRECTORY_SEPARATOR,[$this->project_dir,".env.local"]),"w");
fwrite($file,"ENV=" . $data["env"] . "\n");
if ($generate_app_secret) {
@ -758,7 +758,7 @@ abstract class WebrootSetupController extends AbstractController
} else {
fwrite($file,"APP_SECET=\"" . getenv("APP_SECRET") . "\"\n");
}
fwrite($file,"SITE_NAME=\"" . $data['site']['site_name'] . "\"\n");
fwrite($file,"SITE_NAME=\"" . $data['site']['name'] . "\"\n");
fwrite($file,"SITE_EMAIL=\"". $data['site']['email'] . "\"\n");
fwrite($file,"SITE_ROOTDIR=\"" .$data['site']['rootdir'] ."\"\n");

View File

@ -1,5 +1,5 @@
<!DOCTYPE html>
<html>
<html style="margin:0px;padding:0px;">
<head>
<meta charset="UTF-8">
<title>{% block title %}Welcome!{% endblock %}</title>
@ -11,7 +11,27 @@
{% block importmap %}{{ importmap('app') }}{% endblock %}
{% endblock %}
</head>
<body>
{% block body %}{% endblock %}
<body style="margin:0px;padding:0px;">
{% block body %}
<header class="header" style="color:lightgrey;padding:0px 5px 0px 5px;margin:0px;">
{% block header %}
<div class="center"><pre>
_ _
__ _____| |__ _ __ ___ ___ | |_
\ \ /\ / / _ \ '_ \| '__/ _ \ / _ \| __|
\ V V / __/ |_) | | | (_) | (_) | |_
\_/\_/ \___|_.__/|_| \___/ \___/ \__|
</pre></div>
{% endblock %}
</header>
<main>
{% block main %}
{% endblock %}
</main>
<footer>
{% block footer %}
{% endblock %}
</footer>
{% endblock %}
</body>
</html>

View File

@ -0,0 +1,20 @@
{% extends 'base.html.twig' %}
{% block title %}Hello MainController!{% endblock %}
{% block body %}
<style>
.example-wrapper { margin: 1em auto; max-width: 800px; width: 95%; font: 18px/1.5 sans-serif; }
.example-wrapper code {var(--color-code-background); padding: 2px 6px; }
</style>
<div class="example-wrapper">
<h1>Hello {{ controller_name }}! ✅</h1>
This friendly message is coming from:
<ul>
<li>Your controller at <code>C:/msys64/home/c9mos/www/webroot/src/Controller/MainController.php</code></li>
<li>Your template at <code>C:/msys64/home/c9mos/www/webroot/templates/main/index.html.twig</code></li>
</ul>
</div>
{% endblock %}

View File

@ -1,20 +1,6 @@
{% extends 'base.html.twig' %}
{% block title %}Hello MainController!{% endblock %}
{% block body %}
<style>
.example-wrapper { margin: 1em auto; max-width: 800px; width: 95%; font: 18px/1.5 sans-serif; }
.example-wrapper code { background: #F5F5F5; padding: 2px 6px; }
</style>
<div class="example-wrapper">
<h1>Hello {{ controller_name }}! ✅</h1>
This friendly message is coming from:
<ul>
<li>Your controller at <code>C:/msys64/home/c9mos/www/webroot/src/Controller/MainController.php</code></li>
<li>Your template at <code>C:/msys64/home/c9mos/www/webroot/templates/main/index.html.twig</code></li>
</ul>
</div>
{% block main %}
<p>
You are logged in as <em>{{ user.username }}</em>.
</p>
{% endblock %}

6
templates/webroot.txt Normal file
View File

@ -0,0 +1,6 @@
_ _
__ _____| |__ _ __ ___ ___ | |_
\ \ /\ / / _ \ '_ \| '__/ _ \ / _ \| __|
\ V V / __/ |_) | | | (_) | (_) | |_
\_/\_/ \___|_.__/|_| \___/ \___/ \__|

View File

@ -84,3 +84,12 @@ setupform:
user: 'Neuer Administrator'
title: 'Webroot Installation'
submit: 'Einstellungen andwenden und Setup ausführen'
command:
success: ERFOLGREICH
createdb: 'Erstelle Datenbank'
makemigrations: 'Erstelle Datenbankmigrationen'
migrate: 'Migriere Datenbank'
populatedb: 'Fülle Datenbank'
failed: FEHLGESCHLAGEN
button:
return-setup: 'Zurück zum Setup'

View File

@ -84,3 +84,12 @@ setupform:
user: 'New Adminitrator'
title: 'Setup Webroot'
submit: 'Run setup'
command:
success: SUCCESS
createdb: 'Creating database'
makemigrations: 'Making migrations'
migrate: 'Migrating database'
populatedb: 'Populating database'
failed: FAILED
button:
return-setup: 'Return to setup'