1
0
mirror of https://github.com/typemill/typemill.git synced 2025-07-31 11:20:15 +02:00

V2 001: Hello Typemill 2 with structured system folder

This commit is contained in:
trendschau
2022-06-08 10:32:38 +02:00
parent efd57e368e
commit 0888a8167f
11 changed files with 333 additions and 125 deletions

View File

@@ -1,74 +1,3 @@
<IfModule mod_rewrite.c>
RewriteEngine On
# If your homepage is http://yourdomain.com/yoursite
# Set the RewriteBase to:
# RewriteBase /yoursite
# In some environements, an empty RewriteBase is required:
# RewriteBase /
# Use this to redirect HTTP to HTTPS on apache servers
# RewriteCond %{HTTPS} off
# RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI} [R=301,L]
# Use this to redirect www to non-wwww on apache servers
# RewriteCond %{HTTP_HOST} ^www\.(.*)$ [NC]
# RewriteRule ^(.*)$ http://%1/$1 [R=301,L]
# Use this to redirect slash/ to url without slash on apache servers
# RewriteCond %{REQUEST_FILENAME} !-d
# RewriteRule ^(.*)/$ /$1 [R=301,L]
# Removes index.php
RewriteCond %{THE_REQUEST} ^GET.*index\.php [NC]
RewriteRule (.*?)index\.php/*(.*) /$1$2 [R=301,NE,L]
# REWRITE TO INDEX
# If the requested path and file not /index.php
RewriteCond %{REQUEST_URI} !^/index\.php
# if requested doesn't match a physical file
RewriteCond %{REQUEST_FILENAME} !-f
# if requested doesn't match a physical folder
RewriteCond %{REQUEST_FILENAME} !-d
# then rewrite the request to the index.php script
RewriteRule ^ index.php [QSA,L]
# FILE/FOLDER PROTECTION
# Deny access to these file types generally
RewriteRule ^(.*)?\.yml$ - [F,L]
Rewriterule ^(.*)?\.yaml$ - [F,L]
RewriteRule ^(.*)?\.txt$ - [F,L]
RewriteRule ^(.*)?\.example$ - [F,L]
RewriteRule ^(.*)?\.git+ - [F,L]
RewriteRule ^(.*)?\.md - [F,L]
RewriteCond %{REQUEST_URI} !/index\.php
RewriteRule ^(.*)?\.ph - [F,L]
RewriteRule ^(.*)?\.twig - [F,L]
RewriteRule ^(media\/tmp\/) - [F,L]
# Block access to specific files in the root folder
RewriteRule ^(composer\.lock|composer\.json|\.htaccess)$ error [F,L]
# block files and folders starting with a dot except for the .well-known folder (Let's Encrypt)
RewriteRule (^|/)\.(?!well-known\/) index.php [L]
# Allow access to frontend files in author folder
RewriteRule ^(system\/author\/css\/) - [L]
RewriteRule ^(system\/author\/img\/) - [L]
RewriteRule ^(system\/author\/js\/) - [L]
# redirect all other direct requests to the following physical folders to the index.php so pages with same name work
RewriteRule ^(system|content|data|settings|(media\/files\/)) index.php [QSA,L]
# disallow browsing other folders generally
Options -Indexes
</IfModule>
RewriteEngine on
RewriteRule ^$ public/ [L]
RewriteRule (.*) public/$1 [L]

74
.htaccessold Normal file
View File

@@ -0,0 +1,74 @@
<IfModule mod_rewrite.c>
RewriteEngine On
# If your homepage is http://yourdomain.com/yoursite
# Set the RewriteBase to:
# RewriteBase /yoursite
# In some environements, an empty RewriteBase is required:
# RewriteBase /
# Use this to redirect HTTP to HTTPS on apache servers
# RewriteCond %{HTTPS} off
# RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI} [R=301,L]
# Use this to redirect www to non-wwww on apache servers
# RewriteCond %{HTTP_HOST} ^www\.(.*)$ [NC]
# RewriteRule ^(.*)$ http://%1/$1 [R=301,L]
# Use this to redirect slash/ to url without slash on apache servers
# RewriteCond %{REQUEST_FILENAME} !-d
# RewriteRule ^(.*)/$ /$1 [R=301,L]
# Removes index.php
RewriteCond %{THE_REQUEST} ^GET.*index\.php [NC]
RewriteRule (.*?)index\.php/*(.*) /$1$2 [R=301,NE,L]
# REWRITE TO INDEX
# If the requested path and file not /index.php
RewriteCond %{REQUEST_URI} !^/index\.php
# if requested doesn't match a physical file
RewriteCond %{REQUEST_FILENAME} !-f
# if requested doesn't match a physical folder
RewriteCond %{REQUEST_FILENAME} !-d
# then rewrite the request to the index.php script
RewriteRule ^ index.php [QSA,L]
# FILE/FOLDER PROTECTION
# Deny access to these file types generally
RewriteRule ^(.*)?\.yml$ - [F,L]
Rewriterule ^(.*)?\.yaml$ - [F,L]
RewriteRule ^(.*)?\.txt$ - [F,L]
RewriteRule ^(.*)?\.example$ - [F,L]
RewriteRule ^(.*)?\.git+ - [F,L]
RewriteRule ^(.*)?\.md - [F,L]
RewriteCond %{REQUEST_URI} !/index\.php
RewriteRule ^(.*)?\.ph - [F,L]
RewriteRule ^(.*)?\.twig - [F,L]
RewriteRule ^(media\/tmp\/) - [F,L]
# Block access to specific files in the root folder
RewriteRule ^(composer\.lock|composer\.json|\.htaccess)$ error [F,L]
# block files and folders starting with a dot except for the .well-known folder (Let's Encrypt)
RewriteRule (^|/)\.(?!well-known\/) index.php [L]
# Allow access to frontend files in author folder
RewriteRule ^(system\/author\/css\/) - [L]
RewriteRule ^(system\/author\/img\/) - [L]
RewriteRule ^(system\/author\/js\/) - [L]
# redirect all other direct requests to the following physical folders to the index.php so pages with same name work
RewriteRule ^(system|content|data|settings|(media\/files\/)) index.php [QSA,L]
# disallow browsing other folders generally
Options -Indexes
</IfModule>

View File

@@ -9,6 +9,7 @@
"vendor-dir": "system/vendor"
},
"require": {
"php": "^8.0",
"slim/slim": "4.*",
"slim/psr7": "^1.5",
"php-di/php-di": "^6.3",

67
composer.lock generated
View File

@@ -4,7 +4,7 @@
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies",
"This file is @generated automatically"
],
"content-hash": "9cb56450ca4ec7e5b572cc5f79181d18",
"content-hash": "cec6169bbe69cc122c0c577476c42f23",
"packages": [
{
"name": "akrabat/proxy-detection-middleware",
@@ -1519,20 +1519,20 @@
},
{
"name": "symfony/event-dispatcher",
"version": "v6.1.0",
"version": "v6.0.9",
"source": {
"type": "git",
"url": "https://github.com/symfony/event-dispatcher.git",
"reference": "a0449a7ad7daa0f7c0acd508259f80544ab5a347"
"reference": "5c85b58422865d42c6eb46f7693339056db098a8"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/symfony/event-dispatcher/zipball/a0449a7ad7daa0f7c0acd508259f80544ab5a347",
"reference": "a0449a7ad7daa0f7c0acd508259f80544ab5a347",
"url": "https://api.github.com/repos/symfony/event-dispatcher/zipball/5c85b58422865d42c6eb46f7693339056db098a8",
"reference": "5c85b58422865d42c6eb46f7693339056db098a8",
"shasum": ""
},
"require": {
"php": ">=8.1",
"php": ">=8.0.2",
"symfony/event-dispatcher-contracts": "^2|^3"
},
"conflict": {
@@ -1582,7 +1582,7 @@
"description": "Provides tools that allow your application components to communicate with each other by dispatching events and listening to them",
"homepage": "https://symfony.com",
"support": {
"source": "https://github.com/symfony/event-dispatcher/tree/v6.1.0"
"source": "https://github.com/symfony/event-dispatcher/tree/v6.0.9"
},
"funding": [
{
@@ -1598,24 +1598,24 @@
"type": "tidelift"
}
],
"time": "2022-05-05T16:51:07+00:00"
"time": "2022-05-05T16:45:52+00:00"
},
{
"name": "symfony/event-dispatcher-contracts",
"version": "v3.1.0",
"version": "v3.0.1",
"source": {
"type": "git",
"url": "https://github.com/symfony/event-dispatcher-contracts.git",
"reference": "02ff5eea2f453731cfbc6bc215e456b781480448"
"reference": "7bc61cc2db649b4637d331240c5346dcc7708051"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/symfony/event-dispatcher-contracts/zipball/02ff5eea2f453731cfbc6bc215e456b781480448",
"reference": "02ff5eea2f453731cfbc6bc215e456b781480448",
"url": "https://api.github.com/repos/symfony/event-dispatcher-contracts/zipball/7bc61cc2db649b4637d331240c5346dcc7708051",
"reference": "7bc61cc2db649b4637d331240c5346dcc7708051",
"shasum": ""
},
"require": {
"php": ">=8.1",
"php": ">=8.0.2",
"psr/event-dispatcher": "^1"
},
"suggest": {
@@ -1624,7 +1624,7 @@
"type": "library",
"extra": {
"branch-alias": {
"dev-main": "3.1-dev"
"dev-main": "3.0-dev"
},
"thanks": {
"name": "symfony/contracts",
@@ -1661,7 +1661,7 @@
"standards"
],
"support": {
"source": "https://github.com/symfony/event-dispatcher-contracts/tree/v3.1.0"
"source": "https://github.com/symfony/event-dispatcher-contracts/tree/v3.0.1"
},
"funding": [
{
@@ -1677,27 +1677,24 @@
"type": "tidelift"
}
],
"time": "2022-02-25T11:15:52+00:00"
"time": "2022-01-02T09:55:41+00:00"
},
{
"name": "symfony/finder",
"version": "v6.1.0",
"version": "v6.0.8",
"source": {
"type": "git",
"url": "https://github.com/symfony/finder.git",
"reference": "45b8beb69d6eb3b05a65689ebfd4222326773f8f"
"reference": "af7edab28d17caecd1f40a9219fc646ae751c21f"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/symfony/finder/zipball/45b8beb69d6eb3b05a65689ebfd4222326773f8f",
"reference": "45b8beb69d6eb3b05a65689ebfd4222326773f8f",
"url": "https://api.github.com/repos/symfony/finder/zipball/af7edab28d17caecd1f40a9219fc646ae751c21f",
"reference": "af7edab28d17caecd1f40a9219fc646ae751c21f",
"shasum": ""
},
"require": {
"php": ">=8.1"
},
"require-dev": {
"symfony/filesystem": "^6.0"
"php": ">=8.0.2"
},
"type": "library",
"autoload": {
@@ -1725,7 +1722,7 @@
"description": "Finds files and directories via an intuitive fluent interface",
"homepage": "https://symfony.com",
"support": {
"source": "https://github.com/symfony/finder/tree/v6.1.0"
"source": "https://github.com/symfony/finder/tree/v6.0.8"
},
"funding": [
{
@@ -1741,7 +1738,7 @@
"type": "tidelift"
}
],
"time": "2022-04-15T08:08:08+00:00"
"time": "2022-04-15T08:07:58+00:00"
},
{
"name": "symfony/polyfill-ctype",
@@ -2072,20 +2069,20 @@
},
{
"name": "symfony/yaml",
"version": "v6.1.0",
"version": "v6.0.3",
"source": {
"type": "git",
"url": "https://github.com/symfony/yaml.git",
"reference": "84ce4f9d2d68f306f971a39d949d8f4b5550dba2"
"reference": "e77f3ea0b21141d771d4a5655faa54f692b34af5"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/symfony/yaml/zipball/84ce4f9d2d68f306f971a39d949d8f4b5550dba2",
"reference": "84ce4f9d2d68f306f971a39d949d8f4b5550dba2",
"url": "https://api.github.com/repos/symfony/yaml/zipball/e77f3ea0b21141d771d4a5655faa54f692b34af5",
"reference": "e77f3ea0b21141d771d4a5655faa54f692b34af5",
"shasum": ""
},
"require": {
"php": ">=8.1",
"php": ">=8.0.2",
"symfony/polyfill-ctype": "^1.8"
},
"conflict": {
@@ -2126,7 +2123,7 @@
"description": "Loads and dumps YAML files",
"homepage": "https://symfony.com",
"support": {
"source": "https://github.com/symfony/yaml/tree/v6.1.0"
"source": "https://github.com/symfony/yaml/tree/v6.0.3"
},
"funding": [
{
@@ -2142,7 +2139,7 @@
"type": "tidelift"
}
],
"time": "2022-04-15T14:25:02+00:00"
"time": "2022-01-26T17:23:29+00:00"
},
{
"name": "twig/twig",
@@ -2286,7 +2283,9 @@
"stability-flags": [],
"prefer-stable": true,
"prefer-lowest": false,
"platform": [],
"platform": {
"php": "^8.0"
},
"platform-dev": [],
"plugin-api-version": "2.3.0"
}

View File

4
public/.htaccess Normal file
View File

@@ -0,0 +1,4 @@
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^ index.php [QSA,L]

3
public/index.php Normal file
View File

@@ -0,0 +1,3 @@
<?php
require __DIR__ . '/../system/typemill/system.php';

View File

@@ -249,7 +249,7 @@ WEBSITE_RESTRICTION: Restriction sur le site
WRAP_THE_RESTRICTION_NOTICE_ABOVE_INTO_A_NOTICE_4_ELEMENT_(WHICH_CAN_BE_DESIGNED_AS_SPECIAL_BOX): Insérer l'avis de restriction ci-dessus dans un élément notice-4 (qui peut être conçu comme special box)
ACTIVATE_CACHE_FOR_TWIG_TEMPLATES: Activer le cache pour les templates Twig
ADD_MORE_URL_SCHEMES_FOR_EXTERNAL_LINKS_E_G__LIKE_DICT://_(COMMA_SEPARATED_LIST): Ajouter d'autres schémas d'url pour les liens externes. ex: dict:// (liste séparée par des virgules)
ADD_MORE_URL_SCHEMES_FOR_EXTERNAL_LINKS_E_G__LIKE_DICT://_(COMMA_SEPARATED_LIST): "Ajouter d'autres schémas d'url pour les liens externes. ex: dict:// (liste séparée par des virgules)"
CLEAR_CACHE: Vider le cache
DELETE_ALL_CACHE_FILES: Vider tous les fichiers de cache
DEVELOPER: Développeur

View File

@@ -239,7 +239,7 @@ IF_YOU_ADD_A_VALUE_FOR_THE_HEIGHT__THEN_THE_IMAGE_WILL_BE_CROPPED_: Se aggiungi
PROXY: Proxy
STANDARD_HEIGHT_FOR_IMAGES: Altezza standard per le immagini
STANDARD_WIDTH_FOR_IMAGES: Larghezza standard per le immagini
THE_FOLLOWING_OPTIONS_ARE_ONLY_FOR_DEVELOPERS: Le seguenti opzioni sono solo per sviluppatori e amministratori esperti. Cambia le opzioni solo se le capisci davvero. Ad esempio: non attivare mai la segnalazione degli errori per un sito Web live, utilizzare questa opzione solo per la correzione dei bug.
THE_FOLLOWING_OPTIONS_ARE_ONLY_FOR_DEVELOPERS: "Le seguenti opzioni sono solo per sviluppatori e amministratori esperti. Cambia le opzioni solo se le capisci davvero. Ad esempio: non attivare mai la segnalazione degli errori per un sito Web live, utilizzare questa opzione solo per la correzione dei bug."
THIS_APPLIES_ONLY_FOR_FUTURE_IMAGES_IN_THE_CONTENT_AREA_: Questo vale solo per le immagini future nell'area del contenuto.
TRUSTED_IPS_FOR_PROXY_(COMMA_SEPARATED): IP affidabili per proxy (separati da virgole)
TWIG_CACHE: Twig Cache

213
system/typemill/system.php Normal file
View File

@@ -0,0 +1,213 @@
<?php
use DI\Container;
use Psr\Http\Message\ResponseInterface as Response;
use Psr\Http\Message\ServerRequestInterface as Request;
use Slim\Exception\HttpNotFoundException;
use Slim\Middleware\ErrorMiddleware;
use Slim\Psr7\Response as NewResponse;
use Slim\Factory\AppFactory;
use Slim\Views\Twig;
use Slim\Views\TwigMiddleware;
use Slim\Csrf\Guard;
use Slim\Flash\Messages;
use Nquire\Middleware\ValidationErrors;
use Nquire\Middleware\FlashMessages;
use Nquire\Middleware\JsonBodyParser;
require __DIR__ . '/../vendor/autoload.php';
/****************************
* HIDE ERRORS BY DEFAULT *
****************************/
ini_set('display_errors', 0);
ini_set('display_startup_errors', 0);
error_reporting(E_ALL);
/****************************
* CONTAINER *
****************************/
# https://www.slimframework.com/docs/v4/start/upgrade.html#changes-to-container
$container = new Container();
AppFactory::setContainer($container);
$app = AppFactory::create();
$container = $app->getContainer();
$responseFactory = $app->getResponseFactory();
$routeParser = $app->getRouteCollector()->getRouteParser();
/****************************
* BASE PATH *
****************************/
# basepath must always be set in slim 4
$basepath = preg_replace('/(.*)\/.*/', '$1', $_SERVER['SCRIPT_NAME']);
$container->set('basePath', $basepath);
$app->setBasePath($basepath);
die('hello Typemill V2');
/****************************
* SETTINGS *
****************************/
$settings = require __DIR__ . '/settings/settings.php';
$container->set('settings', function() use ($settings)
{
return $settings;
});
# create a session
ini_set('session.cookie_httponly', 1 );
ini_set('session.use_strict_mode', 1);
ini_set('session.cookie_samesite', 'lax');
if(isset($_SERVER['HTTPS']))
{
ini_set('session.cookie_secure', 1);
session_name('__Secure-nquire-session');
}
else
{
session_name('nquire-session');
}
session_start();
# add flash messsages
$container->set('flash', function(){
return new Messages();
});
# Register Middleware On Container
$container->set('csrf', function () use ($responseFactory) {
return new Guard($responseFactory);
});
# Set view in Container
$container->set('view', function() use ($container) {
$twig = Twig::create(__DIR__ . DIRECTORY_SEPARATOR . 'views',['cache' => false, 'debug' => true]);
$twig->getEnvironment()->addGlobal('errors', NULL);
$twig->getEnvironment()->addGlobal('flash', NULL);
$twig->addExtension(new \Twig\Extension\DebugExtension());
$twig->addExtension(new \Nquire\Extensions\TwigUserExtension());
$twig->addExtension(new \Nquire\Extensions\TwigCsrfExtension($container->get('csrf')));
return $twig;
});
/****************************
* SET ROUTE PARSER TO USE NAMED ROUTES IN CONTROLLER *
****************************/
$container->set('routeParser', $routeParser);
/****************************
* MIDDLEWARE *
****************************/
# Add Validation Errors Middleware
$app->add(new ValidationErrors($container->get('view')));
# Add Flash Messages Middleware
$app->add(new FlashMessages($container->get('view')));
# Add csrf middleware globally
$app->add('csrf');
# Add Twig-View Middleware
$app->add(TwigMiddleware::createFromContainer($app));
# add JsonBodyParser Middleware
$app->add(new JsonBodyParser());
/**
* The routing middleware should be added earlier than the ErrorMiddleware
* Otherwise exceptions thrown from it will not be handled by the middleware
*/
$app->addRoutingMiddleware();
/**
* Add Error Middleware
*
* @param bool $displayErrorDetails -> Should be set to false in production
* @param bool $logErrors -> Parameter is passed to the default ErrorHandler
* @param bool $logErrorDetails -> Display error details in error log
* @param LoggerInterface|null $logger -> Optional PSR-3 Logger
*
* Note: This middleware should be added last. It will not handle any exceptions/errors
* for middleware added after it.
*/
# $errorMiddleware = $app->addErrorMiddleware(true, true, true);
$errorMiddleware = new ErrorMiddleware(
$app->getCallableResolver(),
$app->getResponseFactory(),
true,
false,
false
);
# Set the Not Found Handler
$errorMiddleware->setErrorHandler(HttpNotFoundException::class, function ($request, $exception) use ($container) {
$response = new NewResponse();
return $container->get('view')->render($response->withStatus(404), 'errors/404.twig');
});
$app->add($errorMiddleware);
/*
# Set the Not Found Handler
$errorMiddleware->setErrorHandler(
HttpNotFoundException::class,
function (ServerRequestInterface $request, Throwable $exception, bool $displayErrorDetails) {
$response = new Response();
$response->getBody()->write('404 NOT FOUND');
return $response->withStatus(404);
}
);
# Set the Not Allowed Handler
$errorMiddleware->setErrorHandler(
HttpMethodNotAllowedException::class,
function (ServerRequestInterface $request, Throwable $exception, bool $displayErrorDetails) {
$response = new Response();
$response->getBody()->write('405 NOT ALLOWED');
return $response->withStatus(405);
}
);
# Set the Not Found Handler
$errorMiddleware->setErrorHandler(
HttpNotFoundException::class,
function () {
die('not found');
}
);
$app->add($ErrorMiddleware);
*/
/************************
* ADD ROUTES *
************************/
require __DIR__ . '/routes/api.php';
require __DIR__ . '/routes/web.php';
$app->run();

View File

@@ -1,15 +0,0 @@
● php8.1-fpm.service - The PHP 8.1 FastCGI Process Manager
Loaded: loaded (/lib/systemd/system/php8.1-fpm.service; enabled; vendor preset: enabled)
Active: active (running) since Sun 2022-05-29 22:34:18 CEST; 33s ago
Docs: man:php-fpm8.1(8)
Main PID: 110039 (php-fpm8.1)
Status: "Processes active: 0, idle: 2, Requests: 0, slow: 0, Traffic: 0req/sec"
Tasks: 3 (limit: 4395)
Memory: 10.1M
CGroup: /system.slice/php8.1-fpm.service
├─110039 php-fpm: master process (/etc/php/8.1/fpm/php-fpm.conf)
├─110044 php-fpm: pool www
└─110045 php-fpm: pool www
May 29 22:34:18 sebastian-IdeaPad-1 systemd[1]: Starting The PHP 8.1 FastCGI Process Manager...
May 29 22:34:18 sebastian-IdeaPad-1 systemd[1]: Started The PHP 8.1 FastCGI Process Manager.