From 545ac4963d356c9d52cea01665bc9ff2c314bd10 Mon Sep 17 00:00:00 2001 From: Christophe HENRY Date: Mon, 8 Mar 2021 16:59:17 +0100 Subject: [PATCH] Adds emojis according to links type --- TODO | 1 - htmgem.css | 31 +++++++++++++++++++++++++++++++ htmgem.php | 5 ++++- 3 files changed, 35 insertions(+), 2 deletions(-) diff --git a/TODO b/TODO index e2251c7..4c57a72 100644 --- a/TODO +++ b/TODO @@ -1,7 +1,6 @@ * manage url encoding: The filename fetched on disk may differ from that was asked by URL. * check /etc/passwd not accessible: Perform sanity checks against unauthorized access. * manage 404: Display better errors. -* HTML: On links indicate whether it's on Gemini or Www or image. * a way to get the source of a page, using urlrewriting * options to activate the text decoration * HTML caching: Nginx tries the html, if not found use this script to build it diff --git a/htmgem.css b/htmgem.css index cfabb7c..7aa90aa 100644 --- a/htmgem.css +++ b/htmgem.css @@ -63,6 +63,37 @@ a:visited { color: #868; } +a.local:before { + content: "πŸ›©οΈ "; + font-weight: bold; +} + +a.gemini:before { + content: "πŸš€ "; +} + +a.gopher:before { + content: "πŸ“œ "; +} + +a.https:before { + content: "πŸ•ΈοΈ "; + font-weight: bolder; +} + +a.http:before { + content: "πŸ•ΈοΈ "; + font-weight: lighter; +} + +a.mumble:before { + content: "🎀 "; +} + +a.mailto:before { + content: "βœ‰οΈ "; +} + pre { background-color: #eee; margin: 0 -1rem; diff --git a/htmgem.php b/htmgem.php index d07f7bc..d547081 100644 --- a/htmgem.php +++ b/htmgem.php @@ -128,13 +128,16 @@ foreach ($fileLines as $line) { if (preg_match("/^=>\s*([^\s]+)(?:\s+(.*))?$/", $line, $linkParts)) { $url_link = $linkParts[1]; $url_label = @$linkParts[2]; + preg_match("/^([^:]+):/", $url_link, $matches); + $url_protocol = @$matches[1]; + if (empty($url_protocol)) $url_protocol = "local"; if (empty(trim($url_label))) { $url_label = $url_link; } else { // the label is humain-made, apply formatting htmlPrepare($url_label); } - echo "

".$url_label."

\n"; + echo "

$url_label

\n"; } else { $mode = "raw"; continue;