diff options
| author | polo <ordipolo@gmx.fr> | 2026-07-26 19:29:53 +0200 |
|---|---|---|
| committer | polo <ordipolo@gmx.fr> | 2026-07-26 19:29:53 +0200 |
| commit | 58514668410cb902dab613221a8e7f963cc36317 (patch) | |
| tree | 98d0ec77ba9689997e4af395679ce061b2bff3f9 | |
| parent | fea733a16a666e9b7ecf4729b126d65d1ad9208d (diff) | |
| download | melaine-58514668410cb902dab613221a8e7f963cc36317.tar.gz melaine-58514668410cb902dab613221a8e7f963cc36317.tar.bz2 melaine-58514668410cb902dab613221a8e7f963cc36317.zip | |
versioning fichiers CSS et JS
| -rw-r--r-- | .gitignore | 1 | ||||
| -rw-r--r-- | controller/media.php | 4 | ||||
| -rw-r--r-- | index.php | 1 | ||||
| -rw-r--r-- | public/js/file_upload.js (renamed from public/file_upload.js) | 2 | ||||
| -rw-r--r-- | public/js/index.php | 3 | ||||
| -rw-r--r-- | public/js/inversion.js (renamed from public/inversion.js) | 2 | ||||
| -rw-r--r-- | public/js/main.js (renamed from public/main.js) | 2 | ||||
| -rw-r--r-- | view/Versioning.php | 24 | ||||
| -rw-r--r-- | view/accueil.php | 4 | ||||
| -rw-r--r-- | view/album.php | 23 | ||||
| -rw-r--r-- | view/backup.php | 6 | ||||
| -rw-r--r-- | view/discographie.php | 24 | ||||
| -rw-r--r-- | view/pageArticlesSimples.php | 32 | ||||
| -rw-r--r-- | view/password.php | 6 | ||||
| -rw-r--r-- | view/template.php | 4 |
15 files changed, 61 insertions, 77 deletions
diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..8fce603 --- /dev/null +++ b/.gitignore | |||
| @@ -0,0 +1 @@ | |||
| data/ | |||
diff --git a/controller/media.php b/controller/media.php index b6774e0..71eddf9 100644 --- a/controller/media.php +++ b/controller/media.php | |||
| @@ -3,7 +3,7 @@ | |||
| 3 | // traitement avant enregistrement dans le fichier submit.php | 3 | // traitement avant enregistrement dans le fichier submit.php |
| 4 | // cette fonction extrait les liens pointant vers des medias embarqués | 4 | // cette fonction extrait les liens pointant vers des medias embarqués |
| 5 | // (liste de sites) et les restituent nus, sans les balises | 5 | // (liste de sites) et les restituent nus, sans les balises |
| 6 | function mediaSubmit($chaine) | 6 | function mediaSubmit(string $chaine) |
| 7 | { | 7 | { |
| 8 | // liste de sites concernés par les fonctions de ce fichiers | 8 | // liste de sites concernés par les fonctions de ce fichiers |
| 9 | $listeMedia = "youtube.com|vimeo.com|dailymotion.com|spotify.com|soundcloud.com|instagram.com|twitter.com|flickr.com|facebook.com|fb.watch|deezer.com|openstreetmap.org|goo.gl/maps|google.com/maps|itunes.apple.com|wordpress.com"; | 9 | $listeMedia = "youtube.com|vimeo.com|dailymotion.com|spotify.com|soundcloud.com|instagram.com|twitter.com|flickr.com|facebook.com|fb.watch|deezer.com|openstreetmap.org|goo.gl/maps|google.com/maps|itunes.apple.com|wordpress.com"; |
| @@ -191,7 +191,7 @@ function mediaSubmit($chaine) | |||
| 191 | 191 | ||
| 192 | 192 | ||
| 193 | // embarquement !! | 193 | // embarquement !! |
| 194 | function mediaEmbed($chaine) | 194 | function mediaEmbed(string $chaine) |
| 195 | { | 195 | { |
| 196 | //require("../Embera/src/Autoloader.php"); | 196 | //require("../Embera/src/Autoloader.php"); |
| 197 | //$embera = new Embera\Embera(); | 197 | //$embera = new Embera\Embera(); |
| @@ -57,6 +57,7 @@ if(isset($_GET['page'])) // utile? | |||
| 57 | 57 | ||
| 58 | // contrôleurs | 58 | // contrôleurs |
| 59 | // mode visiteur (sans l'éditeur) | 59 | // mode visiteur (sans l'éditeur) |
| 60 | require 'view/Versioning.php'; | ||
| 60 | require('controller/visitor.php'); | 61 | require('controller/visitor.php'); |
| 61 | 62 | ||
| 62 | // contrôleur des pages en mode admin | 63 | // contrôleur des pages en mode admin |
diff --git a/public/file_upload.js b/public/js/file_upload.js index c24b798..737ca5f 100644 --- a/public/file_upload.js +++ b/public/js/file_upload.js | |||
| @@ -1,4 +1,4 @@ | |||
| 1 | // public/file_upload.js | 1 | // public/js/file_upload.js |
| 2 | // | 2 | // |
| 3 | // envoie d'un gros fichier ZIP en contournant la limite du php.ini | 3 | // envoie d'un gros fichier ZIP en contournant la limite du php.ini |
| 4 | // ce fichier est "caché", il n'est envoyé qu'à un utilisateur connecté et sur la page "restauration" | 4 | // ce fichier est "caché", il n'est envoyé qu'à un utilisateur connecté et sur la page "restauration" |
diff --git a/public/js/index.php b/public/js/index.php new file mode 100644 index 0000000..f67f1d7 --- /dev/null +++ b/public/js/index.php | |||
| @@ -0,0 +1,3 @@ | |||
| 1 | <?php | ||
| 2 | header('Location: ../index.php'); | ||
| 3 | exit(); | ||
diff --git a/public/inversion.js b/public/js/inversion.js index 20a6871..77c3151 100644 --- a/public/inversion.js +++ b/public/js/inversion.js | |||
| @@ -1,4 +1,4 @@ | |||
| 1 | // public/inversion.js | 1 | // public/js/inversion.js |
| 2 | 2 | ||
| 3 | // inverser la position de deux "articles" ou albums d'une page | 3 | // inverser la position de deux "articles" ou albums d'une page |
| 4 | function inversion() | 4 | function inversion() |
diff --git a/public/main.js b/public/js/main.js index 19a09bb..f5f602b 100644 --- a/public/main.js +++ b/public/js/main.js | |||
| @@ -1,4 +1,4 @@ | |||
| 1 | // public/main.js | 1 | // public/js/main.js |
| 2 | 2 | ||
| 3 | function versMenu() | 3 | function versMenu() |
| 4 | { | 4 | { |
diff --git a/view/Versioning.php b/view/Versioning.php new file mode 100644 index 0000000..f75afe1 --- /dev/null +++ b/view/Versioning.php | |||
| @@ -0,0 +1,24 @@ | |||
| 1 | <?php | ||
| 2 | // view/Versioning.php | ||
| 3 | |||
| 4 | class Versioning { | ||
| 5 | static function insertCSS(string $name): string | ||
| 6 | { | ||
| 7 | return '<link rel="stylesheet" href="' . self::versionedFileURL('css', $name) . '">' . "\n"; | ||
| 8 | } | ||
| 9 | static function insertJS(string $name, bool $module = false): string | ||
| 10 | { | ||
| 11 | return '<script ' . ($module ? 'type="module"' : '') . ' src="' . self::versionedFileURL('js', $name) . '"></script>' . "\n"; | ||
| 12 | } | ||
| 13 | |||
| 14 | static function versionedFileURL(string $type, string $filename, ?string $custom_path = null): string | ||
| 15 | { | ||
| 16 | $path = $custom_path ?? 'public/' . $type . '/' . $filename . '.' . $type; // si custom_path, $type et $filename ne servent à rien | ||
| 17 | |||
| 18 | if(file_exists(getcwd() . '/' . $path)){ | ||
| 19 | $version = substr(md5_file($path), 0, 8); | ||
| 20 | return $path . '?v=' . $version; | ||
| 21 | } | ||
| 22 | return $path; // sécurité fichier absent | ||
| 23 | } | ||
| 24 | } | ||
diff --git a/view/accueil.php b/view/accueil.php index 1e8db56..d7297e4 100644 --- a/view/accueil.php +++ b/view/accueil.php | |||
| @@ -2,12 +2,12 @@ | |||
| 2 | // view/accueil.php | 2 | // view/accueil.php |
| 3 | 3 | ||
| 4 | // variable $js | 4 | // variable $js |
| 5 | $js = Versioning::insertJS('main'); | ||
| 5 | ob_start(); | 6 | ob_start(); |
| 6 | ?> | 7 | ?> |
| 7 | <script src="public/main.js" ></script> | ||
| 8 | <script>versMenu();</script> | 8 | <script>versMenu();</script> |
| 9 | <?php | 9 | <?php |
| 10 | $js = ob_get_clean(); | 10 | $js .= ob_get_clean(); |
| 11 | 11 | ||
| 12 | // variable $header | 12 | // variable $header |
| 13 | ob_start(); | 13 | ob_start(); |
diff --git a/view/album.php b/view/album.php index 6fcca36..e568aa2 100644 --- a/view/album.php +++ b/view/album.php | |||
| @@ -2,29 +2,18 @@ | |||
| 2 | // view/album.php | 2 | // view/album.php |
| 3 | 3 | ||
| 4 | // variable $css | 4 | // variable $css |
| 5 | // utilise discographie.css | 5 | $css = Versioning::insertCSS('discographie'); |
| 6 | ob_start(); | 6 | $css .= Versioning::insertCSS('donnees_hors_editeur'); |
| 7 | ?> | ||
| 8 | <link rel="stylesheet" type="text/css" href="public/css/discographie.css"> | ||
| 9 | <link rel="stylesheet" type="text/css" href="public/css/donnees_hors_editeur.css"> | ||
| 10 | <?php | ||
| 11 | $css = ob_get_clean(); | ||
| 12 | 7 | ||
| 13 | // variable $js | 8 | // variable $js |
| 14 | ob_start(); | 9 | $js = Versioning::insertJS('main'); |
| 15 | ?> | 10 | //$js .= Versioning::insertJS('file_upload'); |
| 16 | <script src="public/main.js" ></script> | 11 | |
| 17 | <!-- <script type="text/javascript" src="public/file_upload.js" ></script> --> | ||
| 18 | <?php | ||
| 19 | if(isset($_GET['action']) && $_GET['action'] === 'edition') | 12 | if(isset($_GET['action']) && $_GET['action'] === 'edition') |
| 20 | { | 13 | { |
| 21 | |||
| 22 | // bibliothèques JS ckeditor | 14 | // bibliothèques JS ckeditor |
| 23 | ?> | 15 | $js .= '<script src="' . Versioning::versionedFileURL('', '', 'lib/ckeditor5/build/ckeditor.js') . '"></script>'; |
| 24 | <script src="lib/ckeditor5/build/ckeditor.js"></script> | ||
| 25 | <?php | ||
| 26 | } | 16 | } |
| 27 | $js = ob_get_clean(); | ||
| 28 | 17 | ||
| 29 | // variable $header | 18 | // variable $header |
| 30 | ob_start(); | 19 | ob_start(); |
diff --git a/view/backup.php b/view/backup.php index 78e2d04..c56661f 100644 --- a/view/backup.php +++ b/view/backup.php | |||
| @@ -77,12 +77,12 @@ elseif(isset($_GET['action']) && $_GET['action'] == 'restauration') | |||
| 77 | <title><?= $title ?></title> | 77 | <title><?= $title ?></title> |
| 78 | <!-- <link rel="shortcut icon" type="image/x-icon" href="favicon.ico" /> --> | 78 | <!-- <link rel="shortcut icon" type="image/x-icon" href="favicon.ico" /> --> |
| 79 | <link rel="icon" type="image/png" href="public/mouette-logo.png"> | 79 | <link rel="icon" type="image/png" href="public/mouette-logo.png"> |
| 80 | <link rel="stylesheet" type="text/css" href="public/css/normalize.css"> | 80 | <?= Versioning::insertCSS('normalize') ?> |
| 81 | <link rel="stylesheet" type="text/css" href="public/css/main.css"> | 81 | <?= Versioning::insertCSS('main') ?> |
| 82 | <?php | 82 | <?php |
| 83 | if(isset($_GET['action']) && $_GET['action'] == 'restauration') | 83 | if(isset($_GET['action']) && $_GET['action'] == 'restauration') |
| 84 | { | 84 | { |
| 85 | echo('<script src="public/file_upload.js" ></script>'); | 85 | echo Versioning::insertJS('file_upload'); |
| 86 | } | 86 | } |
| 87 | ?> | 87 | ?> |
| 88 | <meta name="viewport" content="width=device-width, initial-scale=1.0"> | 88 | <meta name="viewport" content="width=device-width, initial-scale=1.0"> |
diff --git a/view/discographie.php b/view/discographie.php index 84358db..96026bf 100644 --- a/view/discographie.php +++ b/view/discographie.php | |||
| @@ -2,30 +2,18 @@ | |||
| 2 | // view/discographie.php | 2 | // view/discographie.php |
| 3 | 3 | ||
| 4 | // variable $css | 4 | // variable $css |
| 5 | ob_start(); | 5 | $css = Versioning::insertCSS($page); |
| 6 | ?> | 6 | $css .= Versioning::insertCSS('donnees_hors_editeur'); |
| 7 | <link rel="stylesheet" type="text/css" href="public/css/<?= $page ?>.css"> | ||
| 8 | <link rel="stylesheet" type="text/css" href="public/css/donnees_hors_editeur.css"> | ||
| 9 | <?php | ||
| 10 | $css = ob_get_clean(); | ||
| 11 | |||
| 12 | 7 | ||
| 13 | // variable $js | 8 | // variable $js |
| 14 | ob_start(); | 9 | $js = Versioning::insertJS('main'); |
| 15 | ?> | 10 | //$js .= Versioning::insertJS('file_upload'); |
| 16 | <script src="public/main.js"></script> | 11 | |
| 17 | <!-- <script type="text/javascript" src="public/file_upload.js" ></script> --> | ||
| 18 | <?php | ||
| 19 | if(isset($_GET['action']) && $_GET['action'] === 'edition') | 12 | if(isset($_GET['action']) && $_GET['action'] === 'edition') |
| 20 | { | 13 | { |
| 21 | |||
| 22 | // bibliothèques JS ckeditor | 14 | // bibliothèques JS ckeditor |
| 23 | ?> | 15 | $js .= '<script src="' . Versioning::versionedFileURL('', '', 'lib/ckeditor5/build/ckeditor.js') . '"></script>'; |
| 24 | <script src="lib/ckeditor5/build/ckeditor.js"></script> | ||
| 25 | <?php | ||
| 26 | } | 16 | } |
| 27 | $js = ob_get_clean(); | ||
| 28 | |||
| 29 | 17 | ||
| 30 | // variable $header | 18 | // variable $header |
| 31 | ob_start(); | 19 | ob_start(); |
diff --git a/view/pageArticlesSimples.php b/view/pageArticlesSimples.php index d282964..fcb453a 100644 --- a/view/pageArticlesSimples.php +++ b/view/pageArticlesSimples.php | |||
| @@ -2,39 +2,17 @@ | |||
| 2 | // view/pageArticleSimple.php | 2 | // view/pageArticleSimple.php |
| 3 | 3 | ||
| 4 | // variable $css | 4 | // variable $css |
| 5 | ob_start(); | 5 | $css = $page === 'menu' ? Versioning::insertCSS('menu') : Versioning::insertCSS('pages_articles_simples'); |
| 6 | if($page == 'menu') | 6 | $css .= Versioning::insertCSS('donnees_hors_editeur'); |
| 7 | { | ||
| 8 | ?> | ||
| 9 | <link rel="stylesheet" type="text/css" href="public/css/menu.css"> | ||
| 10 | <?php | ||
| 11 | } | ||
| 12 | else | ||
| 13 | { | ||
| 14 | ?> | ||
| 15 | <link rel="stylesheet" type="text/css" href="public/css/pages_articles_simples.css"> | ||
| 16 | <?php | ||
| 17 | } | ||
| 18 | ?> | ||
| 19 | <link rel="stylesheet" type="text/css" href="public/css/donnees_hors_editeur.css"> | ||
| 20 | <?php | ||
| 21 | $css = ob_get_clean(); | ||
| 22 | 7 | ||
| 23 | //variable $js | 8 | //variable $js |
| 24 | ob_start(); | 9 | $js = Versioning::insertJS('main'); |
| 25 | ?> | 10 | |
| 26 | <script src="public/main.js"></script> | ||
| 27 | <?php | ||
| 28 | if(isset($_GET['action']) && $_GET['action'] == 'editor') | 11 | if(isset($_GET['action']) && $_GET['action'] == 'editor') |
| 29 | { | 12 | { |
| 30 | |||
| 31 | // bibliothèques JS ckeditor | 13 | // bibliothèques JS ckeditor |
| 32 | ?> | 14 | $js .= '<script src="' . Versioning::versionedFileURL('', '', 'lib/ckeditor5/build/ckeditor.js') . '"></script>'; |
| 33 | <script src="lib/ckeditor5/build/ckeditor.js"></script> | ||
| 34 | <?php | ||
| 35 | } | 15 | } |
| 36 | $js = ob_get_clean(); | ||
| 37 | |||
| 38 | 16 | ||
| 39 | // message lecteur multimedia | 17 | // message lecteur multimedia |
| 40 | if($page == 'archives') | 18 | if($page == 'archives') |
diff --git a/view/password.php b/view/password.php index ae153b5..62f53ec 100644 --- a/view/password.php +++ b/view/password.php | |||
| @@ -75,9 +75,9 @@ ob_start(); | |||
| 75 | 75 | ||
| 76 | <!-- <link rel="shortcut icon" type="image/x-icon" href="favicon.ico" /> --> | 76 | <!-- <link rel="shortcut icon" type="image/x-icon" href="favicon.ico" /> --> |
| 77 | <link rel="icon" type="image/png" href="public/mouette-logo.png"> | 77 | <link rel="icon" type="image/png" href="public/mouette-logo.png"> |
| 78 | <link rel="stylesheet" type="text/css" href="public/css/normalize.css"> | 78 | <?= Versioning::insertCSS('normalize') ?> |
| 79 | <link rel="stylesheet" type="text/css" href="public/css/main.css"> | 79 | <?= Versioning::insertCSS('main') ?> |
| 80 | <script src="public/main.js" ></script> | 80 | <?= Versioning::insertJS('main') ?> |
| 81 | <meta name="viewport" content="width=device-width, initial-scale=1.0"> | 81 | <meta name="viewport" content="width=device-width, initial-scale=1.0"> |
| 82 | </head> | 82 | </head> |
| 83 | 83 | ||
diff --git a/view/template.php b/view/template.php index dfe68bd..3facc13 100644 --- a/view/template.php +++ b/view/template.php | |||
| @@ -10,9 +10,9 @@ | |||
| 10 | 10 | ||
| 11 | <!-- <link rel="shortcut icon" type="image/x-icon" href="public/favicon.ico" /> --> | 11 | <!-- <link rel="shortcut icon" type="image/x-icon" href="public/favicon.ico" /> --> |
| 12 | <link rel="icon" type="image/png" href="public/mouette-logo.png"> | 12 | <link rel="icon" type="image/png" href="public/mouette-logo.png"> |
| 13 | <link rel="stylesheet" type="text/css" href="public/css/normalize.css"> | ||
| 14 | <link rel="stylesheet" type="text/css" href="public/css/main.css"> | ||
| 15 | <?php | 13 | <?php |
| 14 | echo Versioning::insertCSS('normalize'); | ||
| 15 | echo Versioning::insertCSS('main'); | ||
| 16 | if(isset($css)) // fichiers CSS supplémentaires | 16 | if(isset($css)) // fichiers CSS supplémentaires |
| 17 | { | 17 | { |
| 18 | echo($css); | 18 | echo($css); |
