diff --git a/utils/lodspk.sh b/utils/lodspk.sh index 744539040fcb32f64a986f60e18321f064d29ce4..bf1504aee8885c5c5765ea6e84e278278dfa2c28 100755 --- a/utils/lodspk.sh +++ b/utils/lodspk.sh @@ -1,23 +1,16 @@ #!/bin/bash # # https://github.com/alangrafu/lodspeakr/blob/master/utils/ldspk.sh - USAGE="Usage: $0 create|delete uri|type|service foo [html|rdf|ttl|nt|json]" USAGEDEBUG="Usage: $0 debug on|off" if [[ $# -eq 0 || "$1" == "--help" ]]; then - echo $USAGE - exit 1 + echo $USAGE + exit 1 fi DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" -operations=( create delete debug ) -modules=( type service uri ) -formats=( html rdf ttl nt json all ) -debugOptions=( on off 0 1 ) +operations=( create delete debug backup ) currentOperation= -currentModule= -currentFormat= -debugOperation= if [[ ${operations[@]} =~ $1 ]]; then currentOperation=$1 @@ -27,17 +20,17 @@ else exit 1 fi -if [[ $currentOperation = "debug" ]] -then - if [[ ${debugOptions[@]} =~ $2 ]] - then - debugOperation=$2 - else - echo "Debug option not supported. Operation aborted" >&2 - echo $USAGEDEBUG - exit 1 - fi -else +## Backup +if [[ $currentOperation == "backup" ]]; then + $DIR/modules/backup.sh +fi + +## Create/delete +if [[ $currentOperation == "create" || $currentOperation == "delete" ]]; then + modules=( type service uri ) + formats=( html rdf ttl nt json all ) + currentModule= + currentFormat= if [[ ${modules[@]} =~ $2 ]]; then currentModule=$2 else @@ -45,9 +38,9 @@ else echo $USAGE exit 1 fi - + currentUnit=$3 - + if [[ ${formats[@]} =~ $4 ]]; then currentFormat=$4 else @@ -59,15 +52,20 @@ else exit 1 fi fi + $DIR/modules/create-$currentModule.sh "$currentUnit" "$currentFormat" fi - -if [[ $currentOperation == "create" ]]; then - $DIR/modules/create-$currentModule.sh "$currentUnit" "$currentFormat" -fi -if [[ $currentOperation == "delete" ]]; then - $DIR/modules/delete-$currentModule.sh "$currentUnit" "$currentFormat" -fi +## Debug if [[ $currentOperation == "debug" ]]; then - php $DIR/modules/debug.php "$debugOperation" + debugOptions=( on off 0 1 ) + debugOperation= + if [[ ${debugOptions[@]} =~ $2 ]] + then + debugOperation=$2 + else + echo "Debug option not supported. Operation aborted" >&2 + echo $USAGEDEBUG + exit 1 + fi + php $DIR/modules/debug.php "$debugOperation" fi diff --git a/utils/modules/backup.sh b/utils/modules/backup.sh new file mode 100755 index 0000000000000000000000000000000000000000..396de7661cfdf508b49ffe88547c4c33981cfb57 --- /dev/null +++ b/utils/modules/backup.sh @@ -0,0 +1,22 @@ +#!/bin/bash + +DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" +BACKUPDIR=$HOME/lodspeakr_backup +cd $DIR/../.. +if [[ ! -d $BACKUPDIR ]]; then + echo "WARNING: No $BACKUPDIR dir. Creating it." >&2 + mkdir $BACKUPDIR +fi + +if [[ ! -d $BACKUPDIR ]]; then + echo "ERROR: Couldn't create $BACKUPDIR. Operation aborted" >&2 + exit 1 +fi + +tmpFile=lodspeakr_backup_`date +%Y%m%d%H%M%S`.tar.gz + +tar -czf $tmpFile settings.inc.php models views + +mv $tmpFile $BACKUPDIR/ +echo "New backup $tmpFile created" + diff --git a/views/uri.local:alvaro/html.template b/views/uri.local:alvaro/html.template new file mode 100644 index 0000000000000000000000000000000000000000..367b355acf1b01501912d188ec3fb5389eafb8ab --- /dev/null +++ b/views/uri.local:alvaro/html.template @@ -0,0 +1,50 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML+RDFa 1.0//EN" + "http://www.w3.org/MarkUp/DTD/xhtml-rdfa-1.dtd"> +<html xmlns="http://www.w3.org/1999/xhtml" {% for i, ns in base.ns %}xmlns:{{i}}="{{ns}}" + {%endfor%}version="XHTML+RDFa 1.0" xml:lang="en"> + <head> + <title>Page about {{lodspk.this.value}}</title> + <link href="{{lodspk.baseUrl}}css/basic.css" rel="stylesheet" type="text/css" media="screen" /> + <link rel="alternate" type="application/rdf+xml" title="RDF/XML Version" href="{{lodspk.this.value}}.rdf" /> + <link rel="alternate" type="text/turtle" title="Turtle Version" href="{{lodspk.this.value}}.ttl" /> + <link rel="alternate" type="text/plain" title="N-Triples Version" href="{{lodspk.this.value}}.nt" /> + <link rel="alternate" type="application/json" title="RDFJSON Version" href="{{lodspk.this.value}}.json" /> + </head> + <body about="{{lodspk.this.value}}"> + <h1>Page about <a href='{{lodspk.this.value}}'>{{lodspk.this.curie}}</a></h1> + <div> + <h2>Information from {{lodspk.this.curie}}</h2> + <table> + {% for row in models.main %} + + {% if row.s1%} + <tr> + <td><a href='{{row.s1.value}}'>{{row.s1.curie}}</a></td> + + {% if row.p1.uri == 1 %} + <td><a rel='{{row.s1.curie}}' href='{{row.p1.value}}'>{{row.p1.curie}}</a></td> + {% else %} + <td><span property='{{row.s1.curie}}'>{{row.p1.value}}</span></td> + {% endif %} + + </tr> + {% endif %} + {% endfor %} + </table> + + <br/><br/> + <h2>Information pointing to {{lodspk.this.curie}}</h2> + <table> + {% for row in models.main %} + {% if row.s2%} + <tr> + <td><a href='{{row.s2.value}}'>{{row.s2.curie}}</a></td> + <td><a rev='[{{row.p2.curie}}]' href='{{row.s2.value}}'>{{row.p2.curie}}</a></td> + </tr> + {%endif %} + {% endfor %} + </table> + </div> + </body> +</html>