Gestion de la coloration svg 'in-url'

This commit is contained in:
xdrm-brackets 2016-07-16 13:05:24 +02:00
parent 49d35f828e
commit 190610a032
5 changed files with 38 additions and 7 deletions

View File

@ -1,2 +1,2 @@
# stef
Personal STEF project
Personal project

View File

@ -168,7 +168,7 @@
display: block;
margin: 1em;
color: #333;
white-space: nowrap;
// white-space: nowrap;
// svg (icone)
svg{

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@ -37,14 +37,46 @@
/* [2] Gestion du routage
=========================================================*/
/* (1) On initialise le routeur
---------------------------------------------------------*/
$R = new Router( $_GET['url'] );
/* (2) Gestion des SVG avec couleur modifiée */
// path/to/resource/filename-HEXADE.svg
$R->get('(.+)@([a-f0-9]{6})(\.svg)', function($matches){
$path = __ROOT__.'/'.$matches[0].$matches[2];
header('Content-Type: image/svg+xml');
// On crée la partie ajoutée
$stylesheet = "\n<style type='text/css'>\n";
$stylesheet .= "\t#stylisable{\n";
$stylesheet .= "\t\tfill: #".$matches[1]." !important;\n";
$stylesheet .= "\t\tfill-opacity: 1 !important;\n";
$stylesheet .= "\t}\n";
$stylesheet .= "</style></svg>";
// On récupère le fichier
$file = file_get_contents($path);
// On ajoute le style
$file = str_replace('</svg>', $stylesheet, $file);
echo $file;
});
/* (3) On cree les regles de routage QUAND ON EST CONNECTE
---------------------------------------------------------*/
/* (2) Si on est connecté */
@ -56,7 +88,7 @@
$R->get('(.*)', function($m){
// Liste des pages du site
$page_list = [ 'dashboard', 'profile', 'machines', 'users', 'groups', 'analytics', 'settings' ];
if( !preg_match('#^(?:'.implode('|', $page_list).')(?:/[\w-]+)*/?$#i', $m[0]) )
header(__REDIRECT__);