summaryrefslogtreecommitdiff
path: root/examples
diff options
context:
space:
mode:
authorJonas Smedegaard <dr@jones.dk>2013-05-20 23:37:32 +0200
committerJonas Smedegaard <dr@jones.dk>2013-05-20 23:37:32 +0200
commitc2f6227e773263be2aeaf65057c01aac9d1b101b (patch)
treeb0f72764b5b29c5760a41e4a05bf4040acc0ef1e /examples
Initial commit.
Diffstat (limited to 'examples')
-rwxr-xr-xexamples/mkevents64
-rwxr-xr-xexamples/mkhours64
2 files changed, 128 insertions, 0 deletions
diff --git a/examples/mkevents b/examples/mkevents
new file mode 100755
index 0000000..0c25233
--- /dev/null
+++ b/examples/mkevents
@@ -0,0 +1,64 @@
+#!/bin/sh
+#
+# Copyright © 2013 Jonas Smedegaard <dr@jones.dk>
+# Description: render and publish event webpage from RDF data
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 3, or (at your option)
+# any later version.
+#
+# This program is distributed in the hope that it will be useful, but
+# WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+# General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
+
+set -e
+
+# defaults sensible for the author when invoked from project root
+outfile=events.html
+infiles="data/*/*.ttl data/*/*/*.ttl"
+rsync_credentials=coreander
+rsync_path=/home/jonas/public_websites/data.biks.dk/events/index.html
+script=bin/rdf2events
+
+# make backup of eventual existing output
+if [ -f $outfile~ ]; then
+ echo >&2 "ERROR: old tempfile $outfile~ exist!"
+ echo >&2 "Check that script isn't already running, remove the file, and try again."
+ exit 1
+fi
+
+echo "Rendering $outfile..."
+$script $infiles > $outfile~
+
+if [ -f $outfile ]; then
+ echo "Comparing $outfile against older version..."
+ errorcode=0
+ diff -ruN $outfile $outfile~ || errorcode=$?
+ case $errorcode in
+ 0) echo "No changes from previous version"; exit;;
+ 1) printf "Above are changes from previous version. ";;
+ *) echo >&2 "ERROR: internal diff error!"; exit $errorcode;;
+ esac
+fi
+
+# ask, publish, and update on-disk file for later comparison
+printf "OK to publish (y/N)? "
+read do_update
+case $do_update in
+ y|Y)
+ echo "Publishing $outfile..."
+ rsync -a $outfile~ $rsync_credentials:$rsync_path
+ mv -f $outfile~ $outfile
+ echo "Done: $outfile published succesfully!"
+ ;;
+ *)
+ rm $outfile~
+ echo "Cancelled, as requested."
+ exit
+ ;;
+esac
diff --git a/examples/mkhours b/examples/mkhours
new file mode 100755
index 0000000..1e0168a
--- /dev/null
+++ b/examples/mkhours
@@ -0,0 +1,64 @@
+#!/bin/sh
+#
+# Copyright © 2013 Jonas Smedegaard <dr@jones.dk>
+# Description: render and publish opening hours webpage from RDF data
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 3, or (at your option)
+# any later version.
+#
+# This program is distributed in the hope that it will be useful, but
+# WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+# General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
+
+set -e
+
+# defaults sensible for the author when invoked from project root
+outfile=hours.html
+infiles="data/*/*.ttl data/*/*/*.ttl"
+rsync_credentials=coreander
+rsync_path=/home/jonas/public_websites/data.biks.dk/hours/index.html
+script=bin/rdf2hours
+
+# make backup of eventual existing output
+if [ -f $outfile~ ]; then
+ echo >&2 "ERROR: old tempfile $outfile~ exist!"
+ echo >&2 "Check that script isn't already running, remove the file, and try again."
+ exit 1
+fi
+
+echo "Rendering $outfile..."
+$script $infiles > $outfile~
+
+if [ -f $outfile ]; then
+ echo "Comparing $outfile against older version..."
+ errorcode=0
+ diff -ruN $outfile $outfile~ || errorcode=$?
+ case $errorcode in
+ 0) echo "No changes from previous version"; exit;;
+ 1) printf "Above are changes from previous version. ";;
+ *) echo >&2 "ERROR: internal diff error!"; exit $errorcode;;
+ esac
+fi
+
+# ask, publish, and update on-disk file for later comparison
+printf "OK to publish (y/N)? "
+read do_update
+case $do_update in
+ y|Y)
+ echo "Publishing $outfile..."
+ rsync -a $outfile~ $rsync_credentials:$rsync_path
+ mv -f $outfile~ $outfile
+ echo "Done: $outfile published succesfully!"
+ ;;
+ *)
+ rm $outfile~
+ echo "Cancelled, as requested."
+ exit
+ ;;
+esac