Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Make confirmation of Gists optional

This makes use of the rules that are explicit in the
preferences. By default, Gists are always private and there
will always be a confirmation message.

Both options can be changed from the preferences menu.
  • Loading branch information...
commit 11c9f51302eab2b76106b117ed3080b532e54e2a 1 parent b1fccb8
Pieter de Bie authored
Showing with 16 additions and 16 deletions.
  1. +4 −0 PBWebController.m
  2. +12 −16 html/views/history/history.js
View
4 PBWebController.m
@@ -127,6 +127,10 @@ - (BOOL) isFeatureEnabled:(NSString *)feature
return [PBGitDefaults isGravatarEnabled];
else if([feature isEqualToString:@"gist"])
return [PBGitDefaults isGistEnabled];
+ else if([feature isEqualToString:@"confirmGist"])
+ return [PBGitDefaults confirmPublicGists];
+ else if([feature isEqualToString:@"publicGist"])
+ return [PBGitDefaults isGistPublic];
else
return YES;
}
View
28 html/views/history/history.js
@@ -47,29 +47,25 @@ 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) {
+ if (!Controller.isFeatureEnabled_("confirmGist")) {
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";
+ var deleteMessage = Controller.getConfig_("github.token") ? " " : "You might not be able to delete it after posting.<br>";
+ var publicMessage = Controller.isFeatureEnabled_("publicGist") ? "<b>public</b>" : "private";
// 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/>' +
+ var notification_text = 'This will create a ' + publicMessage + ' paste of your commit to <a href="http://gist.github.com/">http://gist.github.com/</a><br>' +
+ deleteMessage +
+ '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>';
+
+ notify(notification_text, 0);
+ // Hide img#spinner, since it?s visible by default
+ $("spinner").style.display = "none";
}
var gistie = function() {
@@ -87,9 +83,9 @@ var gistie = function() {
if (token && login) {
parameters.login = login;
parameters.token = token;
- } else {
- parameters.private = true;
}
+ if (!Controller.isFeatureEnabled_("publicGist"))
+ parameters.private = true;
var params = [];
for (var name in parameters)
Please sign in to comment.
Something went wrong with that request. Please try again.