diff --git a/index.gmi b/index.gmi
index ba08644..5be4e06 100644
--- a/index.gmi
+++ b/index.gmi
@@ -118,8 +118,7 @@ La décoration du texte, qui interprête le **gras** par exemple, ne fait pas pa
### Désactiver la décoration du texte
On peut :
-* commencer la ligne par **^**,
-* faire un bloc non décoré avec **^^^**,
+* désactiver et activer la décoration du texte avec une ligne **^^^**,
* ajouter ce qui suit à la **réécriture** d’URL :
> &textDecoration=0
diff --git a/index.php b/index.php
index cac10d5..5832956 100644
--- a/index.php
+++ b/index.php
@@ -1,91 +1,61 @@
");
}
-?>
-
-
-
-Installation de HtmGem
-
-
-
-
-\n\n";
- die();
+ $t = new \htmgem\GemTextTranslate_html(@file_get_contents("index.gmi"));
+ echo $t->getFullHtml();
+ exit();
}
-######################################## /Installation page
+
+
+# to false only if textDecoration=0 in the URL
+$textDecoration = "0" != @$_REQUEST['textDecoration'];
# Removes the headling and trailling slashes, to be sure there's not any.
$filePath = rtrim($_SERVER['DOCUMENT_ROOT'], "/")."/".ltrim($url, "/");
-$fileContents = @file_get_contents($filePath);
-
-
-######################################## 404 page
-if (empty($fileContents)) {
+/* 404 page
+ */
+if (!file_exists($filePath)) {
error_log("HtmGem: 404 $url $filePath");
- http_response_code(404); ?>
-
-
-
-
-
-
-
- $url Recharger 🔄
-
=> /
EOF;
-echo translateGemToHtml($text404);
-echo "\n";
-die();
+ $t = new \htmgem\GemTextTranslate_html($page404);
+ echo $t->getFullHtml();
+ exit();
}
-######################################## /404 page
+
+$fileContents = @file_get_contents($filePath);
# Removes the Byte Order Mark
$fileContents = preg_replace("/\xEF\xBB\xBF/", "", $fileContents);
-# Gets the page title: the first occurrence with # at the line start
-mb_ereg("#\s*([^\n]+)\n", $fileContents, $matches);
-$page_title = @$matches[1];
-###################################### CSS Management
-/**
-* if &style=source displays the source directly and stops.
-* if there's a filename.css besides filename.gmi, use the css and stops.
-* if &style= then embbed the default style, and stops.
-* if &style= then use htmgem/word.css
-* if &style=/… then use the … as as stylesheet.
-**/
+/* CSS and special style management
+ */
+$style = @$_REQUEST['style'];
if ("source" == $style) {
$basename = basename($filePath);
header("Cache-Control: public");
@@ -93,9 +63,12 @@ if ("source" == $style) {
header("Content-Type: text/plain");
header("Content-Transfer-Encoding: binary");
header('Content-Length: ' . filesize($filePath));
- readfile($filePath);
+ echo $fileContents;
exit();
} elseif ("pre" == $style) {
+ # Gets the page title: the first occurrence with # at the line start
+ mb_ereg("#\s*([^\n]+)\n", $fileContents, $matches);
+ $page_title = @$matches[1];
$fileContents = htmlspecialchars($fileContents, ENT_HTML5|ENT_NOQUOTES, "UTF-8", false);
echo <<
@@ -104,52 +77,32 @@ if ("source" == $style) {
$page_title
-$fileContents
+
+$fileContents