File: auto-redirect.html

package info (click to toggle)
condor 23.9.6%2Bdfsg-2.1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 60,012 kB
  • sloc: cpp: 528,272; perl: 87,066; python: 42,650; ansic: 29,558; sh: 11,271; javascript: 3,479; ada: 2,319; java: 619; makefile: 615; xml: 613; awk: 268; yacc: 78; fortran: 54; csh: 24
file content (86 lines) | stat: -rw-r--r-- 2,951 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
<!DOCTYPE html>
<html class="writer-html5" lang="en" >
<head>
	<link rel="shortcut icon" href="_static/logo.svg"/>
</head>

<body onload="redirect()">

<h2>Error: HTCondor Documentation Auto-Redirect Failed</h2>
<p><b>Reason:</b> <span id="fail-reason">Unknown</span></p>
<h3>What to do:</h3>
<p>
	Please inform the HTCSS development team of this issue by emailing us at htcondor-users@cs.wisc.edu
	with the failure reason, the URL you attempted to reach, and where you found the attempted URL.
</p>

<a id="doc-link">HTCondor Documentation</a>

<script>
// Root URL to redirect too
const url_root = "https://htcondor.readthedocs.io/en/latest/";
//const url_root = "http://127.0.0.1:8000/"; // This is for local testing only!!! Make sure this is commented out for merging

// Map of tag -> URL end
const examples = new Map([
	["convert-multi-queue-statements", "faq/users/convert-multi-q-statements.html"],
	["bagman-percent-done", "faq/DAGMan/bagman-exit-at-percent-done.html"],
]);

// Map of category -> tag map
const categories = new Map([
	["example", examples],
]);

// Magic Redirect function to parse URL info and redirect
// Expects: url_root/auto-redirect.html?category=<value>&tag=<value>
function redirect() {
	// Process extra URL info
	var url = window.location.href;
	var infoStart = url.indexOf("?") + 1,
	    infoEnd = url.length + 1,
	    info = url.slice(infoStart, infoEnd);

	var errmsg = "";
	if (info === url || info === "") { // Verify extra information provided
		errmsg = "No redirect information specified.";
	} else {
		// Parse & delimited key=value pairs post ?
		var params = {}, i, key, val,
		    pairs = info.replace(/\+/g, " ").split("&");
		for (i = 0; i < pairs.length; i++) {
			var pair = pairs[i].split("=", 2);
			key = decodeURIComponent(pair[0]);
			val = decodeURIComponent(pair[1]);
			params[key] = val;
		}

		if (!params.hasOwnProperty("category")) { // Verify category provided
			errmsg = "Redirect URL does not contain a category.";
		} else if (!categories.has(params["category"])) { // Verify valid/existing category
			errmsg = "Redirect URL contains unknown category: " + params["category"];
		} else {
			// Get specified category map
			var category = categories.get(params["category"]);
			if (!params.hasOwnProperty("tag")) { // Verify tag provided
				errmsg = "Redirect URL does not contain a tag.";
			} else if (!category.has(params["tag"])) { // Verify valid/existing tag
				errmsg = "Redirect contains unknown tag (" + params["tag"] + ") for category: " + params["category"];
			} else {
				// Create redirect URL and go there
				var redirect_url = url_root + category.get(params["tag"]);
				window.location.replace(redirect_url);
			}
		}
	}

	// UhOh: error happend so update page display with the found issue
	if (errmsg !== "") {
		document.getElementById("doc-link").href = url_root;
		document.getElementById("fail-reason").innerHTML = errmsg;
	}
}
</script>

</body>
</html>