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')),))
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):
def handleMatch(self, match):
url = match.group('url')
a = markdown.util.etree.Element('a')
a.set('href', url)
a.text = url
fixup_link(a)
return a
class UListProcessor(markdown.blockprocessors.OListProcessor):
@ -47,6 +53,7 @@ class LinkPattern(markdown.inlinepatterns.Pattern):
else:
el.set("href", "")
fixup_link(el)
return el
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')) {
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');
if (ids_where_next_is_same_sender[id]) {
row.find('.messagebox').addClass("next_is_same_sender");