blob: a43a4123b06fbbd3425bcbf332629ca7db222738 (
plain) (
blame)
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
50
51
52
|
#! /bin/rc
#TODO add content type parser
cr=
fn header{
echo $1 $2$cr
}
fn filetype{
filetype=`{file -m $1}
type=text/gemini
#TODO: expand
switch ($filetype){
case image*:
type=$filetype
}
echo $type
}
webroot=./
while(! ~ $#* 0) {
switch ($1) {
case -w
webroot=$2
shift
case -m
mflag='yes'
case *
echo Usage: g9srv/fsr [-w webroot] [-m]
exit usage
}
shift
}
fullurl=`{read}
if(~ $mflag yes)
url=`{echo $fullurl | sed 's/gemini:\/\///
s/
//'}
if not
url=`{echo $fullurl | sed 's/gemini:\/\/[0-9 a-z .]*//
s/
//'}
if(~ $url '') url=/
if(test -f $webroot$url){
header 20 text/gemini
cat $webroot$url
exit 0
}
if(test -f $webroot$url/index.gmi)
header 20 text/utf8
cat $webroot$url/index.gmi
exit 0
}
header 51 'file not found'
|