From 85be6565fcdf8d4006ded9b10250d1a9229e6502 Mon Sep 17 00:00:00 2001 From: David Vogt Date: Sat, 23 Jul 2016 12:09:49 +0200 Subject: [PATCH] Implement feature request #1033: Bookmark display There is a new page now, qute:bookmarks that will display all bookmarks and quickmarks. It's still missing a search / filter feature, but you can use the built-in search / navigation just as easily for now. --- .../browser/webkit/network/qutescheme.py | 14 ++++++ qutebrowser/html/bookmarks.html | 48 +++++++++++++++++++ tests/end2end/features/urlmarks.feature | 13 +++++ 3 files changed, 75 insertions(+) create mode 100644 qutebrowser/html/bookmarks.html diff --git a/qutebrowser/browser/webkit/network/qutescheme.py b/qutebrowser/browser/webkit/network/qutescheme.py index bfa722d43..272f97dfa 100644 --- a/qutebrowser/browser/webkit/network/qutescheme.py +++ b/qutebrowser/browser/webkit/network/qutescheme.py @@ -261,3 +261,17 @@ def qute_pdfjs(_win_id, request): "pdfjs resource requested but not found: {}".format(e.path)) raise QuteSchemeError("Can't find pdfjs resource '{}'".format(e.path), QNetworkReply.ContentNotFoundError) + + +@add_handler('bookmarks') +def qute_bookmarks(_win_id, request): + """Handler for qute:bookmarks. Show a list of all quickmarks / bookmarks""" + + bookmarks = objreg.get('bookmark-manager').marks.items() + quickmarks = objreg.get('quickmark-manager').marks.items() + + html = jinja.render('bookmarks.html', + title='Bookmarks', + bookmarks=bookmarks, + quickmarks=quickmarks) + return html.encode('UTF-8', errors='xmlcharrefreplace') diff --git a/qutebrowser/html/bookmarks.html b/qutebrowser/html/bookmarks.html new file mode 100644 index 000000000..c3a874785 --- /dev/null +++ b/qutebrowser/html/bookmarks.html @@ -0,0 +1,48 @@ +{% extends "base.html" %} + +{% block script %} +var win_id = {{ win_id }}; +var cset = function(section, option, el) { + value = el.value; + window.qute.set(win_id, section, option, value); +} +{% endblock %} + +{% block style %} +table { border: 1px solid grey; border-collapse: collapse; width: 100%;} +pre { margin: 2px; } +th, td { border: 1px solid grey; padding: 0px 5px; } +th { background: lightgrey; } +th pre { color: grey; text-align: left; } +.noscript, .noscript-text { color:red; } +.noscript-text { margin-bottom: 5cm; } +h4 { line-height: 1.2em; } +{% endblock %} + +{% block content %} + + + + + + + + {% for url, title in bookmarks %} + + + + + {% endfor %} + + + + + {% for name, url in quickmarks %} + + + + + {% endfor %} +

Bookmark

URL

{{title}}{{url}}

Quickmark

URL

{{name}}{{url}}
+ +{% endblock %} diff --git a/tests/end2end/features/urlmarks.feature b/tests/end2end/features/urlmarks.feature index 8f0136e59..2f965169f 100644 --- a/tests/end2end/features/urlmarks.feature +++ b/tests/end2end/features/urlmarks.feature @@ -186,3 +186,16 @@ Feature: quickmarks and bookmarks When I run :quickmark-add http://localhost:(port)/data/numbers/15.txt fifteen And I run :quickmark-del fifteen Then the quickmark file should not contain "fourteen http://localhost:*/data/numbers/15.txt " + + Scenario: Listing quickmarks + When I run :quickmark-add http://localhost:(port)/data/numbers/15.txt fifteen + And I run :quickmark-add http://localhost:(port)/data/numbers/14.txt fourteen + And I open qute:bookmarks + Then the page should contain the plaintext "fifteen" + And the page should contain the plaintext "fourteen" + + Scenario: Listing bookmarks + When I open data/title.html + And I run :bookmark-add + And I open qute:bookmarks + Then the page should contain the plaintext "Test title"