Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Fixed character set issues and made slugify unicode-friendly.

  • Loading branch information...
commit 05822e9dfab38ec6bd2e68d2c85a2468ff15749e 1 parent 2c46651
Nicholas Johnson authored
Showing with 6 additions and 2 deletions.
  1. +6 −2 admin.py
View
8 admin.py
@@ -8,6 +8,7 @@
import os
import re
+import unicodedata
import fix_path
import config
@@ -15,6 +16,7 @@
def slugify(s):
+ s = unicodedata.normalize('NFKD', s).encode('ascii', 'ignore')
return re.sub('[^a-zA-Z0-9-]+', '-', s).strip('-')
@@ -36,6 +38,8 @@ def render_template(template_name, template_vals=None, theme=None):
class BlogPost(db.Model):
+ MIME_TYPE = "text/html; charset=utf-8"
+
# The URL path to the blog post. Posts have a path iff they are published.
path = db.StringProperty()
title = db.StringProperty(required=True, indexed=False)
@@ -57,12 +61,12 @@ def publish(self):
content = None
while not content:
path = format_post_path(self, num)
- content = static.add(path, rendered, "text/html")
+ content = static.add(path, rendered, self.MIME_TYPE)
num += 1
self.path = path
self.put()
else:
- static.set(self.path, rendered, "text/html")
+ static.set(self.path, rendered, self.MIME_TYPE)
class PostForm(djangoforms.ModelForm):
Please sign in to comment.
Something went wrong with that request. Please try again.