57 | 58 | 59 | === Configuration === 60 | ==== Server setup ==== 61 |26 | favicon.ico 27 | .htaccess #contains rules for paget's URL dispatching 28 | index.php #main file that dispatches everything 29 | js/ 30 | js/index.js #main script for the site 31 | js/jquery.min.js #jQuery JavaScript library 32 | templates/ 33 | templates/page.about.html #about template 34 | templates/page.default.html #default template that is used to output a resource. includes layout sections 35 | templates/html.html #starts the document 36 | templates/head.html #head element 37 | templates/header.html #header section (e.g., site address, global navigation) 38 | templates/page.home.html #home template 39 | templates/footer.html #footer section (e.g., global navigation) 40 | templates/foot.html #closes the document 41 | templates/page.geo.html #geo template that is used to output demographic stats about a particular location. Geared towards the CSO dataset 42 | templates/nav.html #local navigation (i.e., in context of the viewed page) 43 | templates/page.property.html #default template that is used for properties 44 | 45 | theme/ 46 | theme/base/ 47 | theme/base/css/display.css #layout, typography rules 48 | theme/base/images/ #common icons, illustrations 49 | theme/base/icons/ 50 | theme/base/images/icons/icons-01.png #main icons file (combined into a single file) 51 | theme/base/illustrations/ 52 | theme/default/ 53 | theme/default/css/display.css #imports base stylesheet, and contains background images and colour rules 54 | theme/cso/ 55 | theme/cso/css/display.css #imports default stylesheet and adds CSO specific styles 56 |
62 | /** 63 | * XXX: Review each line before executing! 64 | * The following is tested under Debian/Linux kernel in an Apache and PHP5 environment. 65 | */ 66 | 67 | /* Essential requirements for Fuseki */ 68 | $sudo apt-get install maven2 69 | $sudo apt-get install ruby 70 | $sudo apt-get install subversion 71 | 72 | /* Required to pull Moriarty, Paget, ARC2, and Linked Data Pages */ 73 | $sudo apt-get install git 74 | 75 | /* Setting up Fuseki triple store */ 76 | $sudo svn co http://jena.svn.sourceforge.net/svnroot/jena/Fuseki/trunk /usr/lib/fuseki 77 | $cd /usr/lib/fuseki 78 | $sudo mvn clean package 79 | 80 | /* Fuseki configuration for a DESCRIBE query for resources as subject and object. Optinal. */ 81 | $sudo cp src-dev/dev/BackwardForwardDescribeFactory.java src/main/java/org/openjena/fuseki/ 82 | $sudo nano src/main/java/org/openjena/fuseki/BackwardForwardDescribeFactory.java #Use org.openjena.fuseki instead of dev for package 83 | $sudo nano tdb2.ttl #Use the same path for BackwardForwardDescribeFactory. Uncomment tdb:unionDefaultGraph true ;. Use <#site> instead of <#dataset> 84 | $sudo mvn install 85 | 86 | /* Starts the Fuseki server */ 87 | Default is read only, use --update to enable write 88 | $sudo ./fuseki-server --desc tdb2.ttl /cso 89 | 90 | /* Some tests to make sure the Fuseki server is up and running okay */ 91 | $sudo ./s-put http://localhost:3030/site/data default books.ttl 92 | $sudo ./s-get http://localhost:3030/site/data default 93 | $sudo ./s-query --service http://localhost:3030/site/query 'SELECT * WHERE {?s ?p ?o .}' 94 | $sudo ./s-update --service http://localhost:3030/site/update 'CLEAR default' 95 | 96 | 97 | 98 | /* If you already have Linked Data Pages, you can skip this. */ 99 | $cd /var/www 100 | $sudo mkdir site 101 | $chown -R csarven site 102 | $git clone git://github.com/csarven/Linked Data Pages.git site 103 | 104 | /* Required libraries for Linked Data Pages */ 105 | $svn checkout http://moriarty.googlecode.com/svn/trunk/ lib/moriarty 106 | $svn checkout http://paget.googlecode.com/svn/branches/2.0/ lib/paget 107 | $git clone git://github.com/semsol/arc2.git lib/arc2 108 | 109 | /* Until some of the issues are fixed in Moriarty and Paget, we include the fixes in this package */ 110 | $cp -R patches/moriarty/* lib/moriarty/ 111 | $cp -R patches/paget/* lib/paget/ 112 | 113 | /* Configure paths to libraries and SPARQL endpoint URI */ 114 | Either load install.php from your browser and submit the form or manually edit the directory configuration: 115 | $cp /var/www/site/index.php.sample /var/www/site/index.php 116 | $nano /var/www/site/index.php 117 | 118 | 119 | /* Site configuration (see below for details) */ 120 | $nano /var/www/site/config.php 121 | 122 | /* Take note of the details. Change as you see fit. */ 123 | $nano /var/www/site/.htaccess 124 |
136 | $config['site']['name'] = 'My LDP site'; /*Name of your site. Appears in page title, address etc. */ 137 | $config['site']['server'] = 'site'; /* 'site' in http://site */ 138 | $config['site']['path'] = ''; /* 'foo' in http://site/foo */ 139 | $config['site']['theme'] = 'default'; /* 'default' in /var/www/site/theme/default */ 140 | $config['site']['logo'] = 'logo.png'; /* logo.png in /var/www/site/theme/default/images/logo.jpg */ 141 |
147 | $config['server']['dbpedia.org'] = 'site'; /* URI maps e.g., http://dbpedia.org/resource/Montreal to http://site/resource/Montreal */ 148 |
152 | $config['server']['site'] = 'site'; 153 |154 | 155 | so, you don't have to repeat that. But you can add other ones as mentioned earlier. 156 | 157 | ===== Entity URIs, query types and templates ===== 158 | We use entity ids to determine how to respond back to the request. The entity set id is determined from the requested URI. The example below uses 'site_foo' as the entity set id. The entity set id is also reused in HTML templates < body = "site_foo" >. The path is assigned to '/foo', if there is a request for http://site/foo. The query is also assigned here. For the time being, we only set a query name here. We can set a custom SPARQL query to $config['sparql_query']['site_foo'] and use the index name 'site_foo' at $config['entity']['site_foo']['query'] = 'site_foo'; 159 | 160 |
161 | /* SPARQL query to use for this entity e.g., $config['sparql_query']['cso_home'] */ 162 | $config['sparql_query']['site_foo'] = " 163 | DESCRIBE164 | " 165 | 166 | /* URI path for this entity */ 167 | $config['entity']['site_foo']['path'] = "/foo"; 168 | /* SPARQL query to use for this entity e.g., $config['sparql_query']['site_foo'] */ 169 | $config['entity']['site_foo']['query'] = 'site_foo'; 170 | /* HTML template to use for this entity */ 171 | $config['entity']['site_foo']['template'] = 'page.foo.html'; 172 |
Property | Value |
---|---|
' . $p . ' | ' . $o . ' |
e.g., /var/www/site/
e.g., /var/www/lib/linked-data-pages/
e.g., /var/www/lib/paget/
e.g., /var/www/lib/moriarty/
e.g., /var/www/lib/arc2/
e.g., http://localhost:3030/dataset/query
'.$this->post[$key].'
is not writable.';
301 | break;
302 |
303 | case 'empty':
304 | return 'Required directory name.';
305 | break;
306 |
307 | default:
308 | return 'Who said what now? Check errorMessage()';
309 | break;
310 | }
311 |
312 | }
313 |
314 |
315 | function writeToFile($file, $fileContents)
316 | {
317 | $fp = fopen($file, 'w');
318 | fwrite($fp, $fileContents);
319 |
320 | fclose($fp);
321 | }
322 |
323 | }
324 |
325 |
326 | $i = new Install();
327 | $i->showPage();
328 |
329 | ?>
330 |
--------------------------------------------------------------------------------
/patches/README:
--------------------------------------------------------------------------------
1 | Until some of the issues for Paget and Moriarty are resolved,
2 | copy (*) the files in these directories to your paget and moriarty library.
3 |
4 | * For now. Ideally, they will be actual patches with only the diffs
5 |
6 |
--------------------------------------------------------------------------------
/patches/moriarty/simplegraph.class.php:
--------------------------------------------------------------------------------
1 | 'http://www.w3.org/1999/02/22-rdf-syntax-ns#',
18 | 'rdfs' => 'http://www.w3.org/2000/01/rdf-schema#',
19 | 'owl' => 'http://www.w3.org/2002/07/owl#',
20 | 'cs' => 'http://purl.org/vocab/changeset/schema#',
21 | 'bf' => 'http://schemas.talis.com/2006/bigfoot/configuration#',
22 | 'frm' => 'http://schemas.talis.com/2006/frame/schema#',
23 |
24 | 'dc' => 'http://purl.org/dc/elements/1.1/',
25 | 'dct' => 'http://purl.org/dc/terms/',
26 | 'dctype' => 'http://purl.org/dc/dcmitype/',
27 | 'geo' => 'http://www.w3.org/2003/01/geo/wgs84_pos#',
28 | 'rel' => 'http://purl.org/vocab/relationship/',
29 | 'wn' => 'http://xmlns.com/wordnet/1.6/',
30 | 'air' => 'http://www.daml.org/2001/10/html/airport-ont#',
31 | 'contact' => 'http://www.w3.org/2000/10/swap/pim/contact#',
32 | 'frbr' => 'http://purl.org/vocab/frbr/core#',
33 |
34 | 'ad' => 'http://schemas.talis.com/2005/address/schema#',
35 | 'lib' => 'http://schemas.talis.com/2005/library/schema#',
36 | 'dir' => 'http://schemas.talis.com/2005/dir/schema#',
37 | 'user' => 'http://schemas.talis.com/2005/user/schema#',
38 | 'sv' => 'http://schemas.talis.com/2005/service/schema#',
39 | 'mo' => 'http://purl.org/ontology/mo/',
40 | 'status' => 'http://www.w3.org/2003/06/sw-vocab-status/ns#',
41 | 'label' => 'http://purl.org/net/vocab/2004/03/label#',
42 | 'skos' => 'http://www.w3.org/2004/02/skos/core#',
43 | 'bibo' => 'http://purl.org/ontology/bibo/',
44 | 'ov' => 'http://open.vocab.org/terms/',
45 | 'foaf' => 'http://xmlns.com/foaf/0.1/',
46 | 'void' => 'http://rdfs.org/ns/void#',
47 | 'xsd' => 'http://www.w3.org/2001/XMLSchema#',
48 | );
49 |
50 | var $_labeller;
51 |
52 | function __construct($graph=false){
53 | $this->_labeller = new Labeller();
54 | if($graph){
55 | if(is_string($graph)){
56 | $this->add_rdf($graph);
57 | } else {
58 | $this->_index = $graph;
59 | }
60 | }
61 |
62 | }
63 |
64 | function __destruct(){
65 | unset($this->_index);
66 | unset($this);
67 | }
68 |
69 | function set_request_factory($request_factory) {
70 | $this->request_factory = $request_factory;
71 | }
72 |
73 |
74 | /**
75 | * Map a portion of a URI to a short prefix for use when serialising the graph
76 | * @param string prefix the namespace prefix to associate with the URI
77 | * @param string uri the URI to associate with the prefix
78 | */
79 | function set_namespace_mapping($prefix, $uri) {
80 | $this->_labeller->set_namespace_mapping($prefix, $uri);
81 | }
82 |
83 | /**
84 | * Convert a QName to a URI using registered namespace prefixes
85 | * @param string qname the QName to convert
86 | * @return string the URI corresponding to the QName if a suitable prefix exists, null otherwise
87 | */
88 | function qname_to_uri($qname) {
89 | return $this->_labeller->qname_to_uri($qname);
90 | }
91 |
92 | /**
93 | * Convert a URI to a QName using registered namespace prefixes
94 | * @param string uri the URI to convert
95 | * @return string the QName corresponding to the URI if a suitable prefix exists, null otherwise
96 | */
97 | function uri_to_qname($uri) {
98 | return $this->_labeller->uri_to_qname($uri);
99 | }
100 |
101 | function get_prefix($ns) {
102 | return $this->_labeller->get_prefix($ns);
103 | }
104 |
105 | function add_labelling_property($p) {
106 | $this->_labeller->add_labelling_property($p);
107 | }
108 |
109 |
110 | function update_prefix_mappings() {
111 | foreach ($this->_index as $s => $p_list) {
112 | foreach ($p_list as $p => $v_list) {
113 | $prefix = $this->_labeller->uri_to_qname($p);
114 | }
115 | }
116 | }
117 |
118 |
119 |
120 |
121 | /**
122 | * Constructs an array containing the type of the resource and its value
123 | * @param string resource a URI or blank node identifier (prefixed with _: e.g. _:name)
124 | * @return array an associative array with two keys: 'type' and 'value'. Type is either bnode or uri
125 | */
126 | function make_resource_array($resource) {
127 | $resource_type = strpos($resource, '_:' ) === 0 ? 'bnode' : 'uri';
128 | return array('type' => $resource_type, 'value' => $resource);
129 | }
130 |
131 | /**
132 | * Adds a triple with a resource object to the graph
133 | * @param string s the subject of the triple, either a URI or a blank node in the format _:name
134 | * @param string p the predicate URI of the triple
135 | * @param string o the object of the triple, either a URI or a blank node in the format _:name
136 | * @return boolean true if the triple was new, false if it already existed in the graph
137 | */
138 | function add_resource_triple($s, $p, $o) {
139 | return $this->_add_triple($s, $p, array('type' => strpos($o, '_:' ) === 0 ? 'bnode' : 'uri', 'value' => $o));
140 | }
141 |
142 | /**
143 | * Adds a triple with a literal object to the graph
144 | * @param string s the subject of the triple, either a URI or a blank node in the format _:name
145 | * @param string p the predicate of the triple as a URI
146 | * @param string o the object of the triple as a string
147 | * @param string lang the language code of the triple's object (optional)
148 | * @param string dt the datatype URI of the triple's object (optional)
149 | * @return boolean true if the triple was new, false if it already existed in the graph
150 | */
151 | function add_literal_triple($s, $p, $o, $lang = null, $dt = null) {
152 | $o_info = array('type' => 'literal', 'value' => $o);
153 | if ( $lang != null ) {
154 | $o_info['lang'] = $lang;
155 | }
156 | if ( $dt != null ) {
157 | $o_info['datatype'] = $dt;
158 | }
159 | return $this->_add_triple($s, $p, $o_info);
160 | }
161 |
162 | private function _add_triple($s, $p, $o_info) {
163 | if (!isset($this->_index[$s])) {
164 | $this->_index[$s] = array();
165 | $this->_index[$s][$p] = array( $o_info );
166 | return true;
167 | }
168 | elseif (!isset($this->_index[$s][$p])) {
169 | $this->_index[$s][$p] = array( $o_info);
170 | return true;
171 | }
172 | else {
173 | if ( ! in_array( $o_info, $this->_index[$s][$p] ) ) {
174 | $this->_index[$s][$p][] = $o_info;
175 | return true;
176 | }
177 | }
178 | return false;
179 | }
180 |
181 | /**
182 | * @deprecated this is deprecated
183 | */
184 | function get_triples() {
185 | return ARC2::getTriplesFromIndex($this->_to_arc_index($this->_index));
186 | }
187 |
188 | /**
189 | * Get a copy of the graph's triple index
190 | * @see http://n2.talis.com/wiki/RDF_PHP_Specification
191 | */
192 | function get_index() {
193 | return $this->_index;
194 | }
195 |
196 |
197 | /**
198 | * Serialise the graph to RDF/XML
199 | * @return string the RDF/XML version of the graph
200 | */
201 | function to_rdfxml() {
202 | $this->update_prefix_mappings();
203 | $serializer = ARC2::getRDFXMLSerializer(
204 | array(
205 | 'ns' => $this->_labeller->get_ns(),
206 | )
207 | );
208 | return $serializer->getSerializedIndex($this->_to_arc_index($this->_index));
209 | }
210 |
211 | /**
212 | * Serialise the graph to Turtle
213 | * @see http://www.dajobe.org/2004/01/turtle/
214 | * @return string the Turtle version of the graph
215 | */
216 | function to_turtle() {
217 | $this->update_prefix_mappings();
218 | $serializer = ARC2::getTurtleSerializer(
219 | array(
220 | 'ns' => $this->_labeller->get_ns(),
221 | )
222 | );
223 | return $serializer->getSerializedIndex($this->_to_arc_index($this->_index));
224 | }
225 |
226 | /**
227 | * Serialise the graph to N-Triples
228 | * @see http://www.w3.org/TR/rdf-testcases/#ntriples
229 | * @return string the N-Triples version of the graph
230 | */
231 | function to_ntriples() {
232 | $serializer = ARC2::getComponent('NTriplesSerializer', array());
233 | return $serializer->getSerializedIndex($this->_to_arc_index($this->_index));
234 | }
235 |
236 |
237 | /**
238 | * Serialise the graph to JSON
239 | * @see http://n2.talis.com/wiki/RDF_JSON_Specification
240 | * @return string the JSON version of the graph
241 | */
242 | function to_json() {
243 | return json_encode($this->_index);
244 | }
245 |
246 |
247 | /**
248 | * Serialise the graph to HTML
249 | * @return string a HTML version of the graph
250 | */
251 | function to_html($s = null, $guess_labels = true) {
252 |
253 | $this->update_prefix_mappings();
254 | $h = '';
255 |
256 | if ($s) {
257 | if (is_array($s)) {
258 | $subjects = array_intersect($s, $this->get_subjects());
259 | if (count($subjects) == 0) return '';
260 | }
261 | else {
262 | if (array_key_exists($s, $this->_index)) {
263 | $subjects = array($s);
264 | }
265 | else {
266 | return '';
267 | }
268 | }
269 | }
270 | else {
271 | $subjects = $this->get_subjects();
272 | }
273 |
274 |
275 | if (count($subjects) > 0) {
276 | foreach ($subjects as $subject) {
277 | if (count($subjects) > 1) {
278 | $h .= '' . htmlspecialchars($this->get_label($p, true)). ' | '; 288 | $h .= '';
289 | for ($i = 0; $i < count($this->_index[$subject][$p]); $i++) {
290 | if ($i > 0) $h .= ' '; 291 | if ($this->_index[$subject][$p][$i]['type'] === 'literal') { 292 | $h .= htmlspecialchars($this->_index[$subject][$p][$i]['value'] ); 293 | } 294 | else { 295 | $h .= ''; 296 | if ($guess_labels) { 297 | $h .= htmlspecialchars($this->get_label($this->_index[$subject][$p][$i]['value']) ); 298 | } 299 | else { 300 | $h .= htmlspecialchars($this->_index[$subject][$p][$i]['value'] ); 301 | } 302 | 303 | $h .= ''; 304 | } 305 | } 306 | $h .= ' | ';
307 | $h .= '
---|---|
' . htmlspecialchars($this->get_inverse_label($backlink_p, true)). ' | '; 326 | $h .= '';
327 | for ($i = 0; $i < count($backlink_values); $i++) {
328 | if ($i > 0) $h .= ' '; 329 | 330 | $h .= ''; 331 | if ($guess_labels) { 332 | $h .= htmlspecialchars($this->get_label($backlink_values[$i]) ); 333 | } 334 | else { 335 | $h .= htmlspecialchars($backlink_values[$i] ); 336 | } 337 | 338 | $h .= ''; 339 | } 340 | $h .= ' | ';
341 | $h .= '
URI: ' . $this->link_uri($resource_uri, $resource_uri) . '
'; 20 | $ret .= '' . htmlspecialchars($this->get_description($resource_uri)) . '
'; 21 | 22 | $data = array(); 23 | 24 | if ( $this->desc->subject_has_property($resource_uri, 'http://purl.org/vocab/vann/usageNote') ) { 25 | $ret .= '%s
', $semantics); 130 | } 131 | 132 | if ( $this->desc->subject_has_property($resource_uri, 'http://purl.org/vocab/vann/example') ) { 133 | $ret .= 'This term %s
', $status); 163 | } 164 | 165 | $history_widget = new PAGET_HistoryWidget($this->desc, $this->template, $this->urispace); 166 | $ret .= $history_widget->render($resource_info, FALSE, FALSE); 167 | } 168 | 169 | $data_widget = new PAGET_TableDataWidget($this->desc, $this->template, $this->urispace); 170 | $data_widget->ignore_properties($this->ignore_properties); 171 | $data_widget->ignore_properties(array(RDF_TYPE, DC_TITLE, RDFS_LABEL, DC_DESCRIPTION, RDFS_COMMENT, 'http://purl.org/vocab/vann/example', 'http://www.w3.org/2003/06/sw-vocab-status/ns#term_status', 'http://www.w3.org/2004/02/skos/core#definition')); 172 | $data_widget->ignore_properties(array(OWL_EQUIVALENTCLASS, RDFS_RANGE, RDFS_DOMAIN, OWL_DISJOINTWITH, RDFS_SUBCLASSOF, RDFS_SUBPROPERTYOF, OWL_EQUIVALENTPROPERTY, OWL_INVERSEOF, OWL_SYMMETRICPROPERTY, OWL_FUNCTIONALPROPERTY, OWL_INVERSEFUNCTIONALPROPERTY, OWL_TRANSITIVEPROPERTY )); 173 | $data_widget->ignore_properties(array('http://www.w3.org/2004/02/skos/core#changeNote', 'http://www.w3.org/2004/02/skos/core#historyNote', 'http://purl.org/dc/terms/issued')); 174 | $data_widget->ignore_properties(array('http://purl.org/vocab/vann/usageNote', 'http://purl.org/net/vocab/2004/03/label#plural')); 175 | $other .= $data_widget->render($resource_info, FALSE, FALSE); 176 | if (strlen(trim($other)) > 0) { 177 | $ret .= '