Instantly share code, notes, and snippets.
Created
June 22, 2015 01:55
-
Save PhrozenByte/e2b8add3128829927767 to your computer and use it in GitHub Desktop.
Gitweb site footer (adds support for jQuery-Prettify)
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
<style type="text/css"> | |
.patchset .patch .diff { | |
margin-left: 1em; | |
text-indent: -1em; | |
} | |
.patchset .patch .diff:not(.header):not(.extended_header) { | |
white-space: pre-wrap; | |
word-break: break-all; | |
word-wrap: break-word; | |
} | |
</style> | |
<!-- | |
START jQuery-Prettify for blob view | |
--> | |
<script type="text/javascript" src="https://code.jquery.com/jquery-2.1.0.js"></script> | |
<script type="text/javascript" src="https://google-code-prettify.googlecode.com/svn/trunk/src/prettify.js"></script> | |
<script type="text/javascript" src="https://raw.githubusercontent.com/PhrozenByte/jQuery-XPath/master/jquery.xpath.js"></script> | |
<script type="text/javascript" src="https://raw.githubusercontent.com/PhrozenByte/jQuery-Prettify/master/jquery.prettify.js"></script> | |
<style type="text/css"> | |
.prettify .ready .com { color: #93a1a1; } | |
.prettify .ready .lit { color: #195f91; } | |
.prettify .ready .pun, | |
.prettify .ready .opn, | |
.prettify .ready .clo { color: #93a1a1; } | |
.prettify .ready .fun { color: #dc322f; } | |
.prettify .ready .str, | |
.prettify .ready .atv { color: #D14; } | |
.prettify .ready .kwd, | |
.prettify .ready .tag { color: #1e347b; } | |
.prettify .ready .typ, | |
.prettify .ready .atn, | |
.prettify .ready .dec, | |
.prettify .ready .var { color: teal; } | |
.prettify .ready .pln { color: #48484c; } | |
.prettify.linenums .ready { | |
-webkit-box-shadow: inset 3em 0 0 #fbfbfc, inset 3.1em 0 0 #ececf0; | |
-moz-box-shadow: inset 3em 0 0 #fbfbfc, inset 3.1em 0 0 #ececf0; | |
box-shadow: inset 3em 0 0 #fbfbfc, inset 3.1em 0 0 #ececf0; | |
} | |
.prettify.linenums .ready.linenums-3 { | |
-webkit-box-shadow: inset 4em 0 0 #fbfbfc, inset 4.1em 0 0 #ececf0; | |
-moz-box-shadow: inset 4em 0 0 #fbfbfc, inset 4.1em 0 0 #ececf0; | |
box-shadow: inset 4em 0 0 #fbfbfc, inset 4.1em 0 0 #ececf0; | |
} | |
.prettify.linenums .ready.linenums-4 { | |
-webkit-box-shadow: inset 5em 0 0 #fbfbfc, inset 5.1em 0 0 #ececf0; | |
-moz-box-shadow: inset 5em 0 0 #fbfbfc, inset 5.1em 0 0 #ececf0; | |
box-shadow: inset 5em 0 0 #fbfbfc, inset 5.1em 0 0 #ececf0; | |
} | |
.prettify.linenums .ready.linenums-5 { | |
-webkit-box-shadow: inset 6em 0 0 #fbfbfc, inset 6.1em 0 0 #ececf0; | |
-moz-box-shadow: inset 6em 0 0 #fbfbfc, inset 6.1em 0 0 #ececf0; | |
box-shadow: inset 6em 0 0 #fbfbfc, inset 6.1em 0 0 #ececf0; | |
} | |
.prettify.linenums .ready ol { | |
margin: 0 0 0 2.6em; | |
} | |
.prettify.linenums .ready.linenums-3 ol { | |
margin: 0 0 0 3.6em; | |
} | |
.prettify.linenums .ready.linenums-4 ol { | |
margin: 0 0 0 4.6em; | |
} | |
.prettify.linenums .ready.linenums-5 ol { | |
margin: 0 0 0 5.6em; | |
} | |
.prettify.linenums .ready ol li { | |
padding-left: 12px; | |
color: #bebec5; | |
line-height: 1.5em; | |
text-shadow: 0 1px 0 #fff; | |
} | |
</style> | |
<style type="text/css"> | |
.prettify-wrapper { | |
margin: -20px -8px; | |
} | |
.prettify code, | |
.prettify pre, | |
.prettify xmp { | |
white-space: pre-wrap; | |
word-break: break-all; | |
word-wrap: break-word; | |
} | |
.prettify.prettify-viewWindowWidth code, | |
.prettify.prettify-viewNoLineBreak code, | |
.prettify.prettify-viewWindowWidth pre, | |
.prettify.prettify-viewNoLineBreak pre, | |
.prettify.prettify-viewWindowWidth xmp, | |
.prettify.prettify-viewNoLineBreak xmp { | |
margin-top: 11px; | |
border: 1px solid #D9D8D1; | |
background-color: #FFFFFF; | |
} | |
.prettify ol { | |
padding: 0; | |
} | |
.prettify-buttons { | |
float: right; | |
margin: 0 0 0 1em; | |
padding: 0; | |
list-style-type: none; | |
list-style-position: inline; | |
} | |
.prettify-buttons li { | |
display: inline; | |
} | |
.prettify-buttons li + li:before { | |
content: ' | '; | |
} | |
</style> | |
<script type="text/javascript"> | |
//<![CDATA[ | |
jQuery(document).ready(function($) { | |
console.log('jQuery ready'); | |
var currentPageTree = $('.page_header').text().split('/'); | |
var currentPage = currentPageTree[currentPageTree.length - 1].trim(); | |
var pageBody = $('.page_body'); | |
var pagePath = $('.page_path'); | |
if (currentPage == 'blob') { | |
var buttonGroup = $('<ul class="prettify-buttons" />') | |
.prependTo(pagePath) | |
.hide(); | |
$('<li><a href="#">Normal</a></li>') | |
.appendTo(buttonGroup) | |
.children().on('click.prettify', function() { $(this).prettify('viewNormal'); }); | |
$('<li><a href="#">No line break</a></li>') | |
.appendTo(buttonGroup) | |
.children().on('click.prettify', function() { $(this).prettify('viewNoLineBreak'); }); | |
pageBody.slideUp({ complete: function() { | |
var codeLines = pageBody.find('.pre') | |
.contents() | |
.filter(function() { | |
return this.nodeType == Node.TEXT_NODE; | |
}).each(function() { | |
this.textContent = this.textContent + "\n"; | |
}); | |
pageBody.find('.pre').remove(); | |
var prettifyElement = $('<div class="prettify linenums" data-progress=".prettify-progress" />') | |
.appendTo(pageBody) | |
.hide(); | |
$('<pre />') | |
.appendTo(prettifyElement) | |
.append(codeLines); | |
$('<div class="prettify-progress" style="text-align: center;">Loading...</div>') | |
.appendTo(pageBody); | |
buttonGroup.find('a').data('prettify', prettifyElement); | |
pageBody.slideDown({ complete: function() { | |
pageBody.find('.prettify').prettify(function() { | |
buttonGroup.fadeIn(); | |
}); | |
} }); | |
} }); | |
} | |
}); | |
//]]> | |
</script> | |
<!-- | |
END jQuery-prettify for blob view | |
--> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment