One of the distinguishing features of Ripple is that its programs can be easily embedded in the Web of Data (as well as in RDF triple stores), allowing you to build up a network of interlinked programs, and to build on programs others have put up on the Web.
Similarly to visiting a Web page, discovering and executing a program in Ripple is effortless (all you need is its URI), while publishing new content on the Web requires a little more effort and planning. As with HTML web pages, there are many strategies for getting the data out there. The following will illustrate a file-based approach which uses a basic recipe for serving static RDF files on the Web.
In order to make your programs into Linked Data, you need to know the base URI, or namespace, where you intend to publish them. "Hash" namespaces are particularly simple from a data publishing point of view. For example, this tutorial uses the namespace
http://ripple.fortytwo.net/code/2011/06/publishingExamples#. At the Ripple command line, make this the default namespace using the
@prefix directive (see Commands):
@prefix : <http://ripple.fortytwo.net/code/2011/06/publishingExamples#>
Of course, you should modify the above to use your own chosen namespace.
Once you have some Ripple code you would like to publish on the Web, pare it down to a number of prefix and program definitions (i.e.
@list commands) and make sure they work as expected, in isolation from everything else you may have typed in at the command line. For example, here's a script for months and month names which you can paste in to a fresh Ripple command line session. It includes the default namespace definition:
@prefix : <http://ripple.fortytwo.net/code/2011/06/publishingExamples#> @prefix dbp: <http://dbpedia.org/resource/> @list months: dbp:January dbp:February dbp:March dbp:April dbp:May dbp:June dbp:July dbp:August dbp:September dbp:October dbp:November dbp:December @list language month-names: :months (rdfs:label. (lang. language equal.) require.) map.
If you're using LinkedDataSail (the default), you should now be able to test this script locally, the output of which will look something like this:
7) :months each.  dbp:January  dbp:February  dbp:March  dbp:April  dbp:May  dbp:June  dbp:July  dbp:August  dbp:September  dbp:October  dbp:November  dbp:December 8) "it" :month-names.  ("Gennaio"@it "Febbraio"@it "Marzo"@it "Aprile"@it "Maggio"@it "Giugno"@it "Luglio"@it "Agosto"@it "Settembre"@it "Ottobre"@it "Novembre"@it "Dicembre"@it)
When you are satisfied that your programs behave as they should, proceed to...
In order to prepare the RDF data for publishing, we will re-start Ripple using a configuration which causes all of its data to be saved to a file. Here's an example configuration, which you might save as the file
# Create a temporary store into which to paste the data net.fortytwo.ripple.demo.sailType = org.openrdf.sail.memory.MemoryStore # Put pasted data into a temporary file net.fortytwo.ripple.demo.memoryStorePersistFile = /tmp/ripple-tmp.rdf net.fortytwo.ripple.demo.memoryStorePersistFileFormat = rdfxml
You may notice that this configuration does not use LinkedDataSail, so the programs cannot necessarily be run from here, only dumped to the file. Now start Ripple using the configuration you have just created:
At the Ripple command line, paste in the script you created for Step 2, followed by a
@prefix : <http://ripple.fortytwo.net/code/2011/06/publishingExamples#> @prefix dbp: <http://dbpedia.org/resource/> @list months: dbp:January dbp:February dbp:March dbp:April dbp:May dbp:June dbp:July dbp:August dbp:September dbp:October dbp:November dbp:December @list language month-names: :months (rdfs:label. (lang. language equal.) require.) map. @quit
If you now open the file
/tmp/ripple-tmp.rdf (or whatever you have used in your configuration), you should see an RDF/XML representation of your programs. Now we're on the home stretch.
All we have left to do is to copy the generated RDF/XML file to a Web-accessible location, and to make sure that it is served as RDF/XML content. Please see the above-mentioned resource on serving static RDF files for details.
For example, to publish the above at ripple.fortytwo.net, the following commands were used:
mkdir -p ~/Dropbox/hosts/ripple.fortytwo.net/code/2011/06 mv /tmp/ripple-tmp.rdf ~/Dropbox/hosts/ripple.fortytwo.net/code/2011/06/publishingExamples.rdf vim ~/Dropbox/hosts/ripple.fortytwo.net/code/2011/06/.htaccess
.htaccess file looks like this:
# Rewrite engine setup RewriteEngine On RewriteBase /code/2011/06/ # Rewrite rule to serve RDF/XML content from the vocabulary URI RewriteRule ^publishingExamples$ publishingExamples.rdf
You will have succeeded in publishing your programs when you can issue an HTTP GET request for the default namespace you chose earlier, and have your file served back to you with the
application/rdf+xml MIME type, e.g.
wget http://ripple.fortytwo.net/code/2011/06/publishingExamples# --2011-06-16 07:08:35-- http://ripple.fortytwo.net/code/2011/06/publishingExamples Resolving ripple.fortytwo.net... 18.104.22.168 Connecting to ripple.fortytwo.net|22.214.171.124|:80... connected. HTTP request sent, awaiting response... 200 OK Length: 38481 (38K) [application/rdf+xml] Saving to: `publishingExamples' 100%[======================================>] 38,481 28.1K/s in 1.3s 2011-06-16 07:08:38 (28.1 KB/s) - `publishingExamples' saved [38481/38481]
If all has gone well, you should now be able to type the following into a fresh Ripple-on-LinkedDataSail session and (after a few moments of crawling) get the expected output:
@prefix test: <http://ripple.fortytwo.net/code/2011/06/publishingExamples#> "it" test:month-names.
What has just happened? By applying
test:month-names in the above expression, you have asked Ripple to dereference the URI
http://ripple.fortytwo.net/code/2011/06/publishingExamples#month-names for you, interpret it as an RDF list, and execute it as a Ripple program.
You or anyone else can execute this program from anywhere in the world, and link to it in new programs.