Skip to content

Instantly share code, notes, and snippets.

@ryanmcgrath
Created October 16, 2011 18:14
Show Gist options
  • Save ryanmcgrath/1291221 to your computer and use it in GitHub Desktop.
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.
<!-- 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