Skip to content
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

Merged
merged 1 commit into from
Aug 27, 2024

Conversation

LeXofLeviafan
Copy link
Collaborator

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).
details popup

  • tags are rendered as badges (functioning as clickable filters)
    • edge cases are handled correctly
      unusual tags
    • also applies to the input form
      input tags
      autocomplete
  • favicon is displayed (if enabled) before the URL; it doubles as a netloc filter
    • when favicons are disabled, displaying a regular netloc badge instead
      netloc badge
  • description is rendered with preserved spacing
    description

…And yes, within a popup all these links will get opened externally.

@@ -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
Copy link
Collaborator Author

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;
}
Copy link
Collaborator Author

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>
Copy link
Collaborator Author

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)
Copy link
Collaborator Author

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>')
Copy link
Collaborator Author

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>'
Copy link
Collaborator Author

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'))]
Copy link
Collaborator Author

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()

@jarun jarun merged commit 7b50263 into jarun:master Aug 27, 2024
1 check passed
@jarun
Copy link
Owner

jarun commented Aug 27, 2024

Thank you!

Would you mind listing all the recent improvements under Cooking in the ToDo list: #484

It would help me populate the changelist easily.

@LeXofLeviafan LeXofLeviafan deleted the details-improvements branch August 27, 2024 16:10
@LeXofLeviafan
Copy link
Collaborator Author

"Recent" as in "since #760", or "after v4.9"?

@jarun
Copy link
Owner

jarun commented Aug 27, 2024

After 4.9.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants