diff --git a/web/config.py b/web/config.py
index a72833488..d4ddd9db1 100644
--- a/web/config.py
+++ b/web/config.py
@@ -356,6 +356,11 @@ SQLALCHEMY_TRACK_MODIFICATIONS = False
##########################################################################
ON_DEMAND_RECORD_COUNT = 1000
+##########################################################################
+# Allow users to display Gravatar image for their username in Server mode
+##########################################################################
+SHOW_GRAVATAR_IMAGE = True
+
##########################################################################
# Local config settings
##########################################################################
diff --git a/web/pgadmin/browser/__init__.py b/web/pgadmin/browser/__init__.py
index 158967742..dd2542fbd 100644
--- a/web/pgadmin/browser/__init__.py
+++ b/web/pgadmin/browser/__init__.py
@@ -730,18 +730,18 @@ class BrowserPluginModule(PgAdminModule):
@login_required
def index():
"""Render and process the main browser window."""
- # Get the Gravatar
- Gravatar(
- current_app,
- size=100,
- rating='g',
- default='retro',
- force_default=False,
- use_ssl=True,
- base_url=None
- )
+ # Register Gravatar module with the app only if required
+ if config.SHOW_GRAVATAR_IMAGE:
+ Gravatar(
+ current_app,
+ size=100,
+ rating='g',
+ default='retro',
+ force_default=False,
+ use_ssl=True,
+ base_url=None
+ )
- msg = None
# Get the current version info from the website, and flash a message if
# the user is out of date, and the check is enabled.
if config.UPGRADE_CHECK_ENABLED:
@@ -761,7 +761,7 @@ def index():
if response.getcode() == 200:
data = json.loads(response.read().decode('utf-8'))
current_app.logger.debug('Response data: %s' % data)
- except Exception as e:
+ except Exception:
current_app.logger.exception('Exception when checking for update')
if data is not None:
diff --git a/web/pgadmin/browser/static/css/browser.css b/web/pgadmin/browser/static/css/browser.css
index 2fffd6497..3ba330d30 100644
--- a/web/pgadmin/browser/static/css/browser.css
+++ b/web/pgadmin/browser/static/css/browser.css
@@ -62,3 +62,7 @@ samp,
.sql-editor-grid-container {
font-family: 'Open Sans' !important;
}
+
+.pg-login-icon {
+ font-size: 16px;
+}
diff --git a/web/pgadmin/browser/templates/browser/index.html b/web/pgadmin/browser/templates/browser/index.html
index 58ff43f8d..76c3e4c7c 100644
--- a/web/pgadmin/browser/templates/browser/index.html
+++ b/web/pgadmin/browser/templates/browser/index.html
@@ -1,5 +1,13 @@
{% extends "base.html" %}
+
+{% if config.SERVER_MODE and config.SHOW_GRAVATAR_IMAGE -%}
+{% import 'browser/macros/gravatar_icon.macro' as IMG with context %}
+{% elif config.SERVER_MODE %}
+{% import 'browser/macros/static_user_icon.macro' as IMG with context %}
+{% endif %}
+
{% block title %}{{ config.APP_NAME }}{% endblock %}
+
{% block init_script %}
try {
require(
@@ -66,9 +74,11 @@ require.onResourceLoad = function (context, map, depMaps) {
}, 400)
}
};
+
+{% if config.SERVER_MODE %}
window.onload = function(e){
setTimeout(function() {
- var gravatarImg = '
{{ username }} ';
+ var gravatarImg = {{ IMG.PREPARE_HTML()|safe }}
//$('#navbar-menu .navbar-right > li > a').html(gravatarImg);
var navbarRight = document.getElementById("navbar-menu").getElementsByClassName("navbar-right")[0];
if (navbarRight) {
@@ -77,8 +87,9 @@ window.onload = function(e){
}
}, 1000);
};
-
+{% endif %}
{% endblock %}
+
{% block body %}