Merge branch 'ismail-s-add-bookmark-by-url'
This commit is contained in:
commit
cb84cbf730
@ -34,6 +34,8 @@ Changed
|
|||||||
`gg` can be used with a count.
|
`gg` can be used with a count.
|
||||||
- Aliases can now use `;;` to have an alias which executed multiple commands.
|
- Aliases can now use `;;` to have an alias which executed multiple commands.
|
||||||
- `:edit-url` now does nothing if the URL isn't changed in the spawned editor.
|
- `:edit-url` now does nothing if the URL isn't changed in the spawned editor.
|
||||||
|
- `:bookmark-add` can now be passed a URL and title to add that as a bookmark
|
||||||
|
rather than the current page.
|
||||||
|
|
||||||
Removed
|
Removed
|
||||||
-------
|
-------
|
||||||
|
@ -179,6 +179,7 @@ Contributors, sorted by the number of commits in descending order:
|
|||||||
* skinnay
|
* skinnay
|
||||||
* Zach-Button
|
* Zach-Button
|
||||||
* Tomasz Kramkowski
|
* Tomasz Kramkowski
|
||||||
|
* Ismail S
|
||||||
* Halfwit
|
* Halfwit
|
||||||
* rikn00
|
* rikn00
|
||||||
* kanikaa1234
|
* kanikaa1234
|
||||||
|
@ -8,7 +8,7 @@
|
|||||||
|<<adblock-update,adblock-update>>|Update the adblock block lists.
|
|<<adblock-update,adblock-update>>|Update the adblock block lists.
|
||||||
|<<back,back>>|Go back in the history of the current tab.
|
|<<back,back>>|Go back in the history of the current tab.
|
||||||
|<<bind,bind>>|Bind a key to a command.
|
|<<bind,bind>>|Bind a key to a command.
|
||||||
|<<bookmark-add,bookmark-add>>|Save the current page as a bookmark.
|
|<<bookmark-add,bookmark-add>>|Save the current page as a bookmark, or a specific url.
|
||||||
|<<bookmark-del,bookmark-del>>|Delete a bookmark.
|
|<<bookmark-del,bookmark-del>>|Delete a bookmark.
|
||||||
|<<bookmark-load,bookmark-load>>|Load a bookmark.
|
|<<bookmark-load,bookmark-load>>|Load a bookmark.
|
||||||
|<<buffer,buffer>>|Select tab by index or url/title best match.
|
|<<buffer,buffer>>|Select tab by index or url/title best match.
|
||||||
@ -116,7 +116,15 @@ Bind a key to a command.
|
|||||||
|
|
||||||
[[bookmark-add]]
|
[[bookmark-add]]
|
||||||
=== bookmark-add
|
=== bookmark-add
|
||||||
Save the current page as a bookmark.
|
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.
|
||||||
|
|
||||||
|
==== positional arguments
|
||||||
|
* +'url'+: url to save as a bookmark. If None, use url of current page.
|
||||||
|
* +'title'+: title of the new bookmark.
|
||||||
|
|
||||||
[[bookmark-del]]
|
[[bookmark-del]]
|
||||||
=== bookmark-del
|
=== bookmark-del
|
||||||
|
@ -1081,12 +1081,33 @@ class CommandDispatcher:
|
|||||||
self._open(url, tab, bg, window)
|
self._open(url, tab, bg, window)
|
||||||
|
|
||||||
@cmdutils.register(instance='command-dispatcher', scope='window')
|
@cmdutils.register(instance='command-dispatcher', scope='window')
|
||||||
def bookmark_add(self):
|
def bookmark_add(self, url=None, title=None):
|
||||||
"""Save the current page as a bookmark."""
|
"""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.
|
||||||
|
|
||||||
|
Args:
|
||||||
|
url: url to save as a bookmark. If None, use url of current page.
|
||||||
|
title: title of the new bookmark.
|
||||||
|
"""
|
||||||
|
if url and not title:
|
||||||
|
raise cmdexc.CommandError('Title must be provided if url has '
|
||||||
|
'been provided')
|
||||||
bookmark_manager = objreg.get('bookmark-manager')
|
bookmark_manager = objreg.get('bookmark-manager')
|
||||||
url = self._current_url()
|
if url is None:
|
||||||
|
url = self._current_url()
|
||||||
|
else:
|
||||||
|
try:
|
||||||
|
url = urlutils.fuzzy_url(url)
|
||||||
|
except urlutils.InvalidUrlError as e:
|
||||||
|
raise cmdexc.CommandError(e)
|
||||||
|
if not title:
|
||||||
|
title = self._current_title()
|
||||||
try:
|
try:
|
||||||
bookmark_manager.add(url, self._current_title())
|
bookmark_manager.add(url, title)
|
||||||
except urlmarks.Error as e:
|
except urlmarks.Error as e:
|
||||||
raise cmdexc.CommandError(str(e))
|
raise cmdexc.CommandError(str(e))
|
||||||
else:
|
else:
|
||||||
|
@ -8,6 +8,20 @@ Feature: quickmarks and bookmarks
|
|||||||
Then the message "Bookmarked http://localhost:*/data/title.html!" should be shown
|
Then the message "Bookmarked http://localhost:*/data/title.html!" should be shown
|
||||||
And the bookmark file should contain "http://localhost:*/data/title.html Test title"
|
And the bookmark file should contain "http://localhost:*/data/title.html Test title"
|
||||||
|
|
||||||
|
Scenario: Saving a bookmark with a provided url and title
|
||||||
|
When I run :bookmark-add http://example.com "some example title"
|
||||||
|
Then the message "Bookmarked http://example.com!" should be shown
|
||||||
|
And the bookmark file should contain "http://example.com some example title"
|
||||||
|
|
||||||
|
Scenario: Saving a bookmark with a url but no title
|
||||||
|
When I run :bookmark-add http://example.com
|
||||||
|
Then the error "Title must be provided if url has been provided" should be shown
|
||||||
|
|
||||||
|
Scenario: Saving a bookmark with an invalid url
|
||||||
|
When I set general -> auto-search to false
|
||||||
|
And I run :bookmark-add foo! "some example title"
|
||||||
|
Then the error "Invalid URL" should be shown
|
||||||
|
|
||||||
Scenario: Saving a duplicate bookmark
|
Scenario: Saving a duplicate bookmark
|
||||||
Given I have a fresh instance
|
Given I have a fresh instance
|
||||||
When I open data/title.html
|
When I open data/title.html
|
||||||
|
Loading…
Reference in New Issue
Block a user