Bruce Robertson wrote: > Is is possible to make Exhibit work with the JSON data included in the HTML > file?
This intrigued me so I looked at the source. Turns out it's not hard -- the json file is javascript, after all. You just have to put the JSON in the file and arrange for it to be loaded at the appropriate time with a few extra lines of code. Kudos again to the development team to make something so extensible and so well structured. Here's a bit of a hack converting the MIT Nobel Prize Winners example at http://simile.mit.edu/wiki/Exhibit/Getting_Started_Tutorial to inline. Only the top of the html file has changed (and I only included the first two data items): <html> <head> <title>MIT Nobel Prize Winners</title> <link type="inline" rel="exhibit/data" /> <script src="http://static.simile.mit.edu/exhibit/api-2.0/exhibit-api.js" type="text/javascript"></script> <script src="http://static.simile.mit.edu/exhibit/extensions-2.0/time/time-extension.js" type="text/javascript"></script> <script> Exhibit.InlineImporter = { }; Exhibit.importers["inline"] = Exhibit.InlineImporter; Exhibit.InlineImporter.load = function(link, database, cont) { Exhibit.UI.showBusyIndicator(); database.loadData(Exhibit.InlineImporter.userdata); Exhibit.UI.hideBusyIndicator(); if (cont) cont(); }; Exhibit.InlineImporter.userdata=({ properties: { "co-winner" : { valueType: "item" } }, "items" : [ { type : "Nobelist", label : "Burton Richter", discipline : "Physics", shared : "yes", "last-name" : "Richter", "nobel-year" : "1976", relationship : "alumni", "co-winner" : "Samuel C.C. Ting", "relationship-detail" : "MIT S.B. 1952, Ph.D. 1956", imageURL : "http://nobelprize.org/nobel_prizes/physics/laureates/1976/richter_thumb.jpg" }, { type : "Nobelist", label : "George A. Akerlof", discipline : "Economics", shared : "yes", "last-name" : "Akerlof", "nobel-year" : "2001", relationship : "alumni", "relationship-detail" : "MIT Ph.D. 1966", imageURL : "http://nobelprize.org/nobel_prizes/economics/laureates/2001/akerlof_thumb.jpg" } ] }); </script> <style> ... et voila. Just put your JSON in the userdata, there. Unlike external json files, there's no nice error message with the above method, so if the syntax is invalid, it won't say anything -- just show an empty database. Your browser (the visitor's browser) will indicate a javascript error. And this method isn't guaranteed to work if the Importer API changes in or after v2.0, but I can make it a little safer and turn it into an official importer if there's interest and if the exhibit team will take it. (?) I'd have to guess that exhibit would appear to start slightly faster this way... I'm going to try it with one of my datasets... Brian _______________________________________________ General mailing list General@simile.mit.edu http://simile.mit.edu/mailman/listinfo/general