shithub: misc

Download patch

ref: 103c1ae3c97f64130cc4ed787517a3930ba0add5
parent: a8873f75169ddcb7d280f23e834926ef577b2530
author: qwx <[email protected]>
date: Mon Jan 30 21:47:45 EST 2023

werc/ls: handle an index.html prepending the listing

--- a/werc/ls/app.rc
+++ b/werc/ls/app.rc
@@ -6,8 +6,15 @@
 	d=`{basename -d $1}
 	if(~ $#d 0)
 		d='/'
-	echo $d | sed 's,.*//,,g; s,/$,,; s,/, / ,g; s,.*,<h1 class="dir-list-head">&</h1> <ul class="dir-list">,'
-	echo '<a href="../">..</a><br><table border="0"><tr><th>size<th>last modified<th>name</tr>'
-	ls -Fl $sitedir$d | sed $dirclean'/_werc/d;s/^[^ ]+ [^ ]+ [^ ]+ [^ ]+ [^ ]+ +//;s/^([^ ]+) (.*) [^ ]+\/([^''\/\* ]+\/?)''?(\*?)$/<tr><td>\1<td>\2<td><a href="\3">\3\4<\/a><\/tr>/'
+	if(test -f $sitedir$d/index.md){
+		$formatter $sitedir$d/index.md
+		echo '<ul class="dir-list">'
+	}
+	if not{
+		echo $d | sed 's,.*//,,g; s,/$,,; s,/, / ,g; s,.*,<h1 class="dir-list-head">&</h1> <ul class="dir-list">,'
+		echo '<a href="../">..</a><br>'
+	}
+	echo '<table border="0"><tr><th>size<th>last modified<th>name</tr>'
+	ls -Fl $sitedir$d | sed $dirclean'/_werc/d;/index/d;s/^[^ ]+ [^ ]+ [^ ]+ [^ ]+ [^ ]+ +//;s/^([^ ]+) (.*) [^ ]+\/([^''\/\* ]+\/?)''?(\*?)$/<tr><td>\1<td>\2<td><a href="\3">\3\4<\/a><\/tr>/'
 	echo '</table></ul>'
 }