# HG changeset patch # User Brian Neal # Date 1318896874 0 # Node ID 7c69b1449d7aef290d41fcef3bf81e89e2dcacd7 # Parent bbbc357ac5f3730fc667627116c75d0b278f56c0 For #233, make sure og:url and og:image are fully qualified (http://). diff -r bbbc357ac5f3 -r 7c69b1449d7a gpp/core/templatetags/core_tags.py --- a/gpp/core/templatetags/core_tags.py Tue Oct 18 00:04:37 2011 +0000 +++ b/gpp/core/templatetags/core_tags.py Tue Oct 18 00:14:34 2011 +0000 @@ -66,6 +66,18 @@ } +def _fully_qualify(url, domain): + """ + Returns a "fully qualified" URL by checking the given url. + If the url starts with '/' then http://domain is pre-pended + onto it. Otherwise the original URL is returned. + + """ + if url.startswith('/'): + url = "http://%s%s" % (domain, url) + return url + + @register.inclusion_tag('core/open_graph_meta_tag.html') def open_graph_meta_tags(item): """ @@ -81,6 +93,12 @@ if 'og:image' not in props: props['og:image'] = settings.OGP_DEFAULT_IMAGE + if 'og:url' in props: + props['og:url'] = _fully_qualify(props['og:url'], site.domain) + + if 'og:image' in props: + props['og:image'] = _fully_qualify(props['og:image'], site.domain) + return {'props': props}