shithub: rc

Download patch

ref: 6374ab566521f5d71e3b6e3fac7462206fd31f14
parent: e71cdbf7fb9dbb53915ae74fd8aa56f96b3b7396
author: glenda <glenda@9front.local>
date: Sun Oct 3 22:30:37 EDT 2021

Shorten URLs

--- /dev/null
+++ b/surl
@@ -1,0 +1,25 @@
+#!/bin/rc
+#
+# set site and surl then mkdir $surl
+#
+site=https://9p.sdf.org
+surl=/usr/web/l
+
+if(! test -d $surl){
+	echo $surl does not exist.
+	exit
+}
+
+echo -n 'surl: '
+url=`{read}
+if(! ~ $url ''){
+	last=`{ls -rt $surl|awk -F/ '{print $5}'|tail -1}
+	if(~ $last ''){
+		last=0
+	}
+	last=`{echo $last|tr a-z A-Z}
+	next=`{echo 'ibase=16;obase=16; ' $last+1 | bc|awk '{print $1}'}
+	mkdir $surl/$next
+	echo '<html><meta http-equiv=refresh content="0; url='$url'"></html>' > $surl/$next/index.html
+	echo $site/l/$next
+}