Skip to content

Commit

Permalink
adds custom 404 page
Browse files Browse the repository at this point in the history
- shows helpful information including a sitemap, see demo
  https://w3id.org/dpv/404 which tries to guess whether there is a
  typo in the url or purl, shows versioned url if unversioned url is
  used, and shows a sitemap like structure to pick the intended page
- discussed in https://w3id.org/dpv/meetings/meeting-2024-07-23
  • Loading branch information
coolharsh55 committed Jul 29, 2024
1 parent ebe0309 commit fd3fbd5
Showing 1 changed file with 129 additions and 0 deletions.
129 changes: 129 additions & 0 deletions 404.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,129 @@
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>DPV - 404 error</title>
<style type="text/css">
body {
max-width: 800px;
margin: auto;
/*font-family: monospace;*/
}
.url {
color: blue;
}
</style>
</head>
<body>
<h1>404 Error</h1>
<p><strong>DPVCG Resource Not Found</strong>
<p>Common causes of this error:</p>
<ol>
<li>Typo in the URL - <span id="span-check-url"></span>.</li>
<li>Used an older unversioned URL - <span id="span-check-version"></span>.</li>
<li>The page existed before, but doesn't exist now OR it has been moved to a new location under a different name. You can view the available resources below.</li>
</ol>
<div id="wb404"/>
<script src="https://archive.org/web/wb404.js"></script>
<p><strong>DPV v2.0</strong><br/>
├── <a href="https://w3c.github.io/dpv/2.0/ai/">ai</a><br>
├── <a href="https://w3c.github.io/dpv/2.0/dpv/">dpv</a><br>
├── <a href="https://w3c.github.io/dpv/2.0/examples/">examples</a><br>
├── <a href="https://w3c.github.io/dpv/2.0/justifications/">justifications</a><br>
├── <a href="https://w3c.github.io/dpv/2.0/legal/">legal</a><br>
│   ├── <a href="https://w3c.github.io/dpv/2.0/legal/de/">de</a><br>
│   ├── <a href="https://w3c.github.io/dpv/2.0/legal/eu/">eu</a><br>
│   │   ├── <a href="https://w3c.github.io/dpv/2.0/legal/eu/aiact/">aiact</a><br>
│   │   ├── <a href="https://w3c.github.io/dpv/2.0/legal/eu/dga/">dga</a><br>
│   │   ├── <a href="https://w3c.github.io/dpv/2.0/legal/eu/gdpr/">gdpr</a><br>
│   │   ├── <a href="https://w3c.github.io/dpv/2.0/legal/eu/nis2/">nis2</a><br>
│   │   └── <a href="https://w3c.github.io/dpv/2.0/legal/eu/rights/">rights</a><br>
│   ├── <a href="https://w3c.github.io/dpv/2.0/legal/gb/">gb</a><br>
│   ├── <a href="https://w3c.github.io/dpv/2.0/legal/ie/">ie</a><br>
│   ├── <a href="https://w3c.github.io/dpv/2.0/legal/in/">in</a><br>
│   └── <a href="https://w3c.github.io/dpv/2.0/legal/us/">us</a><br>
├── <a href="https://w3c.github.io/dpv/2.0/loc/">loc</a><br>
├── <a href="https://w3c.github.io/dpv/2.0/pd/">pd</a><br>
├── <a href="https://w3c.github.io/dpv/2.0/risk/">risk</a><br>
└── <a href="https://w3c.github.io/dpv/2.0/tech/">tech</a>
</p>

<p><strong>DPV v1.0</strong><br/>
├── <a href="https://w3c.github.io/dpv/1.0/dpv/">dpv</a><br>
├── <a href="https://w3c.github.io/dpv/1.0/dpv-gdpr/">dpv-gdpr</a><br>
├── <a href="https://w3c.github.io/dpv/1.0/dpv-legal/">dpv-legal</a><br>
├── <a href="https://w3c.github.io/dpv/1.0/dpv-nace/">dpv-nace</a><br>
├── <a href="https://w3c.github.io/dpv/1.0/dpv-owl/">dpv-owl</a><br>
│   ├── <a href="https://w3c.github.io/dpv/1.0/dpv-owl/dpv-gdpr/">dpv-gdpr</a><br>
│   ├── <a href="https://w3c.github.io/dpv/1.0/dpv-owl/dpv-legal/">dpv-legal</a><br>
│   ├── <a href="https://w3c.github.io/dpv/1.0/dpv-owl/dpv-pd/">dpv-pd</a><br>
│   ├── <a href="https://w3c.github.io/dpv/1.0/dpv-owl/dpv-tech/">dpv-tech</a><br>
│   ├── <a href="https://w3c.github.io/dpv/1.0/dpv-owl/rights/">rights</a><br>
│   │   └── <a href="https://w3c.github.io/dpv/1.0/dpv-owl/rights/eu/">eu</a><br>
│   └── <a href="https://w3c.github.io/dpv/1.0/dpv-owl/risk/">risk</a><br>
├── <a href="https://w3c.github.io/dpv/1.0/dpv-pd/">dpv-pd</a><br>
├── <a href="https://w3c.github.io/dpv/1.0/dpv-skos/">dpv-skos</a><br>
│   ├── <a href="https://w3c.github.io/dpv/1.0/dpv-skos/dpv-gdpr/">dpv-gdpr</a><br>
│   ├── <a href="https://w3c.github.io/dpv/1.0/dpv-skos/dpv-legal/">dpv-legal</a><br>
│   ├── <a href="https://w3c.github.io/dpv/1.0/dpv-skos/dpv-pd/">dpv-pd</a><br>
│   ├── <a href="https://w3c.github.io/dpv/1.0/dpv-skos/dpv-tech/">dpv-tech</a><br>
│   ├── <a href="https://w3c.github.io/dpv/1.0/dpv-skos/rights/">rights</a><br>
│   │   └── <a href="https://w3c.github.io/dpv/1.0/dpv-skos/rights/eu/">eu</a><br>
│   └── <a href="https://w3c.github.io/dpv/1.0/dpv-skos/risk/">risk</a><br>
├── <a href="https://w3c.github.io/dpv/1.0/dpv-tech/">dpv-tech</a><br>
├── <a href="https://w3c.github.io/dpv/1.0/examples/">examples</a><br>
├── <a href="https://w3c.github.io/dpv/1.0/rights/">rights</a><br>
│   └── <a href="https://w3c.github.io/dpv/1.0/rights/eu/">eu</a><br>
└── <a href="https://w3c.github.io/dpv/1.0/risk/">risk</a>
</p>

<script type="text/javascript">
// const url = window.location.href;
const url = "https://w3c.github.io/dpv/pd";
const span_typo = document.getElementById('span-check-url');
const span_unversioned = document.getElementById('span-check-version');
const re_check_version = /\d+/;
class PAGE_STATUS {
static _PROD = 0;
static _DEV = 1;
static _LOCAL = 2;
static _OTHER = 3;

static get PROD() { return this._PROD; }
static get DEV() { return this._DEV; }
static get LOCAL() { return this._LOCAL; }
static get OTHER() { return this._OTHER; }
};
var MODE = PAGE_STATUS.OTHER;
if (url.startsWith("https://w3c.github.io/dpv/")) {
MODE = PAGE_STATUS.PROD;
var purl = url.replace("https://w3c.github.io/dpv/", "https://w3id.org/dpv/")
span_typo.innerHTML = "check <span class='url'>"+url+"</span> is correct, or its purl form <a href='"+purl+"'>"+purl+"<a/>";
if (re_check_version.exec(url.replace("https://w3c.github.io/dpv/", "")) == null) {
span_unversioned.innerHTML = "you can check whether this versioned form is the url you are looking for: <a href='https://w3c.github.io/dpv/2.0/" + url.replace("https://w3c.github.io/dpv/", "") + "'>https://w3c.github.io/dpv/2.0/" + url.replace("https://w3c.github.io/dpv/", "") + "</a>";
} else {
span_unversioned.innerHTML = "but this doesn't appear to be the case";
}
} else if (url.startsWith("https://dev.dpvcg.org/")) {
MODE = PAGE_STATUS.DEV;
span_typo.innerHTML = "check <span class='url'>"+url+"</span> is correct";
if (re_check_version.exec(url.replace("https://dev.dpvcg/org/", "")) == null) {
span_unversioned.innerHTML = "this appears to be an unversioned url, you can check whether this versioned form is the url you are looking for: <a href='https://dev.dpvcg/org/2.0/" + url.replace("https://dev.dpvcg/org/", "") + "'>https://dev.dpvcg/org/2.0/" + url.replace("https://dev.dpvcg/org/", "") + "</a>";
} else {
span_unversioned.innerHTML = "... but this doesn't appear to be the case";
}
} else if (url.includes("localhost:")) {
MODE = PAGE_STATUS.LOCAL;
span_typo.innerHTML = "check <span class='url'>"+url+"</span> is correct";
span_unversioned.innerHTML = "but this doesn't appear to be the case";
}

// Typo in the URL
// .replace("https://w3c.github.io/dpv/", "https://w3id.org/dpv");

// const span_currenturl = document.getElementById('current-url');
// span_currenturl.innerHTML = window.location.href;
</script>
</body>
</html>

0 comments on commit fd3fbd5

Please sign in to comment.