-
-
Notifications
You must be signed in to change notification settings - Fork 294
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
improving bookmark details view #771
Conversation
@@ -4,4 +4,5 @@ Flask-API>=3.0.post1 | |||
flask-paginate>=2022.1.8 | |||
Flask-WTF>=1.0.1 | |||
Flask>=2.2.2,<2.3 | |||
Jinja2>=3 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ensuring Jinja version (pass_content
is the name used since v3.0)
} | ||
.tag-list a, .link .netloc, .select2-search-choice > *, .select2-result-label { | ||
white-space: pre; | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ensuring correct spacing within tags
}</script> | ||
<script> | ||
$(`body.popup {{prefix}} a`).attr('target', '_blank'); | ||
</script> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Adding target="_blank"
to all links within a popup
@@ -73,8 +74,11 @@ def last_page(self): | |||
return redirect(url_for('.index_view', **args)) | |||
|
|||
|
|||
def app_param(key, default=None): | |||
return current_app.config.get(f'BUKUSERVER_{key}', default) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A convenient shorthand
res += [link(badge, url_for('bookmark.index_view', flt0_url_netloc_match=netloc), html=True, badge='success')] | ||
res += [escape(value) if not scheme else link(value, value, new_tab=app_param('OPEN_IN_NEW_TAB'))] | ||
return Markup(f'<div class="link">{" ".join(res)}</div>') | ||
return Markup(f'<div class="{name}">{escape(value)}</div>') |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Overriding a method that renders value cell contents in details view
target = ('' if not new_tab else ' target="_blank"') | ||
cls = ('' if not badge else f' class="btn label label-{badge}"') | ||
return f'<a{cls} href="{escape(url)}"{target}>{escape(text)}</a>' | ||
return f'<a{cls} href="{escape(url)}"{target}>{text if html else escape(text)}</a>' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Supporting non-plain-text hyperlinks
elif netloc: | ||
badge = f'<span class="netloc">netloc:{escape(netloc)}</span>' | ||
res += [link(badge, url_for('bookmark.index_view', flt0_url_netloc_match=netloc), html=True, badge='success')] | ||
res += [escape(value) if not scheme else link(value, value, new_tab=app_param('OPEN_IN_NEW_TAB'))] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This reproduces current logic for rendering URL as a hyperlink within _list_entry()
6e2e3e8
to
84d2b76
Compare
Thank you! Would you mind listing all the recent improvements under It would help me populate the changelist easily. |
After 4.9. |
After some more fiddling I decided to move the URL enhancement of the details view to the backend, along with enhancing other fields as well (similar to the bookmarks list view).
…And yes, within a popup all these links will get opened externally.