Created
February 7, 2009 04:19
-
-
Save mikedamage/59759 to your computer and use it in GitHub Desktop.
Get a Gist by ID and copy to clipboard.
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
// Get & copy a Gist by ID | |
CmdUtils.CreateCommand({ | |
name: "gist-copy", | |
icon: "http://gist.github.com/favicon.ico", | |
author: {name: "Mike Green", email: "mike.is.green@gmail.com"}, | |
takes: {"gist": noun_arb_text}, | |
preview: function(pblock, theGist) { | |
var urlTemplate = "http://gist.github.com/${gist}.txt"; | |
var gistURL = CmdUtils.renderTemplate(urlTemplate, {gist: theGist.text}); | |
CmdUtils.previewGet(pblock, gistURL, {}, function(data) { | |
pblock.innerHTML = data; | |
}); | |
}, | |
execute: function(theGist) { | |
var urlTemplate = "http://gist.github.com/${gist}.txt"; | |
var gistURL = CmdUtils.renderTemplate(urlTemplate, {gist: theGist.text}); | |
jQuery.get(gistURL, {}, function(data) { | |
CmdUtils.copyToClipboard(data); | |
displayMessage("Gist " + theGist.text + " copied to clipboard."); | |
}); | |
} | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment