bugdown: Set link target, title attributes on the server

For consistency.  Fixes #266.

(imported from commit 63e199a0fe4534df804a82cc98a1fdcf8ccb45da)
This commit is contained in:
Keegan McAllister 2012-12-04 14:15:50 -05:00
parent 80d07f597b
commit fb77bdf359
2 changed files with 7 additions and 5 deletions

View File

@ -15,12 +15,18 @@ class Gravatar(markdown.inlinepatterns.Pattern):
% (gravatar_hash(match.group('email')),)) % (gravatar_hash(match.group('email')),))
return img return img
def fixup_link(link):
"""Set certain attributes we want on every link."""
link.set('target', '_blank')
link.set('title', link.get('href'))
class AutoLink(markdown.inlinepatterns.Pattern): class AutoLink(markdown.inlinepatterns.Pattern):
def handleMatch(self, match): def handleMatch(self, match):
url = match.group('url') url = match.group('url')
a = markdown.util.etree.Element('a') a = markdown.util.etree.Element('a')
a.set('href', url) a.set('href', url)
a.text = url a.text = url
fixup_link(a)
return a return a
class UListProcessor(markdown.blockprocessors.OListProcessor): class UListProcessor(markdown.blockprocessors.OListProcessor):
@ -47,6 +53,7 @@ class LinkPattern(markdown.inlinepatterns.Pattern):
else: else:
el.set("href", "") el.set("href", "")
fixup_link(el)
return el return el
def sanitize_url(self, url): def sanitize_url(self, url):

View File

@ -365,11 +365,6 @@ function add_to_table(messages, table_name, filter_function, where, allow_collap
if (! row.hasClass('message_row')) { if (! row.hasClass('message_row')) {
return; return;
} }
row.find('.message_content a').each(function (index, link) {
link = $(link);
link.attr('target', '_blank')
.attr('title', link.attr('href'));
});
var id = row.attr('zid'); var id = row.attr('zid');
if (ids_where_next_is_same_sender[id]) { if (ids_where_next_is_same_sender[id]) {
row.find('.messagebox').addClass("next_is_same_sender"); row.find('.messagebox').addClass("next_is_same_sender");