~earboxer/apkbrowser-gemini

apkbrowser-gemini/content -rwxr-xr-x 612 bytes
554033efZach DeCook branding: add index and favicon for musicdir a month 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
#!/bin/sh
. ./config.sh
IFS=/
set -- $PATH_INFO

branch="$(printf '%s' $2 | tr -dc '[:alnum:]-')"
repo="$(printf '%s' $3 | tr -dc '[:alnum:]-')"
arch="$(printf '%s' $4 | tr -dc '[:alnum:]-')"
package="$(printf '%s' $5 | tr -dc '[:alnum:]-')"

content="$(printf "SELECT \"*\", path||\"/\"||file
	FROM files
	LEFT JOIN packages ON pid = packages.id
	WHERE repo=\"$repo\" AND arch=\"$arch\" AND name=\"$package\";" | \
sqlite3 -separator "$(printf "\t")" "db/$branch.db")"

if ! test "$content"; then
	printf "51 Not Found\r\n"
	exit 1
fi

printf "20 text/gemini\r\n"

echo "# Contents of $package"
echo "$content"