Skip to content

Commit

Permalink
add gravatar parameter in config.ini context section
Browse files Browse the repository at this point in the history
set gravatar image as favicon of the blog
  • Loading branch information
microjo committed May 16, 2012
1 parent aa66759 commit 5536022
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 0 deletions.
1 change: 1 addition & 0 deletions liquidluck/_templates/layout.html
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
<head>
<meta charset="UTF-8">
<title>{% block title %}{{context.sitename}}{% endblock %}</title>
{% if context.gravatar %}<link rel="shortcut icon" href="{{gravatar_url(16)}}" />{% endif %}
<script>if (top !== self) top.location = self.location;</script>
<meta name="HandheldFriendly" content="True" />
<meta name="viewport" content="width=device-width, initial-scale=1, user-scalable=0" />
Expand Down
13 changes: 13 additions & 0 deletions liquidluck/writers/default.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import os
import sys
import hashlib
import urllib
from math import log

from liquidluck.writers import Writer, FeedMixin, PagerMixin
Expand All @@ -15,6 +16,17 @@
_hash_cache = {}


def gravatar_url(size):
"""
generate URL requiered to request a Gravatar Image
using varialbe in config.ini context section:
gravatar: your gravatar email address
"""

gravatar_url = "http://www.gravatar.com/avatar/" + hashlib.md5(ns.context.gravatar.lower()).hexdigest() + "?"
return gravatar_url + urllib.urlencode({'s':str(size)})


def static_url(name):
global _hash_cache
url = ns.site.static_prefix
Expand All @@ -40,6 +52,7 @@ class StaticWriter(Writer):

def start(self):
ns.storage.functions.update({'static_url': static_url})
ns.storage.functions.update({'gravatar_url': gravatar_url})
return

def run(self):
Expand Down

0 comments on commit 5536022

Please sign in to comment.