src.hhvn.uk > hhvn.uk-scripts > file > www > generate > breadcrumb

scripts that power hhvn.uk
Log | Files | Refs | README

breadcrumb (670B)


      1 #!/bin/rc
      2 
      3 uri       = $1 # eg, '/hbspbar/log.html'
      4 domain    = $2 # eg, hhvn.uk
      5 subdomain = $3 # eg, src
      6 elems     = `('/' $nl){echo $uri}
      7 
      8 if (~ $domain ()) {
      9 	domain = `hostname
     10 }
     11 
     12 fn plink {
     13 	printf '<a href="%s">%s</a>' $1 $2
     14 }
     15 
     16 fn text {
     17 	printf '%s' $1
     18 }
     19 
     20 if (! ~ $subdomain ()) {
     21 	plink '/' $subdomain
     22 	text '.'
     23 	plink 'https://'^$domain $domain
     24 } else {
     25 	plink '/' $domain
     26 }
     27 
     28 curi = ''
     29 for (e in $elems) {
     30 	if (!~ $e '.') {
     31 		# special case for stagit
     32 		if (~ $subdomain src && ~ $e log.html) {
     33 			exit 0
     34 		}
     35 
     36 		# we're done
     37 		if (~ $e index.html) {
     38 			exit 0
     39 		}
     40 
     41 		curi = $curi ^ '/' ^ $e
     42 
     43 		text ' &gt; '
     44 		plink $curi `$nl{echo $e | sed 's/\.html$//'}
     45 	}
     46 }