lowercase titles in urls/remove redundant title tags in links

This commit is contained in:
Jeremy Edberg
2008-07-24 11:15:10 -07:00
parent 7b937ef72f
commit d09b56e9c7
4 changed files with 5 additions and 5 deletions

View File

@@ -24,6 +24,7 @@ from pylons import c, request, g
from utils import query_string, timeago
from strings import StringHandler, plurals
from r2.lib.db import operators
from r2.lib.filters import _force_unicode
from pylons.i18n import _
#from r2.config import cache
@@ -259,7 +260,7 @@ class NavButton(Styled):
p = {}
base_path = ("%s/%s/" % (base_path, self.dest)).replace('//', '/')
self.bare_path = base_path.replace('//', '/')
self.bare_path = _force_unicode(base_path.replace('//', '/')).lower()
# append the query string
base_path += query_string(p)
@@ -273,7 +274,7 @@ class NavButton(Styled):
if self.opt:
return request.params.get(self.opt, '') in self.aliases
else:
stripped_path = request.path.rstrip('/')
stripped_path = _force_unicode(request.path.rstrip('/')).lower()
if stripped_path == self.bare_path.rstrip('/'):
return True
if stripped_path in (a.rstrip('/') for a in self.aliases):

View File

@@ -755,6 +755,7 @@ def title_to_url(title, max_length = 50):
title = rx_notsafe.sub('', title) #remove non-printables
title = rx_underscore.sub('_', title) #remove double underscores
title = title.strip('_') #remove trailing underscores
title = title.lower() #lowercase the title
if len(title) > max_length:
#truncate to nearest word

View File

@@ -113,7 +113,7 @@ ${parent.midcol()}
<% fullname = thing._fullname %>
<li class="first">
${parent.comment_button("permalink", fullname, _("permalink"), 0,
thing.permalink, title = thing.author.name + " comments on " + thing.link.title)}
thing.permalink)}
</li>
%if not c.profilepage:
%if thing.parent_permalink:

View File

@@ -45,7 +45,6 @@
<a id="${name}_${thing._fullname}"
onmousedown="setClick(this, '${css_class}')"
class="${css_class} ${ c.user_is_loggedin and 'loggedin' or ''} ${thing.clicked and 'click' or ''}"
title="${thing.title}"
%if c.user.pref_frame:
href="/goto?id=${thing._id36}"
%else:
@@ -148,7 +147,6 @@
<li class="first">
${parent.comment_button("comment", fullname, com_label,
thing.num_comments, thing.permalink,
title = "comments on " + thing.title,
newwindow = c.user.pref_newwindow)}
</li>
<li id="share_li_${fullname}">