summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorThomas Letan <lthms@soap.coffee>2020-02-15 23:34:34 +0100
committerThomas Letan <lthms@soap.coffee>2020-02-15 23:39:56 +0100
commit8852c973af08fe6f97c1be6e53524d1dcb2b0eea (patch)
tree6acb1dd32954f5102fd3acd2d3c0b1902e42f21f
parentAdd missing fonts and rename the plugin (diff)
Mark external links with a dedicated icon
-rw-r--r--plugins/external_links.lua16
-rw-r--r--site/style/main.sass7
-rw-r--r--soupault.conf6
3 files changed, 29 insertions, 0 deletions
diff --git a/plugins/external_links.lua b/plugins/external_links.lua
new file mode 100644
index 0000000..0edf9d8
--- /dev/null
+++ b/plugins/external_links.lua
@@ -0,0 +1,16 @@
+links = HTML.select(page, "a")
+
+index, link = next(links)
+
+while index do
+ href = HTML.get_attribute(link, "href")
+
+ if href then
+ if Regex.match(href, "^https?://") then
+ icon = HTML.parse("<i class=\"fa fa-external-link\" aria-hidden=\"true\"></i>")
+ HTML.append_child(link, icon)
+ end
+ end
+
+ index, link = next(links, index)
+end
diff --git a/site/style/main.sass b/site/style/main.sass
index 6996569..383855a 100644
--- a/site/style/main.sass
+++ b/site/style/main.sass
@@ -24,6 +24,10 @@ h1, h2, h3, h4, h5
h1
text-align: center
+a[href] .fa-external-link
+ font-size: smaller;
+ padding-left: 0.2em
+
/* default */
body#default
@@ -85,6 +89,9 @@ body#default
.code a[href]
text-decoration: none
+ .fa-external-link
+ display: none
+
.paragraph
margin-top: 1em
margin-bottom: 1em
diff --git a/soupault.conf b/soupault.conf
index 7e866f3..5e225b7 100644
--- a/soupault.conf
+++ b/soupault.conf
@@ -44,7 +44,13 @@
[plugins.fix_urls]
file = "plugins/fix_urls.lua"
+[plugins.external_links]
+ file = "plugins/external_links.lua"
+
[widgets.fix-urls]
widget = "fix_urls"
prefix_url = "/~lthms"
+
+[widgets.mark-external-urls]
+ widget = "external_links"
prefix_url = "/~lthms" \ No newline at end of file