Site web d'Antopie https://antopie.org
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 

58 lines
1.8 KiB

  1. <?php
  2. require "mdp.php";
  3. if (isset($_GET['pw']) AND $_GET['pw'] == $mdp) {
  4. require "bibli/parsedown/Parsedown.php";
  5. require "bibli/parsedown/ParsedownExtra.php";
  6. $nomsPages = array_diff(scandir("pages"), array('..', '.'));
  7. foreach ($nomsPages as $nomPage) {
  8. $nomPage = basename($nomPage, ".md");
  9. // pages/exemple.md > temp/exemple.temp
  10. // Exécute le HTML/PHP avec header et footer vers du HTML statique
  11. ob_start();
  12. require "pages/" . $nomPage . ".md";
  13. file_put_contents("temp/" . $nomPage . ".temp", ob_get_contents());
  14. ob_end_clean();
  15. // temp/exemple.temp > temp2/exemple.temp2
  16. // Compile le Markdown/PHP vers du HTML/PHP
  17. $contenuPage = ParsedownExtra::instance()
  18. ->setUrlsLinked(false)
  19. ->setMarkupEscaped(false)
  20. ->setBreaksEnabled(true)
  21. ->text(file_get_contents("temp/" .$nomPage . ".temp"));
  22. file_put_contents("temp2/" . $nomPage . ".temp2", $contenuPage);
  23. // temp2/exemple.temp2 > exemple.html
  24. // Exécute et cache le PHP en HTML
  25. $adresse = $nomPage;
  26. ob_start();
  27. require "inc/pages.php";
  28. require "inc/debut.php";
  29. if ($page['type'] == "article") {
  30. echo "<h1>" . $page['h1'] . "</h1>";
  31. echo "<article>";
  32. } else if ($page['type'] == "centré") {
  33. echo "<div class='centre'>";
  34. }
  35. require "temp2/" . $nomPage . ".temp2";
  36. if ($page['type'] == "article") {
  37. echo "</article>";
  38. } else if ($page['type'] == "centré") {
  39. echo "</div>";
  40. }
  41. require "inc/footer.php";
  42. file_put_contents($nomPage . ".html", ob_get_contents());
  43. ob_end_clean();
  44. }
  45. // exemple.html > exemple.html.gz
  46. // Compresse les fichiers textes statiques HTML & CSS à la racine
  47. exec('bibli/static-compress -c zopfli "*.html" "*.css"');
  48. } else {
  49. echo "Non authentifié·e";
  50. }