From f711b172ee6b8de4a40c9d292f7bf0e4927d049a Mon Sep 17 00:00:00 2001 From: Nick White Date: Fri, 7 May 2010 18:15:56 +0100 Subject: Be less stupid with bibtotxt --- Makefile | 6 +++--- bibtotxt.sh | 32 ++++++++++++++++++++++---------- 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 }' -D $rdf |awk '{print $2}'|sed -e 's/^\[s=uri]$//'`; do +q="PREFIX dc: +PREFIX 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}> ?o }" -D $rdf |sed -e 's/result: \[o=string("//' -e 's/")]//'` - artdate=`roqet -q -e "SELECT ?o WHERE { <${uri}> ?o }" -D $rdf |sed -e 's/result: \[o=string("//' -e 's/")]//'` - stat=`roqet -q -e "SELECT ?o WHERE { <${uri}> ?o }" -D $rdf |awk '{print $2}'|sed -e 's/^\[s=uri]$//'| sed 's/.*\/\([^\/]\)/\1/'` - #should be done with smarter queries - journalurn=`roqet -q -e "SELECT ?o WHERE { <${uri}> ?o }" -D $rdf |awk '{print $2}'|sed -e 's/^\[o=uri]$//'| sed 's/.*\/\([^\/]\)/\1/'` - journaltitle=`roqet -q -e "SELECT ?o WHERE { <${journalurn}> ?o }" -D $rdf |sed -e 's/result: \[o=string("//' -e 's/")]//'` - journaluri=`roqet -q -e "SELECT ?o WHERE { <${journalurn}> ?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 -- cgit v1.2.3