Compare commits
76
Commits
8892edd19e
...
liteing
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
4f648b47bd | ||
|
|
60d4c7a900 | ||
|
|
2378245dbf | ||
|
|
2cb911ea6f | ||
|
|
16cd95abe2 | ||
|
|
1241e188e9 | ||
|
|
08c27e38b0 | ||
|
|
1a6d730298 | ||
|
|
0ad57c87df | ||
|
|
590e9d7631 | ||
|
|
7e92391113 | ||
|
|
8f0ebfdf80 | ||
|
|
772de0015e | ||
|
|
d8045b5f3c | ||
|
|
bc6880c166 | ||
|
|
4c0cddd617 | ||
|
|
4dcc7f407e | ||
|
|
3f92287829 | ||
|
|
8d22132ef5 | ||
|
|
438b5a69c0 | ||
|
|
84b3a16b6e | ||
|
|
d30e687e21 | ||
|
|
4309f46c86 | ||
|
|
b6d7e5fad5 | ||
|
|
8a5f5f052b | ||
|
|
2e51ff9f4a | ||
|
|
777f4af1aa | ||
|
|
09b332bde7 | ||
|
|
41083c767a | ||
|
|
52c7407519 | ||
|
|
d402dbeaa0 | ||
|
|
d26a15c0ed | ||
|
|
026a13c766 | ||
|
|
4274a6f4a4 | ||
|
|
4404943f8b | ||
|
|
428e26fbfb | ||
|
|
e2d2ff72bb | ||
|
|
94fc8885cf | ||
|
|
ec250be35b | ||
|
|
8390506361 | ||
|
|
fd95e8db91 | ||
|
|
f0082bf0a9 | ||
|
|
7481b8308b | ||
|
|
778cdcc7af | ||
|
|
e07dcae5f5 | ||
|
|
40f9c246b2 | ||
|
|
58285753ed | ||
|
|
26e5e330f4 | ||
|
|
5f5ca6cff5 | ||
|
|
3ee7d57b31 | ||
|
|
f482c19df5 | ||
|
|
946281c884 | ||
|
|
977aef1b26 | ||
|
|
653f9239b2 | ||
|
|
bdf38285e4 | ||
|
|
3101573603 | ||
|
|
93ec2a7e76 | ||
|
|
7badddd72c | ||
|
|
571846ada7 | ||
|
|
591ba18912 | ||
|
|
5bebe231c7 | ||
|
|
aba9a65a3c | ||
|
|
f719246624 | ||
|
|
f23606de64 | ||
|
|
9ce8e7515a | ||
|
|
3550d9aaa7 | ||
|
|
0689f8dcb7 | ||
|
|
a78d20bc32 | ||
|
|
5c06419f15 | ||
|
|
83d52e87ae | ||
|
|
19ee40dead | ||
|
|
73aa22942f | ||
|
|
06313396f5 | ||
|
|
9f6d873a98 | ||
|
|
80dee6de86 | ||
|
|
1f0edd88d2 |
No files matched your search
+84
-13
@@ -1,42 +1,65 @@
|
||||
{
|
||||
"name": "mcnd/lean",
|
||||
"description": "A more-than-micro framework for basic apps",
|
||||
"description": "A micro framework for rapid application development (RAD)",
|
||||
"type": "library",
|
||||
"license": "MIT",
|
||||
"authors": [
|
||||
{
|
||||
"name": "Dave Mc Nicoll",
|
||||
"email": "mcndave@gmail.com"
|
||||
"email": "info@mcnd.ca"
|
||||
}
|
||||
],
|
||||
"require": {
|
||||
"vlucas/phpdotenv": "^3.4@dev",
|
||||
"php": "^8.2",
|
||||
"php-di/php-di": "dev-master",
|
||||
"league/route": "dev-master",
|
||||
"ext-json": "*",
|
||||
"ext-posix": "*",
|
||||
"ext-xmlreader": "*",
|
||||
"ext-fileinfo": "*",
|
||||
"league/route": "^5.0.0-dev",
|
||||
"laminas/laminas-diactoros": "2.24.x-dev",
|
||||
"laminas/laminas-httphandlerrunner": "2.5.x-dev",
|
||||
"vlucas/phpdotenv": "^3.4@dev",
|
||||
"middlewares/whoops": "dev-master",
|
||||
"guzzlehttp/guzzle": "^7@dev",
|
||||
"swiftmailer/swiftmailer": "^6.2@dev",
|
||||
"mcnd/storage": "dev-master",
|
||||
"mcnd/lean-console": "dev-master",
|
||||
"mcnd/ulmus": "dev-master",
|
||||
"mcnd/picea": "dev-master",
|
||||
"mcnd/picea-ui": "dev-master",
|
||||
"mcnd/cronard": "dev-master",
|
||||
"mcnd/tell": "dev-master",
|
||||
"mcnd/dump": "dev-master",
|
||||
"mcnd/notes": "dev-master",
|
||||
"mcnd/event": "dev-master",
|
||||
"mcnd/notes-breadcrumb": "dev-master",
|
||||
"mcnd/notes-cronard": "dev-master",
|
||||
"mcnd/notes-event": "dev-master",
|
||||
"mcnd/notes-tell": "dev-master",
|
||||
"mcnd/notes-route": "dev-master",
|
||||
"mcnd/notes-security": "dev-master",
|
||||
"mcnd/notes-tell": "dev-master",
|
||||
"swiftmailer/swiftmailer": "^6.2@dev",
|
||||
"league/route": "^5.0.0-dev",
|
||||
"laminas/laminas-diactoros": "2.5.x-dev",
|
||||
"laminas/laminas-httphandlerrunner": "1.3.x-dev",
|
||||
"vlucas/phpdotenv": "^3.4@dev",
|
||||
"middlewares/whoops": "dev-master",
|
||||
"ralouphie/getallheaders": "dev-master"
|
||||
"mcnd/ulmus-user": "dev-master",
|
||||
"mcnd/thebugs": "dev-master",
|
||||
"mcnd/taxus": "dev-master",
|
||||
"psr/simple-cache": "*"
|
||||
},
|
||||
"repositories": [
|
||||
{
|
||||
"type": "vcs",
|
||||
"url": "https://git.mcnd.ca/mcndave/lean-console.git"
|
||||
},
|
||||
{
|
||||
"type": "vcs",
|
||||
"url": "https://git.mcnd.ca/mcndave/cronard.git"
|
||||
},
|
||||
{
|
||||
"type": "vcs",
|
||||
"url": "https://git.mcnd.ca/mcndave/event.git"
|
||||
},
|
||||
{
|
||||
"type": "vcs",
|
||||
"url": "https://git.mcnd.ca/mcndave/the-bugs.git"
|
||||
},
|
||||
{
|
||||
"type": "vcs",
|
||||
"url": "https://git.mcnd.ca/mcndave/storage.git"
|
||||
@@ -45,6 +68,10 @@
|
||||
"type": "vcs",
|
||||
"url": "https://git.mcnd.ca/mcndave/ulmus.git"
|
||||
},
|
||||
{
|
||||
"type": "vcs",
|
||||
"url": "https://git.mcnd.ca/mcndave/ulmus-user.git"
|
||||
},
|
||||
{
|
||||
"type": "vcs",
|
||||
"url": "https://git.mcnd.ca/mcndave/picea.git"
|
||||
@@ -61,10 +88,22 @@
|
||||
"type": "vcs",
|
||||
"url": "https://git.mcnd.ca/mcndave/notes-route.git"
|
||||
},
|
||||
{
|
||||
"type": "vcs",
|
||||
"url": "https://git.mcnd.ca/mcndave/notes-cronard.git"
|
||||
},
|
||||
{
|
||||
"type": "vcs",
|
||||
"url": "https://git.mcnd.ca/mcndave/notes-security.git"
|
||||
},
|
||||
{
|
||||
"type": "vcs",
|
||||
"url": "https://git.mcnd.ca/mcndave/notes-breadcrumb.git"
|
||||
},
|
||||
{
|
||||
"type": "vcs",
|
||||
"url": "https://git.mcnd.ca/mcndave/notes-event.git"
|
||||
},
|
||||
{
|
||||
"type": "vcs",
|
||||
"url": "https://git.mcnd.ca/mcndave/notes-tell.git"
|
||||
@@ -86,5 +125,37 @@
|
||||
"psr-4": {
|
||||
"Lean\\": "src/"
|
||||
}
|
||||
},
|
||||
"scripts": {
|
||||
"post-install-cmd": [
|
||||
"Lean\\Composer::postInstall"
|
||||
],
|
||||
"post-update-cmd": [
|
||||
"Lean\\Composer::postUpdate"
|
||||
]
|
||||
},
|
||||
"extra" : {
|
||||
"lean" : {
|
||||
"autoload": {
|
||||
"definitions" : [
|
||||
"meta/definitions/software.php",
|
||||
"meta/definitions/authorize.php",
|
||||
"meta/definitions/cli.php",
|
||||
"meta/definitions/cronard.php",
|
||||
"meta/definitions/email.php",
|
||||
"meta/definitions/event.php",
|
||||
"meta/definitions/http.php",
|
||||
"meta/definitions/language.php",
|
||||
"meta/definitions/negundo.php",
|
||||
"meta/definitions/routes.php",
|
||||
"meta/definitions/software.php",
|
||||
"meta/definitions/storage.php",
|
||||
"meta/definitions/template.php"
|
||||
],
|
||||
"config": [
|
||||
"meta/config.php"
|
||||
]
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,14 @@
|
||||
<?php
|
||||
|
||||
return [
|
||||
'ulmus' => [
|
||||
'connections' => [
|
||||
'sqlite' => [
|
||||
'adapter' => 'SQLite',
|
||||
'path' => getenv('PROJECT_PATH') . DIRECTORY_SEPARATOR . "var/lean.sqlite3",
|
||||
'pragma_begin' => "journal_mode=WAL",
|
||||
'pragma_close' => "analysis_limit=500,optimize",
|
||||
],
|
||||
],
|
||||
],
|
||||
];
|
||||
@@ -0,0 +1,46 @@
|
||||
<?php
|
||||
|
||||
use Lean\Factory\HttpFactory;
|
||||
|
||||
use Ulmus\User\{Entity,
|
||||
Lib\Authenticate,
|
||||
Middleware\HeaderAuthenticationMiddleware,
|
||||
Middleware\PostRequestAuthenticationMiddleware,
|
||||
Authorize\PostRequestAuthentication};
|
||||
|
||||
use Picea\Picea;
|
||||
|
||||
use Storage\{ Cookie, Session };
|
||||
|
||||
use function DI\{get, autowire, create};
|
||||
|
||||
return [
|
||||
Authenticate::class => create(Authenticate::class)->constructor(get(Entity\UserInterface::class), get(Session::class), get(Cookie::class), get('authentication.method')),
|
||||
|
||||
HeaderAuthenticationMiddleware::class => create(HeaderAuthenticationMiddleware::class)->constructor(get(Entity\UserInterface::class), get('authorize.error')),
|
||||
|
||||
PostRequestAuthentication::class => create(PostRequestAuthentication::class)->constructor(get(\Ulmus\User\Lib\Authenticate::class), "email", "email", "password"),
|
||||
|
||||
PostRequestAuthenticationMiddleware::class => create(PostRequestAuthenticationMiddleware::class)->constructor(get(Entity\UserInterface::class), get('authentication.error'), get(PostRequestAuthentication::class)),
|
||||
|
||||
'authentication.method' => null,
|
||||
|
||||
'authorize.error' => function($c) {
|
||||
return function(array $errorData) {
|
||||
return HttpFactory::createJsonResponse($errorData + [
|
||||
'api.error' => "Authorization failed",
|
||||
'api.datetime' => (new \DateTime)->format(\DateTime::ATOM),
|
||||
]);
|
||||
};
|
||||
},
|
||||
|
||||
'authentication.error' => function($c, Picea $picea) {
|
||||
return function($message) use ($picea) {
|
||||
return HttpFactory::createHtmlResponse($picea->renderHtml('lean/error/500', [
|
||||
'title' => "Authentication failed",
|
||||
'subtitle' => "",
|
||||
'message' => $message,
|
||||
]));
|
||||
};
|
||||
},
|
||||
];
|
||||
@@ -0,0 +1,33 @@
|
||||
<?php
|
||||
|
||||
use function DI\autowire, DI\create, DI\get;
|
||||
|
||||
use Psr\Http\Message\ResponseInterface;
|
||||
|
||||
use Mcnd\CLI\CliMiddleware;
|
||||
|
||||
use Notes\CLI\CommandFetcher;
|
||||
|
||||
use Lean\{ Factory, Lean };
|
||||
|
||||
return [
|
||||
CommandFetcher::class => function($c) {
|
||||
$fetcher = new CommandFetcher(null, null, $c->get('cli.caching'));
|
||||
|
||||
$fetcher->setFolderList(array_map(function($item) {
|
||||
return $item;
|
||||
}, $c->get(Lean::class)->getCli()));
|
||||
|
||||
return $fetcher;
|
||||
},
|
||||
|
||||
CliMiddleware::class => function($c) {
|
||||
return new CliMiddleware($c, $c->get('cli.response:default'), $c->get(CommandFetcher::class));
|
||||
},
|
||||
|
||||
'cli.response:default' => function($c) {
|
||||
return function() {
|
||||
return Factory\HttpFactory::createTextResponse("This is the default response from CLI middleware which indicates that no command were registered for this application.\n");
|
||||
};
|
||||
},
|
||||
];
|
||||
@@ -0,0 +1,30 @@
|
||||
<?php
|
||||
|
||||
use function DI\autowire, DI\create, DI\get;
|
||||
|
||||
use Cronard\CronardMiddleware,
|
||||
Notes\Cronard\TaskFetcher;
|
||||
|
||||
use Psr\Http\Message\ResponseInterface;
|
||||
|
||||
use Lean\{ Factory, Lean };
|
||||
|
||||
return [
|
||||
CronardMiddleware::class => function($c) {
|
||||
$cronardMiddleware = new CronardMiddleware($c, getenv('CRON_KEY'), function() : ResponseInterface {
|
||||
return Factory\HttpFactory::createHtmlResponse(sprintf("%s - cron task begin...", date('Y-m-d H:i:s')));
|
||||
}, []);
|
||||
|
||||
return $cronardMiddleware->fromFile(getenv("META_PATH")."/crontab.php")->fromAnnotations($c->get(TaskFetcher::class));
|
||||
},
|
||||
|
||||
TaskFetcher::class => function($c) {
|
||||
$fetcher = new TaskFetcher(null, null, $c->get('cronard.caching'));
|
||||
|
||||
$fetcher->setFolderList(array_map(function($item) {
|
||||
return $item;
|
||||
}, $c->get(Lean::class)->getCronard()));
|
||||
|
||||
return $fetcher;
|
||||
},
|
||||
];
|
||||
@@ -4,12 +4,12 @@ use function DI\autowire, DI\create, DI\get;
|
||||
|
||||
use TheBugs\Email\EmailConfiguration,
|
||||
TheBugs\Email\MailerInterface,
|
||||
TheBugs\Email\SwiftMailer;
|
||||
TheBugs\Email\SymfonyMailer;
|
||||
|
||||
return [
|
||||
EmailConfiguration::class => function($c) {
|
||||
$email = new EmailConfiguration( EmailConfiguration::AUTH_TYPE_SMTP );
|
||||
$email->smtpHost = getenv('SMTP_HOST');
|
||||
$email->smtpHost = getenv('SMTP_HOSTNAME');
|
||||
$email->smtpPort = getenv('SMTP_PORT');
|
||||
$email->smtpUsername = getenv('SMTP_USERNAME');
|
||||
$email->smtpPassword = getenv('SMTP_PASSWORD');
|
||||
@@ -20,5 +20,5 @@ return [
|
||||
return $email;
|
||||
},
|
||||
|
||||
MailerInterface::class => autowire(SwiftMailer::class),
|
||||
MailerInterface::class => autowire(SymfonyMailer::class),
|
||||
];
|
||||
@@ -0,0 +1,87 @@
|
||||
<?php
|
||||
|
||||
use Picea\Picea;
|
||||
use function DI\autowire, DI\create, DI\get;
|
||||
|
||||
use Lean\{ Lean, Routing, Event\RoutingCompileRoutes, Event\RoutingMapRoutes };
|
||||
use Mcnd\Event;
|
||||
use Taxus\Taxus;
|
||||
use Storage\Session;
|
||||
use Notes\Route\Attribute\Method\Route;
|
||||
use Notes\Security\SecurityHandler;
|
||||
use Psr\Container\ContainerInterface;
|
||||
use Psr\Http\Message\{ ResponseInterface, ServerRequestInterface };
|
||||
|
||||
return [
|
||||
Event\EventManager::class => autowire(Event\EventManager::class),
|
||||
|
||||
Event\EventMiddleware::class => function($c) {
|
||||
$mw = new Event\EventMiddleware($c, $c->get(Event\EventManager::class));
|
||||
$mw->fromAttributes($c->get(Notes\Event\EventFetcher::class));
|
||||
$mw->fromDefinition($c->get(Event\EventDefinition::class));
|
||||
|
||||
return $mw;
|
||||
},
|
||||
|
||||
Event\EventDefinition::class => function($c) {
|
||||
return new Event\EventDefinition([
|
||||
new class() implements RoutingCompileRoutes {
|
||||
public function execute(Routing $routing, Route $attribute) : void
|
||||
{
|
||||
if (null !== ($name = $attribute->name ?? null)) {
|
||||
$routing->extension->registerRoute($name, $attribute->getRoute(), $attribute->class, $attribute->classMethod, $attribute->methods ?? (array)$attribute->method);
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
new class() implements RoutingMapRoutes {
|
||||
public function execute(Routing $routing, ContainerInterface $container, ServerRequestInterface & $request, Route $attribute) : void
|
||||
{
|
||||
$class = $attribute->class;
|
||||
$method = $attribute->classMethod;
|
||||
$object = $container->get($class);
|
||||
|
||||
$request = $request->withAttribute('lean.route', $attribute);
|
||||
|
||||
# Checking if user needs to be logged
|
||||
if ( $container->has(SecurityHandler::class) ){
|
||||
if ( $redirect = $container->get(SecurityHandler::class)->verify($class, $method) ) {
|
||||
if ( empty($object->user) || ! $object->user->logged ) {
|
||||
$routing->session->set('redirectedFrom', (string) $request->getUri());
|
||||
$routing->response = $redirect;
|
||||
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
if ( $container->has(Taxus::class) ) {
|
||||
if ( $forbidden = $container->get(SecurityHandler::class)->taxus($class, $method, $object->user ?? null) ) {
|
||||
$routing->response = $forbidden;
|
||||
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if ($container->has(Picea::class)) {
|
||||
$container->get(Picea::class)->globalVariables['route'] = $attribute;
|
||||
}
|
||||
|
||||
if ($container->has(Session::class)) {
|
||||
$container->get(Session::class)->set("lean.route", $attribute);
|
||||
}
|
||||
}
|
||||
},
|
||||
]);
|
||||
},
|
||||
|
||||
Notes\Event\EventFetcher::class => function($c) {
|
||||
$fetcher = new Notes\Event\EventFetcher(null, null, $c->get('events.caching'));
|
||||
|
||||
$fetcher->setFolderList(array_map(function($item) {
|
||||
return $item;
|
||||
}, $c->get(Lean::class)->getEvents()));
|
||||
|
||||
return $fetcher;
|
||||
},
|
||||
];
|
||||
@@ -4,9 +4,7 @@ use function DI\autowire, DI\create, DI\get;
|
||||
|
||||
use Psr\Http\Message\ServerRequestInterface;
|
||||
|
||||
use Zend\Diactoros\ServerRequestFactory;
|
||||
use Zend\HttpHandlerRunner\Emitter\EmitterInterface,
|
||||
Zend\HttpHandlerRunner\Emitter\SapiEmitter;
|
||||
use Laminas\{ Diactoros\ServerRequestFactory, HttpHandlerRunner\Emitter\EmitterInterface, HttpHandlerRunner\Emitter\SapiEmitter };
|
||||
|
||||
return [
|
||||
ServerRequestInterface::class => function ($c) {
|
||||
|
||||
@@ -8,23 +8,24 @@ return [
|
||||
Tell\I18n::class => create( Tell\I18n::class ) ->constructor(
|
||||
get(Tell\Reader\JsonReader::class),
|
||||
get(Tell\Reader\PhpReader::class),
|
||||
getenv("DEBUG") ? create(Tell\PrintMissingKey::class) : get('tell.fallback')
|
||||
get('tell.fallback') /* getenv("DEBUG") ? create(Tell\PrintMissingKey::class) : get('tell.fallback') */
|
||||
),
|
||||
|
||||
'tell.fallback' => function($c) {
|
||||
$tell = new Tell\I18n( $c->get(Tell\Reader\PhpReader::class) );
|
||||
$tell->locale = "en_US";
|
||||
$i18n = new Tell\I18n( $c->get(Tell\Reader\JsonReader::class), $c->get(Tell\Reader\PhpReader::class), new Tell\PrintMissingKey() );
|
||||
$i18n->locale(getenv('DEFAULT_LOCAL_FALLBACK') ?: "en_US");
|
||||
$i18n->initialize(true);
|
||||
|
||||
return $tell;
|
||||
return $i18n;
|
||||
},
|
||||
|
||||
# TODO -- accept folders from Lean Apps
|
||||
Tell\Reader\PhpReader::class => function($c) {
|
||||
return new Tell\Reader\PhpReader($c->get(Lean\Lean::class)->getI18n('php'), true);
|
||||
return new Tell\Reader\PhpReader($c->get(Lean\Lean::class)->getI18n('php'), false);
|
||||
},
|
||||
|
||||
Tell\Reader\JsonReader::class => function($c) {
|
||||
return new Tell\Reader\JsonReader($c->get(Lean\Lean::class)->getI18n('json'), true);
|
||||
return new Tell\Reader\JsonReader($c->get(Lean\Lean::class)->getI18n('json'), true, \JSON_PRETTY_PRINT);
|
||||
},
|
||||
|
||||
LanguageHandler::class => autowire(LanguageHandler::class),
|
||||
|
||||
@@ -0,0 +1,12 @@
|
||||
<?php
|
||||
|
||||
use function DI\autowire, DI\create, DI\get;
|
||||
|
||||
use Negundo\Client\{ SoftwareConfig, Dump, Task, NegundoMiddleware };
|
||||
|
||||
return [
|
||||
SoftwareConfig::class => create(SoftwareConfig::class)->constructor(getenv('NEGUNDO_HASH'), getenv('NEGUNDO_SERVER')),
|
||||
NegundoMiddleware::class => autowire(NegundoMiddleware::class),
|
||||
Dump::class => autowire(Dump::class),
|
||||
Task::class => autowire(Task::class),
|
||||
];
|
||||
+29
-42
@@ -3,33 +3,28 @@
|
||||
use function DI\autowire, DI\create, DI\get;
|
||||
|
||||
use League\Route\Strategy\ApplicationStrategy,
|
||||
League\Route\Http\Exception\NotFoundException,
|
||||
League\Route\Router;
|
||||
|
||||
use Psr\Http\Message\ResponseFactoryInterface,
|
||||
Psr\Container\ContainerInterface,
|
||||
Psr\Http\Message\ResponseInterface,
|
||||
Psr\Http\Message\ServerRequestInterface,
|
||||
Psr\Http\Server\MiddlewareInterface,
|
||||
Psr\Http\Server\RequestHandlerInterface;
|
||||
|
||||
use TheBugs\JavascriptMiddleware;
|
||||
use Psr\Container\ContainerInterface;
|
||||
|
||||
use Cronard\CronardMiddleware;
|
||||
|
||||
use Tuupola\Middleware\HttpBasicAuthentication;
|
||||
|
||||
use Notes\Route\RouteFetcher;
|
||||
|
||||
use Ulmus\User\Lib\Authenticate;
|
||||
use Notes\Breadcrumb\Breadcrumb;
|
||||
|
||||
use Storage\SessionMiddleware;
|
||||
|
||||
use Ulmus\User\Middleware\{
|
||||
HeaderAuthenticationMiddleware,
|
||||
PostRequestAuthenticationMiddleware
|
||||
};
|
||||
|
||||
return [
|
||||
Lean\Routing::class => autowire(Lean\Routing::class),
|
||||
|
||||
RouteFetcher::class => function($c) {
|
||||
$fetcher = new RouteFetcher();
|
||||
$fetcher = new RouteFetcher(null, [], null, $c->get('routes.caching'));
|
||||
|
||||
$fetcher->setFolderList(array_map(function($item) {
|
||||
return $item;
|
||||
@@ -38,50 +33,42 @@ return [
|
||||
return $fetcher;
|
||||
},
|
||||
|
||||
ApplicationStrategy::class => function($c) {
|
||||
return new class($c->get(Picea\Picea::class)) extends ApplicationStrategy {
|
||||
Breadcrumb::class => function($c) {
|
||||
$breadcrumb = new Breadcrumb(null, [], null, $c->get('breadcrumbs.caching'));
|
||||
|
||||
public Picea\Picea $picea;
|
||||
$breadcrumb->setFolderList(array_map(function($item) {
|
||||
return $item;
|
||||
}, $c->get(Lean\Lean::class)->getRoutable()));
|
||||
|
||||
public function __construct(Picea\Picea $picea) {
|
||||
$this->picea = $picea;
|
||||
}
|
||||
|
||||
public function getNotFoundDecorator(NotFoundException $exception): MiddlewareInterface
|
||||
{
|
||||
return new class($this->picea) implements MiddlewareInterface {
|
||||
|
||||
protected Picea\Picea $picea;
|
||||
|
||||
public function __construct(Picea\Picea $picea) {
|
||||
$this->picea = $picea;
|
||||
}
|
||||
|
||||
public function process(ServerRequestInterface $request, RequestHandlerInterface $handler): ResponseInterface
|
||||
{
|
||||
return new Zend\Diactoros\Response\HtmlResponse($this->picea->renderHtml("lean/error/404", [], $this), 404);
|
||||
}
|
||||
|
||||
};
|
||||
}
|
||||
|
||||
};
|
||||
return $breadcrumb;
|
||||
},
|
||||
|
||||
'routes.middlewares' => [ "dump", "errorHandler", SessionMiddleware::class, CronardMiddleware::class, HttpBasicAuthentication::class, JavascriptMiddleware::class ],
|
||||
ApplicationStrategy::class => autowire(\Lean\ApplicationStrategy::class),
|
||||
|
||||
'routes.middlewares' => [
|
||||
"dump", "errorHandler", SessionMiddleware::class, CronardMiddleware::class, Mcnd\Event\EventMiddleware::class, Mcnd\CLI\CliMiddleware::class,
|
||||
],
|
||||
|
||||
'app.middlewares' => [
|
||||
HeaderAuthenticationMiddleware::class,
|
||||
PostRequestAuthenticationMiddleware::class,
|
||||
],
|
||||
|
||||
'routes.list' => function($c) {
|
||||
return function (ContainerInterface $container) {
|
||||
$router = $container->get(Router::class);
|
||||
|
||||
foreach($container->get('routes.middlewares') as $middleware) {
|
||||
foreach([ 'routes.middlewares', 'app.middlewares' ] as $key) {
|
||||
if ( $container->has($key) ) {
|
||||
foreach ($container->get($key) as $i => $middleware) {
|
||||
if ($container->has($middleware)) {
|
||||
$router->middleware($container->get($middleware));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$routing = $container->get(Lean\Routing::class);
|
||||
|
||||
$routing->registerRoute($container, getenv('URL_BASE'));
|
||||
|
||||
return $router;
|
||||
|
||||
@@ -1,22 +1,18 @@
|
||||
<?php
|
||||
|
||||
use Taxus\Privilege;
|
||||
use function DI\autowire, DI\create, DI\get;
|
||||
|
||||
use Zend\Diactoros\Response\TextResponse;
|
||||
|
||||
use TheBugs\JavascriptMiddleware;
|
||||
|
||||
use Cronard\CronardMiddleware,
|
||||
Notes\Cronard\TaskFetcher;
|
||||
|
||||
use Lean\Lean;
|
||||
|
||||
use Psr\Http\Message\ResponseInterface;
|
||||
|
||||
use Storage\Cookie,
|
||||
Storage\Session,
|
||||
Storage\SessionMiddleware;
|
||||
|
||||
$dir = dirname(__DIR__, 2);
|
||||
|
||||
return [
|
||||
'lean.default' => [
|
||||
'picea' => [
|
||||
@@ -28,11 +24,18 @@ return [
|
||||
'order' => 10,
|
||||
],
|
||||
[
|
||||
'path' => getenv("PROJECT_PATH") . "/vendor/mcnd/lean/view/",
|
||||
'path' => implode(DIRECTORY_SEPARATOR, [ $dir, "view", '' ]),
|
||||
'order' => 99,
|
||||
],
|
||||
],
|
||||
|
||||
'asset' => [
|
||||
[
|
||||
'path' => implode(DIRECTORY_SEPARATOR, [ getenv("PROJECT_PATH"), "asset", '' ]),
|
||||
'order' => 10
|
||||
]
|
||||
],
|
||||
|
||||
'extensions' => [],
|
||||
],
|
||||
|
||||
@@ -62,35 +65,24 @@ return [
|
||||
'routes' => [],
|
||||
|
||||
'cronard' => [],
|
||||
|
||||
'taxus' => [
|
||||
[ new Privilege("dev", "Is a developper of this application."), "is_dev" ],
|
||||
[ new Privilege("admin", "Can manage mostly everything from this application."), "is_admin" ],
|
||||
[ new Privilege("user", "Is an authenticated user."), "is_user" ],
|
||||
[ new Privilege("anonymous", "Is an anonymous (unauthenticated) user."), "is_anonymous" ],
|
||||
]
|
||||
],
|
||||
|
||||
Lean::class => autowire(Lean::class),
|
||||
|
||||
CronardMiddleware::class => function($c) {
|
||||
$cronardMiddleware = new CronardMiddleware($c, getenv('CRON_KEY'), function() : ResponseInterface {
|
||||
return new TextResponse(sprintf("%s - cron task begin...", date('Y-m-d H:i:s')));
|
||||
});
|
||||
|
||||
return $cronardMiddleware->fromFile(getenv("META_PATH")."/crontab.php")->fromAnnotations($c->get(TaskFetcher::class));
|
||||
},
|
||||
|
||||
TaskFetcher::class => function($c) {
|
||||
$fetcher = new TaskFetcher();
|
||||
|
||||
$fetcher->setFolderList(array_map(function($item) {
|
||||
return $item;
|
||||
}, $c->get(Lean::class)->getCronard()));
|
||||
|
||||
return $fetcher;
|
||||
},
|
||||
|
||||
JavascriptMiddleware::class => create(JavascriptMiddleware::class),
|
||||
|
||||
Cookie::class => create(Cookie::class)->constructor([ 'secure' => true, 'path' => getenv('URL_BASE'), ], getenv("LEAN_RANDOM")),
|
||||
Cookie::class => create(Cookie::class)->constructor([ 'secure' => true, 'path' => getenv('URL_BASE') ?: '/', ], getenv("LEAN_RANDOM")),
|
||||
|
||||
Session::class => create(Session::class)->constructor(get(Cookie::class), [ 'path' => getenv('URL_BASE'), ]),
|
||||
Session::class => create(Session::class)->constructor(get(Cookie::class), [ 'path' => getenv('URL_BASE') ?: '/', ]),
|
||||
|
||||
SessionMiddleware::class => create(SessionMiddleware::class)->constructor(get(Cookie::class), [ 'path' => getenv('URL_BASE'), 'name' => "lean_sess_" . substr(md5(getenv("LEAN_RANDOM")), 0, 12) ]),
|
||||
SessionMiddleware::class => create(SessionMiddleware::class)->constructor(get(Cookie::class), [ 'name' => "lean_sess_" . substr(md5(getenv("LEAN_RANDOM")), 0, 12), 'path' => getenv('URL_BASE') ?: '/' ]),
|
||||
|
||||
'git.commit' => function($c) {
|
||||
if ( getenv("DEBUG") ) {
|
||||
@@ -104,10 +96,12 @@ return [
|
||||
$file = explode(": ", $currentBranch)[1];
|
||||
$path = $gitdir . str_replace("/", DIRECTORY_SEPARATOR, trim($file, " \t\n\r"));
|
||||
|
||||
return trim(file_get_contents($path), " \t\n\r");
|
||||
return file_exists($path) ? trim(file_get_contents($path), " \t\n\r") : null;
|
||||
}
|
||||
}
|
||||
|
||||
return "gitless-project";
|
||||
},
|
||||
|
||||
Kash\CacheInvalidator::class => create(Kash\CacheInvalidator::class)->constructor(getenv('CACHE_PATH')."/version.cache", (bool) getenv('DEBUG')),
|
||||
];
|
||||
@@ -0,0 +1,19 @@
|
||||
<?php
|
||||
|
||||
use Psr\Container\ContainerInterface;
|
||||
|
||||
use Ulmus\ConnectionAdapter,
|
||||
Ulmus\Container\AdapterProxy;
|
||||
|
||||
use Storage\Session;
|
||||
|
||||
use function DI\autowire, DI\create, DI\get;
|
||||
|
||||
return [
|
||||
'lean:adapter.sqlite' => function($c) {
|
||||
$adapter = new ConnectionAdapter('sqlite', $c->get('config')['ulmus'], true);
|
||||
$adapter->resolveConfiguration();
|
||||
|
||||
return $adapter;
|
||||
}
|
||||
];
|
||||
@@ -2,53 +2,32 @@
|
||||
|
||||
use function DI\autowire, DI\create, DI\get;
|
||||
|
||||
use Zend\Diactoros\Response\HtmlResponse;
|
||||
use Picea\{
|
||||
Language\LanguageRegistration,
|
||||
Caching\Cache,
|
||||
Caching\Opcache,
|
||||
Compiler,
|
||||
Compiler\Context,
|
||||
Compiler\BaseContext,
|
||||
FileFetcher,
|
||||
Method\Request};
|
||||
|
||||
use Picea\Picea,
|
||||
Picea\Caching\Cache,
|
||||
Picea\Caching\Opcache,
|
||||
Picea\Compiler,
|
||||
Picea\Compiler\Context,
|
||||
Picea\Compiler\BaseContext,
|
||||
Picea\Extension\LanguageHandler,
|
||||
Picea\Extension\LanguageExtension,
|
||||
Picea\Extension\TitleExtension,
|
||||
Picea\Extension\UrlExtension,
|
||||
Picea\FileFetcher,
|
||||
Picea\Language\DefaultRegistrations,
|
||||
Picea\Method\Request,
|
||||
Picea\Ui\Method,
|
||||
Picea\Ui\Ui;
|
||||
use Picea\Extension\{ LanguageHandlerInterface, LanguageExtension, TitleExtension, NumberExtension, UrlExtension };
|
||||
|
||||
use Picea\Ui\{ Method, Ui };
|
||||
|
||||
return [
|
||||
Picea::class => function($c) {
|
||||
return new Picea(function($html) {
|
||||
return new HtmlResponse( $html );
|
||||
}, $c->get(Context::class), $c->get(Cache::class), $c->get(Compiler::class), null, $c->get(FileFetcher::class), null, getenv("DEBUG"));
|
||||
Picea\Picea::class => function($c) {
|
||||
return new Picea\Picea($c->get(Context::class), $c->get(Cache::class), $c->get(Compiler::class), null, $c->get(FileFetcher::class), null, getenv("DEBUG"));
|
||||
},
|
||||
|
||||
Context::class => function($c) {
|
||||
return new BaseContext($c->get(Lean\Lean::class)->getPiceaContext());
|
||||
},
|
||||
|
||||
Compiler::class => function($c) {
|
||||
return new Compiler(new class(array_merge([
|
||||
$c->get(LanguageExtension::class),
|
||||
$c->get(TitleExtension::class),
|
||||
$c->get(UrlExtension::class),
|
||||
$c->get(Method\Form::class),
|
||||
$c->get(Method\Pagination::class),
|
||||
$c->get(Request::class),
|
||||
], array_map(fn($class) => $c->get($class), $c->get(Lean\Lean::class)->getPiceaExtensions() ))) extends DefaultRegistrations {
|
||||
Ui::class => autowire(Ui::class),
|
||||
|
||||
public function registerAll(Compiler $compiler) : void
|
||||
{
|
||||
parent::registerAll($compiler);
|
||||
( new Ui() )->registerFormExtension($compiler);
|
||||
}
|
||||
|
||||
});
|
||||
},
|
||||
Compiler::class => autowire(Compiler::class),
|
||||
|
||||
Request::class => autowire(Request::class),
|
||||
|
||||
@@ -56,26 +35,31 @@ return [
|
||||
|
||||
Method\Pagination::class => autowire(Method\Pagination::class),
|
||||
|
||||
LanguageExtension::class => create(LanguageExtension::class)->constructor(get(LanguageHandler::class)),
|
||||
LanguageExtension::class => create(LanguageExtension::class)->constructor(get(LanguageHandlerInterface::class)),
|
||||
|
||||
LanguageHandler::class => function($c) {
|
||||
return new class( $c->get(Tell\I18n::class) ) implements LanguageHandler {
|
||||
public Tell\I18n $tell;
|
||||
LanguageHandlerInterface::class => autowire(\Lean\LanguageHandler::class),
|
||||
|
||||
public function __construct(Tell\I18n $tell) {
|
||||
$this->tell = $tell;
|
||||
}
|
||||
LanguageRegistration::class => create(\Lean\PiceaDefaultRegistration::class)->constructor(get('picea.extensions'), [], [], get(Ui::class), null),
|
||||
|
||||
public function languageFromKey(string $key, array $variables = []) #: array|string
|
||||
{
|
||||
return $this->tell->fromKey($key, $variables) ?: "";
|
||||
}
|
||||
};
|
||||
'picea.extensions' => function(\Psr\Container\ContainerInterface $c) {
|
||||
return array_merge([
|
||||
$c->get(LanguageExtension::class),
|
||||
$c->get(TitleExtension::class),
|
||||
$c->get(NumberExtension::class),
|
||||
$c->get(UrlExtension::class),
|
||||
$c->get(Method\Form::class),
|
||||
$c->get(Method\Pagination::class),
|
||||
$c->get(Request::class),
|
||||
], class_exists(\Taxus\Picea\Extension::class) ? [ $c->get(\Taxus\Picea\Extension::class) ] : [],
|
||||
array_map(fn($class) => $c->get($class), $c->get(Lean\Lean::class)->getPiceaExtensions())
|
||||
);
|
||||
},
|
||||
|
||||
TitleExtension::class => autowire(TitleExtension::class),
|
||||
|
||||
UrlExtension::class => create(UrlExtension::class)->constructor(get(Context::class), getenv("URL_BASE"), get('git.commit')),
|
||||
NumberExtension::class => autowire(NumberExtension::class),
|
||||
|
||||
UrlExtension::class => create(UrlExtension::class)->constructor(getenv("URL_BASE"), get('git.commit'), explode(',', getenv('APP_URL')), (bool) getenv('FORCE_SSL')),
|
||||
|
||||
Cache::class => create(Opcache::class)->constructor(getenv("CACHE_PATH"), get(Context::class)),
|
||||
|
||||
|
||||
@@ -1,4 +1,10 @@
|
||||
{
|
||||
|
||||
"moment": {
|
||||
"today": "today",
|
||||
"week": "week"
|
||||
},
|
||||
|
||||
"month": {
|
||||
"list": [
|
||||
"January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "Décember"
|
||||
|
||||
@@ -1,4 +1,9 @@
|
||||
{
|
||||
"moment": {
|
||||
"today": "aujourd'hui",
|
||||
"week": "semaine"
|
||||
},
|
||||
|
||||
"month": {
|
||||
"list": [
|
||||
"Janvier", "Février", "Mars", "Avril", "Mai", "Juin", "Juillet", "Août", "Septembre", "Octobre", "Novembre", "Décembre"
|
||||
|
||||
@@ -14,7 +14,7 @@
|
||||
"back": "Revenir à la page précédente"
|
||||
},
|
||||
"500": {
|
||||
"title": "Une erreur semble s'être produite",
|
||||
"title": "Une erreur s'est produite",
|
||||
"page-title": "Une erreur semble s'être produite",
|
||||
"subtitle": "L'action que vous avez tenté d'effectué semble avoir échoué.",
|
||||
"message": "Un message d'erreur a été envoyé au développeur de cette application.",
|
||||
|
||||
+5
-13
@@ -1,11 +1,11 @@
|
||||
APP_ENV = dev
|
||||
DEBUG = 1
|
||||
KEYS = "dev:dev"
|
||||
KEYS = "dev"
|
||||
CRON_KEY = dev
|
||||
|
||||
# Route
|
||||
URL_BASE = ""
|
||||
APP_URL = "dev.cslsj.qc.ca"
|
||||
APP_URL = "dev.mcnd.ca"
|
||||
|
||||
# Path
|
||||
CACHE_DIR = "var/cache"
|
||||
@@ -13,6 +13,7 @@ META_DIR = "meta"
|
||||
LOGS_DIR = "var/logs"
|
||||
PUBLIC_DIR = "public"
|
||||
PRIVATE_DIR = "private"
|
||||
TMP_DIR = "var/tmp"
|
||||
VIEW_DIR = "view"
|
||||
I18N_DIR = "i18n"
|
||||
|
||||
@@ -21,18 +22,9 @@ DEFAULT_LOCAL = "fr_CA.UTF-8"
|
||||
DEFAULT_TIME = "fr.UTF-8"
|
||||
DEFAULT_TIME_FALLBACK = "french.UTF-8"
|
||||
|
||||
# MS Authentication
|
||||
# MS_OAUTH_CLIENT_ID = ""
|
||||
# MS_OAUTH_CLIENT_SECRET = ""
|
||||
|
||||
# MS Graph
|
||||
# MS_GRAPH_CLIENT_ID = ""
|
||||
# MS_GRAPH_CLIENT_SECRET = ""
|
||||
# MS_GRAPH_ACCESS_TOKEN_URL = ""
|
||||
|
||||
# Database
|
||||
DATABASE_PORT = "3306"
|
||||
DATABASE_HOST = "appsdb.cslsj.qc.ca"
|
||||
DATABASE_PORT = ""
|
||||
DATABASE_HOST = ""
|
||||
DATABASE_NAME = ""
|
||||
DATABASE_USERNAME = ""
|
||||
DATABASE_PASSWORD = ""
|
||||
|
||||
Executable
+9
@@ -0,0 +1,9 @@
|
||||
#!/bin/php
|
||||
<?php
|
||||
|
||||
try {
|
||||
require_once(__DIR__."/src/Kernel.php");
|
||||
}
|
||||
catch(\Throwable $t) {
|
||||
echo sprintf("%s [ %s ]" , $t->getMessage(), var_export($t->getTrace(), true));
|
||||
}
|
||||
@@ -10,12 +10,7 @@ return [
|
||||
],
|
||||
|
||||
'keys' => (function() {
|
||||
foreach(explode(',', getenv('KEYS') ?? "") as $item) {
|
||||
list($var, $value) = explode(":", trim($item));
|
||||
$list[$var] = $value;
|
||||
}
|
||||
|
||||
return $list;
|
||||
return explode(',', getenv('KEYS') ?? "") ;
|
||||
})(),
|
||||
|
||||
'meta' => [
|
||||
@@ -35,6 +30,18 @@ return [
|
||||
'charset' => getenv("DATABASE_CHARSET"),
|
||||
],
|
||||
],
|
||||
|
||||
'sqlite' => [
|
||||
'adapter' => getenv("SQLITE_ADAPTER"),
|
||||
'path' => getenv('PROJECT_PATH') . DIRECTORY_SEPARATOR . getenv("SQLITE_PATH"),
|
||||
'pragma' => explode(',', getenv("SQLITE_PRAGMA")),
|
||||
'pragma_begin' => array_merge(
|
||||
explode(',', getenv("SQLITE_PRAGMA_BEGIN")), explode(',', getenv('DEBUG') ? getenv("SQLITE_PRAGMA_DEBUG_BEGIN") : "")
|
||||
),
|
||||
'pragma_close' => array_merge(
|
||||
explode(',', getenv("SQLITE_PRAGMA_CLOSE")), explode(',', getenv('DEBUG') ? getenv("SQLITE_PRAGMA_DEBUG_CLOSE") : "")
|
||||
),
|
||||
],
|
||||
]
|
||||
]
|
||||
];
|
||||
@@ -4,6 +4,8 @@ use function DI\autowire, DI\create, DI\get;
|
||||
|
||||
use %NAMESPACE%\Entity;
|
||||
|
||||
use Psr\Http\Message\ServerRequestInterface;
|
||||
|
||||
use Ulmus\Entity\Field\Datetime,
|
||||
Ulmus\User\Lib\Authenticate;
|
||||
|
||||
@@ -17,30 +19,18 @@ use Picea\Picea;
|
||||
|
||||
use TheBugs\Email\{ EmailConfiguration, MailerInterface, SwiftMailer };
|
||||
|
||||
use Taxus\Taxus;
|
||||
use Taxus\{ Taxus, PermissionGrantInterface };
|
||||
|
||||
return [
|
||||
Entity\User::class => autowire(Entity\User::class),
|
||||
|
||||
Authenticate::class => create(Authenticate::class)->constructor(get(Session::class), get(Cookie::class), get('authentication.method')),
|
||||
\Ulmus\User\Entity\UserInterface::class => autowire(Entity\User::class),
|
||||
|
||||
SecurityHandler::class => create(SecurityHandler::class)->constructor(function() {
|
||||
return new RedirectResponse(getenv("URL_BASE")."/connexion");
|
||||
return Lean\Factory\HttpFactory::createRedirectResponse(getenv("URL_BASE")."/login");
|
||||
}, get('authentication.unauthorize'), get(Taxus::class)),
|
||||
|
||||
'authentication.error' => function($c, Picea $picea) {
|
||||
return function($message) use ($picea) {
|
||||
return new HtmlResponse($picea->renderHtml('lean/error/500', [
|
||||
'title' => "",
|
||||
'subtitle' => "",
|
||||
'message' => $message,
|
||||
]));
|
||||
};
|
||||
},
|
||||
|
||||
'authentication.unauthorize' => function($c, Picea $picea) {
|
||||
return function($message) use ($picea) {
|
||||
return new HtmlResponse($picea->renderHtml('lean/error/401', [
|
||||
return Lean\Factory\HttpFactory::createHtmlResponse($picea->renderHtml('lean/error/401', [
|
||||
'title' => "",
|
||||
'subtitle' => "",
|
||||
'message' => $message,
|
||||
@@ -50,7 +40,7 @@ return [
|
||||
|
||||
EmailConfiguration::class => function($c) {
|
||||
$email = new EmailConfiguration( EmailConfiguration::AUTH_TYPE_SMTP );
|
||||
$email->smtpHost = getenv('SMTP_HOST');
|
||||
$email->smtpHost = getenv('SMTP_HOSTNAME');
|
||||
$email->smtpPort = getenv('SMTP_PORT');
|
||||
$email->smtpUsername = getenv('SMTP_USERNAME');
|
||||
$email->smtpPassword = getenv('SMTP_PASSWORD');
|
||||
@@ -61,6 +51,4 @@ return [
|
||||
|
||||
return $email;
|
||||
},
|
||||
|
||||
PermissionGrantInterface::class => create(%NAMESPACE%\PrivilegeGrantAccess::class)->constructor(get(ServerRequestInterface::class), get(Session::class)),
|
||||
];
|
||||
@@ -7,15 +7,14 @@ $dir = getenv("META_PATH") . "/definitions";
|
||||
return array_merge(
|
||||
Lean\Lean::definitions(),
|
||||
|
||||
Lean\Console\Lean::definitions(),
|
||||
Lean\Lean::autoloadDefinitionsFromComposerExtra(),
|
||||
|
||||
[
|
||||
'%APPKEY%' => [
|
||||
'picea' => [
|
||||
'context' => "%ESCAPED_NAMESPACE%\\View",
|
||||
|
||||
'extensions' => [
|
||||
],
|
||||
'asset' => [],
|
||||
'extensions' => [],
|
||||
|
||||
],
|
||||
|
||||
@@ -26,11 +25,33 @@ return array_merge(
|
||||
'routes' => [
|
||||
'%ESCAPED_NAMESPACE%\\Controller' => getenv("PROJECT_PATH") . '/src/Controller/',
|
||||
],
|
||||
|
||||
'events' => [
|
||||
'%ESCAPED_NAMESPACE%\\Controller' => implode(DIRECTORY_SEPARATOR, [ getenv("PROJECT_PATH"), 'src', 'Controller', '' ]),
|
||||
],
|
||||
|
||||
'cronard' => [
|
||||
'%ESCAPED_NAMESPACE%\\Controller' => implode(DIRECTORY_SEPARATOR, [ getenv("PROJECT_PATH"), 'src', 'Controller', '' ]),
|
||||
],
|
||||
|
||||
'cli' => [
|
||||
'%ESCAPED_NAMESPACE%\\Controller' => implode(DIRECTORY_SEPARATOR, [ getenv("PROJECT_PATH"), 'src', 'Controller', '' ]),
|
||||
],
|
||||
],
|
||||
|
||||
'app.middlewares' => [],
|
||||
],
|
||||
|
||||
require("$dir/auth.php"),
|
||||
require("$dir/storage.php"),
|
||||
require("$dir/security.php"),
|
||||
require("$dir/env/" . getenv('APP_ENV') . ".php"),
|
||||
[ 'config' => function () { return require(getenv("META_PATH")."/config.php"); } ]
|
||||
[
|
||||
'config' => function () {
|
||||
return array_merge_recursive(
|
||||
Lean\Lean::autoloadConfigFromComposerExtra(),
|
||||
require(getenv("META_PATH")."/config.php")
|
||||
);
|
||||
}
|
||||
]
|
||||
);
|
||||
+6
@@ -11,4 +11,10 @@ if ($_GET['sql'] ?? false) {
|
||||
return [
|
||||
"dump" => create(DumpMiddleware::class),
|
||||
"errorHandler" => create(Middlewares\Whoops::class),
|
||||
'routes.caching' => create(Kash\ArrayCache::class)->constructor(get(Kash\CacheInvalidator::class), "lean.routes", 30),
|
||||
'breadcrumbs.caching' => create(Kash\ArrayCache::class)->constructor( get(Kash\CacheInvalidator::class), "lean.breadcrumbs", 30),
|
||||
'ulmus.caching' => create(Kash\ArrayCache::class)->constructor( get(Kash\CacheInvalidator::class), "ulmus.entities", 30),
|
||||
'cronard.caching' => create(Kash\ArrayCache::class)->constructor( get(Kash\CacheInvalidator::class), "lean.cronards", 30),
|
||||
'events.caching' => create(Kash\ArrayCache::class)->constructor( get(Kash\CacheInvalidator::class), "lean.events", 30),
|
||||
'cli.caching' => create(Kash\ArrayCache::class)->constructor( get(Kash\CacheInvalidator::class), "lean.cli", 30),
|
||||
];
|
||||
+14
-3
@@ -2,7 +2,7 @@
|
||||
|
||||
use Picea\Picea;
|
||||
|
||||
use CSLSJ\Debogueur\DebogueurMiddleware;
|
||||
use Negundo\Client\{ NegundoMiddleware, SoftwareConfig };
|
||||
|
||||
use Laminas\Diactoros\Response\HtmlResponse;
|
||||
|
||||
@@ -27,16 +27,27 @@ return [
|
||||
};
|
||||
},
|
||||
|
||||
"errorHandler" => create(DebogueurMiddleware::class)->constructor(getenv('DEBOGUEUR_HASH') ?: "", null, get('app.errorhandler.html')),
|
||||
SoftwareConfig::class => create(SoftwareConfig::class)->constructor(getenv('NEGUNDO_HASH'), getenv('NEGUNDO_SERVER')),
|
||||
|
||||
"errorHandler" => create(NegundoMiddleware::class)->constructor(get(SoftwareConfig::class), null, get('app.errorhandler.html')),
|
||||
|
||||
'app.errorhandler.html' => function($c, Picea $picea) {
|
||||
return function(\Throwable $exception) use ($picea) {
|
||||
error_log($exception->getMessage());
|
||||
|
||||
return new HtmlResponse($picea->renderHtml('lean/error/500', [
|
||||
'title' => "Une erreur s'est produite lors de l'exécution du script.",
|
||||
'subtitle' => "Êtes-vous connecté avec le bon compte ?",
|
||||
'message' => $exception->getMessage(),
|
||||
'exception' => $exception,
|
||||
]));
|
||||
]), 500);
|
||||
};
|
||||
},
|
||||
|
||||
'routes.caching' => create(Kash\ApcuCache::class)->constructor(get(Kash\CacheInvalidator::class), "lean.routes", random_int(3600, 7200)),
|
||||
'breadcrumbs.caching' => create(Kash\ApcuCache::class)->constructor(get(Kash\CacheInvalidator::class), "lean.breadcrumbs", random_int(3600, 7200)),
|
||||
'ulmus.caching' => create(Kash\ApcuCache::class)->constructor( get(Kash\CacheInvalidator::class), "ulmus.entities", random_int(3600, 7200)),
|
||||
'cronard.caching' => create(Kash\ApcuCache::class)->constructor( get(Kash\CacheInvalidator::class), "lean.cronards", random_int(3600, 7200)),
|
||||
'events.caching' => create(Kash\ApcuCache::class)->constructor( get(Kash\CacheInvalidator::class), "lean.events", random_int(3600, 7200)),
|
||||
'cli.caching' => create(Kash\ApcuCache::class)->constructor( get(Kash\CacheInvalidator::class), "lean.cli", random_int(3600, 7200)),
|
||||
];
|
||||
@@ -0,0 +1,22 @@
|
||||
<?php
|
||||
|
||||
use Storage\Session;
|
||||
|
||||
use Taxus\{ Privilege, Taxus, PermissionGrantInterface, DefaultPermissionGrant };
|
||||
|
||||
use Psr\Http\Message\ServerRequestInterface;
|
||||
|
||||
use function DI\autowire, DI\create, DI\get;
|
||||
|
||||
return [
|
||||
Taxus::class => function ($c) {
|
||||
return ( new Taxus( $c->get(PermissionGrantInterface::class) ) )->add(
|
||||
[ new Privilege("dev", "Is a developper of this application."), "is_dev" ],
|
||||
[ new Privilege("admin", "Can manage mostly everything from this application."), "is_admin" ],
|
||||
[ new Privilege("user", "Is an authenticated user."), "is_user" ],
|
||||
[ new Privilege("anonymous", "Is an anonymous (unauthenticated) user."), "is_anonymous" ],
|
||||
);
|
||||
},
|
||||
|
||||
PermissionGrantInterface::class => create(%NAMESPACE%\PrivilegeGrantAccess::class)->constructor(get(ServerRequestInterface::class), get(Session::class)),
|
||||
];
|
||||
@@ -14,8 +14,6 @@ return [
|
||||
$adapter = new ConnectionAdapter('default', $c->get('config')['ulmus'], true);
|
||||
$adapter->resolveConfiguration();
|
||||
|
||||
$adapter->connect();
|
||||
|
||||
return $adapter;
|
||||
},
|
||||
|
||||
|
||||
@@ -1,6 +1,10 @@
|
||||
<IfModule mod_rewrite.c>
|
||||
RewriteEngine On
|
||||
|
||||
# Force HTTPS (disabled by default)
|
||||
# RewriteCond %{HTTPS} off
|
||||
# RewriteRule ^(.*)$ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
|
||||
|
||||
# Remove trailing slashes from request URL
|
||||
RewriteCond %{REQUEST_FILENAME} !-d
|
||||
RewriteCond %{REQUEST_URI} (.+)/$
|
||||
|
||||
@@ -1,3 +1,8 @@
|
||||
<?php
|
||||
|
||||
try {
|
||||
require_once("../src/Kernel.php");
|
||||
}
|
||||
catch(\Throwable $t) {
|
||||
echo $t->getMessage();
|
||||
}
|
||||
@@ -4,19 +4,16 @@ namespace %NAMESPACE%\Controller;
|
||||
|
||||
use Psr\Http\Message\{ServerRequestInterface, ResponseInterface };
|
||||
|
||||
use Notes\Route\Attribute\Method\Route;
|
||||
|
||||
use %NAMESPACE%\{ Lib, Entity, Form, };
|
||||
|
||||
use function %NAMESPACE%\View\{ _, lang, url, route, form };
|
||||
|
||||
/**
|
||||
* @Language("%APPKEY%.home")
|
||||
*/
|
||||
class Home {
|
||||
use Lib\ControllerTrait;
|
||||
|
||||
/**
|
||||
* @Route("/", "name" => "home")
|
||||
*/
|
||||
#[Route("/", name: "home")]
|
||||
public function index(ServerRequestInterface $request, array $arguments) : ResponseInterface
|
||||
{
|
||||
form(new Form\Form(), $this->pushContext(new Lib\FormContext($request, "form.name")));
|
||||
|
||||
@@ -3,12 +3,11 @@
|
||||
namespace %NAMESPACE%\Entity;
|
||||
|
||||
use Ulmus\Entity\Field\Datetime;
|
||||
use Ulmus\{Attribute\Obj\Table};
|
||||
|
||||
use %NAMESPACE%\Lib;
|
||||
|
||||
/**
|
||||
* @Table('name' => "user")
|
||||
*/
|
||||
#[Table(name: "user")]
|
||||
class User extends \Ulmus\User\Entity\User implements \JsonSerializable
|
||||
{
|
||||
use Lib\EntityTrait;
|
||||
|
||||
@@ -23,7 +23,7 @@ class Form implements \Picea\Ui\Method\FormInterface {
|
||||
|
||||
public function execute(FormContextInterface $context) : void
|
||||
{
|
||||
$context->pushMessage(Message::generateSuccess(
|
||||
$context->pushMessage(Lib\Message::generateSuccess(
|
||||
lang("form.success")
|
||||
));
|
||||
}
|
||||
|
||||
@@ -14,6 +14,7 @@ new class(dirname(__DIR__)) extends \Lean\Kernel {
|
||||
'META_PATH' => "META_DIR",
|
||||
'PUBLIC_PATH' => "PUBLIC_DIR",
|
||||
'PRIVATE_PATH' => "PRIVATE_DIR",
|
||||
'TMP_PATH' => "TMP_DIR",
|
||||
'VIEW_PATH' => "VIEW_DIR",
|
||||
];
|
||||
|
||||
@@ -28,8 +29,6 @@ new class(dirname(__DIR__)) extends \Lean\Kernel {
|
||||
|
||||
protected function serviceContainer() : self
|
||||
{
|
||||
# $this->container->get(ConnectionAdapter::class);
|
||||
|
||||
return parent::serviceContainer();
|
||||
}
|
||||
|
||||
|
||||
@@ -5,29 +5,33 @@ namespace %NAMESPACE%\Lib;
|
||||
use Picea\Picea;
|
||||
use Storage\Session;
|
||||
use Ulmus\User\Entity\User;
|
||||
use Ulmus\User\Lib\Authenticate;
|
||||
use %NAMESPACE%\Entity;
|
||||
use Notes\Route\Attribute\Object\Route;
|
||||
use Notes\Security\Attribute\Security;
|
||||
|
||||
/**
|
||||
* @Security("locked" => false)
|
||||
* @RouteParam("methods" => [ "GET", "POST" ])
|
||||
*/
|
||||
use %NAMESPACE%\{ Entity, Lib, Form };
|
||||
|
||||
use Mcnd\Event\EventManager;
|
||||
use Ulmus\User\Entity\UserInterface;
|
||||
|
||||
#[Security(locked: false)]
|
||||
#[Route(method: ['GET', 'POST', ])]
|
||||
trait ControllerTrait {
|
||||
use \Lean\ControllerTrait;
|
||||
|
||||
public ? \Ulmus\User\Entity\User $user;
|
||||
public ? UserInterface $user;
|
||||
|
||||
protected Authenticate $authenticate;
|
||||
protected EventManager $eventManager;
|
||||
|
||||
public function __construct(Picea $picea, Session $session, Authenticate $authenticate) {
|
||||
$this->initializeController($picea, $session, $authenticate);
|
||||
public function __construct(Picea $picea, Session $session, UserInterface $user, \Notes\Breadcrumb\Breadcrumb $breadcrumb, EventManager $eventManager) {
|
||||
$this->initializeController($picea, $session, $user, $breadcrumb, $eventManager);
|
||||
}
|
||||
|
||||
public function initializeController(Picea $picea, Session $session, Authenticate $authenticate) {
|
||||
public function initializeController(Picea $picea, Session $session, UserInterface $user, \Notes\Breadcrumb\Breadcrumb $breadcrumb, EventManager $eventManager) {
|
||||
$this->picea = $picea;
|
||||
$this->authenticate = $authenticate;
|
||||
$this->session = $session;
|
||||
$this->user = $authenticate->rememberMe( Entity\User::repository() ) ?: new Entity\User();
|
||||
$this->eventManager = $eventManager;
|
||||
$this->breadcrumb = $breadcrumb;
|
||||
$this->user = $user;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -2,11 +2,8 @@
|
||||
|
||||
namespace %NAMESPACE%\Middleware;
|
||||
|
||||
use Psr\Http\Server\MiddlewareInterface;
|
||||
use Psr\Http\Message\ServerRequestInterface;
|
||||
use Psr\Http\Server\RequestHandlerInterface;
|
||||
use Psr\Http\Message\ResponseInterface;
|
||||
|
||||
use Psr\Http\Server\{ RequestHandlerInterface, MiddlewareInterface };
|
||||
use Psr\Http\Message\{ ResponseInterface, ServerRequestInterface };
|
||||
use Storage\Session;
|
||||
|
||||
class Authentication implements MiddlewareInterface {
|
||||
@@ -23,13 +20,6 @@ class Authentication implements MiddlewareInterface {
|
||||
$this->session = $session;
|
||||
}
|
||||
|
||||
/**
|
||||
* Middleware request handling
|
||||
*
|
||||
* @param ServerRequestInterface $request
|
||||
* @param RequestHandlerInterface $handler
|
||||
* @return ResponseInterface
|
||||
*/
|
||||
public function process(ServerRequestInterface $request, RequestHandlerInterface $handler) : ResponseInterface
|
||||
{
|
||||
$user = $this->session->get( $this->sessionUserVariable() );
|
||||
@@ -41,12 +31,6 @@ class Authentication implements MiddlewareInterface {
|
||||
return $handler->handle($request);
|
||||
}
|
||||
|
||||
/**
|
||||
* Getter / setter of Session User Variable
|
||||
*
|
||||
* @param string|null sessionUserVariable
|
||||
* @return mixed
|
||||
*/
|
||||
public function sessionUserVariable(?string $set = null) : string
|
||||
{
|
||||
return $set !== null ? $this->sessionUserVariable = $set : $this->sessionUserVariable;
|
||||
|
||||
@@ -25,7 +25,7 @@ class PrivilegeGrantAccess implements PermissionGrantInterface {
|
||||
*/
|
||||
public function is_dev() : bool
|
||||
{
|
||||
return false;
|
||||
return getenv('DEBUG');
|
||||
}
|
||||
|
||||
public function is_admin(User $user) : bool
|
||||
|
||||
Whitespace-only changes.
@@ -5,28 +5,6 @@
|
||||
<meta charset="UTF-8" />
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no">
|
||||
<title>{% section "head.title" %}{{ title() }} — {{ lang('application_name') }}{% endsection %}</title>
|
||||
<link rel="stylesheet" href="{% asset 'static/css/main.e39066da.css' %}">
|
||||
<style>
|
||||
@font-face{
|
||||
font-family:FontAwesome;
|
||||
src:url({% asset 'static/fonts/fontawesome-webfont.674f50d2.eot' %});
|
||||
src:url({% asset 'static/fonts/fontawesome-webfont.674f50d2.eot' %}) format("embedded-opentype"),
|
||||
url({% asset 'static/fonts/fontawesome-webfont.af7ae505.woff2' %}) format("woff2"),
|
||||
url({% asset 'static/fonts/fontawesome-webfont.fee66e71.woff' %}) format("woff"),
|
||||
url({% asset 'static/fonts/fontawesome-webfont.b06871f2.ttf' %}) format("truetype"),
|
||||
url({% asset 'static/images/fontawesome-webfont.912ec66d.svg' %}) format("svg");
|
||||
font-weight:400;
|
||||
font-style:normal;
|
||||
}
|
||||
</style>
|
||||
|
||||
<link rel="apple-touch-icon" sizes="180x180" href="{% asset 'static/favicon/apple-touch-icon.png' %}">
|
||||
<link rel="icon" type="image/png" sizes="32x32" href="{% asset 'static/favicon/favicon-32x32.png' %}">
|
||||
<link rel="icon" type="image/png" sizes="16x16" href="{% asset 'static/favicon/favicon-16x16.png' %}">
|
||||
<link rel="manifest" href="{% asset 'static/favicon/site.webmanifest' %}">
|
||||
<link rel="mask-icon" href="{% asset 'static/favicon/safari-pinned-tab.svg' %}" color="#5bbad5">
|
||||
<meta name="msapplication-TileColor" content="#2d89ef">
|
||||
<meta name="theme-color" content="#ffffff">
|
||||
</head>
|
||||
{% endsection %}
|
||||
|
||||
|
||||
@@ -6,4 +6,8 @@
|
||||
<div class="main">
|
||||
Hello World :) !
|
||||
</div>
|
||||
|
||||
<div>
|
||||
<a href="{% route 'lean.console:home' %}">Accéder à la console LEAN</a>
|
||||
</div>
|
||||
{% endsection %}
|
||||
+29
-3
@@ -1,29 +1,43 @@
|
||||
<?php
|
||||
|
||||
|
||||
namespace Lean;
|
||||
|
||||
|
||||
class Application
|
||||
{
|
||||
public string $piceaContext;
|
||||
public string $name;
|
||||
|
||||
public /*string|array*/ $piceaContext;
|
||||
|
||||
public array $piceaExtensions;
|
||||
|
||||
public array $piceaAssets;
|
||||
|
||||
public array $views;
|
||||
|
||||
public array $routes;
|
||||
|
||||
public array $cli;
|
||||
|
||||
public array $cronard;
|
||||
|
||||
public array $entities;
|
||||
|
||||
public array $events;
|
||||
|
||||
public array $tellJson;
|
||||
|
||||
public array $tellPhp;
|
||||
|
||||
public array $data = [];
|
||||
|
||||
public function __construct(string $name) {
|
||||
$this->name = $name;
|
||||
}
|
||||
|
||||
public function fromArray(array $data) : self
|
||||
{
|
||||
$this->data = array_replace($this->data, $data);
|
||||
|
||||
if (is_array($picea = $data['picea'] ?? false)) {
|
||||
if ($picea['context'] ?? false ) {
|
||||
$this->piceaContext = $picea['context'];
|
||||
@@ -33,6 +47,10 @@ class Application
|
||||
$this->piceaExtensions = $picea['extensions'];
|
||||
}
|
||||
|
||||
if ($picea['asset'] ?? false ) {
|
||||
$this->piceaAssets = $picea['asset'];
|
||||
}
|
||||
|
||||
if ($picea['view'] ?? false) {
|
||||
$this->views = $picea['view'];
|
||||
}
|
||||
@@ -62,6 +80,14 @@ class Application
|
||||
$this->cronard = $data['cronard'];
|
||||
}
|
||||
|
||||
if (is_array($data['events'] ?? false)) {
|
||||
$this->events = $data['events'];
|
||||
}
|
||||
|
||||
if (is_array($data['cli'] ?? false)) {
|
||||
$this->cli = $data['cli'];
|
||||
}
|
||||
|
||||
return $this;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,61 @@
|
||||
<?php
|
||||
|
||||
namespace Lean;
|
||||
|
||||
use League\Route\Strategy;
|
||||
|
||||
use League\Route\Http\Exception\NotFoundException;
|
||||
use Picea\Asset\Asset;
|
||||
use Psr\Container\ContainerInterface;
|
||||
use Psr\Http\Message\ResponseInterface;
|
||||
use Psr\Http\Message\ServerRequestInterface;
|
||||
use Psr\Http\Server\MiddlewareInterface;
|
||||
use Picea\Picea;
|
||||
use Psr\Http\Server\RequestHandlerInterface;
|
||||
use function DI\get;
|
||||
|
||||
class ApplicationStrategy extends Strategy\ApplicationStrategy {
|
||||
|
||||
public const ASSET_TRIGGER_UPDATE = [
|
||||
"js", "mjs", "manifest", "webmanifest", "css", "png", "ico",
|
||||
"jpg", "jpeg", "gif", "webp", "woff", "woff2", "eot", "svg",
|
||||
"ttf"
|
||||
];
|
||||
|
||||
public function __construct(
|
||||
protected Picea $picea,
|
||||
protected ContainerInterface $di,
|
||||
) {}
|
||||
|
||||
public function getNotFoundDecorator(NotFoundException $exception): MiddlewareInterface
|
||||
{
|
||||
return new class($this->picea, $this->di) implements MiddlewareInterface {
|
||||
|
||||
public function __construct(
|
||||
protected Picea $picea,
|
||||
protected ContainerInterface $di,
|
||||
) { }
|
||||
|
||||
public function process(ServerRequestInterface $request, RequestHandlerInterface $handler): ResponseInterface
|
||||
{
|
||||
return $this->throw404($request);
|
||||
}
|
||||
|
||||
public function throw404(ServerRequestInterface $request) : ResponseInterface
|
||||
{
|
||||
if ( getenv('DEBUG') && $this->di->has(\Picea\Asset\Asset::class) ) {
|
||||
$params = $request->getServerParams();
|
||||
|
||||
$scpName = basename(explode('?', $params['REQUEST_URI'] ?? "", 2)[0]);
|
||||
list(, $ext) = array_pad(explode('.', $scpName), 2, null);
|
||||
|
||||
if ($ext && in_array($ext, ApplicationStrategy::ASSET_TRIGGER_UPDATE)) {
|
||||
$this->di->get(\Picea\Asset\Asset::class)->launchInstall();
|
||||
}
|
||||
}
|
||||
|
||||
return new \Laminas\Diactoros\Response\HtmlResponse($this->picea->renderHtml("lean/error/404", [], $this), 404);
|
||||
}
|
||||
};
|
||||
}
|
||||
}
|
||||
+43
-4
@@ -3,6 +3,7 @@
|
||||
namespace Lean;
|
||||
|
||||
use Composer\EventDispatcher\Event;
|
||||
use Kash\CacheInvalidator;
|
||||
|
||||
class Composer
|
||||
{
|
||||
@@ -48,6 +49,8 @@ class Composer
|
||||
rmdir($dest);
|
||||
|
||||
$event->getIO()->write("Installation completed.");
|
||||
|
||||
static::postUpdate($event);
|
||||
}
|
||||
else {
|
||||
$event->getIO()->writeError(sprintf("The user you are running this script with doesn't seem to have a writable permission on directory %s", static::createPath()));
|
||||
@@ -55,16 +58,52 @@ class Composer
|
||||
}
|
||||
}
|
||||
|
||||
protected static function readComposerJson(Event $event) : ? array
|
||||
public static function postUpdate(Event $event) : void
|
||||
{
|
||||
$event->getIO()->write("post-update script executing ...");
|
||||
|
||||
$path = static::createPath('var/cache/version.cache');
|
||||
|
||||
if ( is_writeable(dirname($path)) ) {
|
||||
$event->getIO()->write("regenerating cache file version to invalidate cache for path '$path'");
|
||||
|
||||
new CacheInvalidator($path, true);
|
||||
}
|
||||
|
||||
if ( file_exists($container = static::createPath('var/cache/di/CompiledContainer.php')) ) {
|
||||
unlink($container);
|
||||
}
|
||||
}
|
||||
|
||||
public static function readComposerLock() : false|array
|
||||
{
|
||||
static $content = null;
|
||||
|
||||
$path = static::createPath('composer.lock');
|
||||
|
||||
if (! file_exists($path) ) {
|
||||
throw new \UnexpectedValueException("Composer file 'composer.lock' could not be found within your project's root folder.");
|
||||
}
|
||||
|
||||
return $content ??= file_exists($path) ? json_decode(file_get_contents($path), true) : false;
|
||||
}
|
||||
|
||||
public static function readComposerJson() : false|array
|
||||
{
|
||||
static $content = null;
|
||||
|
||||
$path = static::createPath('composer.json');
|
||||
|
||||
return file_exists($path) ? json_decode(file_get_contents($path), true) : null;
|
||||
if (! file_exists($path) ) {
|
||||
throw new \UnexpectedValueException("Composer file 'composer.json' could not be found within your project's root folder.");
|
||||
}
|
||||
|
||||
return $content ??= file_exists($path) ? json_decode(file_get_contents($path), true) : false;
|
||||
}
|
||||
|
||||
protected static function getNamespaceFromAutoload(Event $event) : ? string
|
||||
{
|
||||
if ( null !== $composerJson = static::readComposerJson($event) ) {
|
||||
if ( false !== $composerJson = static::readComposerJson() ) {
|
||||
if ( $psr4 = $composerJson['autoload']['psr-4'] ?? false ) {
|
||||
foreach($psr4 as $ns => $directory) {
|
||||
if ($directory === 'src/') {
|
||||
@@ -87,6 +126,6 @@ class Composer
|
||||
|
||||
protected static function createPath(... $path) : string
|
||||
{
|
||||
return implode(DIRECTORY_SEPARATOR, array_merge([ $_SERVER['PWD'] ], $path));
|
||||
return implode(DIRECTORY_SEPARATOR, array_merge([ $_SERVER['PWD'] ?? getenv('PROJECT_PATH') ], $path));
|
||||
}
|
||||
}
|
||||
+80
-38
@@ -2,35 +2,22 @@
|
||||
|
||||
namespace Lean;
|
||||
|
||||
use CSLSJ\Common\RequestResponse\{ PdfResponse, ImageResponse, DownloadResponse };
|
||||
|
||||
use Picea,
|
||||
Picea\Ui\Method\FormContext;
|
||||
|
||||
use Psr\Http\Message\ServerRequestInterface;
|
||||
use Lean\Factory\HttpFactory;
|
||||
use Notes\Route\Attribute\Object\Route;
|
||||
use Notes\Security\Attribute\Security;
|
||||
use Picea, Picea\Ui\Method\FormContext;
|
||||
use TheBugs\Email\MailerInterface;
|
||||
use Storage\Session;
|
||||
|
||||
use Laminas\Diactoros\Response\{ HtmlResponse, TextResponse, RedirectResponse, JsonResponse, EmptyResponse };
|
||||
|
||||
use Ulmus\EntityCollection;
|
||||
|
||||
use Psr\Http\Message\ResponseInterface;
|
||||
|
||||
use TheBugs\Email\MailerInterface;
|
||||
|
||||
use Notes\Route\Annotation\Object\Route as RouteParam,
|
||||
Notes\Route\Annotation\Method\Route,
|
||||
Notes\Security\Annotation\Security,
|
||||
Notes\Security\Annotation\Taxus,
|
||||
Notes\Tell\Annotation\Language;
|
||||
use Psr\Http\Message\{ ServerRequestInterface, ResponseInterface };
|
||||
|
||||
use function file_get_contents;
|
||||
|
||||
/**
|
||||
* @Security("locked" => true)
|
||||
* @RouteParam("methods" => [ "GET", "POST", "DELETE" ])
|
||||
*/
|
||||
#[Security(locked: true)]
|
||||
#[Route(method: [ "GET", "POST", "DELETE" ])]
|
||||
trait ControllerTrait {
|
||||
public ? \Notes\Breadcrumb\Breadcrumb $breadcrumb;
|
||||
|
||||
public ? Session $session;
|
||||
|
||||
public ? Picea\Picea $picea;
|
||||
@@ -50,7 +37,11 @@ trait ControllerTrait {
|
||||
|
||||
public function renderRawView(string $view, ?array $variables = null) : string
|
||||
{
|
||||
return $this->picea->renderHtml($view, $variables ?? [], $this);
|
||||
if ( null === $content = $this->picea->renderHtml($view, $variables ?? [], $this) ) {
|
||||
throw new \RuntimeException("Picea's renderHtml() returned NULL as result ; an error occurred within your template `$view`.");
|
||||
}
|
||||
|
||||
return $content;
|
||||
}
|
||||
|
||||
public function renderView(string $view, ?array $variables = null) : ResponseInterface
|
||||
@@ -60,54 +51,93 @@ trait ControllerTrait {
|
||||
);
|
||||
}
|
||||
|
||||
public function renderError(string $errorCode, ?array $variables = null) : ResponseInterface
|
||||
{
|
||||
return static::renderHtml(
|
||||
$this->renderRawView("lean/error/{$errorCode}", $variables ?? [])
|
||||
);
|
||||
}
|
||||
|
||||
public function renderDocumentation(string $filename) : ResponseInterface
|
||||
{
|
||||
return $this->renderMarkdown( file_get_contents(getenv("PROJECT_PATH") . "/meta/doc/$filename.md") );
|
||||
}
|
||||
|
||||
protected function redirect(string $url, int $code = 302, array $headers = []) {
|
||||
return new RedirectResponse($url, $code, $headers);
|
||||
return HttpFactory::createRedirectResponse($url, $code, $headers);
|
||||
}
|
||||
|
||||
public static function renderNothing(int $code = 204, array $headers = []) : ResponseInterface
|
||||
{
|
||||
return new EmptyResponse($code, $headers);
|
||||
return HttpFactory::createEmptyResponse($code, $headers);
|
||||
}
|
||||
|
||||
public static function renderText(string $text, int $code = 200, array $headers = []) : ResponseInterface
|
||||
{
|
||||
return new TextResponse($text, $code, $headers);
|
||||
return HttpFactory::createTextResponse($text, $code, $headers);
|
||||
}
|
||||
|
||||
public static function renderHtml(string $html, int $code = 200, array $headers = []) : ResponseInterface
|
||||
{
|
||||
return new HtmlResponse($html, $code, $headers);
|
||||
return HttpFactory::createHtmlResponse($html, $code, $headers);
|
||||
}
|
||||
|
||||
public static function renderJson(array $data, int $code = 200, array $headers = []) : ResponseInterface
|
||||
public static function renderJson(mixed $data, int $code = 200, array $headers = []) : ResponseInterface
|
||||
{
|
||||
return new JsonResponse($data, $code, $headers);
|
||||
return HttpFactory::createJsonResponse($data, $code, $headers);
|
||||
}
|
||||
|
||||
public function renderPdf($rawdata, int $status = 200, array $headers = []) : PdfResponse
|
||||
public function renderPdf($rawdata, int $status = 200, array $headers = []) : ResponseInterface
|
||||
{
|
||||
return new PdfResponse($rawdata, $status, $headers);
|
||||
return HttpFactory::createPdfResponse($rawdata, $status, $headers);
|
||||
}
|
||||
|
||||
public static function renderDownloadable(string $data, string $filename, int $code = 200, array $headers = []) : ResponseInterface
|
||||
{
|
||||
return new DownloadResponse($data, $filename, $code, $headers);
|
||||
return HttpFactory::createDownloadableResponse($data, $filename, $code, $headers);
|
||||
}
|
||||
|
||||
public static function renderImage(string $data, int $code = 200, array $headers = []) : ResponseInterface
|
||||
{
|
||||
return new ImageResponse($data, $code, $headers);
|
||||
return HttpFactory::createImageResponse($data, $code, $headers);
|
||||
}
|
||||
|
||||
public static function renderAsset(string $path, int $code = 200, array $headers = []) : ResponseInterface
|
||||
{
|
||||
return HttpFactory::createFileDownloadResponse($path, $code, $headers);
|
||||
}
|
||||
|
||||
public function renderMarkdown(string $filepath, int $code = 200, array $headers = []) : ResponseInterface
|
||||
{
|
||||
if ( ! class_exists(CommonMarkConverter::class)) {
|
||||
throw new \BadFunctionCallException("League\CommonMark seems to be missing, please install dependency before trying to render Markdown content");
|
||||
}
|
||||
|
||||
$markdown = ( new CommonMarkConverter() )->convertToHtml(file_get_contents($filepath));
|
||||
|
||||
return $this->renderView("docs", get_defined_vars());
|
||||
}
|
||||
|
||||
public function renderCLI(ServerRequestInterface $request, mixed $data) : ResponseInterface
|
||||
{
|
||||
if ($data instanceof \JsonSerializable ) {
|
||||
return $this->renderJson(
|
||||
$data
|
||||
);
|
||||
}
|
||||
elseif ( is_array($data) ) {
|
||||
var_export($data);
|
||||
}
|
||||
|
||||
return $this->renderText(
|
||||
$data . PHP_EOL
|
||||
);
|
||||
}
|
||||
|
||||
public function fromResponse(ResponseInterface $response)
|
||||
{
|
||||
if ( $response->getStatusCode() === 200 ) {
|
||||
if ( $response instanceof \Zend\Diactoros\Response\JsonResponse) {
|
||||
if ( $response instanceof \Laminas\Diactoros\Response\JsonResponse) {
|
||||
return $response->getPayload();
|
||||
}
|
||||
}
|
||||
@@ -142,7 +172,8 @@ trait ControllerTrait {
|
||||
return $this->picea->compiler->getExtensionFromToken('route')->buildRouteUrl($name, $parameters);
|
||||
}
|
||||
|
||||
public function json($data, int $flags = 0) {
|
||||
public function json($data, int $flags = 0) : string
|
||||
{
|
||||
return htmlentities(json_encode($data, $flags), ENT_QUOTES, 'UTF-8');
|
||||
}
|
||||
|
||||
@@ -153,8 +184,19 @@ trait ControllerTrait {
|
||||
return $context;
|
||||
}
|
||||
|
||||
public function context(string $name) : FormContext
|
||||
public function context(? string $name = null) : ? FormContext
|
||||
{
|
||||
return $this->contextList[$name];
|
||||
return $name ? $this->contextList[$name] : array_values($this->contextList)[0] ?? null;
|
||||
}
|
||||
|
||||
public function isRoute(mixed $name, ServerRequestInterface $request) : bool
|
||||
{
|
||||
foreach((array) $name as $item) {
|
||||
if ( fnmatch($item, $request->getAttribute('lean.route')->name) ) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,10 @@
|
||||
<?php
|
||||
|
||||
namespace Lean\Event;
|
||||
|
||||
use Lean\Routing;
|
||||
use Notes\Route\Attribute\Method\Route;
|
||||
|
||||
interface RoutingCompileRoutes {
|
||||
public function execute(Routing $routing, Route $attribute) : void;
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
<?php
|
||||
|
||||
namespace Lean\Event;
|
||||
|
||||
use Lean\Routing;
|
||||
use Notes\Route\Attribute\Method\Route;
|
||||
use Psr\Container\ContainerInterface;
|
||||
use Psr\Http\Message\{ ResponseInterface, ServerRequestInterface };
|
||||
|
||||
interface RoutingMapRoutes {
|
||||
public function execute(Routing $routing, ContainerInterface $container, ServerRequestInterface & $request, Route $attribute) : void;
|
||||
}
|
||||
@@ -0,0 +1,55 @@
|
||||
<?php
|
||||
|
||||
namespace Lean\Factory;
|
||||
|
||||
use Laminas\Diactoros\Response\{EmptyResponse, HtmlResponse, JsonResponse, RedirectResponse, TextResponse};
|
||||
use Lean\Response\{ DownloadResponse, ImageResponse, FileDownloadResponse, PdfResponse };
|
||||
use Psr\Http\Message\ResponseInterface;
|
||||
|
||||
class HttpFactory
|
||||
{
|
||||
public static function createRedirectResponse(string $url, int $code = 302, array $headers = []) : ResponseInterface
|
||||
{
|
||||
return new RedirectResponse($url, $code, $headers);
|
||||
}
|
||||
|
||||
public static function createHtmlResponse(string $html, int $code = 200, array $headers = []) : ResponseInterface
|
||||
{
|
||||
return new HtmlResponse($html, $code, $headers);
|
||||
}
|
||||
|
||||
public static function createTextResponse(string $text, int $code = 200, array $headers = []) : ResponseInterface
|
||||
{
|
||||
return new TextResponse($text, $code, $headers);
|
||||
}
|
||||
|
||||
public static function createJsonResponse(mixed $data, int $code = 200, array $headers = []) : ResponseInterface
|
||||
{
|
||||
return new JsonResponse($data, $code, $headers);
|
||||
}
|
||||
|
||||
public static function createEmptyResponse(int $code = 204, array $headers = []) : ResponseInterface
|
||||
{
|
||||
return new EmptyResponse($code, $headers);
|
||||
}
|
||||
|
||||
public static function createPdfResponse(\Stringable $binary, int $code = 200, array $headers = []) : ResponseInterface
|
||||
{
|
||||
return new PdfResponse((string) $binary, $code, $headers);
|
||||
}
|
||||
|
||||
public static function createDownloadableResponse(string $data, string $filename, int $code = 200, array $headers = []) : ResponseInterface
|
||||
{
|
||||
return new DownloadResponse($data, $filename, $code, $headers);
|
||||
}
|
||||
|
||||
public static function createImageResponse(string $data, int $code = 200, array $headers = []) : ResponseInterface
|
||||
{
|
||||
return new ImageResponse($data, $code, $headers);
|
||||
}
|
||||
|
||||
public static function createFileDownloadResponse(string $path, int $code = 200, array $headers = []) : ResponseInterface
|
||||
{
|
||||
return new FileDownloadResponse($path, $code, $headers);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,43 @@
|
||||
<?php
|
||||
|
||||
namespace Lean;
|
||||
|
||||
class File
|
||||
{
|
||||
public static function tail(string $path, int $lines = 10) : false|array
|
||||
{
|
||||
$handle = fopen($path, "r");
|
||||
|
||||
$counter = $lines;
|
||||
|
||||
$pos = -2;
|
||||
$beginning = false;
|
||||
$text = array();
|
||||
|
||||
while ($counter && ! $beginning) {
|
||||
$t = "";
|
||||
|
||||
while ($t !== PHP_EOL) {
|
||||
if(fseek($handle, $pos, SEEK_END) == -1) {
|
||||
$beginning = true;
|
||||
break;
|
||||
}
|
||||
|
||||
$t = fgetc($handle);
|
||||
$pos --;
|
||||
}
|
||||
|
||||
$counter --;
|
||||
|
||||
if ($beginning) {
|
||||
rewind($handle);
|
||||
}
|
||||
|
||||
$text[$lines - $counter - 1] = fgets($handle);
|
||||
}
|
||||
|
||||
fclose ($handle);
|
||||
|
||||
return array_reverse($text);
|
||||
}
|
||||
}
|
||||
+20
-6
@@ -14,8 +14,10 @@ use Psr\Http\Message\ServerRequestInterface;
|
||||
use Tell\I18n;
|
||||
use Ulmus\Container\AdapterProxy;
|
||||
|
||||
use Zend\Diactoros\ServerRequestFactory,
|
||||
Zend\HttpHandlerRunner\Emitter\EmitterInterface;
|
||||
use Laminas\Diactoros\ServerRequestFactory,
|
||||
Laminas\HttpHandlerRunner\Emitter\EmitterInterface;
|
||||
|
||||
use Ulmus\Ulmus;
|
||||
|
||||
class Kernel {
|
||||
|
||||
@@ -59,11 +61,13 @@ class Kernel {
|
||||
Dotenv::create(getenv("PROJECT_PATH"))->load();
|
||||
|
||||
// Override using headers
|
||||
if ( ( $keys = getenv('KEYS') ) && ( $auth = $_SERVER["HTTP_X_DEV_AUTH"] ?? null ) && in_array($auth, explode(',', $keys)) ) {
|
||||
foreach (['APP_ENV', 'DEBUG',] as $env) {
|
||||
if ( null !== $value = $_SERVER["HTTP_$env"] ?? null ) {
|
||||
if (null !== $value = $_SERVER["HTTP_X_$env"] ?? null) {
|
||||
static::putenv($env, $value);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Paths and directories
|
||||
foreach($this->paths as $name => $envkey) {
|
||||
@@ -106,12 +110,21 @@ class Kernel {
|
||||
|
||||
if (getenv("APP_ENV") === "prod") {
|
||||
if (getenv("CACHE_PATH")) {
|
||||
# $containerBuilder->enableCompilation(getenv("CACHE_PATH") . "/di/");
|
||||
# $containerBuilder->writeProxiesToFile(true);
|
||||
# check if ACPU is there first, $containerBuilder->enableDefinitionCache();
|
||||
|
||||
$containerBuilder->enableCompilation(getenv("CACHE_PATH") . "/di/");
|
||||
# No proxies yet... $containerBuilder->writeProxiesToFile(true, getenv("CACHE_PATH") . "/di/");
|
||||
}
|
||||
}
|
||||
else {
|
||||
$compiled = getenv("CACHE_PATH") . "/di/CompiledContainer.php";
|
||||
|
||||
if ( file_exists($compiled) ) {
|
||||
unlink($compiled);
|
||||
}
|
||||
}
|
||||
|
||||
$containerBuilder->useAnnotations(false);
|
||||
# $containerBuilder->useAnnotations(false);
|
||||
|
||||
if ($this->definitionFilePath ?? false) {
|
||||
$containerBuilder->addDefinitions(require($this->definitionFilePath));
|
||||
@@ -125,6 +138,7 @@ class Kernel {
|
||||
protected function serviceContainer() : self
|
||||
{
|
||||
$this->container->has(AdapterProxy::class) and $this->container->get(AdapterProxy::class);
|
||||
$this->container->has('ulmus.caching') and ( Ulmus::$cache = $this->container->get('ulmus.caching') );
|
||||
$this->container->has(Lean::class) and $this->container->get(Lean::class);
|
||||
|
||||
if ($this->container->has(I18n::class)) {
|
||||
|
||||
@@ -0,0 +1,18 @@
|
||||
<?php
|
||||
|
||||
namespace Lean;
|
||||
|
||||
use Picea\Extension\LanguageHandlerInterface;
|
||||
use Tell;
|
||||
|
||||
class LanguageHandler implements LanguageHandlerInterface {
|
||||
|
||||
public function __construct(
|
||||
public Tell\I18n $tell
|
||||
) {}
|
||||
|
||||
public function languageFromKey(string $key, array $variables = []) #: array|string
|
||||
{
|
||||
return $this->tell->fromKey($key, $variables) ?: "";
|
||||
}
|
||||
}
|
||||
+109
-5
@@ -30,7 +30,7 @@ class Lean
|
||||
|
||||
foreach(array_filter($list) as $application) {
|
||||
if ( $this->container->has($application) ) {
|
||||
$this->applications[] = ( new Application() )->fromArray($this->container->get($application));
|
||||
$this->applications[] = ( new Application($application) )->fromArray($this->container->get($application));
|
||||
}
|
||||
else {
|
||||
throw new \RuntimeException("Trying to load an application '$application' which have not been configured yet");
|
||||
@@ -38,7 +38,18 @@ class Lean
|
||||
}
|
||||
}
|
||||
|
||||
public function getPiceaContext() : string
|
||||
public function getApplication(string $name) : ? Application
|
||||
{
|
||||
foreach($this->applications as $app) {
|
||||
if ($app->name === $name) {
|
||||
return $app;
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
public function getPiceaContext() /*: string|array */
|
||||
{
|
||||
foreach(array_reverse($this->applications) as $apps) {
|
||||
if ( $apps->piceaContext ?? null ) {
|
||||
@@ -72,6 +83,21 @@ class Lean
|
||||
return array_merge(...array_map(fn($app) => $app->cronard ?? [], $this->applications));
|
||||
}
|
||||
|
||||
public function getCLI() : array
|
||||
{
|
||||
return array_merge(...array_map(fn($app) => $app->cli ?? [], $this->applications));
|
||||
}
|
||||
|
||||
public function getEvents() : array
|
||||
{
|
||||
return array_merge(...array_map(fn($app) => $app->events ?? [], $this->applications));
|
||||
}
|
||||
|
||||
public function getTaxusPrivileges() : array
|
||||
{
|
||||
return array_merge(...array_map(fn($app) => $app->taxus ?? [], $this->applications));
|
||||
}
|
||||
|
||||
public function getEntities() : array
|
||||
{
|
||||
return array_merge(...array_map(fn($app) => $app->entities ?? [], $this->applications));
|
||||
@@ -81,11 +107,33 @@ class Lean
|
||||
{
|
||||
$list = array_merge(...array_map(fn($app) => $app->views ?? [], $this->applications));
|
||||
|
||||
$this->verifyPathList($list);
|
||||
|
||||
uasort($list, fn($i1, $i2) => $i1['order'] <=> $i2['order'] );
|
||||
|
||||
return $list;
|
||||
}
|
||||
|
||||
public function getAssetPaths() : array
|
||||
{
|
||||
$list = array_merge(...array_map(fn($app) => $app->piceaAssets ?? [], $this->applications));
|
||||
|
||||
$this->verifyPathList($list);
|
||||
|
||||
uasort($list, fn($i1, $i2) => $i1['order'] <=> $i2['order'] );
|
||||
|
||||
return $list;
|
||||
}
|
||||
|
||||
protected function verifyPathList(array $list) : void
|
||||
{
|
||||
foreach($list as $item) {
|
||||
if (! isset($item['order']) ) {
|
||||
throw new \RuntimeException(sprintf("An error occured while verifying a path list (%s)", json_encode($item, \JSON_PRETTY_PRINT)));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public function getI18n(string $reader) : ? array
|
||||
{
|
||||
switch($reader) {
|
||||
@@ -109,16 +157,72 @@ class Lean
|
||||
|
||||
public static function definitions() : array
|
||||
{
|
||||
return [];
|
||||
|
||||
$path = dirname(__DIR__) . "/meta/definitions/";
|
||||
|
||||
return array_merge(
|
||||
return array_replace(
|
||||
require($path . "authorize.php"),
|
||||
class_exists(\Mcnd\CLI\CliMiddleware::class) ? require($path . "cli.php") : [],
|
||||
class_exists(\Cronard\CronardMiddleware::class) ? require($path . "cronard.php") : [],
|
||||
require($path . "email.php"),
|
||||
require($path . "event.php"),
|
||||
require($path . "http.php"),
|
||||
require($path . "language.php"),
|
||||
class_exists(\Negundo\Client\NegundoMiddleware::class) ? require($path . "negundo.php") : [],
|
||||
require($path . "routes.php"),
|
||||
require($path . "security.php"),
|
||||
require($path . "software.php"),
|
||||
require($path . "template.php"),
|
||||
require($path . "storage.php"),
|
||||
class_exists(\Picea\Picea::class) ? require($path . "template.php") : [],
|
||||
);
|
||||
}
|
||||
|
||||
public static function autoloadDefinitionsFromComposerExtra() : array
|
||||
{
|
||||
$list = [];
|
||||
|
||||
foreach(Composer::readComposerLock()['packages'] as $package) {
|
||||
foreach($package['extra']['lean']['autoload']['definitions'] ?? [] as $autoload) {
|
||||
$list = array_replace($list, static::loadFromPackage($package, $autoload));
|
||||
}
|
||||
}
|
||||
|
||||
return $list;
|
||||
}
|
||||
|
||||
public static function autoloadConfigFromComposerExtra() : array
|
||||
{
|
||||
$list = [];
|
||||
|
||||
foreach(Composer::readComposerLock()['packages'] as $package) {
|
||||
foreach($package['extra']['lean']['autoload']['config'] ?? [] as $autoload) {
|
||||
$list = array_merge_recursive($list, static::loadFromPackage($package, $autoload));
|
||||
}
|
||||
}
|
||||
|
||||
return $list;
|
||||
}
|
||||
|
||||
protected static function loadFromPackage(array $package, array|string $autoload) : false|array
|
||||
{
|
||||
$list = [];
|
||||
|
||||
if (is_string($autoload)) {
|
||||
$vendor = getenv('VENDOR_DIR') ? getenv('VENDOR_PATH') : dirname(__DIR__, 3);
|
||||
$file = $vendor . DIRECTORY_SEPARATOR . $package['name'] . DIRECTORY_SEPARATOR . $autoload;
|
||||
|
||||
if ( ! file_exists($file) ) {
|
||||
throw new \InvalidArgumentException(sprintf("Given autoload file `%s` from package `%s` was not found or is unreachable", $autoload, $package['name']));
|
||||
}
|
||||
|
||||
return require($file);
|
||||
}
|
||||
else {
|
||||
$func = implode('::', array_merge([ key($autoload) ], $autoload));
|
||||
|
||||
return call_user_func($func);
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,28 @@
|
||||
<?php
|
||||
|
||||
namespace Lean;
|
||||
|
||||
use Picea\Compiler;
|
||||
use Picea\Language\DefaultRegistrations;
|
||||
use Picea\{ Ui\Ui, Asset\Asset };
|
||||
|
||||
class PiceaDefaultRegistration extends DefaultRegistrations {
|
||||
|
||||
public function __construct(
|
||||
protected array $extensions,
|
||||
protected array $syntaxes,
|
||||
protected array $controlStructures,
|
||||
public null|Ui $ui,
|
||||
public null|Asset $asset,
|
||||
) {
|
||||
parent::__construct($this->extensions, $this->syntaxes, $this->controlStructures);
|
||||
}
|
||||
|
||||
public function registerAll(Compiler $compiler) : void
|
||||
{
|
||||
parent::registerAll($compiler);
|
||||
|
||||
$this->ui AND $this->ui->registerFormExtension($compiler);
|
||||
$this->asset AND $this->asset->registerExtension($compiler);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,80 @@
|
||||
<?php declare(strict_types=1);
|
||||
|
||||
namespace Lean\Response;
|
||||
|
||||
use function get_class, gettype, is_object, is_string, sprintfm, pathinfo, PATHINFO_EXTENSION;
|
||||
|
||||
use Psr\Http\Message\StreamInterface;
|
||||
|
||||
use Laminas\Diactoros\Exception,
|
||||
Laminas\Diactoros\Response,
|
||||
Laminas\Diactoros\Stream,
|
||||
Laminas\Diactoros\Response\InjectContentTypeTrait;
|
||||
|
||||
/**
|
||||
* PDF Response
|
||||
*
|
||||
* Allows creating a response by passing a string to the constructor;
|
||||
* by default, sets a status code of 200 and sets the Content-Type header to
|
||||
* application/pdf.
|
||||
*/
|
||||
class DownloadResponse extends Response
|
||||
{
|
||||
use InjectContentTypeTrait;
|
||||
|
||||
/**
|
||||
* Create a PDF response
|
||||
*
|
||||
* Produces a pdf response with a Content-Type of application/json and a default
|
||||
* status of 200.
|
||||
*
|
||||
* @param string|StreamInterface $content String or stream for the message body.
|
||||
* @param int $status Integer status code for the response; 200 by default.
|
||||
* @param array $headers Array of headers to use at initialization.
|
||||
* @throws Exception\InvalidArgumentException if $filepath is neither a string or stream.
|
||||
*/
|
||||
public function __construct(string $content, string $filename, int $status = 200, array $headers = [])
|
||||
{
|
||||
parent::__construct(
|
||||
$this->createBody($content),
|
||||
$status,
|
||||
$this->injectFilename($filename, $this->injectContentType("application/octet-stream", $headers))
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Inject the provided Content-Type, if none is already present.
|
||||
*
|
||||
* @return array Headers with injected Content-Type
|
||||
*/
|
||||
private function injectFilename(string $filename, array $headers) : array
|
||||
{
|
||||
$hasContentType = array_reduce(array_keys($headers), function ($carry, $item) {
|
||||
return $carry ?: (strtolower($item) === 'content-disposition');
|
||||
}, false);
|
||||
|
||||
if (! $hasContentType) {
|
||||
$headers['content-disposition'] = ['Content-Disposition:attachment; filename="' . $filename . '"'];
|
||||
}
|
||||
|
||||
return $headers;
|
||||
}
|
||||
|
||||
/**
|
||||
* Create the message body.
|
||||
*
|
||||
* @param string|StreamInterface $content
|
||||
* @throws Exception\InvalidArgumentException if $content is neither a string or stream.
|
||||
*/
|
||||
private function createBody(string $content) : StreamInterface
|
||||
{
|
||||
if ($content instanceof StreamInterface) {
|
||||
return $content;
|
||||
}
|
||||
|
||||
$body = new Stream('php://temp', 'wb+');
|
||||
$body->write($content);
|
||||
$body->rewind();
|
||||
return $body;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,86 @@
|
||||
<?php declare(strict_types=1);
|
||||
|
||||
namespace Lean\Response;
|
||||
|
||||
use function get_class, gettype, is_object, is_string, sprintfm, pathinfo, PATHINFO_EXTENSION;
|
||||
|
||||
use Psr\Http\Message\StreamInterface;
|
||||
|
||||
use Laminas\Diactoros\Exception,
|
||||
Laminas\Diactoros\Response,
|
||||
Laminas\Diactoros\Stream,
|
||||
Laminas\Diactoros\Response\InjectContentTypeTrait;
|
||||
|
||||
/**
|
||||
* PDF Response
|
||||
*
|
||||
* Allows creating a response by passing a string to the constructor;
|
||||
* by default, sets a status code of 200 and sets the Content-Type header to
|
||||
* application/pdf.
|
||||
*/
|
||||
class FileDownloadResponse extends Response
|
||||
{
|
||||
use InjectContentTypeTrait;
|
||||
|
||||
/**
|
||||
* Create a PDF response
|
||||
*
|
||||
* Produces a pdf response with a Content-Type of application/json and a default
|
||||
* status of 200.
|
||||
*
|
||||
* @param string|StreamInterface $filepath String or stream for the message body.
|
||||
* @param int $status Integer status code for the response; 200 by default.
|
||||
* @param array $headers Array of headers to use at initialization.
|
||||
* @throws Exception\InvalidArgumentException if $filepath is neither a string or stream.
|
||||
*/
|
||||
public function __construct($filepath, int $status = 200, array $headers = [])
|
||||
{
|
||||
$body = $this->createBody($filepath);
|
||||
|
||||
if (class_exists(\Mimey\MimeTypes::class)) {
|
||||
$mime = (new \Mimey\MimeTypes())->getMimeType(pathinfo($filepath, PATHINFO_EXTENSION));
|
||||
}
|
||||
else {
|
||||
$finfo = finfo_open(FILEINFO_MIME_TYPE);
|
||||
$mime = finfo_file($finfo, $filepath);
|
||||
finfo_close($finfo);
|
||||
}
|
||||
|
||||
parent::__construct(
|
||||
$body,
|
||||
$status,
|
||||
$this->injectContentType($mime, $headers)
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Create the message body.
|
||||
*
|
||||
* @param string|StreamInterface $filepath
|
||||
* @throws Exception\InvalidArgumentException if $filepath is neither a string or stream.
|
||||
*/
|
||||
private function createBody($filepath) : StreamInterface
|
||||
{
|
||||
if ($filepath instanceof StreamInterface) {
|
||||
return $filepath;
|
||||
}
|
||||
|
||||
if (! is_string($filepath)) {
|
||||
throw new Exception\InvalidArgumentException(sprintf(
|
||||
'Invalid content (%s) provided to %s',
|
||||
(is_object($filepath) ? get_class($filepath) : gettype($filepath)),
|
||||
__CLASS__
|
||||
));
|
||||
}
|
||||
|
||||
if ( ! file_exists($filepath) ) {
|
||||
throw new Exception\InvalidArgumentException("Given file (%s) do not look like a valid file path.", $filepath);
|
||||
}
|
||||
|
||||
if ( ! is_readable($filepath) ) {
|
||||
throw new Exception\InvalidArgumentException("Given file (%s) do not seem to be readable. This could indicate a permission problem", $filepath);
|
||||
}
|
||||
|
||||
return new Stream(fopen($filepath, "r"), 'r');
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,74 @@
|
||||
<?php declare(strict_types=1);
|
||||
|
||||
namespace Lean\Response;
|
||||
|
||||
use function get_class, gettype, is_object, is_string, sprintf;
|
||||
|
||||
use Psr\Http\Message\StreamInterface;
|
||||
|
||||
use Laminas\Diactoros\Exception,
|
||||
Laminas\Diactoros\Response,
|
||||
Laminas\Diactoros\Stream,
|
||||
Laminas\Diactoros\Response\InjectContentTypeTrait;
|
||||
|
||||
/**
|
||||
* PDF Response
|
||||
*
|
||||
* Allows creating a response by passing a string to the constructor;
|
||||
* by default, sets a status code of 200 and sets the Content-Type header to
|
||||
* application/pdf.
|
||||
*/
|
||||
class ImageResponse extends Response
|
||||
{
|
||||
use InjectContentTypeTrait;
|
||||
|
||||
/**
|
||||
* Create a PDF response
|
||||
*
|
||||
* Produces a pdf response with a Content-Type of application/json and a default
|
||||
* status of 200.
|
||||
*
|
||||
* @param string|StreamInterface $content String or stream for the message body.
|
||||
* @param int $status Integer status code for the response; 200 by default.
|
||||
* @param array $headers Array of headers to use at initialization.
|
||||
* @throws Exception\InvalidArgumentException if $content is neither a string or stream.
|
||||
*/
|
||||
public function __construct($content, int $status = 200, array $headers = [])
|
||||
{
|
||||
if ( false === ( array_change_key_case($headers)['content-disposition'] ?? false )) {
|
||||
$headers['Content-Disposition'] = 'inline';
|
||||
}
|
||||
|
||||
parent::__construct(
|
||||
$this->createBody($content),
|
||||
$status,
|
||||
$this->injectContentType('image', $headers)
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Create the message body.
|
||||
*
|
||||
* @param string|StreamInterface $content
|
||||
* @throws Exception\InvalidArgumentException if $content is neither a string or stream.
|
||||
*/
|
||||
private function createBody($content) : StreamInterface
|
||||
{
|
||||
if ($content instanceof StreamInterface) {
|
||||
return $content;
|
||||
}
|
||||
|
||||
if (! is_string($content)) {
|
||||
throw new Exception\InvalidArgumentException(sprintf(
|
||||
'Invalid content (%s) provided to %s',
|
||||
(is_object($content) ? get_class($content) : gettype($content)),
|
||||
__CLASS__
|
||||
));
|
||||
}
|
||||
|
||||
$body = new Stream('php://temp', 'wb+');
|
||||
$body->write($content);
|
||||
$body->rewind();
|
||||
return $body;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,20 @@
|
||||
<?php declare(strict_types=1);
|
||||
|
||||
namespace Lean\Response;
|
||||
|
||||
use Laminas\Diactoros\Response\HtmlResponse;
|
||||
use League\CommonMark\CommonMarkConverter;
|
||||
|
||||
/**
|
||||
* Markdown response.
|
||||
*
|
||||
* Permet de convertir un fichier Markdown en html, et utilise en suite le HtmlResponse
|
||||
* pour pousser le résultat en ligne, avec un code 200 par défault et un Content-Type approprié
|
||||
*/
|
||||
class MarkdownResponse extends HtmlResponse
|
||||
{
|
||||
public function __construct(string $markdown, int $status = 200, array $headers = [])
|
||||
{
|
||||
parent::__construct(( new CommonMarkConverter() )->convertToHtml($markdown), $status, $headers);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,70 @@
|
||||
<?php declare(strict_types=1);
|
||||
|
||||
namespace Lean\Response;
|
||||
|
||||
use function get_class, gettype, is_object, is_string, sprintf;
|
||||
|
||||
use Psr\Http\Message\StreamInterface;
|
||||
|
||||
use Laminas\Diactoros\Exception,
|
||||
Laminas\Diactoros\Response,
|
||||
Laminas\Diactoros\Stream,
|
||||
Laminas\Diactoros\Response\InjectContentTypeTrait;
|
||||
|
||||
/**
|
||||
* PDF Response
|
||||
*
|
||||
* Allows creating a response by passing a string to the constructor;
|
||||
* by default, sets a status code of 200 and sets the Content-Type header to
|
||||
* application/pdf.
|
||||
*/
|
||||
class PdfResponse extends Response
|
||||
{
|
||||
use InjectContentTypeTrait;
|
||||
|
||||
/**
|
||||
* Create a PDF response
|
||||
*
|
||||
* Produces a pdf response with a Content-Type of application/json and a default
|
||||
* status of 200.
|
||||
*
|
||||
* @param string|StreamInterface $content String or stream for the message body.
|
||||
* @param int $status Integer status code for the response; 200 by default.
|
||||
* @param array $headers Array of headers to use at initialization.
|
||||
* @throws Exception\InvalidArgumentException if $content is neither a string or stream.
|
||||
*/
|
||||
public function __construct($content, int $status = 200, array $headers = [])
|
||||
{
|
||||
parent::__construct(
|
||||
$this->createBody($content),
|
||||
$status,
|
||||
$this->injectContentType('application/pdf; charset=utf-8', $headers)
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Create the message body.
|
||||
*
|
||||
* @param string|StreamInterface $content
|
||||
* @throws Exception\InvalidArgumentException if $content is neither a string or stream.
|
||||
*/
|
||||
private function createBody($content) : StreamInterface
|
||||
{
|
||||
if ($content instanceof StreamInterface) {
|
||||
return $content;
|
||||
}
|
||||
|
||||
if (! is_string($content)) {
|
||||
throw new Exception\InvalidArgumentException(sprintf(
|
||||
'Invalid content (%s) provided to %s',
|
||||
(is_object($content) ? get_class($content) : gettype($content)),
|
||||
__CLASS__
|
||||
));
|
||||
}
|
||||
|
||||
$body = new Stream('php://temp', 'wb+');
|
||||
$body->write($content);
|
||||
$body->rewind();
|
||||
return $body;
|
||||
}
|
||||
}
|
||||
+20
-58
@@ -2,6 +2,7 @@
|
||||
|
||||
namespace Lean;
|
||||
|
||||
use Notes\Annotation;
|
||||
use Taxus\Taxus;
|
||||
|
||||
use League\Route\RouteGroup,
|
||||
@@ -23,53 +24,34 @@ use Picea\Picea,
|
||||
use Storage\Cookie,
|
||||
Storage\Session;
|
||||
|
||||
use Mcnd\Event\EventManager;
|
||||
|
||||
use function DI\autowire, DI\create;
|
||||
|
||||
class Routing {
|
||||
|
||||
protected Session $session;
|
||||
public Annotation $selectedRoute;
|
||||
|
||||
protected Cookie $cookie;
|
||||
|
||||
protected UrlExtension $extension;
|
||||
|
||||
protected RouteFetcher $fetcher;
|
||||
|
||||
protected SecurityHandler $security;
|
||||
|
||||
protected LanguageHandler $language;
|
||||
|
||||
protected Taxus $taxus;
|
||||
public ResponseInterface $response;
|
||||
|
||||
public function __construct(
|
||||
Session $session,
|
||||
Cookie $cookie,
|
||||
UrlExtension $extension,
|
||||
Router $router,
|
||||
RouteFetcher $routeFetcher,
|
||||
SecurityHandler $security,
|
||||
LanguageHandler $language,
|
||||
Taxus $taxus
|
||||
)
|
||||
{
|
||||
$this->session = $session;
|
||||
$this->cookie = $cookie;
|
||||
$this->extension = $extension;
|
||||
$this->fetcher = $routeFetcher;
|
||||
$this->security = $security;
|
||||
$this->language = $language;
|
||||
$this->router = $router;
|
||||
$this->taxus = $taxus;
|
||||
}
|
||||
public Session $session,
|
||||
public Cookie $cookie,
|
||||
public UrlExtension $extension,
|
||||
public Router $router,
|
||||
public RouteFetcher $fetcher,
|
||||
public SecurityHandler $security,
|
||||
public LanguageHandler $language,
|
||||
public Taxus $taxus,
|
||||
public EventManager $eventManager,
|
||||
) { }
|
||||
|
||||
public function registerRoute(ContainerInterface $container, string $urlBase) {
|
||||
$this->router->group(rtrim($urlBase, "/"), function (RouteGroup $route) use ($container) {
|
||||
foreach($this->fetcher->compile() as $annotation) {
|
||||
# Register routes to the UrlExtension from picea (handling url, route and asset extensions)
|
||||
if ( null !== ( $name = $annotation->name ?? null ) ) {
|
||||
$this->extension->registerRoute($name, $annotation->getRoute(), $annotation->class, $annotation->classMethod, $annotation->methods ?? (array) $annotation->method);
|
||||
}
|
||||
$this->eventManager->execute(Event\RoutingCompileRoutes::class, $this, $annotation);
|
||||
|
||||
/* @deprecated annotation->method will become standard when using native attributes */
|
||||
foreach((array) ( $annotation->method ?? $annotation->methods ) as $method) {
|
||||
# Mapping every URLs from annotations in searched folders (Api, Controller, etc...)
|
||||
$route->map(strtoupper($method), $annotation->getRoute(), function (ServerRequestInterface $request, array $arguments) use (
|
||||
@@ -78,33 +60,13 @@ class Routing {
|
||||
{
|
||||
$class = $annotation->class;
|
||||
$method = $annotation->classMethod;
|
||||
|
||||
# $container->set($class, autowire($class)->method($method, $request));
|
||||
|
||||
if ( null !== ( $languageAnnotation = $this->language->verify($class) ) ) {
|
||||
if ( $languageAnnotation->key ) {
|
||||
# TODO !!! $language
|
||||
}
|
||||
}
|
||||
|
||||
$object = $container->get($class);
|
||||
|
||||
# Checking if user needs to be logged
|
||||
if ( ( $redirect = $this->security->verify($class, $method) ) && ( empty($object->user) || ! $object->user->logged ) ) {
|
||||
$this->session->redirectedFrom = (string) $request->getUri();
|
||||
$this->eventManager->execute(Event\RoutingMapRoutes::class, $this, $container, $request, $annotation);
|
||||
|
||||
return $redirect;
|
||||
}
|
||||
$container->set(ServerRequestInterface::class, $request);
|
||||
|
||||
if ( $forbidden = $this->security->taxus($class, $method, $object->user) ) {
|
||||
return $forbidden;
|
||||
}
|
||||
|
||||
if ( $container->has(Picea::class) ) {
|
||||
$container->get(Picea::class)->globalVariables['route'] = $annotation;
|
||||
}
|
||||
|
||||
return $object->$method($request->withAttribute('lean.route', $annotation), $arguments);
|
||||
return $this->response ?? $object->$method($request, $arguments);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,26 @@
|
||||
{% extends "lean/layout/error" %}
|
||||
|
||||
{% language.set "lean.error.401" %}
|
||||
|
||||
{% title _('page-title') %}
|
||||
|
||||
{% section "content-right" %}
|
||||
<div>
|
||||
<div class="title">{% _ "title" %}</div>
|
||||
<div class="subtitle">{% _ "subtitle" %}</div>
|
||||
<div class="content">{% _ "message" %}</div>
|
||||
<u><a href="#" onclick="history.back()">{% _ "back" %}</a></u>
|
||||
</div>
|
||||
{% endsection %}
|
||||
|
||||
{% section "content-left" %}
|
||||
<div class="picto-login">
|
||||
{% view "lean/picto/undraw_forbidden" %}
|
||||
</div>
|
||||
{% endsection %}
|
||||
|
||||
{% section "head.css" %}
|
||||
.title {font-size:2rem}
|
||||
.subtitle {font-size:1.25rem; padding-top: 1rem;}
|
||||
.content {padding-top:1rem}
|
||||
{% endsection %}
|
||||
@@ -6,7 +6,7 @@
|
||||
|
||||
{% section "content-right" %}
|
||||
<div>
|
||||
<div class="title">{% _ "title" %}</div>
|
||||
<div class="title">{{ $title ?? title() }}</div>
|
||||
<div class="subtitle">{{= isset($subtitle) ? nl2br($subtitle) : _("subtitle") }}</div>
|
||||
<div class="content">{{= isset($message) ? nl2br($message) : _("message") }}</div>
|
||||
<u><a href="#" onclick="history.back()">{% _ "back" %}</a></u>
|
||||
@@ -22,5 +22,5 @@
|
||||
{% section "head.css" %}
|
||||
.title {font-size:2rem}
|
||||
.subtitle {font-size:1.25rem; padding-top: 1rem;}
|
||||
.content {padding-top:1rem}
|
||||
.content {background: #f7f7f7;padding: 7px;color: #8c3c3c;max-height:300px;overflow-y:auto}
|
||||
{% endsection %}
|
||||
@@ -8,9 +8,6 @@
|
||||
|
||||
<link rel="stylesheet" href="https://fonts.googleapis.com/css?family=Lato|Ubuntu%20Mono">
|
||||
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/bulma/0.7.1/css/bulma.min.css">
|
||||
<link rel="stylesheet" href='{% asset "asset/css/bulma.extension.css" %}'>
|
||||
<link rel="stylesheet" href="https://cdn.eckinox.net/fontawesome/latest/css/fontawesome-all.min.css">
|
||||
|
||||
|
||||
<style>
|
||||
body {background:#272822}
|
||||
|
||||
@@ -0,0 +1,65 @@
|
||||
{% use
|
||||
Ulmus\Entity\Field\Date
|
||||
%}
|
||||
|
||||
{% arguments int $month, int $year %}
|
||||
|
||||
{% define "week.heading", int $day, int $month, int $year %}
|
||||
{% define "day.content", \DateTime $date, bool $today %}
|
||||
{% define "day.empty", int $day, int $month, int $year %}
|
||||
|
||||
{% php
|
||||
$month = ltrim($month, "0");
|
||||
$datetime = ( new Date( "{$year}-{$month}-1" ) );
|
||||
$index = $datetime->format('w');
|
||||
$dayCount = $datetime->format('t');
|
||||
$currentDay = 0;
|
||||
%}
|
||||
|
||||
<div class="calendar-wrapper">
|
||||
<div class='week-heading'>
|
||||
{% foreach range(1, 7) as $day %}
|
||||
{% slot "week.heading", $day, $month, $year %}
|
||||
<div class="day-box">
|
||||
{# Random calendar date that starts on a sunday #}
|
||||
{{ substr(( new Date("2019-12-$day") )->formatLocale("%A"), 0, 3) }}
|
||||
</div>
|
||||
{% endslot %}
|
||||
{% endforeach %}
|
||||
</div>
|
||||
|
||||
{% foreach range(0, 5) as $week %}
|
||||
<div class="week">
|
||||
{% foreach range(0, 6) as $day %}
|
||||
{% if ( $week * 6 + $day >= $index ) && ( $currentDay < $dayCount ) %}
|
||||
{% php $currentDay++; %}
|
||||
|
||||
{% slot "day.content", new \DateTime("$year-$month-$currentDay"), date("$year-$month-$currentDay") === date('Y-n-j') %}
|
||||
<div class="day-box {{ $today ? 'today' : '' }}">{{ $date->format('d') }}</div>
|
||||
{% endslot %}
|
||||
{% else %}
|
||||
{% slot "day.empty", $day, $month, $year %}
|
||||
<div class="day-box"></div>
|
||||
{% endslot %}
|
||||
{% endif %}
|
||||
{% endforeach %}
|
||||
</div>
|
||||
|
||||
{% if $currentDay >= $dayCount %}
|
||||
{% break %}
|
||||
{% endif %}
|
||||
{% endforeach %}
|
||||
</div>
|
||||
|
||||
<style>
|
||||
.legend {margin:6px 0 0 0; padding:5px 8px;background:#f9f2f2}
|
||||
.calendar-wrapper {border:1px solid #e3e6f0}
|
||||
.calendar-wrapper .day-box {position:relative;width:14.29%;border:2px solid #fff;height:60px;display:flex;flex-direction:column;justify-content:center;padding:6px 0; text-align:center}
|
||||
.calendar-wrapper .day-box.today {border:2px dashed #4e73df;}
|
||||
.calendar-wrapper .bg-conge,
|
||||
.calendar-wrapper .bg-pedagogique {position:absolute;top:0;bottom:0;left:0;right:0;opacity:0.5;pointer-events:none;}
|
||||
.calendar-wrapper .week,
|
||||
.calendar-wrapper .week-heading {display:flex;}
|
||||
.week-heading {background:#eaecf4;font-weight:bold;}
|
||||
.week:nth-child(even) {background:#f9f2f2; }
|
||||
</style>
|
||||
@@ -1,4 +1,11 @@
|
||||
{% php $messageList = array_filter(array_merge($this->contextList, [ $context ?? null ])) %}
|
||||
{% php
|
||||
$messageList = $this->contextList;
|
||||
$context ??= false;
|
||||
|
||||
if ($context && ! in_array($context, $messageList)) {
|
||||
$messageList[] = $context;
|
||||
}
|
||||
%}
|
||||
|
||||
{% if $messageList %}
|
||||
<div class="message-wrapper">{% php
|
||||
|
||||
@@ -0,0 +1,19 @@
|
||||
<style>
|
||||
ui-popup {width:80vw; max-width:520px; box-shadow:0px 0px 0px 9999px rgba(0, 0, 0, 0.5);z-index:9999;transition:all 0.3s ease-out;background:#fff;position:fixed!important;top:0;left: 50%;transform:translate(-50%, 5%);max-height:calc(100vh - 10%);}
|
||||
ui-popup.large {max-width:640px;}
|
||||
ui-popup.x-large {max-width:830px;}
|
||||
ui-popup:not(.visible) {transform: translate(-50%, -200%);transition-timing-function: ease-in;box-shadow:none;}
|
||||
ui-popup .button-list {text-align:center;}
|
||||
ui-popup .button-list .button {padding: 0px 7%;}
|
||||
ui-popup .message {background: transparent}
|
||||
ui-popup .title {font-size:1.5rem}
|
||||
ui-popup:before {left:0;right:0;top:0;bottom:0;background:rgba(0,0,0,0.1);content:" ";}
|
||||
</style>
|
||||
|
||||
<template id="ui-popup">
|
||||
<div class="ui-popup">
|
||||
<slot name="title"></slot>
|
||||
<slot name="message"></slot>
|
||||
<slot name="buttons"></slot>
|
||||
</div>
|
||||
</template>
|
||||
Reference in new issue
Block a user