diff --git a/qutebrowser/browser/commands.py b/qutebrowser/browser/commands.py index 5192ac895..42b91f737 100644 --- a/qutebrowser/browser/commands.py +++ b/qutebrowser/browser/commands.py @@ -1104,6 +1104,9 @@ class CommandDispatcher: If a url and title have been provided, then save the given url as a bookmark with the provided title. + You can view all saved bookmarks on the + link:qute://bookmarks[bookmarks page]. + Args: url: url to save as a bookmark. If None, use url of current page. title: title of the new bookmark. diff --git a/qutebrowser/browser/urlmarks.py b/qutebrowser/browser/urlmarks.py index df1302535..e7b78c310 100644 --- a/qutebrowser/browser/urlmarks.py +++ b/qutebrowser/browser/urlmarks.py @@ -178,6 +178,9 @@ class QuickmarkManager(UrlMarkManager): def quickmark_add(self, win_id, url, name): """Add a new quickmark. + You can view all saved quickmarks on the + link:qute://bookmarks[bookmarks page]. + Args: win_id: The window ID to display the errors in. url: The url to add as quickmark. diff --git a/qutebrowser/browser/webkit/network/qutescheme.py b/qutebrowser/browser/webkit/network/qutescheme.py index bfa722d43..85be4ceff 100644 --- a/qutebrowser/browser/webkit/network/qutescheme.py +++ b/qutebrowser/browser/webkit/network/qutescheme.py @@ -261,3 +261,18 @@ 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. Display all quickmarks / bookmarks.""" + bookmarks = sorted(objreg.get('bookmark-manager').marks.items(), + key=lambda x: x[1]) # Sort by title + quickmarks = sorted(objreg.get('quickmark-manager').marks.items(), + key=lambda x: x[0]) # Sort by name + + 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..2f82453ab --- /dev/null +++ b/qutebrowser/html/bookmarks.html @@ -0,0 +1,34 @@ +{% extends "base.html" %} + +{% block style %} +table { border: 1px solid grey; border-collapse: collapse; width: 100%;} +th, td { border: 1px solid grey; padding: 0px 5px; } +th { background: lightgrey; } +{% 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..010d87f90 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"