summaryrefslogtreecommitdiff
path: root/websummary.sh
blob: 1b9e22f586e88067cb00be3b812d81c7c0c1c8c2 (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/sh
# See COPYING file for copyright and license details.
#
# Creates a project summary based on a doap file

test $# -ne 1 && echo "usage: $0 doap" && exit 1

rdf="$1"

q="PREFIX doap: <http://usefulinc.com/ns/doap#>
PREFIX foaf: <http://xmlns.com/foaf/0.1/>
SELECT ?home ?repo ?license ?maintainer ?maintainerhome ?lang ?repotype
WHERE {
?p a doap:Project;
   doap:homepage ?home;
   doap:repository ?r;
   doap:license ?license;
   doap:programming-language ?lang;
   doap:maintainer ?m.
?r a ?repotype;
   doap:location ?repo.
?m foaf:name ?maintainer;
   foaf:homepage ?maintainerhome.
}"

roqet -q -r csv -e "$q" -D /dev/stdin < $rdf | sed '1d' \
| while read r; do
	home=`echo $r | awk -F , '{print $2}' | sed 's/uri(//;s/)$//'`
	repo=`echo $r | awk -F , '{print $3}' | sed 's/uri(//;s/)$//'`
	licenseuri=`echo $r | awk -F , '{print $4}' | sed 's/uri(//;s/)$//'`
	maint=`echo $r | awk -F , '{print $5}' | sed 's/"//g'`
	mainthome=`echo $r | awk -F , '{print $6}' | sed 's/uri(//;s/)$//'`
	lang=`echo $r | awk -F , '{print $7}' | sed 's/"//g'`
	test "$licenseuri" = "http://www.gnu.org/licenses/gpl.html" && license="GPL"
	test "$licenseuri" = "http://www.gnu.org/licenses/agpl.html" && license="AGPL"
	test "$licenseuri" = "http://creativecommons.org/licenses/MIT/" && license="MIT"
	test "$licenseuri" = "http://www.isc.org/software/license" && license="ISC"
	repotype=`echo $r | awk -F , '{print $8}' | sed 's/uri(//;s/)$//'`
	test "$repotype" = "http://usefulinc.com/ns/doap#GitRepository" && repocmd="git clone"

	cat <<- _EOF_
- Project homepage: [$home]($home)
- Code repository: $repocmd $repo
- Maintainer: [$maint]($mainthome)
- Language: $lang
- License: [$license]($licenseuri)
- DOAP: [${home}doap.ttl](${home}doap.ttl)
_EOF_
done