Skip to content

Commit

Permalink
Deploying to main from @ 870569161c0a5c302511f7910e8dd2e0056137e9 🚀
Browse files Browse the repository at this point in the history
  • Loading branch information
ahus1 committed Feb 3, 2025
1 parent a5d96dc commit 04a4297
Show file tree
Hide file tree
Showing 3 changed files with 75 additions and 10 deletions.
30 changes: 20 additions & 10 deletions 404.html
Original file line number Diff line number Diff line change
Expand Up @@ -59,18 +59,26 @@


<div class="container mt-5">
<h1>Page not found</h1>
<h1 id="heading">Page not found</h1>

<p>
The page you’re looking for does not exist. It may have been moved. You can return to <a href="https://www.keycloak.org/">the start page</a>, or follow one of the links in the navigation on the top.
</p>
<p>
If you arrived at this page by clicking on a link, please notify the owner of the site that the link is broken. If you typed the URL of this page manually, please double-check that you entered the address correctly.
</p>
<div id="notfound">
<p>
The page you’re looking for does not exist. It may have been moved. You can return to <a href="https://www.keycloak.org/">the start page</a>, or follow one of the links in the navigation on the top.
</p>
<p>
If you arrived at this page by clicking on a link, please notify the owner of the site that the link is broken. If you typed the URL of this page manually, please double-check that you entered the address correctly.
</p>

<p>
If you think this is a bug that the Keycloak team should fix, create <a id="buglink" href="https://github.com/keycloak/keycloak-web/issues/new?template=bug.yml&title=Broken%20link%20on%20the%20website%20{url}&description=%0A%0AURL:%20{url}">a bug issue on the GitHub issue tracker</a>.
</p>
<p>
If you think this is a bug that the Keycloak team should fix, create <a id="buglink" href="https://github.com/keycloak/keycloak-web/issues/new?template=bug.yml&title=Broken%20link%20on%20the%20website%20{url}&description=%0A%0AURL:%20{url}">a bug issue on the GitHub issue tracker</a>.
</p>
</div>

<div id="redirecting" style="display: none">
<p>
You are being redirected to <a id="redirectlink" href="...">...</a>.
</p>
</div>

<script>
document.addEventListener("DOMContentLoaded", function() {
Expand All @@ -83,6 +91,8 @@ <h1>Page not found</h1>

</div>

<script src="https://www.keycloak.org/resources/js/redirect.js" type="text/javascript"></script>


<div class="container mt-5">
<footer class="py-3 my-4 border-top">
Expand Down
46 changes: 46 additions & 0 deletions resources/js/redirect.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
var pageWithHash = window.location.pathname + window.location.hash;
var page = window.location.pathname;
var openRedirects = new XMLHttpRequest();
openRedirects.onreadystatechange = function() {
if (this.readyState === 4 && this.status === 200) {
var redirects = this.responseText.split(/\r?\n/);
for (var i = 0; i < redirects.length; i++) {
var redirect = redirects[i].split("=");
if (redirects[i].trim().startsWith("#")) {
// allow for line comments
continue;
}
var pattern = new RegExp(redirect[0])
if (pattern.test(page) || pattern.test(pageWithHash)) {
document.title = "Redirecting..."
document.getElementById("heading").innerText = "Redirecting...";
document.getElementById("redirecting").style.display = "block";
document.getElementById("notfound").style.display = "none";
document.getElementById("redirectlink").href = redirect[1];
document.getElementById("redirectlink").innerText = redirect[1];
var anchor = "";
if (redirect[1].indexOf("#") !== -1) {
anchor = "#" + redirect[1].split("#")[1];
}
var checkRedirect = new XMLHttpRequest();
checkRedirect.onreadystatechange = function() {
if (this.readyState === 4) {
if (this.status === 200) {
// The response URL will no longer contain the anchor, therefore, add it again
window.location = checkRedirect.responseURL + anchor;
} else {
document.getElementById("heading").innerText = "Redirect failed";
document.getElementById("notfound").style.display = "block";
document.getElementById("redirecting").style.display = "none";
}
}
}
checkRedirect.open("GET", redirect[1], true);
checkRedirect.send();
break;
}
}
}
};
openRedirects.open("GET", "/resources/redirects", true);
openRedirects.send();
9 changes: 9 additions & 0 deletions resources/redirects
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
# Regex with with or without a anchor -> target path
^/docs/(latest|[0-9.]+)/securing_apps=/guides.html#securing-apps
^/docs/(latest|[0-9.]+)/server_installation=/guides.html#server
^/docs/(latest|[0-9.]+)/getting_started=/guides.html#getting-started
^/docs/([0-9.]+)/server-admin=/docs-api/latest/server-admin/index.html
^/docs/([0-9.]+)/upgrading=/docs-api/latest/upgrading/index.html
^/docs-api/[0-9.]+/rest-api=/docs-api/latest/rest-api/index.html
^/[0-9]+/[0-9]+/keycloak-[0-9]+-released=/blog.html
^/404=/

0 comments on commit 04a4297

Please sign in to comment.