diff --git a/PBWebController.m b/PBWebController.m index d61d2fd..95319e7 100644 --- a/PBWebController.m +++ b/PBWebController.m @@ -9,6 +9,7 @@ #import "PBWebController.h" #import "PBGitRepository.h" #import "PBGitXProtocol.h" +#import "PBGitDefaults.h" #include @@ -110,6 +111,16 @@ return flags > 0; } +- (BOOL) isFeatureEnabled:(NSString *)feature +{ + if([feature isEqualToString:@"gravatar"]) + return [PBGitDefaults isGravatarEnabled]; + else if([feature isEqualToString:@"gist"]) + return [PBGitDefaults isGistEnabled]; + else + return YES; +} + #pragma mark Using async function from JS - (void) runCommand:(WebScriptObject *)arguments inRepository:(PBGitRepository *)repo callBack:(WebScriptObject *)callBack diff --git a/html/views/history/history.js b/html/views/history/history.js index d93cec9..d61a465 100644 --- a/html/views/history/history.js +++ b/html/views/history/history.js @@ -97,6 +97,11 @@ var setGravatar = function(email, image) { if (Controller && !Controller.isReachable_("www.gravatar.com")) return; + if(Controller && !Controller.isFeatureEnabled_("gravatar")) { + image.src = ""; + return; + } + if (!email) { image.src = "http://www.gravatar.com/avatar/?d=wavatar&s=60"; return; @@ -188,6 +193,23 @@ var showImage = function(element, filename) return false; } +var enableFeature = function(feature, element) +{ + if(!Controller || Controller.isFeatureEnabled_(feature)) { + element.style.display = ""; + } else { + element.style.display = "none"; + } +} + +var enableFeatures = function() +{ + enableFeature("gist", $("gist")) + if(commit) + setGravatar(commit.author_email, $("gravatar")); + enableFeature("gravatar", $("gravatar")) +} + var loadExtendedCommit = function(commit) { if (commit.author_email) @@ -202,5 +224,5 @@ var loadExtendedCommit = function(commit) $("diff").innerHTML = "This is a large commit. Click here or press 'v' to view."; hideNotification(); - setGravatar(commit.author_email, $("gravatar")); + enableFeatures(); } \ No newline at end of file