From 3ace44f60bf05af698ed8860a478404376c2aac5 Mon Sep 17 00:00:00 2001 From: Milos Jovanovik Date: Thu, 6 Jun 2013 20:34:50 +0200 Subject: [PATCH 01/11] Displaying URIs as links in the table Added support for displaying values which represent an URI as links (anchors) in the HTML table. --- js/browser.js | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/js/browser.js b/js/browser.js index 098c4b9..dd572eb 100644 --- a/js/browser.js +++ b/js/browser.js @@ -1,8 +1,17 @@ $(document).ready(function() { var urlRegex = /(#(.+)|\/([^\/#]+))$/, + uriRegex = /^(([a-z][\-a-z0-9+\.]*):){1}(\/\/([^\/?#]+))?([^?#]*)?(\?([^#]*))?(#(.*))?$/i, fragidRegex = /^#row=(\d+)(-(\d+))?$/, + isURI = function (u) { + var m = u.match(uriRegex); + if (m === null) { + return false; + } + return true; + }, + extractMetadata = function (metadata, fields) { var value; for (i in fields) { @@ -78,7 +87,10 @@ $(document).ready(function() { } v += ''; return v; - } else { + } else if (isURI(value)) { + return '' + value + ''; + } + else { return v.toString().replace(/\s+/, ' '); } }, From 4c3e3b814ea7b5ef7c6b92e2ed74096869bf26e3 Mon Sep 17 00:00:00 2001 From: Milos Jovanovik Date: Tue, 21 Jan 2014 10:33:33 +0100 Subject: [PATCH 02/11] Sniffing URI values Added support for sniffing values as URIs, whenever the type is not set explicitly to 'url', but the value is an URI. Also, I rolled back the previous changes to browser.js which displayed URI strings as anchors. This is now done by the rest of the code, once the string is identified to be an URI. --- js/browser.js | 14 +------------- js/jquery.linked-csv.js | 3 ++- 2 files changed, 3 insertions(+), 14 deletions(-) diff --git a/js/browser.js b/js/browser.js index dd572eb..098c4b9 100644 --- a/js/browser.js +++ b/js/browser.js @@ -1,17 +1,8 @@ $(document).ready(function() { var urlRegex = /(#(.+)|\/([^\/#]+))$/, - uriRegex = /^(([a-z][\-a-z0-9+\.]*):){1}(\/\/([^\/?#]+))?([^?#]*)?(\?([^#]*))?(#(.*))?$/i, fragidRegex = /^#row=(\d+)(-(\d+))?$/, - isURI = function (u) { - var m = u.match(uriRegex); - if (m === null) { - return false; - } - return true; - }, - extractMetadata = function (metadata, fields) { var value; for (i in fields) { @@ -87,10 +78,7 @@ $(document).ready(function() { } v += ''; return v; - } else if (isURI(value)) { - return '' + value + ''; - } - else { + } else { return v.toString().replace(/\s+/, ' '); } }, diff --git a/js/jquery.linked-csv.js b/js/jquery.linked-csv.js index 72e22b2..4f059e4 100644 --- a/js/jquery.linked-csv.js +++ b/js/jquery.linked-csv.js @@ -18,6 +18,7 @@ 'skos-xl': "http://www.w3.org/2008/05/skos-xl#", // SKOS Extensions for Labels }, prefixRegex = new RegExp('^(' + Object.keys(namespaces).join('|') + '):(.+)$'), + uriRegex = /^(([a-z][\-a-z0-9+\.]*):){1}(\/\/([^\/?#]+))?([^?#]*)?(\?([^#]*))?(#(.*))?$/i, init = function (linkedCSV, data, base) { var @@ -52,7 +53,7 @@ }, parseValue = function(value, type, lang) { var val = value; - if (type === 'url') { + if (type === 'url' || uriRegex.test(value)) { val = { '@id': $.uri.resolve(value, base).toString() }; From a27b1f341ffd74f06d104d5269e9bbc8ab0f8c1e Mon Sep 17 00:00:00 2001 From: Milos Jovanovik Date: Tue, 21 Jan 2014 19:08:02 +0100 Subject: [PATCH 03/11] Alternative display for URIs Added an alternative representation of URIs, as full URI strings part of an anchor tag. The icon representation remains a default, but using a query string parameter (showUri=true), the URIs can be displayed in a readable manner. --- js/browser.js | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/js/browser.js b/js/browser.js index 098c4b9..0479720 100644 --- a/js/browser.js +++ b/js/browser.js @@ -53,6 +53,8 @@ $(document).ready(function() { tableValue = function (value, includeBadge) { var v = value; + query = document.location.search; + showUri = /\?showUri=true/.test(query) ? true : false; if ($.isArray(value)) { v = ''; return v; } else if (value['@id']) { - return ''; + if(showUri) + return '' + value['@id'] + ''; + else + return ''; } else if (value['@value']) { v = value['@value'].replace(/\s+/, ' '); if (includeBadge) { From 2f92d74c53116827563b89740a1af018ab8db5b9 Mon Sep 17 00:00:00 2001 From: Milos Jovanovik Date: Tue, 21 Jan 2014 19:34:54 +0100 Subject: [PATCH 04/11] Alternative display for URIs Added an alternative representation of URIs, as full URI strings part of an anchor tag. The icon representation remains a default, but using a query string parameter (showUri=true), the URIs can be displayed in a readable manner. --- js/browser.js | 1 + 1 file changed, 1 insertion(+) diff --git a/js/browser.js b/js/browser.js index 0479720..abe5543 100644 --- a/js/browser.js +++ b/js/browser.js @@ -2,6 +2,7 @@ $(document).ready(function() { var urlRegex = /(#(.+)|\/([^\/#]+))$/, fragidRegex = /^#row=(\d+)(-(\d+))?$/, + showUri = /\?showUri=true/.test(document.location.search) ? true : false, extractMetadata = function (metadata, fields) { var value; From 3991716cf9500e5cc22fc62f0df79a15144a1158 Mon Sep 17 00:00:00 2001 From: Milos Jovanovik Date: Tue, 21 Jan 2014 19:37:23 +0100 Subject: [PATCH 05/11] Revert "Alternative display for URIs" This reverts commit 2f92d74c53116827563b89740a1af018ab8db5b9. --- js/browser.js | 1 - 1 file changed, 1 deletion(-) diff --git a/js/browser.js b/js/browser.js index abe5543..0479720 100644 --- a/js/browser.js +++ b/js/browser.js @@ -2,7 +2,6 @@ $(document).ready(function() { var urlRegex = /(#(.+)|\/([^\/#]+))$/, fragidRegex = /^#row=(\d+)(-(\d+))?$/, - showUri = /\?showUri=true/.test(document.location.search) ? true : false, extractMetadata = function (metadata, fields) { var value; From 2326510004ba69c5638b97f2892efe3fa96e0392 Mon Sep 17 00:00:00 2001 From: Milos Jovanovik Date: Tue, 21 Jan 2014 19:37:47 +0100 Subject: [PATCH 06/11] Revert "Alternative display for URIs" This reverts commit a27b1f341ffd74f06d104d5269e9bbc8ab0f8c1e. --- js/browser.js | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/js/browser.js b/js/browser.js index 0479720..098c4b9 100644 --- a/js/browser.js +++ b/js/browser.js @@ -53,8 +53,6 @@ $(document).ready(function() { tableValue = function (value, includeBadge) { var v = value; - query = document.location.search; - showUri = /\?showUri=true/.test(query) ? true : false; if ($.isArray(value)) { v = ''; return v; } else if (value['@id']) { - if(showUri) - return '' + value['@id'] + ''; - else - return ''; + return ''; } else if (value['@value']) { v = value['@value'].replace(/\s+/, ' '); if (includeBadge) { From 6236b1cd538e1f341e16cc77e5fcbd2e1cfce952 Mon Sep 17 00:00:00 2001 From: Milos Jovanovik Date: Tue, 21 Jan 2014 19:40:20 +0100 Subject: [PATCH 07/11] Alternative display for URIs (corrected) Added an alternative representation of URIs, as full URI strings part of an anchor tag. The icon representation remains a default, but using a query string parameter (showUri=true), the URIs can be displayed in a readable manner. --- js/browser.js | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/js/browser.js b/js/browser.js index 098c4b9..7d1279d 100644 --- a/js/browser.js +++ b/js/browser.js @@ -2,6 +2,7 @@ $(document).ready(function() { var urlRegex = /(#(.+)|\/([^\/#]+))$/, fragidRegex = /^#row=(\d+)(-(\d+))?$/, + showUri = /\?showUri=true/.test(document.location.search) ? true : false, extractMetadata = function (metadata, fields) { var value; @@ -64,7 +65,10 @@ $(document).ready(function() { v += ''; return v; } else if (value['@id']) { - return ''; + if(showUri) + return '' + value['@id'] + ''; + else + return ''; } else if (value['@value']) { v = value['@value'].replace(/\s+/, ' '); if (includeBadge) { From ef9546df8bd9bd84f1d8d30e81214e13f59b039c Mon Sep 17 00:00:00 2001 From: Milos Jovanovik Date: Wed, 22 Jan 2014 00:15:35 +0100 Subject: [PATCH 08/11] Query string parameter correction Correcting the way the query string parameter is used and detected. Using '&' instead of '?', since it cannot be the first query string parameter. --- js/browser.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/js/browser.js b/js/browser.js index 7d1279d..5e23d88 100644 --- a/js/browser.js +++ b/js/browser.js @@ -2,7 +2,7 @@ $(document).ready(function() { var urlRegex = /(#(.+)|\/([^\/#]+))$/, fragidRegex = /^#row=(\d+)(-(\d+))?$/, - showUri = /\?showUri=true/.test(document.location.search) ? true : false, + showUri = /\&showUri=true/.test(document.location.search) ? true : false, extractMetadata = function (metadata, fields) { var value; From 57e0212df195e7127779e6dd6ec0f63532eebe45 Mon Sep 17 00:00:00 2001 From: Milos Jovanovik Date: Wed, 22 Jan 2014 01:11:06 +0100 Subject: [PATCH 09/11] Query string to Load URI correction Correcting the way the query string parameter 'uri=' is being transferred as a Load URL for CSV files / content. The addition of the 'showUri' query string parameter makes this change necessary. The original code does not assume usage of other query string parameters besides the 'uri' parameter. --- js/browser.js | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/js/browser.js b/js/browser.js index 5e23d88..d4a848c 100644 --- a/js/browser.js +++ b/js/browser.js @@ -410,8 +410,15 @@ $(document).ready(function() { }, query = document.location.search, - url = /^\?url=/.test(query) ? decodeURIComponent(query.substring(5)) : null, + url, filename; + + if(showUri) { + var pos = query.indexOf("&showUri"); + url = /^\?url=/.test(query) ? decodeURIComponent(query.substring(5,pos)) : null; + } + else + url = /^\?url=/.test(query) ? decodeURIComponent(query.substring(5)) : null; if (url) { filename = urlRegex.exec(url)[3]; From 8ea27afe05cefd83b90994624101091e7efebb21 Mon Sep 17 00:00:00 2001 From: Milos Jovanovik Date: Tue, 22 Apr 2014 18:47:42 +0200 Subject: [PATCH 10/11] Different default display for URIs Changed the default URI display from icons to HTML anchors. If a user wants to view the URIs as icons, the optional query string parameter 'showUri' can be used, with the value set to 'false', i.e. "&showUri=false". --- js/browser.js | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/js/browser.js b/js/browser.js index d4a848c..f95138e 100644 --- a/js/browser.js +++ b/js/browser.js @@ -2,7 +2,7 @@ $(document).ready(function() { var urlRegex = /(#(.+)|\/([^\/#]+))$/, fragidRegex = /^#row=(\d+)(-(\d+))?$/, - showUri = /\&showUri=true/.test(document.location.search) ? true : false, + dontShowUri = /\&showUri=false/.test(document.location.search) ? true : false, extractMetadata = function (metadata, fields) { var value; @@ -65,10 +65,10 @@ $(document).ready(function() { v += ''; return v; } else if (value['@id']) { - if(showUri) - return '' + value['@id'] + ''; - else + if(dontShowUri) return ''; + else + return '' + value['@id'] + ''; } else if (value['@value']) { v = value['@value'].replace(/\s+/, ' '); if (includeBadge) { @@ -413,7 +413,7 @@ $(document).ready(function() { url, filename; - if(showUri) { + if(dontShowUri) { var pos = query.indexOf("&showUri"); url = /^\?url=/.test(query) ? decodeURIComponent(query.substring(5,pos)) : null; } From c2a022c0a1795acff18245dc67a26a009c307fc5 Mon Sep 17 00:00:00 2001 From: Milos Jovanovik Date: Tue, 22 Apr 2014 18:52:39 +0200 Subject: [PATCH 11/11] Different default display for URIs Changed the default URI display from icons to HTML anchors. If a user wants to view the URIs as icons, the optional query string parameter 'showUri' can be used, with the value set to 'false', i.e. "&showUri=false". --- js/browser.js | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/js/browser.js b/js/browser.js index d4a848c..c68cdfa 100644 --- a/js/browser.js +++ b/js/browser.js @@ -2,7 +2,7 @@ $(document).ready(function() { var urlRegex = /(#(.+)|\/([^\/#]+))$/, fragidRegex = /^#row=(\d+)(-(\d+))?$/, - showUri = /\&showUri=true/.test(document.location.search) ? true : false, + dontShowUri = /\&showUri=false/.test(document.location.search) ? true : false, extractMetadata = function (metadata, fields) { var value; @@ -65,10 +65,10 @@ $(document).ready(function() { v += ''; return v; } else if (value['@id']) { - if(showUri) - return '' + value['@id'] + ''; - else + if(dontShowUri) return ''; + else + return '' + value['@id'] + ''; } else if (value['@value']) { v = value['@value'].replace(/\s+/, ' '); if (includeBadge) { @@ -413,10 +413,9 @@ $(document).ready(function() { url, filename; - if(showUri) { - var pos = query.indexOf("&showUri"); + var pos = query.indexOf("&showUri"); + if (pos != -1) url = /^\?url=/.test(query) ? decodeURIComponent(query.substring(5,pos)) : null; - } else url = /^\?url=/.test(query) ? decodeURIComponent(query.substring(5)) : null;