.conkerorrc/init.js

This commit is contained in:
Tom Willemsen 2012-10-03 02:48:59 +02:00
parent b4e8c45e18
commit 59a8f44e4d

View file

@ -167,3 +167,91 @@ remove_hook("download_added_hook", open_download_buffer_automatically);
hints_minibuffer_annotation_mode(true); hints_minibuffer_annotation_mode(true);
theme_load("naquadah"); theme_load("naquadah");
var gh_url = "http://github.com/";
function read_url_github_ad_command_handler(input)
{
var m = /^gh\s+@(\S+)(?:\s+((?:un)?follow))?/.exec(input);
if (m) {
if (m[2])
return gh_url + "users/follow?target=";
return gh_url + m[1];
}
return null;
}
function read_url_github_my_command_handler(input)
{
var m = /^gh\s+my\s+(dashboard|issues|notifications|profile|pulls|stars)/.exec(input);
if (m) {
switch (m[1]) {
case "dashboard":
case "notifications":
case "stars":
return gh_url + m[1];
case "issues":
case "pulls":
return gh_url + "dashboard/" + m[1];
case "profile":
return gh_url + "settings/" + m[1];
}
}
return null;
}
function read_url_github_repo_command_handler(input)
{
var m = /^gh\s+(\S+\/\S+)(?:\s+(\#\d+|\@\S+|issues|pulls|wiki|graphs|network|admin)(?:\s+(\#\d+|new))?)?$/.exec(input);
if (m) {
repo_url = gh_url + m[1] + "/";
switch (m[2]) {
case "issues":
issues_url = repo_url + m[2] + "/";
if (m[3]) {
if (m[3][0] == '#')
return issues_url + m[3].substring(1);
else if (m[3] == "new")
return issues_url + m[3];
else
break;
}
return issues_url;
case "pulls":
case "wiki":
case "graphs":
case "network":
case "admin":
return repo_url + m[2];
default:
// Still need watch and unwatch
if (m[2]) {
if (m[2][0] == '#')
return repo_url + "issues/" + m[2].substring(1);
else if (m[2][0] == '@')
return repo_url + "tree/" + m[2].substring(1);
else
break;
}
return repo_url;
}
}
return null;
}
function read_url_github_command_handler(input)
{
return read_url_github_ad_command_handler(input)
|| read_url_github_my_command_handler(input)
|| read_url_github_repo_command_handler(input);
}
read_url_handler_list = [read_url_github_command_handler];