Splux Linux

source-based Linux using SPS

splux-site · log · files · refs · tags · releases · people · languages · GitHub · commit

648c7f6


Link news authors and avatars to their GitHub profiles.

Date
Commit648c7f6cd58b7d2fb92d8b88fcf3f2aa7f0c9fb1
GitHubmirror

Parents

Stat

 site/assets/live.js   | 15 +++++++++++++--
 site/assets/style.css |  8 ++++++++
 tools/news.awk        | 19 ++++++++++++++++---
 3 files changed, 37 insertions(+), 5 deletions(-)

Diff

diff --git a/site/assets/live.js b/site/assets/live.js
index 7b94072..f9caac3 100644
--- a/site/assets/live.js
+++ b/site/assets/live.js
@@ -159,8 +159,16 @@
 		return "";
 	}
 
+	function profileOf(it) {
+		var name = it && it.author ? String(it.author) : "";
+		if (/^[A-Za-z0-9]([A-Za-z0-9-]*[A-Za-z0-9])?$/.test(name) && name.length <= 39)
+			return "https://github.com/" + name;
+		return "";
+	}
+
 	function renderItem(it, hideSummary) {
 		var av = avatarOf(it);
+		var profile = profileOf(it);
 		var html = "<article class=\"item\" data-kind=\"" + esc(it.kind || "") +
 			"\" data-repo=\"" + esc(it.repo || "") +
 			"\" data-author=\"" + esc(it.author || "") +
@@ -170,13 +178,16 @@
 			esc(formatLocal(it.iso)) + "</time> <span class=\"kind\">" +
 			esc(it.kind) + "</span> " + esc(it.repo);
 		if (it.author || av) {
-			html += " <span class=\"who\">";
+			if (profile)
+				html += " <a class=\"who\" href=\"" + esc(profile) + "\">";
+			else
+				html += " <span class=\"who\">";
 			if (av)
 				html += "<img class=\"avatar\" src=\"" + esc(av) +
 					"\" width=\"24\" height=\"24\" alt=\"\" loading=\"lazy\">";
 			if (it.author)
 				html += esc(it.author);
-			html += "</span>";
+			html += profile ? "</a>" : "</span>";
 		}
 		if (it.verified)
 			html += " <span class=\"verified\">verified</span>";
diff --git a/site/assets/style.css b/site/assets/style.css
index 2a76132..2eaf4a5 100644
--- a/site/assets/style.css
+++ b/site/assets/style.css
@@ -285,6 +285,14 @@ footer p {
 	color: var(--fg);
 }
 
+.feed a.who {
+	color: var(--accent);
+}
+
+.feed a.who:hover .avatar {
+	border-color: var(--accent);
+}
+
 .feed .avatar {
 	display: block;
 	width: 24px;
diff --git a/tools/news.awk b/tools/news.awk
index 75c3a05..470a301 100644
--- a/tools/news.awk
+++ b/tools/news.awk
@@ -113,23 +113,36 @@ END {
 	print "</div>"
 }
 
-function print_item(i, brief,    k, when, s, v, a, av) {
+function profile_href(a) {
+	if (a ~ /^[A-Za-z0-9]([A-Za-z0-9-]*[A-Za-z0-9])?$/ && length(a) <= 39)
+		return "https://github.com/" a
+	return ""
+}
+
+function print_item(i, brief,    k, when, s, v, a, av, href) {
 	when = esc(utc_label(iso[i]))
 	k = esc(kind_label(kind[i]))
 	a = author[i]
 	v = verified[i]
 	av = avatar[i]
+	href = profile_href(a)
 	printf "<article class=\"item\" data-kind=\"%s\" data-repo=\"%s\" data-author=\"%s\" data-verified=\"%s\" data-avatar=\"%s\">\n", \
 		k, esc(repo[i]), esc(a), esc(v), esc(av)
 	printf "<p class=\"meta\"><time datetime=\"%s\">%s</time> <span class=\"kind\">%s</span> %s", \
 		esc(iso[i]), when, k, esc(repo[i])
 	if (a != "" || av != "") {
-		printf " <span class=\"who\">"
+		if (href != "")
+			printf " <a class=\"who\" href=\"%s\">", esc(href)
+		else
+			printf " <span class=\"who\">"
 		if (av != "")
 			printf "<img class=\"avatar\" src=\"%s\" width=\"24\" height=\"24\" alt=\"\" loading=\"lazy\">", esc(av)
 		if (a != "")
 			printf "%s", esc(a)
-		printf "</span>"
+		if (href != "")
+			printf "</a>"
+		else
+			printf "</span>"
 	}
 	if (v == "yes")
 		printf " <span class=\"verified\">verified</span>"