Permalink
Browse files

various nits fixes on prefixing

  • Loading branch information...
1 parent ed3f0f7 commit c4ed7ce438229ab8fb4fdaffa4436aaa2fb02dae @peterbe committed Mar 28, 2013
Showing with 16 additions and 6 deletions.
  1. +3 −2 apps/homepage/views.py
  2. +9 −0 apps/plog/utils.py
  3. +3 −3 apps/plog/views.py
  4. +1 −1 peterbecom/templates/base.html
View
5 apps/homepage/views.py
@@ -22,12 +22,13 @@
from .utils import (parse_ocs_to_categories, make_categories_q, split_search)
from fancy_cache import cache_page
from apps.mincss_response import mincss_response
+from apps.plog.utils import make_prefix
def _home_key_prefixer(request):
if request.method != 'GET':
return None
- prefix = urllib.urlencode(request.GET)
+ prefix = make_prefix(request.GET)
cache_key = 'latest_comment_add_date'
if request.path_info.startswith('/oc-'):
categories = parse_ocs_to_categories(request.path_info[len('/oc-'):])
@@ -115,7 +116,7 @@ def home(request, oc=None):
def search(request):
data = {}
search = request.GET.get('q', '')
- if len(search) > 100:
+ if len(search) > 90:
return http.HttpResponse("Search too long")
documents = []
data['base_url'] = 'http://%s' % RequestSite(request).domain
View
9 apps/plog/utils.py
@@ -1,3 +1,4 @@
+import urllib
import markdown
import time
import datetime
@@ -14,6 +15,14 @@
from gfm import gfm
+def make_prefix(request_dict):
+ _get = dict(request_dict)
+ for key, value in _get.items():
+ _get[key] = [isinstance(x, unicode) and x.encode('utf-8') or x
+ for x in value]
+ return urllib.urlencode(_get, True)
+
+
def utcify(dateinstance):
return dateinstance.replace(tzinfo=UTC)
View
6 apps/plog/views.py
@@ -60,7 +60,7 @@ def _blog_post_key_prefixer(request):
return None
if request.user.is_authenticated():
return None
- prefix = urllib.urlencode(request.GET)
+ prefix = utils.make_prefix(request.GET)
if request.path.endswith('/'):
oid = request.path.split('/')[-2]
else:
@@ -403,7 +403,7 @@ def _plog_index_key_prefixer(request):
return None
if request.user.is_authenticated():
return None
- prefix = urllib.urlencode(request.GET)
+ prefix = utils.make_prefix(request.GET)
cache_key = 'latest_post_modify_date'
latest_date = cache.get(cache_key)
if latest_date is None:
@@ -455,7 +455,7 @@ def _new_comment_key_prefixer(request):
return None
if request.user.is_authenticated():
return None
- prefix = urllib.urlencode(request.GET)
+ prefix = utils.make_prefix(request.GET)
cache_key = 'latest_comment_add_date'
latest_date = cache.get(cache_key)
if latest_date is None:
View
2 peterbecom/templates/base.html
@@ -19,7 +19,7 @@
<div class="container">
<a class="brand" href="/"><span class="logo-text">Peterbe.com</span></a>
<form action="/search" class="navbar-search pull-right">
- <input type="text" name="q" class="search-query" placeholder="Search" {% if q %}value="{{ q }}"{% endif %}>
+ <input type="text" name="q" class="search-query" maxlength="90" placeholder="Search" {% if q %}value="{{ q }}"{% endif %}>
</form>
<div class="pull-right">
<ul class="nav">

0 comments on commit c4ed7ce

Please sign in to comment.