Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save heipei/86036 to your computer and use it in GitHub Desktop.
Save heipei/86036 to your computer and use it in GitHub Desktop.
From 1e55f3c8b91450a04b4c7bc68e76842f4e4a8d51 Mon Sep 17 00:00:00 2001
From: Johannes Gilger <heipei@hackvalue.de>
Date: Thu, 26 Mar 2009 12:42:56 +0100
Subject: [PATCH] HistoryView: Confirm paste to Gist if github.user is unset
This patch relates to ticket #58. It adds a method which will ask for
confirmation when pasting to Gist as an anonymous user. Since users
which have github.user and github.token set can easily delete pasted
snippets no confirmation is needed for them.
Signed-off-by: Johannes Gilger <heipei@hackvalue.de>
---
html/views/history/history.js | 27 +++++++++++++++++++++++++++
html/views/history/index.html | 2 +-
2 files changed, 28 insertions(+), 1 deletions(-)
diff --git a/html/views/history/history.js b/html/views/history/history.js
index 57cee0d..e8136a6 100644
--- a/html/views/history/history.js
+++ b/html/views/history/history.js
@@ -45,6 +45,33 @@ var Commit = function(obj) {
};
+
+var confirm_gist = function(confirmation_message) {
+
+ // Check whether github user/token are set in .gitconfig
+ // If yes, we can paste without waiting for confirmation
+ token = Controller.getConfig_("github.token");
+ login = Controller.getConfig_("github.user");
+ if (token && login) {
+ gistie();
+ return;
+ }
+
+ // Set optional confirmation_message
+ confirmation_message = confirmation_message || "Yes. Paste this commit.";
+ // Show div#notification, since it?s set to display:none; by default
+ $("notification").style.display = "";
+ // Reset the class (and therefore the color)
+ $("notification").setAttribute("class", "");
+ // Hide img#spinner, since it?s visible by default
+ $("spinner").style.display = "none";
+ // Insert the verification links into div#notification_message
+ $("notification_message").innerHTML = 'This will upload your commit to <a href="http://gist.github.com/">http://gist.github.com/</a>' +
+ '<br/>Are you sure you want to continue?<br/><br/>' +
+ '<a href="#" onClick="hideNotification();return false;" style="color: red;">No. Cancel.</a> | ' +
+ '<a href="#" onClick="gistie();return false;" style="color: green;">' + confirmation_message + '</a>';
+}
+
var gistie = function() {
notify("Uploading code to Gistie..", 0);
diff --git a/html/views/history/index.html b/html/views/history/index.html
index 29c9122..65117c3 100644
--- a/html/views/history/index.html
+++ b/html/views/history/index.html
@@ -14,7 +14,7 @@
<body style="padding: 0px; border: 0px">
<div id="rightcontent">
<div id="buttons">
- <a class="servicebutton" id="gist" onClick="gistie();return false" href='#'>
+ <a class="servicebutton" id="gist" onClick="confirm_gist();return false" href='#'>
Gist&nbsp;it
</a>
</div>
--
1.6.1.1.g764e+GitX
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment