summaryrefslogtreecommitdiff
path: root/www/generate/breadcrumb
blob: 6b9f821b55abb9e73f10e7756531ece355a12fbf (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
#!/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 '<a href="%s">%s</a>' $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 ' &gt; '
	plink $curi `$nl{echo $e | sed 's/\.html$//'}
}