diff options
| -rw-r--r-- | examples/templates/base.html | 7 | ||||
| -rw-r--r-- | examples/templates/registration/login.html | 26 | ||||
| -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 |
5 files changed, 40 insertions, 6 deletions
diff --git a/examples/templates/base.html b/examples/templates/base.html new file mode 100644 index 00000000..1ff37dab --- /dev/null +++ b/examples/templates/base.html @@ -0,0 +1,7 @@ +<html> + <head> + </head> + <body> +{% block content %}{% endblock %} + </body> +</html>
\ No newline at end of file diff --git a/examples/templates/registration/login.html b/examples/templates/registration/login.html new file mode 100644 index 00000000..9d0b481b --- /dev/null +++ b/examples/templates/registration/login.html @@ -0,0 +1,26 @@ +{% extends "base.html" %} + +{% block content %} + +{% if form.errors %} +<p>Your username and password didn't match. Please try again.</p> +{% endif %} + +<form method="post" action="{% url django.contrib.auth.views.login %}"> +{% csrf_token %} +<table> +<tr> + <td>{{ form.username.label_tag }}</td> + <td>{{ form.username }}</td> +</tr> +<tr> + <td>{{ form.password.label_tag }}</td> + <td>{{ form.password }}</td> +</tr> +</table> + +<input type="submit" value="login" /> +<input type="hidden" name="next" value="{{ next }}" /> +</form> + +{% endblock %}
\ No newline at end of file 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. |
