diff --git a/classes/BasicSpecialFunction.php b/classes/BasicSpecialFunction.php index 93dde2673700ce127152eb91dfcce4f0f45328f9..28d3ac5a265d4843db3fcf3c0c8b014c034acd75 100644 --- a/classes/BasicSpecialFunction.php +++ b/classes/BasicSpecialFunction.php @@ -73,7 +73,8 @@ class SpecialFunction extends AbstractSpecialFunction{ $base['this']['contentType'] = $acceptContentType; $base['model']['directory'] = $conf['model']['directory']; $base['view']['directory'] = $conf['view']['directory']; - $base['ns'] = $conf['ns']; $base['ns'] = $conf['ns']; + $base['ns'] = $conf['ns']; + $base['sparqlendpoint'] = $conf['endpoint']; $base['type'] = $modelFile; $base['header'] = $prefixHeader; $base['args'] = $args; @@ -83,7 +84,8 @@ class SpecialFunction extends AbstractSpecialFunction{ $base['view']['directory'] = $conf['home'].$conf['view']['directory']; $base['model']['directory'] = $conf['home'].$conf['model']['directory']; chdir($conf['model']['directory']); - Utils::queryFile($modelFile, $endpoints['local'], $data); + $first = array(); + Utils::queryFile($modelFile, $endpoints['local'], $data, $first); chdir($conf['home']); $data = Utils::internalize($data); diff --git a/classes/MetaDb.php b/classes/MetaDb.php index 6bed8c9096fdccb8c1a7496d379ebd4d5e230ae8..5cf0d89a8d04cc9a2cd58341c2edf11b09912946 100644 --- a/classes/MetaDb.php +++ b/classes/MetaDb.php @@ -30,13 +30,13 @@ class MetaDb{ global $conf; try{ $db = new PDO('sqlite:'.$this->dbLocation); - $db->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_WARNING); - - $results = $db->exec($q); + $db->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION); + $results = $db->exec($q); $db = NULL; - }catch(PDOException $e){ - print 'Exception exec: '.$e->getMessage()."\n\n"; - exit(10); + }catch(Exception $e){ + echo "Can't write in SQLite database. Please check you have granted write permissions to <tt>meta/</tt> and <tt>meta/db.sqlite</tt>."; + trigger_error('Exception exec: '.$e->getMessage(), E_USER_ERROR); + exit(1); } return $results; } diff --git a/classes/Utils.php b/classes/Utils.php index 6002caa4a753b2d472e250bd8fa01a4068c14a15..2c7581fd54bca5b4accc910fee429ab5075d4802 100644 --- a/classes/Utils.php +++ b/classes/Utils.php @@ -22,9 +22,12 @@ class Utils{ exit(0); } - public static function send500($uri){ + public static function send500($msg = null){ header("HTTP/1.0 500 Internal Server Error"); echo "An internal error ocurred. Please try later\n\n"; + if($msg != null){ + echo $msg; + } exit(0); } diff --git a/utils/install b/utils/install new file mode 100644 index 0000000000000000000000000000000000000000..29935f55980c9422e4f73ee8790ad5cfe2373b9c --- /dev/null +++ b/utils/install @@ -0,0 +1,23 @@ +#!/usr/bin/env bash +# Installation script for LODSPeaKr (http://lodspeakr.org) +# Author: Alvaro Graves (alvaro@graves.cl) +# Modified by: Tim Lebo (lebot@rpi.edu) + +lodspeakr_repository="git://github.com/alangrafu/lodspeakr.git" +home=`basename $lodspeakr_repository | sed 's/.git//'` + +source ~/.bashrc +GIT=`which git` + +if [ -z "$GIT" ]; then + echo "git is required to continue installation. Please add git to your \$PATH." + exit 1 +fi + +if [ ! -e "$home" ]; then + $GIT clone $lodspeakr_repository + cd $home + ./install.sh +else + echo "There is already an existing directory called '$home'. Installation cancelled. Remove it first and try again." +fi diff --git a/utils/link-components.sh b/utils/link-components.sh new file mode 100755 index 0000000000000000000000000000000000000000..430311398d71bf34fd0b12bf568641ed8752c980 --- /dev/null +++ b/utils/link-components.sh @@ -0,0 +1,45 @@ +#!/bin/bash +# +# Script to borrow essential bits ;rom another lodspeakr instance on local machine. +# Desired when lodspeakr essentials are maintained in a project-specfic repository. +# Contributed by Tim Lebo when trying to apply lodspeakr for DataFAQs. +# +# Usage: +# bash-3.2$ pwd +# /Applications/XAMPP/htdocs/hello/lodspeakr +# +# bash-3.2$ sudo rm -rf .htaccess settings.inc.php models views +# +# bash-3.2$ sudo /Users/lebo/projects/lodspeakr/github/lodspeakr/utils/link-components.sh /Users/lebo/projects/DataFAQs/github/DataFAQs/ui/configure-epoch/lodspeakr +# ln -s /Users/lebo/projects/DataFAQs/github/DataFAQs/ui/configure-epoch/lodspeakr/settings.inc.php settings.inc.php +# ln -s /Users/lebo/projects/DataFAQs/github/DataFAQs/ui/configure-epoch/lodspeakr/.htaccess .htaccess +# ln -s /Users/lebo/projects/DataFAQs/github/DataFAQs/ui/configure-epoch/lodspeakr/models models +# ln -s /Users/lebo/projects/DataFAQs/github/DataFAQs/ui/configure-epoch/lodspeakr/views views +# +# bash-3.2$ sudo /Users/lebo/projects/lodspeakr/github/lodspeakr/utils/link-components.sh /Users/lebo/projects/DataFAQs/github/DataFAQs/ui/configure-epoch/lodspeakr +# WARNING: not linking settings.inc.php because it exists. +# WARNING: not linking .htaccess because it exists. +# WARNING: not linking models because it exists. +# WARNING: not linking views because it exists. + +essentials='settings.inc.php .htaccess models views' +if [ $# -lt 1 ]; then + echo "usage: `basename $0` other-lodspeakr-directory" + echo " soft links the following from other-lodspeakr-director to current directory: $essentials" + exit 1 +fi + +otherDir="$1" +if [[ ! -d $otherDir && "$otherDir" != "/" ]]; then + echo "$otherDir does not exist." + exit 1 +fi + +for essential in $essentials; do + if [[ ! -e $essential && -e $otherDir/$essential ]]; then + echo ln -s $otherDir/$essential $essential + ln -s $otherDir/$essential + else + echo "WARNING: not linking $essential because it exists." + fi +done diff --git a/views/header.inc b/views/header.inc index 2f26f6f401cc1fbda895c3e1e787bfe528d8e4c6..7aad9cf624b51f51958f89a9f147644f8df296c6 100644 --- a/views/header.inc +++ b/views/header.inc @@ -1,4 +1,5 @@ +<h4>Endpoint: {{base.sparqlendpoint.local}}</h4> <div style='float:center'> -<a href='{{base.home}}'>Home</a> | <a href='{{base.home}}/special/classes'>Classes</a> | <a href='{{base.home}}/special/namedGraphs'>Named Graphs</a> +<a href='{{base.home}}'>Home</a> | <a href='{{base.home}}special/classes'>Classes</a> | <a href='{{base.home}}special/namedGraphs'>Named Graphs</a> </div> diff --git a/views/special.classes.view.html b/views/special.classes.view.html index 0f25575e1de1fad85e6b7d893e5dd692541b4f01..8a7777fe863303235d9f846e0be11cfbb70b9f00 100644 --- a/views/special.classes.view.html +++ b/views/special.classes.view.html @@ -11,14 +11,8 @@ <h1>Classes available</h1> {%include "header.inc"%} <ul> - {% if r.resource.value != null %} - <!-- Only one class available --> - <li><a href='{{base.baseUrl}}special/instances/{{ r.resource.curie }}'>{{r.resource.curie}}</a></li> - {% endif %} {% for row in r %} - {% if row.resource.value %} <li><a href='{{base.baseUrl}}special/instances/{{ row.resource.curie }}'>{{row.resource.curie}}</a></li> - {% endif %} {% endfor %} </ul> </body> diff --git a/views/special.namedGraphs.view.html b/views/special.namedGraphs.view.html index e7eca6c297aa76144fdbb0ffe674176f28cceca0..65ee0d422589ded5522de1f6a0330367f293fefc 100644 --- a/views/special.namedGraphs.view.html +++ b/views/special.namedGraphs.view.html @@ -8,7 +8,7 @@ <link href="{{base.baseUrl}}/lodspeakr/css/basic.css" rel="stylesheet" type="text/css" media="screen" /> </head> <body> - <h1>Graphs available in the triple store</h1> + <h1>Graphs available</h1> {%include "header.inc"%} <ul> {% for row in r %}