~moody/rc-gemd

ref: ed5406089b36f97cbe0178a8bcb24652f4d4022a rc-gemd/handlers/serve-static -rwxr-xr-x 516 bytes
ed540608Moody Initial commit 11 months ago
                                                                                
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
#!/bin/rc
full_path=`{echo $"fs_root^$"location | urlencode -d}
full_path=$"full_path

if(! test -e $full_path){
	error 41 'file does not exist'
	exit
}

if(! test -r $full_path){
	error 42 'file is not readble'
	exit
}

switch($full_path){
case *.gem *.gemini
        type=text/gemini
case *.txt *.md
        type=text/plain
case *.jpg *.jpeg
        type=image/jpeg
case *.gif
        type=image/gif
case *.png
        type=image/png
case *
        type=`{file -m $full_path}
}

echo 20' '$type^$cr
cat $full_path