Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.89) (envelope-from ) id 1et6ZM-00022G-2d for pgadmin-hackers@arkaria.postgresql.org; Tue, 06 Mar 2018 06:59:28 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1et6ZK-0001vK-13 for pgadmin-hackers@arkaria.postgresql.org; Tue, 06 Mar 2018 06:59:26 +0000 Received: from makus.postgresql.org ([2001:4800:1501:1::229]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.89) (envelope-from ) id 1et6ZJ-0001vA-Gw for pgadmin-hackers@lists.postgresql.org; Tue, 06 Mar 2018 06:59:25 +0000 Received: from mail-ot0-x22a.google.com ([2607:f8b0:4003:c0f::22a]) by makus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1et6ZF-0007Ka-UZ for pgadmin-hackers@postgresql.org; Tue, 06 Mar 2018 06:59:23 +0000 Received: by mail-ot0-x22a.google.com with SMTP id y11so17444806otg.0 for ; Mon, 05 Mar 2018 22:59:21 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=enterprisedb-com.20150623.gappssmtp.com; s=20150623; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :cc; bh=m+Qb+mvuVnY1jc16WLc5UAME0WNuIr6qYUklWUZF1gI=; b=a2bkmRm9uJHcuUa6uuYg81tIp5TFTLM6K8a2VnI6DtCDZfDbx4FtfQEBOxlPXaw8g1 BYywEBdG1eqAT5U6cSPRSgys+1qhXTSAyHvGHR/K6F/nPmjCIUUkKu14awDtAF+c9DcA fH/0WWQ4dp1DZ6mTeaOU2BF9F9Hl9SxCAsxdnjH+TJ/sUsMPCeMs5ttpGl4/ImuX/QNG 0EX6s0jUq6+AbIqgSQE6/WXNY4wVbZ+Btg3dgvGD+FZgHACOpZScm4aQ62HxlRMZEWYg aQiYNpUEGf2z0CYafiWU4bzT1cenn5YQJA2DXcmnEsPkfBnaF3fxGE79W3iM9MYEixLE c77A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:in-reply-to:references:from:date :message-id:subject:to:cc; bh=m+Qb+mvuVnY1jc16WLc5UAME0WNuIr6qYUklWUZF1gI=; b=agd7Wm77kI7tate75ZK2k8AYAdvXXg+fjD3EBdD4S9YGTVqvu++VuZ4JlS6TCw/oMO r3SUgWMleyMLusFki2k7l+01D1pmjurk0rjv7SVlKZVeK+7S2/Tq3pkEUE/sf08G8jfP Kieakf29tmc5sWThRNFhFNOQTZsr/WaUPZffKTB2UMufNQ/wqDZkvOb6T3E+Yhla/7Rx z7noCHGKtKzaHUr6FWKmwHcTRNGouIxMvoLJ199fYyUjOUxbr61EuQ4P/PXGLM8qceDp UIjw/ey6juUOrYGkbkPoJjLJJ6S20RZSGvArfg7bNUfQBL3lMAVxTYAar8myFHqEy4hJ 49FA== X-Gm-Message-State: AElRT7G0LTBoXllohgJzd1lWKDganfa8+IXrq7sJVO7OYjOZ6RqHusgc ROwu4VJI9FWA/+AOqSwh9o0psFAq5m/CYQ4eMyi0zQ== X-Google-Smtp-Source: AG47ELuxSyDp4WiyVCMpuJ1a6NxzyFjbxPn/rKostiL+nGLi7q4MMV5ZLwaU6tp92KghFypH95SrdjS+FwqSIqofLGw= X-Received: by 10.157.58.53 with SMTP id j50mr11807966otc.157.1520319560440; Mon, 05 Mar 2018 22:59:20 -0800 (PST) MIME-Version: 1.0 Received: by 10.74.8.150 with HTTP; Mon, 5 Mar 2018 22:59:00 -0800 (PST) In-Reply-To: References: From: Murtuza Zabuawala Date: Tue, 6 Mar 2018 12:29:00 +0530 Message-ID: Subject: Re: [pgAdmin4][RM#3037] Allow user to disable Gravatar image To: Joao De Almeida Pereira Cc: pgadmin-hackers Content-Type: multipart/alternative; boundary="001a114719105875200566b8fb4d" List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk --001a114719105875200566b8fb4d Content-Type: text/plain; charset="UTF-8" Hi Joao, Your suggestion is good but in my own opinion it is overkill just to replace code {{ username| gravatar }} as rest of the syntax is pure HTML, This makes code much simpler and easy to understand. Apart from that we will be rendering 'index.html' template anyways and I don't see any extra overhead. I may be wrong, Let's wait for the input from other community members. Regards, Murtuza On Tue, Mar 6, 2018 at 1:17 AM, Joao De Almeida Pereira < jdealmeidapereira@pivotal.io> wrote: > Hello, > I understand that, but what do we win by using it? As you have noticed by > now I am not very fond of using templates for everything, and I believe > this is one of the things that we can skip templates. > We might even shift this to a frontend concern and if we want there are > node libraries to get gravatars. > > I was able to create a PoC as a sample of what I was talking about: > - Add gravatar library to package.json > - Created a Preferences cache. (js/preferences.js) > - So this was the concept I was talking about in a previous email we > talked about caching. > the getConfiguration and the getAllConfiguration are not great > names, but they return a Promise that is consumed in the load_gravatar. The > idea here is that we are caching the pgAdmin settings and when need need to > consume them, we wait for it to be available. > - load_gravatar is using the pattern to retrieve the configuration from a > possible cache and then apply the gravatar > > > Things that need to be revisited in the PoC: > - No tests, just some spiked code > - Did not retrieve the username from the backend, we need to create an > endpoint that give us this > - The url is hardcoded to get the configuration > - Maybe the Preferences is not the correct place to get server_mode > configuration not sure, what do you think? > > > Thanks > Joao > > On Mon, Mar 5, 2018 at 11:21 AM Murtuza Zabuawala < > murtuza.zabuawala@enterprisedb.com> wrote: > >> Hi Joao, >> >> We are using Flask-Gravatar >> module for this and it is designed to work with template only. >> >> -- >> Regards, >> Murtuza Zabuawala >> EnterpriseDB: http://www.enterprisedb.com >> The Enterprise PostgreSQL Company >> >> >> On Mon, Mar 5, 2018 at 8:57 PM, Joao De Almeida Pereira < >> jdealmeidapereira@pivotal.io> wrote: >> >>> Hi Murtuza, >>> >>> Why are we doing this using templates? Can this be done with a request >>> to the backend to get the image and then retrieve the Gravatar if it is >>> defined or return a static image if not? >>> >>> + >>> +{% if config.SERVER_MODE %} >>> window.onload = function(e){ >>> setTimeout(function() { >>> - var gravatarImg = '>> height="18" alt="Gravatar image for {{ username }}"> {{ username }} >> class="caret">'; >>> + var gravatarImg = {{ IMG.PREPARE_HTML()|safe }} >>> //$('#navbar-menu .navbar-right > li > a').html(gravatarImg); >>> var navbarRight = document.getElementById("navba >>> r-menu").getElementsByClassName("navbar-right")[0]; >>> if (navbarRight) { >>> >>> what if we have >>> >>> var gravatarImg = '>> height="18" alt="Gravatar image for {{ username }}"> {{ username }} >> class="caret">'; >>> >>> And then the endpoint >>> /user/{{username}}/gravatar >>> would be responsible for returning a Gravatar or not depending on the >>> configuration? >>> >>> >>> Thanks >>> Joao >>> >>> On Mon, Mar 5, 2018 at 3:13 AM Murtuza Zabuawala < >>> murtuza.zabuawala@enterprisedb.com> wrote: >>> >>>> Hi, >>>> >>>> PFA patch to disable Gravatar image in Server mode. >>>> >>>> Requirments & Issues: >>>> - For security reasons. >>>> - For systems which do not have internet access. >>>> - Hangs pgAdmin4 while loading the page if connection has no internet >>>> access (as described in the ticket) >>>> >>>> -- >>>> Regards, >>>> Murtuza Zabuawala >>>> EnterpriseDB: http://www.enterprisedb.com >>>> The Enterprise PostgreSQL Company >>>> >>>> >> --001a114719105875200566b8fb4d Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable
Hi Joao,

Your suggestion is good but in my own opinion it is overkill just to rep= lace code=C2=A0{{ username| gravatar }}=C2=A0as rest of the syntax=C2=A0is pure HT= ML, This makes code much simpler and easy to understand.
=
Apart from that we will be rendering 'index.html' te= mplate anyways and I don't see any extra overhead.
=
I may be wrong, Let's wait for the input from = other community members.

Regar= ds,=C2=A0
Murtuza

On Tue, Mar 6, 2018 at 1:17 AM, Joao De Alme= ida Pereira <jdealmeidapereira@pivotal.io> wrote:=
Hello,
I understand that, but what do we win by using it? As you have= noticed by now I am not very fond of using templates for everything, and I= believe this is one of the things that we can skip templates.=C2=A0
We= might even shift this to a frontend concern and if we want there are node = libraries to get gravatars.

I was able to create a= PoC as a sample of what I was talking about:
=C2=A0- Add gravata= r library to package.json
=C2=A0- Created a Preferences cache. (j= s/preferences.js)
=C2=A0 =C2=A0- So this was the concept I was ta= lking about in a previous email we talked about caching.
=C2=A0 = =C2=A0 =C2=A0 the getConfiguration and the getAllConfiguration are not grea= t names, but they return a Promise that is consumed in the load_gravatar. T= he idea here is that we are caching the pgAdmin settings and when need need= to consume them, we wait for it to be available.
=C2=A0- load_gr= avatar is using the pattern to retrieve the configuration from a possible c= ache and then apply the gravatar


Th= ings that need to be revisited in the PoC:
- No tests, just some = spiked code
- Did not retrieve the username from the backend, we = need to create an endpoint that give us this
- The url is hardcod= ed to get the configuration
- Maybe the Preferences is not the co= rrect place to get server_mode configuration not sure, what do you think?


Thanks
Joao

On Mon, Mar 5, 2018 at 11= :21 AM Murtuza Zabuawala <murtuza.zabuawala@enterprisedb.com> w= rote:
= Hi Joao,

We are using Flask-Gravatar module for this and it is designed to wor= k with template only.

--
Regards,
Murtuza Zabuawala
EnterpriseDB:=C2=A0http://= www.enterprisedb.com
The Enterprise PostgreSQL Company


On Mon, Mar= 5, 2018 at 8:57 PM, Joao De Almeida Pereira <jdealmeidapereir= a@pivotal.io> wrote:
Hi Murtuza,

Why are we doi= ng this using templates? Can this be done with a request to the backend to = get the image and then retrieve the Gravatar if it is defined or return a s= tatic image if not?

+
+{% if config= .SERVER_MODE %}
=C2=A0window.onload =3D function(e){
= =C2=A0 setTimeout(function() {
-=C2=A0 =C2=A0var gravatarImg =3D = '<img src=3D"{{ username | gravatar }}" width=3D"18&q= uot; height=3D"18" alt=3D"Gravatar image for {{ username }}&= quot;> {{ username }} <span class=3D"caret"></span>= ;';
+=C2=A0 =C2=A0var gravatarImg =3D {{ IMG.PREPARE_HTML()|s= afe }}
=C2=A0 =C2=A0 //$('#navbar-menu .navbar-right > li = > a').html(gravatarImg);
=C2=A0 =C2=A0 var navbarRight =3D= document.getElementById("navbar-menu").getElementsByClassNa= me("navbar-right")[0];
=C2=A0 =C2=A0 if (navbarRig= ht) {

what if we have=C2=A0

var gravatarImg =3D '<img src=3D"/user/{{username}}/gr= avatar" width=3D"18" height=3D"18" alt=3D&quo= t;Gravatar image for {{ username }}"> {{ username }} <span class= =3D"caret"></span>';

An= d then the endpoint
/user/{{username}}/gravatar=C2=A0
w= ould be responsible for returning a Gravatar or not depending on the config= uration?


Thanks
Joao

On Mon, Mar 5, 2018 = at 3:13 AM Murtuza Zabuawala <murtuza.zabuawala@enterprisedb.com&g= t; wrote:
Hi,

PFA patch to disable Gravatar image in Server mode.

Requirments & Issue= s:
-= For security reasons.
- For syst= ems which do not have internet access.
- Hangs pgAdmin4 while loading = the page if connection has no internet access (as described in the ticket)<= /div>

=
--
Regards,
Murtuza Zabuawala
EnterpriseDB:=C2=A0h= ttp://www.enterprisedb.com
The Enterprise PostgreSQL Company



--001a114719105875200566b8fb4d--