From c5fae9e7ce50d83880acf33e364caab9a954c235 Mon Sep 17 00:00:00 2001 From: xdrm-brackets Date: Sun, 3 Dec 2017 15:43:13 +0100 Subject: [PATCH] add: router.controller.svg (now manage svg recoloring) --- build/router/controller/svg.php | 60 +++++++++++++++++++++++++++++++++ config/routes.json | 15 +++++++-- 2 files changed, 72 insertions(+), 3 deletions(-) create mode 100644 build/router/controller/svg.php diff --git a/build/router/controller/svg.php b/build/router/controller/svg.php new file mode 100644 index 0000000..ac308c1 --- /dev/null +++ b/build/router/controller/svg.php @@ -0,0 +1,60 @@ + Calling URI + * + */ + public function __construct($url){ + $this->path = $url['path']; + $this->color = substr($url['color'], 1); + } + + + /* Colorate svg + * + */ + public function color(){ + header('Content-Type: image/svg+xml'); + + // On crée la partie ajoutée + $stylesheet = "\n"; + + // On récupère le fichier + $file = file_get_contents(__PUBLIC__.'/'.$this->path); + + // On ajoute le style + $file = str_replace('', $stylesheet, $file); + + echo $file; + + } + + /* POST-CALL + * + */ + public function __destruct(){ + + } + + + + } diff --git a/config/routes.json b/config/routes.json index c06c786..3dfec84 100755 --- a/config/routes.json +++ b/config/routes.json @@ -5,10 +5,13 @@ "routes": { - "/js/bundle.js": { + "/{path}{color}": { "methods": ["GET"], - "controller": "js:bundle", - "arguments": {} + "controller": "svg:color", + "arguments": { + "path": ".+\\.svg", + "color": "@[a-fA-F0-9]{6}" + } }, "/js/_SERVER.js": { @@ -17,6 +20,12 @@ "arguments": {} }, + "/js/bundle.js": { + "methods": ["GET"], + "controller": "js:bundle", + "arguments": {} + }, + "/{page}/": { "methods": ["GET"], "controller": "page:load",