Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code

Side by Side Diff: sitescripts/templateFilters.py

Issue 4786120848048128: Issue 224 - Links to `Issue ###` in dev build changelogs should link to issues.adblockplus.org (Closed)
Patch Set: Created April 15, 2014, 10:21 a.m.
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
View unified diff | Download patch
« no previous file with comments | « .hgsubstate ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 # coding: utf-8 1 # coding: utf-8
2 2
3 # This file is part of the Adblock Plus web scripts, 3 # This file is part of the Adblock Plus web scripts,
4 # Copyright (C) 2006-2014 Eyeo GmbH 4 # Copyright (C) 2006-2014 Eyeo GmbH
5 # 5 #
6 # Adblock Plus is free software: you can redistribute it and/or modify 6 # Adblock Plus is free software: you can redistribute it and/or modify
7 # it under the terms of the GNU General Public License version 3 as 7 # it under the terms of the GNU General Public License version 3 as
8 # published by the Free Software Foundation. 8 # published by the Free Software Foundation.
9 # 9 #
10 # Adblock Plus is distributed in the hope that it will be useful, 10 # Adblock Plus is distributed in the hope that it will be useful,
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after
82 82
83 def formatBugLinks(value): 83 def formatBugLinks(value):
84 def addLink(match): 84 def addLink(match):
85 linkApp = match.group(1) 85 linkApp = match.group(1)
86 if linkApp != None: 86 if linkApp != None:
87 linkApp = linkApp.lower() 87 linkApp = linkApp.lower()
88 linkType = match.group(2).lower() 88 linkType = match.group(2).lower()
89 linkNum = int(match.group(3)) 89 linkNum = int(match.group(3))
90 if linkType == 'topic': 90 if linkType == 'topic':
91 link = 'https://adblockplus.org/forum/viewtopic.php?t=%i' % linkNum 91 link = 'https://adblockplus.org/forum/viewtopic.php?t=%i' % linkNum
92 elif linkApp == None and linkType == 'issue':
93 link = 'https://issues.adblockplus.org/ticket/%i' % linkNum
92 elif linkApp == 'webkit': 94 elif linkApp == 'webkit':
93 link = 'https://bugs.webkit.org/show_bug.cgi?id=%i' % linkNum 95 link = 'https://bugs.webkit.org/show_bug.cgi?id=%i' % linkNum
94 elif linkApp != None: 96 elif linkApp != None:
95 link = 'http://code.google.com/p/chromium/issues/detail?id=%i' % linkNum 97 link = 'http://code.google.com/p/chromium/issues/detail?id=%i' % linkNum
96 elif linkNum > 100000: 98 else:
97 link = 'https://bugzilla.mozilla.org/show_bug.cgi?id=%i' % linkNum 99 link = 'https://bugzilla.mozilla.org/show_bug.cgi?id=%i' % linkNum
98 else:
99 link = 'https://www.mozdev.org/bugs/show_bug.cgi?id=%i' % linkNum
100 return '<a href="%s">%s</a>' % (link, match.group(0)) 100 return '<a href="%s">%s</a>' % (link, match.group(0))
101 101
102 regexp = re.compile(r'(?:\b(WebKit|Chrome|Chromium)\s+)?\b(bug|issue|topic)\s+ (\d+)', re.I | re.U) 102 regexp = re.compile(r'(https?://\S+?)([.,:;!?"\']?(?:\s|$))', re.I | re.U)
103 regexp2 = re.compile(r'(?:\b(WebKit|Chrome|Chromium)\s+)?\b(bug|issue|topic)\s +(\d+)', re.I | re.U)
103 value = unicode(Markup.escape(value)) 104 value = unicode(Markup.escape(value))
104 value = re.sub(regexp, addLink, value) 105 value = re.sub(regexp, r'<a href="\1">\1</a>\2', value);
106 value = re.sub(regexp2, addLink, value)
105 return Markup(value) 107 return Markup(value)
106 108
107 def urlencode(value): 109 def urlencode(value):
108 return urllib.quote(value.encode('utf-8'), '') 110 return urllib.quote(value.encode('utf-8'), '')
109 111
110 def subscriptionSort(value, prioritizeRecommended=True): 112 def subscriptionSort(value, prioritizeRecommended=True):
111 value = value[:] # create a copy of the list 113 value = value[:] # create a copy of the list
112 if prioritizeRecommended: 114 if prioritizeRecommended:
113 value.sort(lambda a, b: ( 115 value.sort(lambda a, b: (
114 cmp(a.type, b.type) or 116 cmp(a.type, b.type) or
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after
173 'urlencode': urlencode, 175 'urlencode': urlencode,
174 'subscriptionSort': subscriptionSort, 176 'subscriptionSort': subscriptionSort,
175 'mime': formatmime, 177 'mime': formatmime,
176 'ljust': ljust, 178 'ljust': ljust,
177 'rjust': rjust, 179 'rjust': rjust,
178 'ltruncate': ltruncate, 180 'ltruncate': ltruncate,
179 'weekday': formatweekday, 181 'weekday': formatweekday,
180 'bytes': formatbytes, 182 'bytes': formatbytes,
181 'json': toJSON, 183 'json': toJSON,
182 } 184 }
OLDNEW
« no previous file with comments | « .hgsubstate ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld