summaryrefslogtreecommitdiff
path: root/misc/chrome
diff options
context:
space:
mode:
authorBrad Fitzpatrick <bradfitz@golang.org>2011-05-23 14:05:18 -0700
committerBrad Fitzpatrick <bradfitz@golang.org>2011-05-23 14:05:18 -0700
commit9fb5ef37141eba8d6ab86e8056dd98eef6c2f5f2 (patch)
treed50548fa79a5507233e8edf9f4266f7a936a4f0e /misc/chrome
parentf38a4301fb8d3f8f7e746d11a91c92822c6f9e5e (diff)
downloadgo-9fb5ef37141eba8d6ab86e8056dd98eef6c2f5f2.tar.gz
gophertool: Chrome extension to aid in Go development
Contains common links & a smart text box that recognizes various identifiers and jumps to one of: * issue URL, * codereview URL, * commit URL, * package docs R=golang-dev, rsc CC=golang-dev http://codereview.appspot.com/4553058
Diffstat (limited to 'misc/chrome')
-rw-r--r--misc/chrome/gophertool/gopher.pngbin0 -> 5588 bytes
-rw-r--r--misc/chrome/gophertool/manifest.json12
-rw-r--r--misc/chrome/gophertool/popup.html69
3 files changed, 81 insertions, 0 deletions
diff --git a/misc/chrome/gophertool/gopher.png b/misc/chrome/gophertool/gopher.png
new file mode 100644
index 000000000..0d1abb741
--- /dev/null
+++ b/misc/chrome/gophertool/gopher.png
Binary files differ
diff --git a/misc/chrome/gophertool/manifest.json b/misc/chrome/gophertool/manifest.json
new file mode 100644
index 000000000..a8de8dfd2
--- /dev/null
+++ b/misc/chrome/gophertool/manifest.json
@@ -0,0 +1,12 @@
+{
+ "name": "Hacking Gopher",
+ "version": "1.0",
+ "description": "Go Hacking utility",
+ "browser_action": {
+ "default_icon": "gopher.png",
+ "popup": "popup.html"
+ },
+ "permissions": [
+ "tabs"
+ ]
+}
diff --git a/misc/chrome/gophertool/popup.html b/misc/chrome/gophertool/popup.html
new file mode 100644
index 000000000..a953054c7
--- /dev/null
+++ b/misc/chrome/gophertool/popup.html
@@ -0,0 +1,69 @@
+<html>
+<!--
+ Copyright 2011 The Go Authors. All rights reserved.
+ Use of this source code is governed by a BSD-style
+ license that can be found in the LICENSE file.
+-->
+<head>
+ <script>
+
+function focusinput() {
+ box = document.getElementById("inputbox");
+ box.focus();
+}
+
+var numericRE = /^\d+$/;
+var commitRE = /^[0-9a-f]{6,20}$/;
+var pkgRE = /^[a-z0-9_\/]+$/;
+
+function navigate() {
+ box = document.getElementById("inputbox");
+ box.focus();
+ var t = box.value;
+ if (t == "") {
+ return false;
+ }
+
+ success = function(url) {
+ console.log("matched " + t + " to: " + url)
+ box.value = "";
+ openURL(url);
+ return false; // cancel form submission
+ };
+
+ if (numericRE.test(t)) {
+ if (t < 1000000) {
+ return success("http://code.google.com/p/go/issues/detail?id=" + t);
+ }
+ return success("http://codereview.appspot.com/" + t + "/");
+ }
+
+ if (commitRE.test(t)) {
+ return success("http://code.google.com/p/go/source/detail?r=" + t);
+ }
+
+ if (pkgRE.test(t)) {
+ // TODO: make this smarter, using a list of packages + substring matches.
+ // Get the list from godoc itself in JSON format?
+ // TODO: prefer localhost:6060 to golang.org if localhost:6060 is responding.
+ return success("http://golang.org/pkg/" + t);
+ }
+ console.log("no match for text: " + t)
+ return false;
+}
+
+function openURL(url) {
+ chrome.tabs.create({ "url": url })
+}
+
+</script>
+</head>
+<body onload="focusinput()" style='margin: 0.5em; font-family: sans;'>
+<small><a href="#" onclick="openURL('http://code.google.com/p/go/issues/list')">issue</a>,
+<a href="#" onclick="openURL('http://codereview.appspot.com/')">codereview</a>,
+<a href="#" onclick="openURL('http://code.google.com/p/go/source/list')">commit</a>, or
+<a href="#" onclick="openURL('http://golang.org/pkg/')">pkg</a> id/name:</small>
+<form style='margin: 0' onsubmit="return navigate();"><nobr><input id="inputbox" size=10 /><input type="submit" value="go" /></nobr></form>
+<small>Also: <a href="#" onclick="openURL('http://godashboard.appspot.com/')">buildbots</small>
+</body>
+</html>