Skip to content

Commit

Permalink
Proper response returns, v1.0 cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
skoczen committed May 9, 2014
1 parent 89760a4 commit a42ace4
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 6 deletions.
2 changes: 1 addition & 1 deletion README.md
Expand Up @@ -37,7 +37,7 @@ MIDDLEWARE_CLASSES = (
'django_seo_js.middleware.UserAgentMiddleware', # If you want to detect by user agent
) + MIDDLEWARE_CLASSES

INSTALLED_APPS += ('django_ses_js',)
INSTALLED_APPS += ('django_seo_js',)

# If you're using prerender.io (the default backend):
SEO_JS_PRERENDER_TOKEN = "123456789abcdefghijkl"
Expand Down
1 change: 0 additions & 1 deletion django_seo_js/helpers.py
@@ -1,4 +1,3 @@

from django_seo_js.backends import SelectedBackend

def update_cache_for_url(url):
Expand Down
5 changes: 3 additions & 2 deletions django_seo_js/middleware/hashbang.py
@@ -1,8 +1,9 @@
from django_seo_js.backends import SelectedBackend
from django.http import HttpResponse


class HashBangMiddleware(SelectedBackend):
def process_request(self, request):
if "_escaped_fragment_" in request.GET:
url = "%s://%s%s" % (request.protocol, request.host, request.uri)
return self.backend.get_rendered_page(url)
url = request.build_absolute_uri()
return HttpResponse(self.backend.get_rendered_page(url))
5 changes: 3 additions & 2 deletions django_seo_js/middleware/useragent.py
@@ -1,6 +1,7 @@
import re
from django.conf import settings
from django_seo_js.backends import SelectedBackend
from django.http import HttpResponse

DEFAULT_SEO_JS_USER_AGENTS = [
"Googlebot",
Expand All @@ -23,5 +24,5 @@ def __init__(self, *args, **kwargs):

def process_request(self, request):
if self.USER_AGENT_REGEX.match(request.META["HTTP_USER_AGENT"]):
url = "%s://%s%s" % (request.protocol, request.host, request.uri)
return self.backend.get_rendered_page(url)
url = request.build_absolute_uri()
return HttpResponse(self.backend.get_rendered_page(url))

0 comments on commit a42ace4

Please sign in to comment.