's libravatar lua script

Konstantin Ryabitsev mricon at
Fri Mar 14 16:37:56 CET 2014

Hi, all:

We upgraded to 0.10.1 on with libravatar support:

As you'll notice, it's slightly different from the default gravatar
script, so here are our changes (using lua-md5 instead of luacrypto):

local md5 = require("md5")

function filter_open(email, page)
        buffer = ""
        hexdigest = md5.sumhexa(email:sub(2, -2):lower())

function filter_close()
        html("<span class='libravatar'><img class='inline'
src='//" .. hexdigest ..
"?s=13&d=retro' /><img class='onhover'
src='//" .. hexdigest ..
"?s=128&d=retro' /></span>" .. buffer)
        return 0

function filter_write(str)
        buffer = buffer .. str

The following css additions are required for the hover effect:

div#cgit span.libravatar img.onhover {
        display: none;
        border: 1px solid gray;
        padding: 0px;
        -webkit-border-radius: 4px;
        -moz-border-radius: 4px;
        border-radius: 4px;
        width: 128px;
        height: 128px;

div#cgit span.libravatar img.inline {
        -webkit-border-radius: 3px;
        -moz-border-radius: 3px;
        border-radius: 3px;
        width: 13px;
        height: 13px;
        margin-right: 0.2em;
        opacity: 0.4;

div#cgit span.libravatar:hover > img.onhover {
        display: block;
        position: absolute;
        margin-left: 1.5em;
        background-color: #eeeeee;
        box-shadow: 5px 5px 3px #bbb;

Konstantin Ryabitsev
Senior Systems Administrator
Linux Foundation Collab Projects
Montréal, Québec

-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 713 bytes
Desc: OpenPGP digital signature
URL: <>

More information about the CGit mailing list