Permalink
Browse files

cleaned up a little... :)

  • Loading branch information...
1 parent 0d53b59 commit f9f4e70ca58e48cdf00cd402d3aaa60f3d5c49ac @bsstoner committed Jan 17, 2010
View
@@ -1,69 +0,0 @@
-import random, string
-import re
-import unicodedata
-from htmlentitydefs import name2codepoint
-
-def unique_slugify(s, entities=True, decimal=True, hexadecimal=True,
- instance=None, slug_field='slug', filter_dict=None, content_object=False,
- delimiter='_',site=False):
- """
- Based on Django snippet 369: http://www.djangosnippets.org/snippets/369/
- Modified to use underscores instead of hyphens....
- Also added owner_instance, when passed, slug only has to be unique to owner
-
- **BS added content_type variable, if set to true instance slug will be made unique for
- that content_object only. Can have have duplicate slugs in system as long as they are owned by different content_objects
- """
- #s = smart_unicode(s)
-
- #character entity reference
- if entities:
- s = re.sub('&(%s);' % '|'.join(name2codepoint), lambda m: unichr(name2codepoint[m.group(1)]), s)
-
- #decimal character reference
- if decimal:
- try:
- s = re.sub('&#(\d+);', lambda m: unichr(int(m.group(1))), s)
- except:
- pass
-
- #hexadecimal character reference
- if hexadecimal:
- try:
- s = re.sub('&#x([\da-fA-F]+);', lambda m: unichr(int(m.group(1), 16)), s)
- except:
- pass
-
- #translate
- s = unicodedata.normalize('NFKD', s).encode('ascii', 'ignore')
-
- #replace unwanted characters
- s = re.sub(r'[^-a-z0-9]+', delimiter, s.lower())
-
- # replace hyphens with underscores....
- s = re.sub('-', delimiter, s)
-
- #remove redundant -
- s = re.sub(delimiter + '{2,}', delimiter, s).strip('_')
-
- return s
-
-#===============================================================================
-# if instance:
-# def get_query():
-# query = instance.__class__.objects.filter(**{slug_field: slug})
-# if filter_dict:
-# query = query.filter(**filter_dict)
-# if content_object:
-# query = query.filter(**{'content_type':instance.content_type,'object_id':instance.object_id})
-# if site:
-# query = query.filter(**{'site__domain__slug':instance.site.domain.slug})
-# if instance.pk:
-# query = query.exclude(pk=instance.pk)
-# print query
-# return query
-# counter = 1
-# while get_query():
-# slug = "%s%s" % (s, counter)
-# counter += 1
-#===============================================================================
No changes.
@@ -1,14 +0,0 @@
-<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
-<html xmlns="http://www.w3.org/1999/xhtml">
- <head>
- <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
- <title>{{ escape(handler.settings["blog_title"]) }}</title>
- <link rel="stylesheet" href="{{ static_url("blog.css") }}" type="text/css"/>
- {% block head %}{% end %}
- </head>
- <body>
- <div id="body">
- {% block content %}{% end %}
- </div>
- </body>
-</html>
No changes.
No changes.
@@ -1,14 +0,0 @@
-{% extends "base.html" %}
-{% block content %}
-
-<form action="{{ request.path }}" method="post">
- <label>Name:</label><br />
- <input type="text" id="name" name="name" /><br />
- <label>Url:</label><br />
- <input type="text" id="feed_url" name="feed_url" /><br />
- <input type="submit" name="submit" id="submit" value="Add Feed" />
-</form>
-{% for f in feeds %}
- <a href='{{ escape(f["feed_url"]) }}'>{{ escape(f["name"]) }}</a>
-{% endfor %}
-{% endblock %}
No changes.

0 comments on commit f9f4e70

Please sign in to comment.