summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNick White <git@njw.me.uk>2010-05-07 18:15:56 +0100
committerNick White <git@njw.me.uk>2010-05-07 18:15:56 +0100
commitf711b172ee6b8de4a40c9d292f7bf0e4927d049a (patch)
tree245979e189c867b1d8fc8f9adc035b0d3b4632c3
parentda14c926936da061be35db3f350afcded7a7f657 (diff)
downloadnjw-website-f711b172ee6b8de4a40c9d292f7bf0e4927d049a.tar.bz2
njw-website-f711b172ee6b8de4a40c9d292f7bf0e4927d049a.zip
Be less stupid with bibtotxt
-rw-r--r--Makefile6
-rwxr-xr-xbibtotxt.sh32
2 files changed, 25 insertions, 13 deletions
diff --git a/Makefile b/Makefile
index 5c8a01e..bc0a0e1 100644
--- a/Makefile
+++ b/Makefile
@@ -16,13 +16,13 @@ all: $(TARGETS) $(GZIP)
$(TARGETS): includes/header.xml includes/footer.xml
-$(RSS): $(PAGES) makerss.sh
+$(RSS): $(PAGES)
echo making $@
sh makerss.sh $(SITENAME) $(FOAF) $* > $@
-publications/index.txt: $(BIB) bibtotxt.sh
+publications/index.txt: $(BIB)
echo making $@
- sh bibtotxt.sh $(BIB) > $@
+ sh bibtotxt.sh $< > $@
.txt.xml:
echo making $@
diff --git a/bibtotxt.sh b/bibtotxt.sh
index 2e584b7..681ab7c 100755
--- a/bibtotxt.sh
+++ b/bibtotxt.sh
@@ -6,19 +6,31 @@ echo "Publications"
echo "======================================================================="
echo ""
-# do this with awk
-for uri in `roqet -q -e 'SELECT ?s WHERE { ?s a <http://purl.org/ontology/bibo/Article> }' -D $rdf |awk '{print $2}'|sed -e 's/^\[s=uri<//' -e 's/>]$//'`; do
+q="PREFIX dc: <http://purl.org/dc/elements/1.1/>
+PREFIX bibo: <http://purl.org/ontology/bibo/>
+SELECT ?a ?title ?artdate ?stat ?jtitle ?juri
+WHERE {
+?a a bibo:Article;
+ dc:title ?title;
+ dc:date ?artdate;
+ bibo:status ?stat;
+ dc:isPartOf ?j.
+?j dc:title ?jtitle;
+ bibo:uri ?juri.
+}"
+
+roqet -q -r csv -e "$q" -D /dev/stdin < $rdf | sed '/^Result/d' \
+| while read r; do
+ uri=`echo $r | awk -F , '{print $2}'| sed -e 's/uri(\(.*\))/\1/'`
reluri=`echo $uri | sed 's/.*\/\([^\/]\)/\1/'`
- title=`roqet -q -e "SELECT ?o WHERE { <${uri}> <http://purl.org/dc/elements/1.1/title> ?o }" -D $rdf |sed -e 's/result: \[o=string("//' -e 's/")]//'`
- artdate=`roqet -q -e "SELECT ?o WHERE { <${uri}> <http://purl.org/dc/elements/1.1/date> ?o }" -D $rdf |sed -e 's/result: \[o=string("//' -e 's/")]//'`
- stat=`roqet -q -e "SELECT ?o WHERE { <${uri}> <http://purl.org/ontology/bibo/status> ?o }" -D $rdf |awk '{print $2}'|sed -e 's/^\[s=uri<//' -e 's/>]$//'| sed 's/.*\/\([^\/]\)/\1/'`
- #should be done with smarter queries
- journalurn=`roqet -q -e "SELECT ?o WHERE { <${uri}> <http://purl.org/dc/elements/1.1/isPartOf> ?o }" -D $rdf |awk '{print $2}'|sed -e 's/^\[o=uri<//' -e 's/>]$//'| sed 's/.*\/\([^\/]\)/\1/'`
- journaltitle=`roqet -q -e "SELECT ?o WHERE { <${journalurn}> <http://purl.org/dc/elements/1.1/title> ?o }" -D $rdf |sed -e 's/result: \[o=string("//' -e 's/")]//'`
- journaluri=`roqet -q -e "SELECT ?o WHERE { <${journalurn}> <http://purl.org/ontology/bibo/uri> ?o }" -D $rdf |sed -e 's/result: \[o=string("//' -e 's/")]//'`
+ title=`echo $r | awk -F , '{print $3}'| sed -e 's/"\(.*\)"/\1/'`
+ artdate=`echo $r | awk -F , '{print $4}'| sed -e 's/"\(.*\)"/\1/'`
+ stat=`echo $r | awk -F , '{print $5}'| sed -e 's/uri(\(.*\))/\1/' -e 's/.*\/\([^\/]\)/\1/'`
+ jtitle=`echo $r | awk -F , '{print $6}'| sed -e 's/"\(.*\)"/\1/'`
+ juri=`echo $r | awk -F , '{print $7}'| sed -e 's/"\(.*\)"/\1/'`
echo "- [${title}](${reluri})"
echo " [[PDF]](${reluri}.pdf) (${artdate})"
- echo " *[${journaltitle}](${journaluri})*"
+ echo " *[${jtitle}](${juri})*"
echo " [${stat}]"
done