Show More
@@ -1283,6 +1283,16 b' def urlify_changesets(text_, repository)' | |||||
1283 |
|
1283 | |||
1284 | return re.sub(r'(?:^|(?<=[\s(),]))([0-9a-fA-F]{12,40})(?=$|\s|[.,:()])', url_func, text_) |
|
1284 | return re.sub(r'(?:^|(?<=[\s(),]))([0-9a-fA-F]{12,40})(?=$|\s|[.,:()])', url_func, text_) | |
1285 |
|
1285 | |||
|
1286 | def linkify_others(t, l): | |||
|
1287 | urls = re.compile(r'(\<a.*?\<\/a\>)',) | |||
|
1288 | links = [] | |||
|
1289 | for e in urls.split(t): | |||
|
1290 | if not urls.match(e): | |||
|
1291 | links.append('<a class="message-link" href="%s">%s</a>' % (l, e)) | |||
|
1292 | else: | |||
|
1293 | links.append(e) | |||
|
1294 | ||||
|
1295 | return ''.join(links) | |||
1286 |
|
1296 | |||
1287 | def urlify_commit(text_, repository, link_=None): |
|
1297 | def urlify_commit(text_, repository, link_=None): | |
1288 | """ |
|
1298 | """ | |
@@ -1294,30 +1304,22 b' def urlify_commit(text_, repository, lin' | |||||
1294 | :param repository: |
|
1304 | :param repository: | |
1295 | :param link_: changeset link |
|
1305 | :param link_: changeset link | |
1296 | """ |
|
1306 | """ | |
1297 | import traceback |
|
|||
1298 | from pylons import url # doh, we need to re-import url to mock it later |
|
|||
1299 |
|
||||
1300 | def escaper(string): |
|
1307 | def escaper(string): | |
1301 | return string.replace('<', '<').replace('>', '>') |
|
1308 | return string.replace('<', '<').replace('>', '>') | |
1302 |
|
1309 | |||
1303 | def linkify_others(t, l): |
|
|||
1304 | urls = re.compile(r'(\<a.*?\<\/a\>)',) |
|
|||
1305 | links = [] |
|
|||
1306 | for e in urls.split(t): |
|
|||
1307 | if not urls.match(e): |
|
|||
1308 | links.append('<a class="message-link" href="%s">%s</a>' % (l, e)) |
|
|||
1309 | else: |
|
|||
1310 | links.append(e) |
|
|||
1311 |
|
||||
1312 | return ''.join(links) |
|
|||
1313 |
|
||||
1314 | # urlify changesets - extract revisions and make link out of them |
|
1310 | # urlify changesets - extract revisions and make link out of them | |
1315 | newtext = urlify_changesets(escaper(text_), repository) |
|
1311 | newtext = urlify_changesets(escaper(text_), repository) | |
1316 |
|
1312 | |||
1317 | # extract http/https links and make them real urls |
|
1313 | # extract http/https links and make them real urls | |
1318 | newtext = urlify_text(newtext, safe=False) |
|
1314 | newtext = urlify_text(newtext, safe=False) | |
1319 |
|
1315 | |||
|
1316 | newtext = urlify_issues(newtext, repository, link_) | |||
|
1317 | ||||
|
1318 | return literal(newtext) | |||
|
1319 | ||||
|
1320 | def urlify_issues(newtext, repository, link_=None): | |||
1320 | try: |
|
1321 | try: | |
|
1322 | import traceback | |||
1321 | from kallithea import CONFIG |
|
1323 | from kallithea import CONFIG | |
1322 | conf = CONFIG |
|
1324 | conf = CONFIG | |
1323 |
|
1325 | |||
@@ -1329,8 +1331,9 b' def urlify_commit(text_, repository, lin' | |||||
1329 | and 'issue_prefix%s' % x.group(1) in conf |
|
1331 | and 'issue_prefix%s' % x.group(1) in conf | |
1330 | ] |
|
1332 | ] | |
1331 |
|
1333 | |||
1332 | log.debug('found issue server suffixes `%s` during valuation of: %s' |
|
1334 | if valid_indices: | |
1333 | % (','.join(valid_indices), newtext)) |
|
1335 | log.debug('found issue server suffixes `%s` during valuation of: %s' | |
|
1336 | % (','.join(valid_indices), newtext)) | |||
1334 |
|
1337 | |||
1335 | for pattern_index in valid_indices: |
|
1338 | for pattern_index in valid_indices: | |
1336 | ISSUE_PATTERN = conf.get('issue_pat%s' % pattern_index) |
|
1339 | ISSUE_PATTERN = conf.get('issue_pat%s' % pattern_index) | |
@@ -1377,8 +1380,7 b' def urlify_commit(text_, repository, lin' | |||||
1377 | except Exception: |
|
1380 | except Exception: | |
1378 | log.error(traceback.format_exc()) |
|
1381 | log.error(traceback.format_exc()) | |
1379 | pass |
|
1382 | pass | |
1380 |
|
1383 | return newtext | ||
1381 | return literal(newtext) |
|
|||
1382 |
|
1384 | |||
1383 |
|
1385 | |||
1384 | def rst(source): |
|
1386 | def rst(source): |
General Comments 0
You need to be logged in to leave comments.
Login now