Created
October 16, 2011 18:14
-
-
Save ryanmcgrath/1291221 to your computer and use it in GitHub Desktop.
An example of how to use githubcommitembed.js to fetch data for a given commit from GitHub.
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
<!-- May want a pre/code tag combo here --> | |
<div id="code_block"></div> | |
<script type="text/javascript" src="path/to/githubcommitembed.min.js"></script> | |
<script type="text/javascript"> | |
// Create a new commit to fetch; .fetch() actually fires calls (below). | |
var commit = new GitHubCommit({ | |
username: 'mygengo', | |
reponame: 'mygengo-python', | |
fileSHA: 'cbb0816e1fb873019d8617500e4562299663bf4f', | |
node: 'code_block' | |
}); | |
// Once we're safe and jazz, pull it down. | |
$(document).ready(function() { | |
// Fetch the data and handle it 100% yourself after callback | |
commit.fetch(function(content) { | |
// Inject/highlight/etc with content (also as this.content) | |
}); | |
}); | |
</script> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment