-
-
Save kohsuke/60123 to your computer and use it in GitHub Desktop.
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
CmdUtils.CreateCommand({ | |
name: "javanet", | |
icon: "http://example.com/example.png", | |
homepage: "http://ubiquity.dev.java.net/", | |
author: { name: "Kohsuke Kawaguchi", email: "[email protected]"}, | |
license: "MIT license", | |
description: "java.net scripts", | |
help: "how to use your command", | |
takes: {"input": noun_arb_text}, | |
modifiers: {"in": noun_arb_text}, | |
parse: function( input, mods ) { | |
var re = new RegExp("([A-Z][A-Z0-9_-]+)-([0-9]+)"); | |
var r = re.exec(input.text); | |
if(r!=null) return [r[1].toLowerCase(),r[2]]; | |
var i = mods['in'].text; | |
if(i!=null) | |
return [i,input.text]; | |
// huh? | |
return null; | |
}, | |
preview: function( pblock, input, mods ) { | |
var r = this.parse(input,mods); | |
if(r==null) | |
pblock.innerHTML = CmdUtils.renderTemplate("???"); | |
else { | |
pblock.innerHTML = CmdUtils.renderTemplate( | |
"Open issue #${id} in the ${project} project", | |
{"project":r[0], "id":r[1]}); | |
} | |
}, | |
execute: function(input,mods) { | |
var r = this.parse(input,mods); | |
if(r!=null) { | |
var doc = Application.activeWindow.activeTab.document; | |
doc.location.href = "http://"+r[0]+".dev.java.net/issues/show_bug.cgi?id="+r[1]; | |
} | |
} | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment