Add contextual link to source file on GitHub in devel-doc (thanks @icook @harding)

This commit is contained in:
Saivann 2014-11-16 17:28:56 -05:00
parent e29104fb82
commit 7a6484fc21
7 changed files with 159 additions and 5 deletions

View file

@ -743,6 +743,9 @@ table td,table th{
.toc ul.reportissue li{
background:url(/img/mini_ico_report.svg) no-repeat 0 3px;
}
.toc ul.editsource li{
background:url(/img/mini_ico_rev.svg) no-repeat 0 3px;
}
.toc a,
.toc a:link,
.toc a:active,
@ -818,6 +821,11 @@ table td,table th{
margin:0;
overflow-y:visible;
}
.toccontent .sourcefile{
width:0;
height:0;
position:absolute;
}
.anchorAf{
position:relative;
@ -2174,10 +2182,9 @@ h2 .rssicon{
.toc ul li ul li a.active:before{
content:"";
}
.toc ul.goback li{
background:none;
}
.toc ul.reportissue li{
.toc ul.goback li,
.toc ul.reportissue li,
.toc ul.editsource li{
background:none;
}
.toccontent{

View file

@ -16,6 +16,7 @@ title: "Developer Examples - Bitcoin"
<ul class="goback"><li><a href="/en/developer-documentation">Return To Overview</a></li></ul>
<ul class="reportissue"><li><a href="https://github.com/bitcoin/bitcoin.org/issues/new" onmouseover="updateIssue(event);">Report An Issue</a></li></ul>
<ul class="editsource"><li><a href="https://github.com/bitcoin/bitcoin.org/tree/master/_includes" onmouseover="updateSource(event);">Edit On GitHub</a></li></ul>
</div></div>
<div markdown="1" class="toccontent">
@ -24,12 +25,20 @@ title: "Developer Examples - Bitcoin"
{% include example_intro.md %}
<div class="sourcefile" data-sourcefile="example_testing.md"></div>
{% include example_testing.md %}
<div class="sourcefile" data-sourcefile="example_transactions.md"></div>
{% include example_transactions.md %}
<div class="sourcefile" data-sourcefile="example_payment_processing.md"></div>
{% include example_payment_processing.md %}
<div class="sourcefile" data-sourcefile="example_p2p_networking.md"></div>
{% include example_p2p_networking.md %}
{% include references.md %}

View file

@ -16,6 +16,7 @@ title: "Developer Guide - Bitcoin"
<ul class="goback"><li><a href="/en/developer-documentation">Return To Overview</a></li></ul>
<ul class="reportissue"><li><a href="https://github.com/bitcoin/bitcoin.org/issues/new" onmouseover="updateIssue(event);">Report An Issue</a></li></ul>
<ul class="editsource"><li><a href="https://github.com/bitcoin/bitcoin.org/tree/master/_includes" onmouseover="updateSource(event);">Edit On GitHub</a></li></ul>
</div></div>
@ -29,20 +30,36 @@ of the following file. -->
{% include guide_intro.md %}
<div class="sourcefile" data-sourcefile="guide_block_chain.md"></div>
{% include guide_block_chain.md %}
<div class="sourcefile" data-sourcefile="guide_transactions.md"></div>
{% include guide_transactions.md %}
<div class="sourcefile" data-sourcefile="guide_contracts.md"></div>
{% include guide_contracts.md %}
<div class="sourcefile" data-sourcefile="guide_wallets.md"></div>
{% include guide_wallets.md %}
<div class="sourcefile" data-sourcefile="guide_payment_processing.md"></div>
{% include guide_payment_processing.md %}
<div class="sourcefile" data-sourcefile="guide_operating_modes.md"></div>
{% include guide_operating_modes.md %}
<div class="sourcefile" data-sourcefile="guide_p2p_network.md"></div>
{% include guide_p2p_network.md %}
<div class="sourcefile" data-sourcefile="guide_mining.md"></div>
{% include guide_mining.md %}
{% include references.md %}

View file

@ -16,6 +16,7 @@ title: "Developer Reference - Bitcoin"
<ul class="goback"><li><a href="/en/developer-documentation">Return To Overview</a></li></ul>
<ul class="reportissue"><li><a href="https://github.com/bitcoin/bitcoin.org/issues/new" onmouseover="updateIssue(event);">Report An Issue</a></li></ul>
<ul class="editsource"><li><a href="https://github.com/bitcoin/bitcoin.org/tree/master/_includes" onmouseover="updateSource(event);">Edit On GitHub</a></li></ul>
</div></div>
<div markdown="1" class="toccontent">
@ -24,12 +25,20 @@ title: "Developer Reference - Bitcoin"
{% include ref_intro.md %}
<div class="sourcefile" data-sourcefile="ref_block_chain.md"></div>
{% include ref_block_chain.md %}
<div class="sourcefile" data-sourcefile="ref_transactions.md"></div>
{% include ref_transactions.md %}
<div class="sourcefile" data-sourcefile="ref_wallets.md"></div>
{% include ref_wallets.md %}
<div class="sourcefile" data-sourcefile="ref_p2p_networking.md"></div>
{% include ref_p2p_networking.md %}
## Bitcoin Core APIs
@ -39,6 +48,8 @@ title: "Developer Reference - Bitcoin"
-- * https://en.bitcoin.it/wiki/API_reference_(JSON-RPC)
-->
<div class="sourcefile" data-sourcefile="ref_core_rpc_intro.md"></div>
{% include ref_core_rpc_intro.md %}
### Remote Procedure Calls (RPCs)
@ -52,10 +63,22 @@ create a cross-site scripting (XSS) exploit. To avoid problems, please
treat block chain and memory pool data as an arbitrary input from an
untrusted source.
<div class="sourcefile" data-sourcefile="ref_core_rpc_abcdefg.md"></div>
{% include ref_core_rpcs-abcdefg.md %}
<div class="sourcefile" data-sourcefile="ref_core_rpc_hijklmn.md"></div>
{% include ref_core_rpcs-hijklmn.md %}
<div class="sourcefile" data-sourcefile="ref_core_rpc_opqrst.md"></div>
{% include ref_core_rpcs-opqrst.md %}
<div class="sourcefile" data-sourcefile="ref_core_rpc_uvwxyz.md"></div>
{% include ref_core_rpcs-uvwxyz.md %}
{% include references.md %}
</div>

BIN
img/mini_ico_rev.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 189 B

73
img/mini_ico_rev.svg Normal file
View file

@ -0,0 +1,73 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<!-- Created with Inkscape (http://www.inkscape.org/) -->
<svg
xmlns:dc="http://purl.org/dc/elements/1.1/"
xmlns:cc="http://creativecommons.org/ns#"
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
xmlns:svg="http://www.w3.org/2000/svg"
xmlns="http://www.w3.org/2000/svg"
xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
width="16px"
height="16px"
id="svg2985"
version="1.1"
inkscape:version="0.48.4 r9939"
inkscape:export-filename="/media/X/bitcoin.org/current/img/mini_ico_rev.png"
inkscape:export-xdpi="90"
inkscape:export-ydpi="90"
sodipodi:docname="mini_ico_rev.svg">
<defs
id="defs2987" />
<sodipodi:namedview
id="base"
pagecolor="#ffffff"
bordercolor="#666666"
borderopacity="1.0"
inkscape:pageopacity="0.0"
inkscape:pageshadow="2"
inkscape:zoom="32"
inkscape:cx="4.1148252"
inkscape:cy="9.5177827"
inkscape:current-layer="layer1"
showgrid="true"
inkscape:grid-bbox="true"
inkscape:document-units="px"
inkscape:window-width="1615"
inkscape:window-height="1026"
inkscape:window-x="65"
inkscape:window-y="24"
inkscape:window-maximized="1"
showguides="true"
inkscape:guide-bbox="true" />
<metadata
id="metadata2990">
<rdf:RDF>
<cc:Work
rdf:about="">
<dc:format>image/svg+xml</dc:format>
<dc:type
rdf:resource="http://purl.org/dc/dcmitype/StillImage" />
<dc:title></dc:title>
</cc:Work>
</rdf:RDF>
</metadata>
<g
id="layer1"
inkscape:label="Layer 1"
inkscape:groupmode="layer">
<path
style="font-size:22.21102905px;font-style:normal;font-weight:normal;line-height:125%;letter-spacing:0px;word-spacing:0px;fill:#2c6fad;fill-opacity:1;stroke:none;font-family:Sans;-inkscape-font-specification:Sans"
d="M 7,1 7,5 3,5 3,7 7,7 7,11 9,11 9,7 13,7 13,5 9,5 9,1 z"
id="path3776"
inkscape:connector-curvature="0"
sodipodi:nodetypes="ccccccccccccc" />
<path
inkscape:connector-curvature="0"
id="path3776-2"
style="font-size:22.21102905px;font-style:normal;font-weight:normal;line-height:125%;letter-spacing:0px;word-spacing:0px;fill:#2c6fad;fill-opacity:1;stroke:none;font-family:Sans;-inkscape-font-specification:Sans"
d="M 4.0000001,13 12,13 l 0,2 -8,0 0,-2"
sodipodi:nodetypes="ccccc" />
</g>
</svg>

After

Width:  |  Height:  |  Size: 2.5 KiB

View file

@ -414,11 +414,36 @@ for (var i = 0, n = nodes.length; i < n; i++) {
}
function updateIssue(e) {
// Update GitHub issue link with pre-filled with current page location.
// Update GitHub issue link pre-filled with current page location.
var t = getEventTarget(e);
t.href = 'https://github.com/bitcoin/bitcoin.org/issues/new?body=' + encodeURIComponent('Location: ' + window.location.href.toString() + "\n\n");
}
function updateSource(e){
// Update GitHub source file link pre-filled with current page location.
if (!document.getElementsByClassName) return;
var t = getEventTarget(e),
nodes = document.getElementsByClassName('sourcefile'),
pageoffset = getPageYOffset(),
windowy = getWindowY(),
fallback = nodes[0],
first = [fallback, getTop(fallback)],
last = [fallback, getTop(fallback)],
closer = [fallback, getTop(fallback)];
// Find first, last and closer node.
for (var i = 0, n = nodes.length; i < n; i++) {
var top = getTop(nodes[i]);
if (top < first[1]) first = [nodes[i], top];
if (top > last[1]) last = [nodes[i], top];
if (top < pageoffset + 10 && top > closer[1]) closer = [nodes[i], top];
}
// Set closer title to first or last title if at the top or bottom of the page.
if (pageoffset < first[1]) closer = [first[0], first[1]];
if (windowy + pageoffset >= getHeight(document.body)) closer = [last[0], last[1]];
// Set updated url to source file.
t.href = 'https://github.com/bitcoin/bitcoin.org/edit/master/_includes/' + closer[0].getAttribute('data-sourcefile');
}
function disclaimerClose(e) {
// Auto close temporary disclaimer in devel-docs.
if (e) cancelEvent(e);