Skip to content

Commit

Permalink
og:image wants an absolute URL.
Browse files Browse the repository at this point in the history
  • Loading branch information
berkerpeksag committed Sep 18, 2015
1 parent 3768cdc commit cc32756
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 1 deletion.
7 changes: 7 additions & 0 deletions pydotorg/context_processors.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
def site_info(request):
return {'SITE_INFO': settings.SITE_VARIABLES}


def url_name(request):
try:
match = resolve(request.path)
Expand All @@ -15,3 +16,9 @@ def url_name(request):
if namespace:
url_name = "%s:%s" % (namespace, url_name)
return {'URL_NAMESPACE': namespace, 'URL_NAME': url_name}


def get_host_with_scheme(request):
return {
'GET_HOST_WITH_SCHEME': request.build_absolute_uri('/').rstrip('/'),
}
1 change: 1 addition & 0 deletions pydotorg/settings/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,7 @@
"django.contrib.messages.context_processors.messages",
"pydotorg.context_processors.site_info",
"pydotorg.context_processors.url_name",
"pydotorg.context_processors.get_host_with_scheme",
]

### URLs, WSGI, middleware, etc.
Expand Down
2 changes: 1 addition & 1 deletion templates/base.html
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@
{# permalink to the current page #}
<meta property="og:url" content="{% block og-url %}{{ request.build_absolute_uri }}{% endblock %}">
{# a path to an image used on the page. helpful for telling crawlers what image to use for a page preview. #}
<meta property="og:image" content="{% block og-image %}{{ STATIC_URL }}img/python-logo-large.png{% endblock %}">
<meta property="og:image" content="{% block og-image %}{{ GET_HOST_WITH_SCHEME }}{{ STATIC_URL }}img/python-logo-large.png{% endblock %}">

<link rel="author" href="{{ STATIC_URL }}humans.txt">

Expand Down

0 comments on commit cc32756

Please sign in to comment.