don't push react dist anymore

This commit is contained in:
2022-12-01 11:01:49 +01:00
parent cb75e22811
commit 963088e9b8
17 changed files with 29 additions and 131 deletions

View File

@@ -246,6 +246,8 @@ namespace Core\API\Routes {
"type" => new StringType("type"),
"target" => new StringType("target", 128),
"extra" => new StringType("extra", 64, true, ""),
"exact" => new Parameter("exact", Parameter::TYPE_BOOLEAN),
"active" => new Parameter("active", Parameter::TYPE_BOOLEAN, true, true),
));
$this->isPublic = false;
}

View File

@@ -44,7 +44,7 @@ class CreateDatabase extends DatabaseScript {
new DocumentRoute("/login", true, \Core\Documents\Account::class, "account/login.twig"),
new DocumentRoute("/resendConfirmEmail", true, \Core\Documents\Account::class, "account/resend_confirm_email.twig"),
new DocumentRoute("/debug", true, \Core\Documents\Info::class),
new StaticFileRoute("/static", true, "/static/welcome.html"),
new StaticFileRoute("/", true, "/static/welcome.html"),
]);
$queries[] = $sql->createTable("Settings")

View File

@@ -7,12 +7,9 @@ use Core\Objects\Router\Router;
class Admin extends TemplateDocument {
public function __construct(Router $router) {
$user = $router->getContext()->getUser();
$template = $user ? "admin.twig" : "redirect.twig";
$params = $user ? [] : ["url" => "/login"];
parent::__construct($router, "admin.twig", []);
$this->title = "Administration";
$this->searchable = false;
parent::__construct($router, $template, $params);
$this->enableCSP();
$this->addCSPWhitelist("/js/admin-panel/");
}

View File

@@ -8,6 +8,6 @@
{% block body %}
<noscript>You need Javascript enabled to run this app</noscript>
<div type="module" id="admin-panel"></div>
<script src="/js/admin-panel/index.js" nonce="{{ site.csp.nonce }}"></script>
<link rel="stylesheet" href="/js/admin-panel/index.css" nonce="{{ site.csp.nonce }}"></link>
<script src="/react/dist/admin-panel/index.js" nonce="{{ site.csp.nonce }}"></script>
<link rel="stylesheet" href="/react/dist/admin-panel/index.css" nonce="{{ site.csp.nonce }}"></link>
{% endblock %}

28
cli.php
View File

@@ -456,7 +456,7 @@ function onRoutes(array $argv) {
_exit("Error fetching routes: " . $req->getLastError());
} else {
$routes = $req->getResult()["routes"];
$head = ["id", "request", "action", "target", "extra", "active", "exact"];
$head = ["id", "pattern", "type", "target", "extra", "active", "exact"];
// strict boolean
foreach ($routes as &$route) {
@@ -467,14 +467,15 @@ function onRoutes(array $argv) {
printTable($head, $routes);
}
} else if ($action === "add") {
if (count($argv) < 6) {
_exit("Usage: cli.php routes add <request> <action> <target> [extra]");
if (count($argv) < 7) {
_exit("Usage: cli.php routes add <pattern> <type> <target> <exact> [extra]");
}
$params = array(
"request" => $argv[3],
"action" => $argv[4],
"pattern" => $argv[3],
"type" => $argv[4],
"target" => $argv[5],
"exact" => $argv[6],
"extra" => $argv[7] ?? "",
);
@@ -486,23 +487,23 @@ function onRoutes(array $argv) {
_exit("Route added successfully");
}
} else if (in_array($action, ["remove","modify","enable","disable"])) {
$uid = $argv[3] ?? null;
if ($uid === null || ($action === "modify" && count($argv) < 7)) {
$routeId = $argv[3] ?? null;
if ($routeId === null || ($action === "modify" && count($argv) < 8)) {
if ($action === "modify") {
_exit("Usage: cli.php routes $action <id> <request> <action> <target> [extra]");
_exit("Usage: cli.php routes $action <id> <pattern> <type> <target> <exact> [extra]");
} else {
_exit("Usage: cli.php routes $action <id>");
}
}
$params = ["id" => $uid];
$params = ["id" => $routeId];
if ($action === "remove") {
$input = null;
do {
if ($input === "n") {
die();
}
echo "Remove route #$uid? (y|n): ";
echo "Remove route #$routeId? (y|n): ";
} while(($input = trim(fgets(STDIN))) !== "y");
$req = new \Core\API\Routes\Remove($context);
@@ -512,10 +513,11 @@ function onRoutes(array $argv) {
$req = new \Core\API\Routes\Disable($context);
} else if ($action === "modify") {
$req = new \Core\API\Routes\Update($context);
$params["request"] = $argv[4];
$params["action"] = $argv[5];
$params["pattern"] = $argv[4];
$params["type"] = $argv[5];
$params["target"] = $argv[6];
$params["extra"] = $argv[7] ?? "";
$params["exact"] = $argv[7];
$params["extra"] = $argv[8] ?? "";
} else {
_exit("Unsupported action");
}

View File

@@ -23,6 +23,12 @@ server {
rewrite ^(.*)$ /index.php?site=$1;
}
# but allow access to react/dist
location ~ ^/react/dist/.*$ {
add_header "Cache-Control" "max-age=0; must-revalidate";
try_files $uri $uri @redirectToIndex;
}
# deny access to specific directories
location ~ ^/(files/uploaded|react|docker|Site|Core|test)/.*$ {
rewrite ^(.*)$ /index.php?site=$1;

View File

File diff suppressed because one or more lines are too long

View File

File diff suppressed because one or more lines are too long

View File

File diff suppressed because one or more lines are too long

View File

File diff suppressed because one or more lines are too long

View File

@@ -1,2 +0,0 @@
!function(){function e(e,t,n,r){Object.defineProperty(e,t,{get:n,set:r,enumerable:!0,configurable:!0})}var t=("undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:"undefined"!=typeof window?window:"undefined"!=typeof global?global:{}).parcelRequireeec4;t.register("aNQgM",(function(n,r){var o;o=n.exports,Object.defineProperty(o,"__esModule",{value:!0,configurable:!0}),e(n.exports,"default",(function(){return c}));var a=t("lBpE3");t("6cds3");var s=t("1dF7x"),i=t("2eEzJ");function c(e){for(var t=new Date,n=(0,i.default)(t),r=["#ff4444","#ffbb33","#00C851","#33b5e5"];r.length<n;)r=r.concat(r);var o=new Array(n).fill(0);Array.from(Array(n),(function(e,t){return t+1})),format(t,"MMMM");return(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)("div",{className:"content-header",children:(0,a.jsx)("div",{className:"container-fluid",children:(0,a.jsxs)("div",{className:"row mb-2",children:[(0,a.jsx)("div",{className:"col-sm-6",children:(0,a.jsx)("h1",{className:"m-0 text-dark",children:"Dashboard"})}),(0,a.jsx)("div",{className:"col-sm-6",children:(0,a.jsxs)("ol",{className:"breadcrumb float-sm-right",children:[(0,a.jsx)("li",{className:"breadcrumb-item",children:(0,a.jsx)(s.Link,{to:"/admin/dashboard",children:"Home"})}),(0,a.jsx)("li",{className:"breadcrumb-item active",children:"Dashboard"})]})})]})})}),(0,a.jsx)("section",{className:"content"})]})}})),t.register("2eEzJ",(function(n,r){e(n.exports,"default",(function(){return s}));var o=t("18SRp"),a=t("3QBsJ");function s(e){(0,a.default)(1,arguments);var t=(0,o.default)(e),n=t.getFullYear(),r=t.getMonth(),s=new Date(0);return s.setFullYear(n,r+1,0),s.setHours(0,0,0,0),s.getDate()}})),t.register("18SRp",(function(n,r){e(n.exports,"default",(function(){return s}));var o=t("3QBsJ");function a(e){return a="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},a(e)}function s(e){(0,o.default)(1,arguments);var t=Object.prototype.toString.call(e);return e instanceof Date||"object"===a(e)&&"[object Date]"===t?new Date(e.getTime()):"number"==typeof e||"[object Number]"===t?new Date(e):("string"!=typeof e&&"[object String]"!==t||"undefined"==typeof console||(console.warn("Starting with v2.0.0-beta.1 date-fns doesn't accept strings as date arguments. Please use `parseISO` to parse strings. See: https://github.com/date-fns/date-fns/blob/master/docs/upgradeGuide.md#string-arguments"),console.warn((new Error).stack)),new Date(NaN))}})),t.register("3QBsJ",(function(t,n){function r(e,t){if(t.length<e)throw new TypeError(e+" argument"+(e>1?"s":"")+" required, but only "+t.length+" present")}e(t.exports,"default",(function(){return r}))}))}();
//# sourceMappingURL=overview.01501b20.js.map

View File

File diff suppressed because one or more lines are too long

View File

File diff suppressed because one or more lines are too long

View File

File diff suppressed because one or more lines are too long

1
react/.gitignore vendored
View File

@@ -94,6 +94,7 @@ out
# Nuxt.js build / generate output
.nuxt
dist
!dist/.htaccess
# Gatsby files
.cache/

1
react/dist/.htaccess vendored Normal file
View File

@@ -0,0 +1 @@
ALLOW FROM ALL

View File

@@ -14,7 +14,6 @@
],
"scripts": {
"build": "parcel build",
"deploy": "cp -r dist/* ../js/",
"clean": "rm -rfd .parcel-cache dist/*"
},
"author": "",