#!/bin/rc
uri = $1 # eg, '/hbspbar/log.html'
domain = $2 # eg, hhvn.uk
subdomain = $3 # eg, src
elems = `('/' $nl){echo $uri}
if (~ $domain ()) {
domain = `hostname
}
fn plink {
printf '%s' $1 $2
}
fn text {
printf '%s' $1
}
if (! ~ $subdomain ()) {
plink '/' $subdomain
text '.'
plink 'https://'^$domain $domain
} else {
plink '/' $domain
}
curi = ''
for (e in $elems) {
# special case for stagit
if (~ $subdomain src && ~ $e log.html) {
exit 0
}
# we're done
if (~ $e index.html) {
exit 0
}
curi = $curi ^ '/' ^ $e
text ' > '
plink $curi `$nl{echo $e | sed 's/\.html$//'}
}