diff options
| author | tom christie tom@tomchristie.com | 2011-01-27 21:19:25 +0000 |
|---|---|---|
| committer | tom christie tom@tomchristie.com | 2011-01-27 21:19:25 +0000 |
| commit | e9168b508b38b545406089c8592342e5eb70f9f9 (patch) | |
| tree | eca0ff410c21374a6e055be1c71bd671e640a4ed /flywheel | |
| parent | 216baa551fdce6394aa640ee0806c79b38658daf (diff) | |
| download | django-rest-framework-e9168b508b38b545406089c8592342e5eb70f9f9.tar.bz2 | |
Login/Logout and FlyWheel API link in HTML emitter - Add templates, quote next value, only use login/logout if settings.LOGIN_URL and settings.LOGOUT_URL are in urlconf
Diffstat (limited to 'flywheel')
| -rw-r--r-- | flywheel/emitters.py | 7 | ||||
| -rw-r--r-- | flywheel/templates/emitter.html | 4 | ||||
| -rw-r--r-- | flywheel/templatetags/urlize_quoted_links.py | 2 |
3 files changed, 7 insertions, 6 deletions
diff --git a/flywheel/emitters.py b/flywheel/emitters.py index 458fa68c..d535f7b0 100644 --- a/flywheel/emitters.py +++ b/flywheel/emitters.py @@ -3,8 +3,9 @@ from django.template import RequestContext, loader from django import forms from flywheel.response import NoContent +from flywheel.utils import dict2xml, url_resolves -from utils import dict2xml, url_resolves +from urllib import quote_plus import string try: import json @@ -121,8 +122,8 @@ class DocumentingTemplateEmitter(BaseEmitter): form_instance = self._get_form_instance(self.resource) if url_resolves(settings.LOGIN_URL) and url_resolves(settings.LOGOUT_URL): - login_url = "%s?next=%s" % (settings.LOGIN_URL, self.resource.request.path) - logout_url = "%s?next=%s" % (settings.LOGOUT_URL, self.resource.request.path) + login_url = "%s?next=%s" % (settings.LOGIN_URL, quote_plus(self.resource.request.path)) + logout_url = "%s?next=%s" % (settings.LOGOUT_URL, quote_plus(self.resource.request.path)) else: login_url = None logout_url = None diff --git a/flywheel/templates/emitter.html b/flywheel/templates/emitter.html index 7078eafd..7959af17 100644 --- a/flywheel/templates/emitter.html +++ b/flywheel/templates/emitter.html @@ -36,11 +36,11 @@ {% if 'GET' in resource.allowed_methods %} <div class='action'> - <a href='{{ request.path }}'>GET</a> + <a href='{{ request.path }}' rel="nofollow">GET</a> <ul class="accepttypes"> {% for media_type in resource.emitted_media_types %} {% with resource.ACCEPT_QUERY_PARAM|add:"="|add:media_type as param %} - <li>[<a href='{{ request.path|add_query_param:param }}'>{{ media_type }}</a>]</li> + <li>[<a href='{{ request.path|add_query_param:param }} rel="nofollow"'>{{ media_type }}</a>]</li> {% endwith %} {% endfor %} </ul> diff --git a/flywheel/templatetags/urlize_quoted_links.py b/flywheel/templatetags/urlize_quoted_links.py index 4e3ae6c8..60088cf6 100644 --- a/flywheel/templatetags/urlize_quoted_links.py +++ b/flywheel/templatetags/urlize_quoted_links.py @@ -33,7 +33,7 @@ html_gunk_re = re.compile(r'(?:<br clear="all">|<i><\/i>|<b><\/b>|<em><\/em>|<st hard_coded_bullets_re = re.compile(r'((?:<p>(?:%s).*?[a-zA-Z].*?</p>\s*)+)' % '|'.join([re.escape(x) for x in DOTS]), re.DOTALL) trailing_empty_content_re = re.compile(r'(?:<p>(?: |\s|<br \/>)*?</p>\s*)+\Z') -def urlize_quoted_links(text, trim_url_limit=None, nofollow=False, autoescape=True): +def urlize_quoted_links(text, trim_url_limit=None, nofollow=True, autoescape=True): """ Converts any URLs in text into clickable links. |
