A Linked Data publishing framework in PHP. It uses Paget to dispatch URIs and build a local index from the SPARQL query result. See also http://csarven.ca/how-to-create-a-linked-data-site for a walkthrough.
GPL-3.0 License
== Overview == http://csarven.ca/statistical-linked-dataspaces#linked-data-pages
== Package overview == Majority of what's discussed here is written as a how-to article at http://csarven.ca/how-to-create-a-linked-data-site . If you want to dive into this project using steps, I suggest reading that first. Naturally there is a lot of overlap with what's mentioned here.
=== Requirements ===
== Installation == This is an ongoing process to make installation and configuration of this framework. At the moment, you can use the initial install.php file to setup the directories for your setup. All you have to do is copy the install.php file to the directory that you want to setup your site at. For example, if you want to run your site from /var/www/site/, then make sure you to chmod a+w that directory (or at least the script that's running PHP has write access). Then go to http://example.org/install.php (replace example.org with whatever host you have /var/www/site/ pointing to. This only copies the necessary files and configures the index.php file for you. You'd still have to setup your SPARQL endpoint and all that... but, yea, stay tuned.
=== Directory/file structure for templating and themes === Templates go under the templates/ directory. Templates are used to render different requests made by the client. For example, if the client requests the resource http://site/geo/Montreal, we might want to serve the page.geo.html. Templates generally include layout sections like; html, head, header, nav, footer, foot. It is aimed to modularize common components. There is still a lot of flexibility for any template, hence one can include or exclude any component. $nano /var/www/site/index.php Themes go under the theme/ directory. A theme is assigned by $config['site']['theme']. See Site configuration below. The ones that are included in this package are base, default and cso. Base contains all layout and typographical rules, and common images like icons. Default imports base and extends it by including background images and colour rules. By default this package sets the theme to 'default', but you can set your own, in site configuration.
Custom data processing for templates can be created in classes/SITE_Template.php
For now, jQuery minimal library comes with this package.
=== Configuration === ==== Server setup ==== /**
/* Essential requirements for Fuseki */ $sudo apt-get install maven2 $sudo apt-get install ruby $sudo apt-get install subversion
/* Required to pull Moriarty, Paget, ARC2, and Linked Data Pages */ $sudo apt-get install git
/* Setting up Fuseki triple store */ $sudo svn co http://jena.svn.sourceforge.net/svnroot/jena/Fuseki/trunk /usr/lib/fuseki $cd /usr/lib/fuseki $sudo mvn clean package
/* Fuseki configuration for a DESCRIBE query for resources as subject and object. Optinal. */ $sudo cp src-dev/dev/BackwardForwardDescribeFactory.java src/main/java/org/openjena/fuseki/ $sudo nano src/main/java/org/openjena/fuseki/BackwardForwardDescribeFactory.java #Use org.openjena.fuseki instead of dev for package $sudo nano tdb2.ttl #Use the same path for BackwardForwardDescribeFactory. Uncomment tdb:unionDefaultGraph true ;. Use <#site> instead of <#dataset> $sudo mvn install
/* Starts the Fuseki server */ Default is read only, use --update to enable write $sudo ./fuseki-server --desc tdb2.ttl /cso
/* Some tests to make sure the Fuseki server is up and running okay */ $sudo ./s-put http://localhost:3030/site/data default books.ttl $sudo ./s-get http://localhost:3030/site/data default $sudo ./s-query --service http://localhost:3030/site/query 'SELECT * WHERE {?s ?p ?o .}' $sudo ./s-update --service http://localhost:3030/site/update 'CLEAR default'
/* If you already have Linked Data Pages, you can skip this. */ $cd /var/www $sudo mkdir site $chown -R csarven site $git clone git://github.com/csarven/Linked Data Pages.git site
/* Required libraries for Linked Data Pages */ $svn checkout http://moriarty.googlecode.com/svn/trunk/ lib/moriarty $svn checkout http://paget.googlecode.com/svn/branches/2.0/ lib/paget $git clone git://github.com/semsol/arc2.git lib/arc2
/* Until some of the issues are fixed in Moriarty and Paget, we include the fixes in this package / $cp -R patches/moriarty/ lib/moriarty/ $cp -R patches/paget/* lib/paget/
/* Configure paths to libraries and SPARQL endpoint URI */ Either load install.php from your browser and submit the form or manually edit the directory configuration: $cp /var/www/site/index.php.sample /var/www/site/index.php $nano /var/www/site/index.php
/* Site configuration (see below for details) */ $nano /var/www/site/config.php
/* Take note of the details. Change as you see fit. */ $nano /var/www/site/.htaccess
==== Site configuration ====
===== Site settings ===== The settings extend the base LDP config site settings. These values are used throughout the site, therefore make sure to configure them for your own needs.
$config['site']['name'] = 'My LDP site'; /*Name of your site. Appears in page title, address etc. / $config['site']['server'] = 'site'; / 'site' in http://site / $config['site']['path'] = ''; / 'foo' in http://site/foo / $config['site']['theme'] = 'default'; / 'default' in /var/www/site/theme/default / $config['site']['logo'] = 'logo.png'; / logo.png in /var/www/site/theme/default/images/logo.jpg */
===== Server URI mapping ===== This setting is used to map server names that are found in the dataset to the ones that are requested by the client. For example, if the user requests http://site/resource/Montreal, you would look for http://dbpedia.org/resource/Montreal in your dataset.
$config['server']['dbpedia.org'] = 'site'; /* URI maps e.g., http://dbpedia.org/resource/Montreal to http://site/resource/Montreal */
There is a default mapping of:
so, you don't have to repeat that. But you can add other ones as mentioned earlier.
===== Entity URIs, query types and templates ===== 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';
/* SPARQL query to use for this entity e.g., $config['sparql_query']['cso_home'] */ $config['sparql_query']['site_foo'] = " DESCRIBE "
/* URI path for this entity / $config['entity']['site_foo']['path'] = "/foo"; / SPARQL query to use for this entity e.g., $config['sparql_query']['site_foo'] / $config['entity']['site_foo']['query'] = 'site_foo'; / HTML template to use for this entity */ $config['entity']['site_foo']['template'] = 'page.foo.html';
===== PHP Classes ===== Classes are located in '/var/www/site/classes/':
class LDP_Config
getCurrentRequest()
getEntityId()
getEntityQuery()
getEntityPaths()
getRemoteURIFromCurrentRequest()
getConfig()
getPrefix()
getURI()
object()
class LDP_UriSpace extends PAGET_StoreBackedUriSpace
class LDP_ResourceDescription extends PAGET_ResourceDescription
class LDP_StoreDescribeGenerator extends PAGET_StoreDescribeGenerator
class LDP_Template extends PAGET_Template
class LDP_TableDataWidget extends PAGET_TableDataWidget
class LDP_Store extends Store
class LDP_SparqlServiceBase extends SparqlServiceBase