List for cgit developers and users
 help / color / mirror / Atom feed
From: list at eworm.de (Christian Hesse)
Subject: [PATCH 1/1] enable cgit to show gravatar for author, committer and tagger
Date: Wed, 27 Nov 2013 23:59:03 +0100	[thread overview]
Message-ID: <20131127235903.33d5b310@leda.localdomain> (raw)
In-Reply-To: <461884100.iMVHHtLi2p@al>

Peter Wu <lekensteyn at gmail.com> on Wed, 2013/11/27 23:11:
> On Wednesday 27 November 2013 22:14:22 Christian Hesse wrote:
> > +char * cgit_get_gravatar(const char *email) {
> > +       unsigned char digest[16];
> > +       char hex[33], *lower, *tmp;
> > +       char *gravatar;
> > +
> > +       gravatar = malloc(77);
> 
> I do not quite like this magic number, does anyone have problems with
> creating a GRAVATAR_URL macro? 77 seems also small enough to throw on the
> stack. (Btw, len("//www.gravatar.com/avatar/?s=16&amp;d=retro") + 32 + 1
> says that the length is 76 including nul byte).

Created a GRAVATAR_URL macro now. I do prefer this solution as well.

Got rid of some more magic numbers for MD5 hashing.

> > +       /* duplicate to lower and skip brackets! */
> > +       lower = strdup(email + 1);
> > +       lower[strlen(lower) - 1] = '\0';
> 
> Ahh, I though it was off by one, but apparently you remove the brackets. OK.
> 
> > +
> > +       /* make the chars lower case */
> > +       for (tmp = lower; *tmp; ++tmp)
> > +               *tmp = tolower(*tmp);
> > +
> > +       MD5((unsigned char *)lower, strlen(lower), digest);
> > +
> > +       str_to_hex(hex, digest, 16);
> > +
> > +       sprintf(gravatar,
> > "//www.gravatar.com/avatar/%s?s=16&amp;d=retro", hex);
> 
> It seems ugly to me to store the HTML-escaped URL here. What do you think of
> using just "&" here and html_txt() when outputting the URL? Processing these
> few chars and performing an extra write() should not hurt performance.

Agreed.

> Regarding the GRAVATAR_URL macro mentioned earlier, if used that could
> also be inserted here. A comment could then describe why this URL is used
> (16x16 image using "awesome generated, 8-bit arcade-style pixelated faces"
> as default, https://en.gravatar.com/site/implement/images/)

Done.

> > +       free(lower);
> > +
> > +       return gravatar;
> > +}

I will replay with my updated patch.

-- 
main(a){char*c=/*    Schoene Gruesse                         */"B?IJj;MEH"
"CX:;",b;for(a/*    Chris           get my mail address:    */=0;b=c[a++];)
putchar(b-1/(/*               gcc -o sig sig.c && ./sig    */b/42*2-3)*42);}
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 490 bytes
Desc: not available
URL: <http://lists.zx2c4.com/pipermail/cgit/attachments/20131127/49b03159/attachment.asc>


  reply	other threads:[~2013-11-27 22:59 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-11-27 15:17 mail
2013-11-27 16:17 ` list
2013-11-27 16:37 ` john
2013-11-27 20:51   ` list
2013-11-27 21:00     ` john
2013-11-27 16:46 ` lekensteyn
2013-11-27 20:59   ` list
2013-11-27 21:14     ` mail
2013-11-27 22:11       ` lekensteyn
2013-11-27 22:59         ` list [this message]
2013-11-27 23:00           ` mail
2014-01-08 15:12 [RESEND PATCH " Jason
2014-01-08 15:23 ` [PATCH " mail
2014-01-08 15:56   ` Jason
2014-01-09  8:52     ` mail
2014-01-09 15:13       ` Jason
2014-01-08 16:00   ` Jason
2014-01-09  9:13     ` mail

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20131127235903.33d5b310@leda.localdomain \
    --to=cgit@lists.zx2c4.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).