Skip to content

Commit

Permalink
Make confirmation of Gists optional
Browse files Browse the repository at this point in the history
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
Pieter de Bie committed Mar 26, 2009
1 parent b1fccb8 commit 11c9f51
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 16 deletions.
4 changes: 4 additions & 0 deletions PBWebController.m
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -127,6 +127,10 @@ - (BOOL) isFeatureEnabled:(NSString *)feature
return [PBGitDefaults isGravatarEnabled]; return [PBGitDefaults isGravatarEnabled];
else if([feature isEqualToString:@"gist"]) else if([feature isEqualToString:@"gist"])
return [PBGitDefaults isGistEnabled]; return [PBGitDefaults isGistEnabled];
else if([feature isEqualToString:@"confirmGist"])
return [PBGitDefaults confirmPublicGists];
else if([feature isEqualToString:@"publicGist"])
return [PBGitDefaults isGistPublic];
else else
return YES; return YES;
} }
Expand Down
28 changes: 12 additions & 16 deletions html/views/history/history.js
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -47,29 +47,25 @@ var Commit = function(obj) {




var confirm_gist = function(confirmation_message) { var confirm_gist = function(confirmation_message) {

if (!Controller.isFeatureEnabled_("confirmGist")) {
// 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(); gistie();
return; return;
} }


// Set optional confirmation_message // Set optional confirmation_message
confirmation_message = confirmation_message || "Yes. Paste this commit."; confirmation_message = confirmation_message || "Yes. Paste this commit.";
// Show div#notification, since it?s set to display:none; by default var deleteMessage = Controller.getConfig_("github.token") ? " " : "You might not be able to delete it after posting.<br>";
$("notification").style.display = ""; var publicMessage = Controller.isFeatureEnabled_("publicGist") ? "<b>public</b>" : "private";
// 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 // 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>' + 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>' +
'<br/>Are you sure you want to continue?<br/><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="hideNotification();return false;" style="color: red;">No. Cancel.</a> | ' +
'<a href="#" onClick="gistie();return false;" style="color: green;">' + confirmation_message + '</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() { var gistie = function() {
Expand All @@ -87,9 +83,9 @@ var gistie = function() {
if (token && login) { if (token && login) {
parameters.login = login; parameters.login = login;
parameters.token = token; parameters.token = token;
} else {
parameters.private = true;
} }
if (!Controller.isFeatureEnabled_("publicGist"))
parameters.private = true;


var params = []; var params = [];
for (var name in parameters) for (var name in parameters)
Expand Down

0 comments on commit 11c9f51

Please sign in to comment.