Support linking to individual guide pages.
This commit is contained in:
@ -63,7 +63,7 @@
|
|||||||
</div>
|
</div>
|
||||||
|
|
||||||
<script type="text/javascript">
|
<script type="text/javascript">
|
||||||
// Download the go-ethereum wiki sidebar and convert it into a guide sidebar
|
// Download the developer guide ToC and convert it into a guide sidebar
|
||||||
$.ajax({
|
$.ajax({
|
||||||
url: 'https://raw.githubusercontent.com/wiki/ethereum/go-ethereum/Developer-Guide.md',
|
url: 'https://raw.githubusercontent.com/wiki/ethereum/go-ethereum/Developer-Guide.md',
|
||||||
error: function() {
|
error: function() {
|
||||||
@ -97,12 +97,13 @@
|
|||||||
// Otherwise if the line is a link, add a new entry to the sub-menu
|
// Otherwise if the line is a link, add a new entry to the sub-menu
|
||||||
if (line[0] == "[") {
|
if (line[0] == "[") {
|
||||||
var name = /\[(.*)\]/g.exec(line)[1];
|
var name = /\[(.*)\]/g.exec(line)[1];
|
||||||
|
var id = (head + "-" + name).split(" ").join("-");
|
||||||
|
|
||||||
var link = /\((.*)\)/g.exec(line)[1];
|
var link = /\((.*)\)/g.exec(line)[1];
|
||||||
link = "https://raw.githubusercontent.com/wiki/" + link.slice("https://github.com/".length).replace("wiki/", "") + ".md";
|
link = "https://raw.githubusercontent.com/wiki/" + link.slice("https://github.com/".length).replace("wiki/", "") + ".md";
|
||||||
|
|
||||||
var item = $("<a href='#' class='list-group-item'>" + name + "</a>").appendTo(menu);
|
var item = $("<a id='menu-" + id + "' href='#" + id + "' class='list-group-item'>" + name + "</a>").appendTo(menu);
|
||||||
$(item).click(function(head, name, link) {
|
$(item).click(function(id, head, name, link) {
|
||||||
return function() {
|
return function() {
|
||||||
$.ajax({
|
$.ajax({
|
||||||
url: link,
|
url: link,
|
||||||
@ -111,22 +112,27 @@
|
|||||||
},
|
},
|
||||||
dataType: 'text',
|
dataType: 'text',
|
||||||
success: function(data) {
|
success: function(data) {
|
||||||
|
// Load the wiki page content into the current page
|
||||||
$('#content').html("<h1>" + head + ": " + name + "</h1>" + marked(data));
|
$('#content').html("<h1>" + head + ": " + name + "</h1>" + marked(data));
|
||||||
emojify.setConfig({img_dir: '../static/images/emoji'});
|
emojify.setConfig({img_dir: '../static/images/emoji'});
|
||||||
emojify.run(document.getElementById('content'));
|
emojify.run(document.getElementById('content'));
|
||||||
|
|
||||||
|
// Run the syntax highlighter on all code blocks
|
||||||
$('pre code').each(function(i, block) {
|
$('pre code').each(function(i, block) {
|
||||||
console.log("hl", i, block);
|
|
||||||
hljs.highlightBlock(block);
|
hljs.highlightBlock(block);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
}(head, name, link));
|
}(id, head, name, link));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// Menu constructed, load the first entry
|
// Menu constructed, load the specified entry, or first if non existent
|
||||||
console.log(menu.children()[1].click());
|
if (window.location.hash.length > 1) {
|
||||||
|
$('#menu-' + window.location.hash.split('#')[1])[0].click();
|
||||||
|
} else {
|
||||||
|
$(toc.children()[0]).children()[1].click();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
</script>
|
</script>
|
||||||
|
Reference in New Issue
Block a user