From ae8f3ae4adc95e42b697f93ed7b697d83bb96ef0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nicol=C3=B2=20P?= Date: Wed, 12 Apr 2023 15:53:39 +0200 Subject: [PATCH] Basic 404 handling --- 404.html | 95 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ js/ds.js | 10 +++--- 2 files changed, 99 insertions(+), 6 deletions(-) create mode 100644 404.html diff --git a/404.html b/404.html new file mode 100644 index 0000000..274f881 --- /dev/null +++ b/404.html @@ -0,0 +1,95 @@ + + + + DataSpace | Not Found + + + + + + +
+
+

+ 404
+ Not Found +

+
+
+

+ The requested resource wasn't found or it is not + implemented yet. +

+
+
+ +
+
+
+
+ + + \ No newline at end of file diff --git a/js/ds.js b/js/ds.js index 5a55a65..e33dbc4 100644 --- a/js/ds.js +++ b/js/ds.js @@ -75,15 +75,13 @@ DataSpace.renderReport = async function (report, archesJson, images) { let resource = report.resource; let resKeys = Object.keys(resource); - // TODO prepare 404 page - if (!resKeys.length) { + let resType = resKeys[0].split(' ')[0]; + + if (!resKeys.length || ! (resType in this.RESOURCE_REPORT)) { location.href = '/404.html'; return; } - let resType = resKeys[0].split(' ')[0]; - - if (['Object', 'Context'].includes(resType)) { const geoJSON = JSON.parse( resource[`${resType} Coordinates`] @@ -350,7 +348,7 @@ DataSpace.attachReadMore = function (cssClass, maxWords = 100) // TODO change this element, don't create a new one more.onclick = function () { const less = document.createElement('span'); - less.textContent = 'Less'; + less.textContent = 'Show less'; less.className = 'text-primary c-hand'; // Hacky...