aboutsummaryrefslogtreecommitdiff
path: root/mkweb
blob: 2be2275ab4e2382a40a5015d21b84680bb055e5b (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
45
46
47
48
49
#!/bin/rc
rfork en
filter='^(bin|lib|pic|tpl)'
sections=`{walk -d | grep -v $filter}

fn entitle {
	basename $1 | sed 's/-/ /g' | bin/capitalize
}

fn usage {
	echo usage: $0 [ -m ] [ -s section ] >[1=2]
	exit usage
}

fn buildsection {
	if(test -f $1/index.md)
		>$1/index.html {
			if(! ~ $1 .){
				title=`{entitle $1}
				<tpl/head sed 's/(<title>[^<]*)/\1 - '^$"title^'/'
			}
			if not cat tpl/head
			cat tpl/menu \
			<{bin/md2html.awk $1/index.md}\
			tpl/feet
		}
}

if(! ~ $#* 0)
	switch($1){
	case -m
		>sitemap.txt {
			site=http://rgl.antares-labs.eu
			echo $site/index.html
			for(d in $sections)
				echo $site/$d/index.html
		}
		exit
	case -s
		if(~ $#2 0)
			usage
		sections=`{walk -d $2 | grep -v $filter}
	case -*
		usage
	}

for(d in $sections .){
	buildsection $d
}