diff --git a/README b/README index 820de6a..b005339 100644 --- a/README +++ b/README @@ -30,3 +30,22 @@ If an RDF representation is available, it will be rendered behind the current page and a peel-back animation will reveal the background RDF data as the mouse hovers over the top left corner of the page. + +Examples +-------- + +http://data.nytimes.com/48675831753778135041 + +http://collection.britishmuseum.org/id/object/EOC3130 + +http://data.ordnancesurvey.co.uk/datasets/os-linked-data + +http://id.loc.gov/vocabulary/organizations/ukmajru.html + +http://www.bbc.co.uk/programmes/b03kqfzx + +http://alpha.acropolis.org.uk/dc1c141fe5d14dcbb04e907156c62e46#id + +http://live.dbpedia.org/page/William_Shakespeare + +http://data.europeana.eu/item/92056/BD9D5C6C6B02248F187238E9D7CC09EAF17BEA59 diff --git a/background.js b/background.js index 23434cb..a867d5a 100644 --- a/background.js +++ b/background.js @@ -1,6 +1,6 @@ chrome.runtime.onMessage.addListener( function(request, sender, sendResponse) { - console.log("Message from content: " + request); + console.log("Message from content: " + request.method); if (request.method == 'setLicense') { var messages = { 'error': 'Error parsing RDF', @@ -23,9 +23,9 @@ }); sendResponse({text: "ok"}); } else if (request.method == 'isRedirect') { - if (request.url == redirectToUrl) { + if (request.url == redirectList[redirectList.length - 1]) { sendResponse({redirect: true, - fromUrl: redirectFromUrl}); + fromUrl: redirectList[0]}); } else { sendResponse({redirect: false}); } @@ -33,17 +33,20 @@ } ); -redirectToUrl = null; -redirectFromUrl = null; +redirectId = null; +redirectList = []; chrome.webRequest.onBeforeRedirect.addListener( function(details) { - if (details.statusCode == 303) { - console.log(details.url + " is being redirected to " + details.redirectUrl); - redirectToUrl = details.redirectUrl; - redirectFromUrl = details.url; + if (details.requestId != redirectId) { + redirectId = details.requestId; + redirectList = [details.url]; + console.log("redirect start, " + details.url); } - console.log("redirect"); + if (details.redirectUrl != null) { + console.log("redirect to " + details.redirectUrl); + redirectList.push(details.redirectUrl); + } }, {urls: [""]} ); diff --git a/contentscript.js b/contentscript.js index 052fc9b..63e4fb0 100644 --- a/contentscript.js +++ b/contentscript.js @@ -36,6 +36,15 @@ } }; +$.typedValue.types['http://www.w3.org/2001/XMLSchema#nonNegativeInteger'] = { + regex: /^(-0)|(\+?[0-9]+)$/, + strip: true, + /** @ignore */ + value: function (v) { + return parseInt(v, 10); + } + }; + function checkRdfXmlLicense(data, format) { var parser = new DOMParser(); @@ -64,9 +73,9 @@ function fetchRdf(rdfUrl, failfunc) { $.ajax(rdfUrl, { headers: { - Accept: acceptFormats.join(', ') + Accept: acceptFormats.join(', '), + 'Cache-Control': 'no-cache' }, - cache: true, dataType: 'text', error: function(req, textStatus, errorThrown) { failfunc(); @@ -122,7 +131,7 @@ }, function(response) { if (response.redirect) { fetchRdf(response.fromUrl, function() { - fetchRdf(document.URL); // if failed to fetch prior page as RDF + fetchRdf(document.URL, function() {}); // if failed to fetch prior page as RDF }); } else { // if no redirect, try fetching current page as RDF fetchRdf(document.URL, function() {}); diff --git a/manifest.json b/manifest.json index a685186..6f4b0ba 100644 --- a/manifest.json +++ b/manifest.json @@ -3,7 +3,7 @@ "name": "LOD-check", "description": "Checks pages as you browse for the presence of Linked Open Data behind them and reveals the underlying data.", - "version": "1.1", + "version": "1.2", "permissions": [ "webRequest", ""