-
Notifications
You must be signed in to change notification settings - Fork 190
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix loading from incorrect URI on 404 page. (#1843)
* Present a list of possible options when encountering a 404. * Also affix cccl/ onto URL since that's what GitHub does. * Update gitignore to exclude _site
- Loading branch information
Showing
3 changed files
with
38 additions
and
27 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,5 +5,6 @@ build*/ | |
.config | ||
_deps/catch2-src/ | ||
.vscode/ | ||
_site/ | ||
compile_commands.json | ||
CMakeUserPresets.json |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,38 +1,48 @@ | ||
<!DOCTYPE html> | ||
<meta charset="utf-8"> | ||
<title>Redirecting to nvidia.github.io/cccl/thrust</title> | ||
<title>CCCL - 404</title> | ||
|
||
<html> | ||
<head> | ||
<link rel="stylesheet" href="/cccl/_static/basic.css" type="text/css"/> | ||
<link rel="stylesheet" href="/cccl/_static/css/theme.css" type="text/css"/> | ||
</head> | ||
<body> | ||
<h1>404 - That link no longer works.</h1> | ||
<p>Here is a list of possible options:</p> | ||
<ul> | ||
<div id="linkGen"></div> | ||
</ul> | ||
<script type="module"> | ||
import Fuse from 'https://cdn.jsdelivr.net/npm/[email protected]/dist/fuse.mjs' | ||
var localUri = window.location.pathname; | ||
var hostUrl = window.location.protocol + "//" + window.location.host | ||
var pagelistUrl = hostUrl + "/pagelist.txt" | ||
import Fuse from 'https://cdn.jsdelivr.net/npm/[email protected]/dist/fuse.mjs' | ||
var localUri = window.location.pathname; | ||
var hostUrl = window.location.protocol + "//" + window.location.host | ||
var pagelistUrl = hostUrl + "/cccl/pagelist.txt" | ||
|
||
fetch(pagelistUrl) | ||
.then((response) => response.text()) | ||
.then((text) => { | ||
const pagelist = text.split(",") | ||
console.log(pagelist) | ||
fetch(pagelistUrl) | ||
.then((response) => response.text()) | ||
.then((text) => { | ||
const pagelist = text.split(",") | ||
|
||
const options = { | ||
includeScore: true, | ||
distance: 100, | ||
threshold: 0.8, | ||
} | ||
const options = { | ||
includeScore: true, | ||
distance: 100, | ||
threshold: 0.8, | ||
ignoreLocation: true | ||
} | ||
|
||
const fuse = new Fuse(pagelist, options) | ||
const result = fuse.search(localUri) | ||
// cccl/device_vector.html => 'cccl 'device 'vector | ||
const query = localUri.replace(/\/|-|_/gi," '").replace(".html","") | ||
console.log("query:" + query) | ||
const fuse = new Fuse(pagelist, options) | ||
const result = fuse.search(query, {limit: 10}) | ||
|
||
if (result.length) { | ||
console.log(result[0]) | ||
var possibleUri = hostUrl + "/" + result[0].item | ||
window.location.href = possibleUri | ||
} else { | ||
window.location.href = hostUrl + "/index.html" | ||
} | ||
}) | ||
const listItem = '<li><a href=\"{2}{0}\">{0}</a> - Score: {1}</li>'.replace(/\{2\}/g, hostUrl + "/") | ||
document.getElementById('linkGen').innerHTML = "" | ||
result.forEach(element => { | ||
document.getElementById('linkGen').innerHTML += listItem.replace(/\{0\}/g, element.item).replace(/\{1\}/g, element.score.toFixed(2)) | ||
}); | ||
}) | ||
</script> | ||
</head> | ||
</body> | ||
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters