Skip to content

Instantly share code, notes, and snippets.

@VladRassokhin
Created June 8, 2012 23:15
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save VladRassokhin/2898604 to your computer and use it in GitHub Desktop.
Save VladRassokhin/2898604 to your computer and use it in GitHub Desktop.
Simple gravatar.tag for JSP
<%@ tag import="java.util.Formatter"
%><%@ tag import="java.security.MessageDigest"
%><%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"
%><%@ attribute name="email" required="true" type="java.lang.String"
%><%@ attribute name="sz" required="false" type="java.lang.Integer"
%><c:if test="${empty sz}"><c:set var="sz">20</c:set></c:if><c:choose
><c:when test="${empty email}"><c:set var="hash">00000000000000000000000000000000</c:set></c:when><c:otherwise
><c:set var="hash"><%=javax.xml.bind.DatatypeConverter.printHexBinary(MessageDigest.getInstance("MD5").digest(email.toLowerCase().trim().getBytes("UTF-8"))).trim().toLowerCase()%></c:set></c:otherwise
></c:choose><img class="gravatarimg${sz}" src="http://www.gravatar.com/avatar/${hash}?s=${sz}&d=mm" alt="">
@jonnyzzz
Copy link

If only we had email in web page of TeamCity we could have implemented this in JS...

@VladRassokhin
Copy link
Author

Maybe it's possible to use email from sso header

@VladRassokhin
Copy link
Author

Or static ui extension which adds simple json with email into all pages.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment