From cef92ab99d7a6fc0e8fdaa5db961789e931330d6 Mon Sep 17 00:00:00 2001 From: "James E. Blair" Date: Tue, 7 Apr 2015 10:01:46 -0700 Subject: [PATCH] Open internal URLs in commentlinks If a URL is found in commentlink-processed text (eg, commit or review messages), open it internally if it is an internal link, otherwise, use the web browser. Change-Id: I91f226ab600ad334df8144c23a2e7b232781e24c --- gertty/commentlink.py | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/gertty/commentlink.py b/gertty/commentlink.py index 97c2d46..6ab9de4 100644 --- a/gertty/commentlink.py +++ b/gertty/commentlink.py @@ -50,9 +50,15 @@ class LinkReplacement(object): def replace(self, app, data): link = mywid.Link(self.text.format(**data), 'link', 'focused-link') urwid.connect_signal(link, 'selected', - lambda link:app.openURL(self.url.format(**data))) + lambda link:self.activate(app, self.url.format(**data))) return link + def activate(self, app, url): + result = app.parseInternalURL(url) + if result is not None: + return app.openInternalURL(result) + return app.openURL(url) + class SearchReplacement(object): def __init__(self, config): self.query = config['query']