commit 1743061793e4cc23e36ac329672c84545f407069
parent 38c746a94b80375b29284ef835b6d973be43c0cd
Author: hhvn <dev@hhvn.uk>
Date: Fri, 25 Nov 2022 17:42:51 +0000
Generate blog
Diffstat:
3 files changed, 64 insertions(+), 1 deletion(-)
diff --git a/gen/generate.rc b/gen/generate.rc
@@ -0,0 +1,59 @@
+#!/bin/rc
+
+cd `$nl{dirname $0}
+
+make -C stagit
+./stagit-create.rc
+
+make -C stagit-gopher
+./stagit-gopher-create.rc
+
+# Blog generation
+blog = ../www/blog/index.html
+blogdir = ../www/blog
+
+rm $blogdir/*
+for (f in ../notes/*) {
+ cp $f $blogdir/ ^ `$nl{basename $f}
+}
+
+cat > $blog <<'EOF'
+<!DOCTYPE html>
+<html>
+<head>
+ <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
+ <meta name="viewport" content="width=device-width, initial-scale=1" />
+ <title>hhvn's blog</title>
+ <link rel="stylesheet" type="text/css" href="../index.css" />
+</head>
+<body>
+ <h1>hhvn's blog</h1>
+ <hr />
+
+EOF
+
+fn recent {
+ test `{datediff -f '%d' $1 now} -le 5
+}
+
+
+{for (f in $blogdir/*.txt) {
+ date = `$nl{grep '^Date: ' < $f | sed 's/[^ ]* //'}
+ updated = `$nl{grep '^Upated: ' < $f | sed 's/[^ ]* //;s/ .*//'}
+
+ if (recent $date || {!~ $updated () && recent $updated}) {
+ recent = '<b style="color:#00aa00 !important;">[NEW]</b> '
+ } else {
+ recent = ' '
+ }
+
+ printf '[%s] %s<a href="./%s">%s</a><br />' \
+ $date \
+ $recent \
+ `$nl{basename $f} \
+ `$nl{grep '^Title: ' < $f | sed 's/[^ ]* //'}
+}} | sort >> $blog
+
+cat >> $blog <<'EOF'
+</body>
+EOF
diff --git a/gen/stagit-create.rc b/gen/stagit-create.rc
@@ -23,7 +23,7 @@ for (d in $repos/*) {
stagit -c '.cache' -u 'git://hhvn.uk/' ^ $base $d
ln -sf log.html index.html
- ln -sf $me/../www/index.css style.css
+ ln -sf ../index.css style.css
}
echo 'done'
diff --git a/www/index.css b/www/index.css
@@ -13,6 +13,10 @@ body {
margin: 0 auto;
}
+* {
+ font-family: monospace;
+}
+
table.log {
width: 80vw;
}