wm: infra

Download patch

ref: 32ffe2f950e8fc5a18a13a586c890cf4c828f754
parent: 45c1a8e584fc2d7d352bc58aadc38389af6a6193
author: mkf <mkf>
date: Thu Sep 5 02:02:19 EDT 2024

doc{txt,web}: import

these tools are used to generate wiki pages
loosely based on ori's shithub.

--- /dev/null
+++ b/doctxt
@@ -1,0 +1,30 @@
+#!/bin/rc -e
+
+. /sys/lib/shithub/common.rc
+
+cd $1
+shift
+
+rfork ne
+nl='
+'
+
+gituser=$1
+repo=$2
+refname=$3
+file=$4
+
+repons $gituser $repo
+if(! ref=`{resolveref $refname}){
+	echo 'Invalid ref '$refname''
+	exit
+}
+
+if(! test -d $gitfs/$ref/tree){
+	echo 'No such document'
+	exit
+}
+
+cd $gitfs/$ref/tree
+nroff -ms $gitfs/$ref/tree/$file.ms | col -bf
+
--- /dev/null
+++ b/docweb
@@ -1,0 +1,42 @@
+#!/bin/rc -e
+
+. /sys/lib/shithub/common.rc
+
+cd $1
+shift
+
+rfork ne
+nl='
+'
+
+gituser=$1
+repo=$2
+refname=$3
+file=$4
+
+repons $gituser $repo
+if(! ref=`{resolveref $refname}){
+	echo '<b>invalid ref '$refname'</b>'
+	exit
+}
+
+if(! test -d $gitfs/$ref/tree){
+	echo '	<p>No code pushed</p>
+		</body>
+		</html>
+	'
+	exit
+}
+
+cd $gitfs/$ref/tree
+
+echo '	<p>'
+
+echo '<p><div id="content">'
+
+ms2html < $gitfs/$ref/tree/$file.ms
+	
+echo '	</div>
+	</p>
+	</body>
+	</html>'