From 048fa894e40b4e4c7842c19ab63125df583105d1 Mon Sep 17 00:00:00 2001 From: Miraty Date: Thu, 7 Oct 2021 20:21:30 +0200 Subject: [PATCH] Move source documents to src/ --- .gitignore | 4 +-- antopie/{ => src}/404.md | 0 antopie/{ => src}/cgu.md | 0 antopie/{ => src}/contact.md | 0 antopie/{ => src}/courriel.md | 0 antopie/{ => src}/details-techniques.md | 0 antopie/{ => src}/index.md | 0 antopie/{ => src}/manifeste-sur-le-contenu.md | 0 antopie/{ => src}/matrix.md | 0 antopie/{ => src}/nextcloud.md | 0 compil.php | 31 ++++++++++--------- style.less | 8 ++--- 12 files changed, 21 insertions(+), 22 deletions(-) rename antopie/{ => src}/404.md (100%) rename antopie/{ => src}/cgu.md (100%) rename antopie/{ => src}/contact.md (100%) rename antopie/{ => src}/courriel.md (100%) rename antopie/{ => src}/details-techniques.md (100%) rename antopie/{ => src}/index.md (100%) rename antopie/{ => src}/manifeste-sur-le-contenu.md (100%) rename antopie/{ => src}/matrix.md (100%) rename antopie/{ => src}/nextcloud.md (100%) diff --git a/.gitignore b/.gitignore index 0074e6d..94424ad 100644 --- a/.gitignore +++ b/.gitignore @@ -1,9 +1,7 @@ *.gz temp/* mdp.php -antopie/css -antopie/*.html -!antopie/*.inc.html +*/css /docs /miraty .directory diff --git a/antopie/404.md b/antopie/src/404.md similarity index 100% rename from antopie/404.md rename to antopie/src/404.md diff --git a/antopie/cgu.md b/antopie/src/cgu.md similarity index 100% rename from antopie/cgu.md rename to antopie/src/cgu.md diff --git a/antopie/contact.md b/antopie/src/contact.md similarity index 100% rename from antopie/contact.md rename to antopie/src/contact.md diff --git a/antopie/courriel.md b/antopie/src/courriel.md similarity index 100% rename from antopie/courriel.md rename to antopie/src/courriel.md diff --git a/antopie/details-techniques.md b/antopie/src/details-techniques.md similarity index 100% rename from antopie/details-techniques.md rename to antopie/src/details-techniques.md diff --git a/antopie/index.md b/antopie/src/index.md similarity index 100% rename from antopie/index.md rename to antopie/src/index.md diff --git a/antopie/manifeste-sur-le-contenu.md b/antopie/src/manifeste-sur-le-contenu.md similarity index 100% rename from antopie/manifeste-sur-le-contenu.md rename to antopie/src/manifeste-sur-le-contenu.md diff --git a/antopie/matrix.md b/antopie/src/matrix.md similarity index 100% rename from antopie/matrix.md rename to antopie/src/matrix.md diff --git a/antopie/nextcloud.md b/antopie/src/nextcloud.md similarity index 100% rename from antopie/nextcloud.md rename to antopie/src/nextcloud.md diff --git a/compil.php b/compil.php index a2e226b..6ee5b96 100755 --- a/compil.php +++ b/compil.php @@ -61,8 +61,6 @@ else define("CSS_FILENAME", Less_Cache::Get($lessFiles, $options, $colorScheme)); -exec(FIND . " " . SITE . " -name '*.gmi' -o -name '*.md'", $pages); - // URLs don't end with .html on the Antopie website function formerUrlLocale($page) { if (DESTINATION === "dns" OR DESTINATION === "onion") { @@ -81,13 +79,25 @@ function clearnetOrOnion($clearnetUrl, $onionUrl) { } } +exec(FIND . " " . SITE . "/src -name '*.gmi' -o -name '*.md'", $pages); + foreach ($pages as $page) { - $pathParts = pathinfo($page); + $pathParts = pathinfo(str_replace("/src", "", $page)); + + // Create parent directory if needed + if (!file_exists($pathParts['dirname'])) + mkdir($pathParts['dirname'], 0755, true); + + // Execute PHP code + ob_start(); + eval("?>" . file_get_contents($page)); + file_put_contents($pathParts['dirname'] . "/" . $pathParts['basename'], ob_get_contents()); + ob_end_clean(); // Convert Gemtext to Markdown if ($pathParts['extension'] === "gmi") { - $gmilines = explode("\n", file_get_contents($page)); + $gmilines = explode("\n", file_get_contents($pathParts['dirname'] . "/" . $pathParts['basename'])); if (substr($gmilines[0], 0, 2) === "# ") $title = substr($gmilines[0], 2); @@ -126,13 +136,6 @@ foreach ($pages as $page) { } - // Execute PHP code - ob_start(); - eval("?>" . file_get_contents($pathParts['dirname'] . "/" . $pathParts['filename'] . ".md")); - $pageContent = ob_get_contents(); - ob_end_clean(); - - // Compile Markdown to HTML with Parsedown require_once ROOT . "/bibli/parsedown/Parsedown.php"; require_once ROOT . "/bibli/parsedown-extra/ParsedownExtra.php"; @@ -140,7 +143,7 @@ foreach ($pages as $page) { $Parsedown = $Parsedown->setUrlsLinked(false); $Parsedown = $Parsedown->setMarkupEscaped(false); $Parsedown = $Parsedown->setBreaksEnabled(true); - $pageContent = $Parsedown->text($pageContent); + $pageContent = $Parsedown->text(file_get_contents($pathParts['dirname'] . "/" . $pathParts['filename'] . ".md")); // .md > .html for local links @@ -162,11 +165,9 @@ foreach ($pages as $page) { else echo $config['siteTitle']; ?> - - - +