"GOT", but the "O" is a cute, smiling pufferfish. Index | Thread | Search

From:
Omar Polo <op@omarpolo.com>
Subject:
Re: got-www: generate HTML page from CHANGES
To:
Stefan Sperling <stsp@stsp.name>
Cc:
gameoftrees@openbsd.org
Date:
Mon, 28 Oct 2024 12:49:36 +0100

Download raw body.

Thread
On 2024/10/28 07:43:15 +0100, Stefan Sperling <stsp@stsp.name> wrote:
> On Sun, Oct 27, 2024 at 06:21:10PM +0100, Omar Polo wrote:
> > Just an idea.  It's easier to read the changelog on a web browser this
> > way, and we could even link the changes for a specific release?
> > 
> > Here's a preview: https://tmp.omarpolo.com/changes.html
> > 
> > If ok I'll commit the generated releases/changes.html as well.
> > 
> > Thoughs?  Do we need something similar for -portable too? =)
> 
> I am not opposed. Fine with me.
> I don't mind plaintext but HTML certainly looks better in a browser.

Great, I'll do something similar for -portable changelog as well as a
follow-up then.

> > +<p>
> > +See git repository history for per-change authorship information
> > +</p>
> 
> Might as well make "git repository" a clickable link?

Yes, makes sense!

Here's an updated diff with some feedback that I received off-list.

 - slightly better awk code
 - better html
 - updated the links in index.html
 - changed the format of the title

I've also updated the preview at <https://tmp.omarpolo.com/changes.html>.


Thanks,
Omar Polo

diff /home/op/w/got-www
commit - 2fa5e3a8004ff7eea62475253244dec9567b245f
path + /home/op/w/got-www
blob - 9ff7cfc546813adf215ffaa0ef7f7b0344856d52
file + index.html
--- index.html
+++ index.html
@@ -14,7 +14,7 @@
       <h1>About Got</h1>
       <ul>
         <li><a href="goals.html">Project Goals</a>
-        <li><a href="releases/CHANGES">Change Log</a>
+        <li><a href="releases/changes.html">Change Log</a>
       </ul>
       <h1>Resources</h1>
       <ul>
@@ -62,7 +62,7 @@
       </h1>
 
       <p id="callout">
-      <a href="releases/CHANGES">Game of Trees 0.104</a> released October 22, 2024
+      <a href="releases/changes.html">Game of Trees 0.104</a> released October 22, 2024
       <br>
       <a href="releases/portable/CHANGELOG">Game of Trees -portable 0.104</a> released October 22, 2024
 
blob - /dev/null
file + sync-changes.sh (mode 755)
--- /dev/null
+++ sync-changes.sh
@@ -0,0 +1,105 @@
+#!/bin/sh
+
+exec >releases/changes.html
+
+cat <<EOF
+<!doctype html>
+<html lang="en">
+<head>
+  <meta charset=utf-8>
+  <title>Game of Trees Changes</title>
+  <meta name="description" content="Game of Trees Changelog">
+  <meta name="viewport" content="width=device-width, initial-scale=1">
+  <link rel="stylesheet" type="text/css" href="/openbsd.css">
+  <link rel="canonical" href="https://gameoftrees.org/releases/changes.html">
+</head>
+<body>
+
+<h2>
+<a href="/"><i>Game of Trees</i></a>
+Changes
+</h2>
+<hr>
+
+<p>
+See the
+<a href="https://got.gameoftrees.org/?action=summary&path=got.git">git repository</a>
+history for per-change authorship information.
+</p>
+
+EOF
+
+awk '
+// {
+	sub("^ +", "")
+	sub(" +$", "")
+}
+/^\*/ {
+	if (change != "") {
+		emit()
+		doclose = 1
+	}
+	if (insublist) {
+		insublist = 0
+		print("</ul></li>")
+	}
+	if (doclose == 1) {
+		doclose = 0
+		print("</ul>")
+	}
+	sub(";", "", $3)
+	version = $3
+	date = $4
+	printf("<h3 id=\"%s\"><a href=\"#%s\">GoT %s - %s</a></h3>\n", date, date, version, date)
+	print("<ul>")
+	next
+}
+/^$/ { next }
+/see git repository history for per-change authorship/ { next }
+/^-/ {
+	emit()
+	if (insublist) {
+		insublist = 0
+		print("</ul></li>")
+	}
+	sub("^- *", "", $0)
+	change = $0
+	next
+}
+/^o / {
+	emit()
+	if (!insublist) {
+		insublist = 1
+		print("<li><ul>")
+	}
+	sub("^o +", "", $0)
+	change = $0
+	next
+}
+// { change = change " " $0 }
+END {
+	emit()
+	if (insublist)
+		print("</ul></li>")
+	print("</ul>")
+}
+function san(s) {
+	gsub("&", "\\&amp;", s)
+	gsub("<", "\\&lt;", s)
+	gsub(">", "\\&gt;", s)
+	return s
+}
+function emit() {
+	if (change == "")
+		return
+	print("<li>")
+	print(san(change))
+	print("</li>")
+	change = ""
+}
+' < releases/CHANGES
+
+cat <<EOF
+</body>
+</html>
+EOF