Merge branch 'winged-issue_1033_bookmark_display'

This commit is contained in:
Florian Bruhin 2016-07-23 15:48:41 +02:00
commit 3d4a01ef4c
8 changed files with 73 additions and 1 deletions

View File

@ -31,6 +31,7 @@ Added
- New `:repeat-command` command (mapped to `.`) to repeat the last command.
Note that two former default bundings conflict with that binding, unbinding
them via `:unbind .i` and `:unbind .o` is recommended.
- New `qute:bookmarks` page which displays all bookmarks and quickmarks.
Changed
~~~~~~~

View File

@ -181,6 +181,7 @@ Contributors, sorted by the number of commits in descending order:
* Tomasz Kramkowski
* Ismail S
* Halfwit
* David Vogt
* rikn00
* kanikaa1234
* haitaka

View File

@ -120,7 +120,7 @@ Syntax: +:bookmark-add ['url'] ['title']+
Save the current page as a bookmark, or a specific url.
If no url and title are provided, then save the current page as a bookmark. If a url and title have been provided, then save the given url as a bookmark with the provided title.
If no url and title are provided, then save the current page as a bookmark. 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].
==== positional arguments
* +'url'+: url to save as a bookmark. If None, use url of current page.
@ -512,6 +512,8 @@ Syntax: +:quickmark-add 'url' 'name'+
Add a new quickmark.
You can view all saved quickmarks on the link:qute://bookmarks[bookmarks page].
==== positional arguments
* +'url'+: The url to add as quickmark.
* +'name'+: The name for the new quickmark.

View File

@ -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.

View File

@ -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.

View File

@ -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')

View File

@ -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 %}
<table>
<tr>
<th><h3>Bookmark</h3></th>
<th><h3>URL</h3></th>
</tr>
{% for url, title in bookmarks %}
<tr>
<td><a href="{{url}}">{{title}}</a></td>
<td>{{url}}</td>
</tr>
{% endfor %}
<tr>
<th><h3>Quickmark</h3></th>
<th><h3>URL</h3></th>
</tr>
{% for name, url in quickmarks %}
<tr>
<td><a href="{{url}}">{{name}}</a></td>
<td>{{url}}</td>
</tr>
{% endfor %}
</table>
{% endblock %}

View File

@ -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"