diff --git a/tailbone/views/master.py b/tailbone/views/master.py index 98355ec3..735755f0 100644 --- a/tailbone/views/master.py +++ b/tailbone/views/master.py @@ -2644,17 +2644,33 @@ class MasterView(View): return normal def make_xref_button(self, **kwargs): + """ + Make and return a HTML ```` literal, for display in + the cross-reference helper panel. + :param url: URL for the link. + :param text: Label for the button. + :param internal: Boolean indicating if the link is internal to + the site. This is false by default, meaning the link is + assumed to be external, which affects the icon and causes + button click to open link in a new tab. + """ # nb. unfortunately HTML.tag() calls its first arg 'tag' and # so we can't pass a kwarg with that name...so instead we # patch that into place manually - button = HTML.tag('b-button', type='is-primary', - href=kwargs['url'], target='_blank', - icon_pack='fas', icon_left='external-link-alt', - c=kwargs['text']) + btn_kw = dict(type='is-primary', + href=kwargs['url'], + icon_pack='fas', + c=kwargs['text']) + if kwargs.get('internal'): + btn_kw['icon_left'] = 'eye' + else: + btn_kw['icon_left'] = 'external-link-alt' + btn_kw['target'] = '_blank' + button = HTML.tag('b-button', **btn_kw) button = six.text_type(button) - button = button.replace('target="_blank"', - 'target="_blank" tag="a"') + button = button.replace('