summaryrefslogtreecommitdiffstats
path: root/conkeror/.conkerorrc/site-js/quickdispatch.js
diff options
context:
space:
mode:
Diffstat (limited to 'conkeror/.conkerorrc/site-js/quickdispatch.js')
-rw-r--r--conkeror/.conkerorrc/site-js/quickdispatch.js33
1 files changed, 33 insertions, 0 deletions
diff --git a/conkeror/.conkerorrc/site-js/quickdispatch.js b/conkeror/.conkerorrc/site-js/quickdispatch.js
new file mode 100644
index 0000000..15fc63c
--- /dev/null
+++ b/conkeror/.conkerorrc/site-js/quickdispatch.js
@@ -0,0 +1,33 @@
+define_variable("quickdispatch_prefix", "#",
+ "Prefix which indicates a quickdispatch URL.");
+define_variable("quickdispatch_list", {},
+ "List of key-value pairs representing the RegExp and"
+ + " replacement values for dispatches.");
+
+quickdispatch_list =
+ {"lh (\\d{1,5})(?:\\s+([a-z0-9%_/-]+))?$": "http://localhost:$1/$2",
+ "r ([a-zA-Z0-9_-]+)$": "http://reddit.com/r/$1",
+ "gh \\+([a-zA-Z0-9_-]+)$": "http://github.com/users/follow?target=$1",
+ "gh -([a-zA-Z0-9_-]+)$": "http://github.com/users/follow?target=$1",
+ "gh @([a-zA-Z0-9_-]*)$": "http://github.com/$1",
+ "ghw @([a-zA-Z0-9_-]+)$": "http://$1.github.io",
+ "gh ([a-zA-Z0-9_-]+/[a-zA-Z0-9_-]+(?:/(pulls|wiki|graphs|network|admin))?)$": "http://github.com/$1",
+ "ghw ([a-zA-Z0-9_-]+)/([a-zA-z0-9_-]+)$": "http://$1.github.io/$2",
+ "gh my (dashboard|notifications|stars)$": "http://github.com/$1",
+ "gh my (issues|pulls)$": "http://github.com/dashboard/$1",
+ "gh my profile$": "http://github.com/settings/profile"};
+
+function read_url_qd_handler(input)
+{
+ var keys = Object.keys(quickdispatch_list);
+
+ for (var i = 0; i < keys.length; i++) {
+ var rx = new RegExp(quickdispatch_prefix + keys[i]);
+ if (rx.test(input))
+ return input.replace(rx, quickdispatch_list[keys[i]]);
+ }
+
+ return "http://example.com";
+}
+
+provide("quickdispatch");