Skip to content

Commit

Permalink
Add godoc, sourcegraph and goreportcard support
Browse files Browse the repository at this point in the history
  • Loading branch information
dlsniper committed Jun 7, 2016
1 parent f3cdab9 commit a965988
Show file tree
Hide file tree
Showing 6 changed files with 50 additions and 5 deletions.
10 changes: 10 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,16 @@ The button will copy to clipboard the following command:

To install this, visit the [Chrome Store](https://chrome.google.com/webstore/detail/go-get-for-github/ahkfiobnoafagbaaghmbbopfdpdbaidi)

## Usage

See options to get the options for this extension.

Usage:
- left click copies the `go get` command to clipboard
- CTRL + left click opens godoc.org for the current repository
- ALT + left click opens goreportcard.com for the current repository
- SHIFT + left click opens Sourcegraph for the current repository

## License

Copyright 2016 Florin Pățan
Expand Down
2 changes: 1 addition & 1 deletion manifest.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "go get for Github",
"short_name": "go get",
"version": "1.0.2",
"version": "1.0.3",
"manifest_version": 2,
"description": "Add a \"go get\" button to GitHub.",
"homepage_url": "https://github.com/dlsniper/ggg",
Expand Down
1 change: 1 addition & 0 deletions src/css/ggg.css
Original file line number Diff line number Diff line change
Expand Up @@ -31,5 +31,6 @@ limitations under the License.*/
padding: 0;
width: 24px;
height: 24px;
target-new: tab;
background: url(/icons/icon20.png) no-repeat center;
}
31 changes: 28 additions & 3 deletions src/ggg/ggg.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,13 +36,37 @@ function ggg() {
$("div.select-menu-modal-holder.dropdown-menu-content.js-menu-content")
.after("<div class='btn btn-sm ggg-btn'><div class='ggg-gopher'></div></div>");

$("div.ggg-btn").click(function () {
$("div.ggg-btn").click(function (event) {
var pkg = "github.com" + window.location.pathname.replace(/\/$/, "");
var location = "";

if (event.ctrlKey) {
location = "https://godoc.org/" + pkg;
}


if (event.altKey) {
location = "https://goreportcard.com/report/" + pkg;
}

if (event.shiftKey) {
location = "https://sourcegraph.com/" + pkg;

}

if (location !== "") {
if (options.newWindow) {
window.open(location);
} else {
window.location = location;
}
}

var fetchOptions = "";
if (options.fetchUpdate) fetchOptions += "--u";
if (options.fetchVerbose) fetchOptions += "--v";
if (options.fetchTest) fetchOptions += "--t";

var pkg = "github.com" + window.location.pathname.replace(/\/$/, "");

if (options.fetchSubPackages) pkg += "/...";
copyToClipboard("go get" + fetchOptions.replace(/--/g, " -") + " " + pkg);
Expand All @@ -59,7 +83,8 @@ var init = function () {
fetchUpdate: true,
fetchVerbose: false,
fetchTest: false,
fetchSubPackages: false
fetchSubPackages: false,
newWindow: false
}, function (items) {
options = items;
});
Expand Down
7 changes: 7 additions & 0 deletions src/ggg/options.html
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,13 @@
</li>
</ul>

<label>
<input type="checkbox" id="newWindow">
Open links in new windows (or tabs?)
</label>
<br/>
<br/>

<div id="status"></div>
<button id="save">Save</button>

Expand Down
4 changes: 3 additions & 1 deletion src/ggg/options.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,8 @@ function save_options() {
fetchUpdate: document.getElementById('update').checked,
fetchVerbose: document.getElementById('verbose').checked,
fetchTest: document.getElementById('test').checked,
fetchSubPackages: document.getElementById('subpackages').checked
fetchSubPackages: document.getElementById('subpackages').checked,
newWindow: document.getElementById('newWindow').checked
}, function () {
var status = document.getElementById('status');
status.textContent = 'Options saved.';
Expand All @@ -39,6 +40,7 @@ function restore_options() {
document.getElementById('verbose').checked = items.fetchVerbose;
document.getElementById('test').checked = items.fetchTest;
document.getElementById('subpackages').checked = items.fetchSubPackages;
document.getElementById('newWindow').checked = items.newWindow;
});
}

Expand Down

0 comments on commit a965988

Please sign in to comment.