-
Notifications
You must be signed in to change notification settings - Fork 71
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #526 from r-o-b-e-r-t-o/issue_390
Adds Permalink feature. Fixes #390
- Loading branch information
Showing
10 changed files
with
227 additions
and
16 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 |
---|---|---|
|
@@ -22,4 +22,6 @@ Philip Partsch <[email protected]> | |
|
||
David Le Nir <[email protected]> | ||
|
||
Baran Barış Yıldızlı <[email protected]> | ||
Baran Barış Yıldızlı <[email protected]> | ||
|
||
Roberto Rötting <[email protected]> |
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
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
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
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
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
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
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
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
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 |
---|---|---|
@@ -0,0 +1,68 @@ | ||
<!DOCTYPE html> | ||
<html lang="en"> | ||
|
||
<head> | ||
<meta charset="UTF-8"> | ||
<meta name="viewport" content="width=device-width, initial-scale=1.0"> | ||
<meta http-equiv="X-UA-Compatible" content="ie=edge"> | ||
<title>sphinx-needs permalink</title> | ||
|
||
<script> | ||
function loadJSON(filename, callback) { | ||
var xobj = new XMLHttpRequest(); | ||
xobj.overrideMimeType('application/json'); | ||
xobj.open('GET', filename, true); | ||
xobj.onreadystatechange = function () { | ||
if (xobj.readyState == 4 && xobj.status == '200') { | ||
callback(xobj.responseText); | ||
} | ||
}; | ||
xobj.send(null); | ||
} | ||
|
||
function main() { | ||
loadJSON('{{ needs_file }}', function (response) { | ||
const needs = JSON.parse(response); | ||
const current_version = needs['current_version']; | ||
const versions = needs['versions']; | ||
const version = versions[current_version]; | ||
const needs_obj = version['needs']; | ||
|
||
const id = getParameterByName('id'); | ||
var pathname = new URL(window.location.href).pathname; | ||
pathname = pathname.substring(0, pathname.lastIndexOf('{{ permalink_file }}')); | ||
|
||
const keys = Object.keys(needs_obj); | ||
|
||
var docname = 'index'; | ||
|
||
keys.forEach((key, index) => { | ||
if (key === id) { | ||
const need = needs_obj[key]; | ||
docname = need['docname']; | ||
return; | ||
} | ||
}); | ||
|
||
window.location.replace(pathname + docname + '.html#' + id); | ||
}); | ||
} | ||
|
||
function getParameterByName(name, url = window.location.href) { | ||
name = name.replace(/[\[\]]/g, '\\$&'); | ||
var regex = new RegExp('[?&]' + name + '(=([^&#]*)|&|#|$)'), | ||
results = regex.exec(url); | ||
if (!results) return null; | ||
if (!results[2]) return ''; | ||
return decodeURIComponent(results[2].replace(/\+/g, ' ')); | ||
} | ||
|
||
window.addEventListener('DOMContentLoaded', main); | ||
</script> | ||
|
||
</head> | ||
|
||
<body> | ||
</body> | ||
|
||
</html> |