Include base URI in playground options.
authorDave Longley <dlongley@digitalbazaar.com>
Wed, 18 Apr 2012 13:15:18 -0400
changeset 533 5e5c74a119b5
parent 532 5afe57e01f8e
child 534 cd22a6ca6e70
Include base URI in playground options.
playground/jsonld-turtle.js
playground/playground.js
--- a/playground/jsonld-turtle.js	Wed Apr 18 13:05:07 2012 -0400
+++ b/playground/jsonld-turtle.js	Wed Apr 18 13:15:18 2012 -0400
@@ -106,10 +106,11 @@
  * Converts JSON-LD input to a TURTLE formatted string.
  *
  * @param input the JSON-LD object as a JavaScript object.
+ * @param options the JSON-LD options.
  * @param callback(err, turtle) called once the operation completes.
  */
-jsonld.turtle = function(input, callback) {
-  jsonld.normalize(input, function(err, normalized) {
+jsonld.turtle = function(input, options, callback) {
+  jsonld.normalize(input, options, function(err, normalized) {
     var output = '';
     for(s in normalized) {
       // print out each key in the normalized array (the subjects)
--- a/playground/playground.js	Wed Apr 18 13:05:07 2012 -0400
+++ b/playground/playground.js	Wed Apr 18 13:15:18 2012 -0400
@@ -172,8 +172,11 @@
    * @param callback(err) called once the operation completes.
    */
   playground.performAction = function(input, param, callback) {
+    // set base IRI
+    var options = {base: document.baseURI};
+
     if(playground.activeTab === 'tab-normalized') {
-      jsonld.normalize(input, function(err, normalized) {
+      jsonld.normalize(input, options, function(err, normalized) {
         if(err) {
           return callback(err);
         }
@@ -183,7 +186,7 @@
       });
     }
     else if(playground.activeTab === 'tab-expanded') {
-      jsonld.expand(input, function(err, expanded) {
+      jsonld.expand(input, options, function(err, expanded) {
         if(err) {
           return callback(err);
         }
@@ -193,7 +196,7 @@
       });
     }
     else if(playground.activeTab === 'tab-compacted') {
-      jsonld.compact(input, param, function(err, compacted) {
+      jsonld.compact(input, param, options, function(err, compacted) {
         if(err) {
           return callback(err);
         }
@@ -203,7 +206,7 @@
       });
     }
     else if(playground.activeTab === 'tab-framed') {
-      jsonld.frame(input, param, function(err, framed) {
+      jsonld.frame(input, param, options, function(err, framed) {
         if(err) {
           return callback(err);
         }
@@ -213,7 +216,7 @@
       });
     }
     else if(playground.activeTab === 'tab-turtle') {
-      jsonld.turtle(input, function(err, turtle) {
+      jsonld.turtle(input, options, function(err, turtle) {
         if(err) {
           return callback(err);
         }