summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSam Thursfield <sam.thursfield@codethink.co.uk>2015-07-02 12:18:22 +0100
committerSam Thursfield <sam.thursfield@codethink.co.uk>2015-07-02 12:18:22 +0100
commit4cff169332db751203f5a006928b6a31de0092f0 (patch)
tree37333a08b231ae368e92a1073e4a9fef80f81e8b
parent11e5784ed2616b51a464d5e7c0b487cf575d08bf (diff)
downloaddefinitions-4cff169332db751203f5a006928b6a31de0092f0.tar.gz
schema: Add example browser application
Change-Id: I1a4f97db7db32d33530ad9fd1009579611f8521d
-rw-r--r--schema/browser/README.txt41
-rw-r--r--schema/browser/main.py23
-rw-r--r--schema/browser/manifest.yml10
-rw-r--r--schema/browser/requirements.txt5
4 files changed, 79 insertions, 0 deletions
diff --git a/schema/browser/README.txt b/schema/browser/README.txt
new file mode 100644
index 00000000..45745b6d
--- /dev/null
+++ b/schema/browser/README.txt
@@ -0,0 +1,41 @@
+This is a demo application for browsing Baserock definitions.
+
+It is a tiny wrapper over the 'rdflib_web' Python library, which provides a
+really cool web interface for browsing RDF data, based on the Flask and RDFLib
+libaries.
+
+DISCLAIMER: this was hacked up in a few hours, please don't expect greatness.
+
+
+Deploying to Cloud Foundry
+--------------------------
+
+You can deploy to Pivotal Cloud Foundry by setting up an account at
+<https://run.pivotal.io>. Or you can deploy to another Cloud Foundry instance,
+probably. Make sure you have the `cf` commandline client installed and have run
+`cf login` with your details.
+
+You need to 'vendor' the dependencies by running:
+
+ mkdir vendor
+ pip install --download vendor -r requirements.txt
+
+You need to clone 'rdflib_web' from Git, because it isn't packaged in Pip.
+
+ git clone https://github.com/RDFLib/rdflib-web
+
+Finally you need to create the file 'definitions.rdfxml' from the definitions.
+
+ cd ../
+ python ./to-rdfxml.py
+ cd schema
+ mv ../definitions.rdfxml .
+
+Test the app locally.
+
+ PYTHONPATH=rdflib-web python main.py
+
+If it works, push to Cloud Foundry (10 second timeout, the default is probably
+too long):
+
+ cf push -t 10
diff --git a/schema/browser/main.py b/schema/browser/main.py
new file mode 100644
index 00000000..e977cd76
--- /dev/null
+++ b/schema/browser/main.py
@@ -0,0 +1,23 @@
+import flask
+import rdflib
+import rdflib_web.lod
+
+import os
+
+
+definitions = rdflib.Graph()
+definitions.parse('definitions.rdfxml')
+
+#app = flask.Flask('Example Baserock definitions browser')
+#app.config['graph'] = definitions
+#app.register_blueprint(rdflib_web.lod.lod)
+
+app = rdflib_web.lod.get(
+ definitions,
+ types='auto',
+ dbname='Baserock reference system definitions (example)')
+
+# Cloud Foundry runtime will set this variable. Or you can set it.
+port = int(os.environ.get('PORT', 5000))
+
+app.run(host="0.0.0.0", port=port)
diff --git a/schema/browser/manifest.yml b/schema/browser/manifest.yml
new file mode 100644
index 00000000..6722944b
--- /dev/null
+++ b/schema/browser/manifest.yml
@@ -0,0 +1,10 @@
+# Cloud Foundry manifest for Baserock definitions browser demo app
+#
+# You can deploy with: `cf push`. But you'll need to change the name if you're
+# deploying to Pivotal's Cloud Foundry http://run.pivotal.io/ because I already
+# used 'http://baserock-definitions-rdf-test.cfapps.io'.
+
+---
+applications:
+- name: baserock-definitions-rdf-test
+ command: PYTHONPATH=rdflib-web python main.py
diff --git a/schema/browser/requirements.txt b/schema/browser/requirements.txt
new file mode 100644
index 00000000..63034598
--- /dev/null
+++ b/schema/browser/requirements.txt
@@ -0,0 +1,5 @@
+# This file causes the Cloud Foundry Python buildpack to recognise this app
+# as Python.
+
+Flask==0.10.1
+rdflib==4.2.0