From 554b9b2bda94f4381b19292b19f50d292f558217 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Maciej=20Wo=C5=82czyk?= Date: Fri, 18 Nov 2016 20:16:43 +0100 Subject: [PATCH 1/6] Added chronicle flag --- qutebrowser/browser/hints.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/qutebrowser/browser/hints.py b/qutebrowser/browser/hints.py index af1827b2f..7ef136ed7 100644 --- a/qutebrowser/browser/hints.py +++ b/qutebrowser/browser/hints.py @@ -602,7 +602,7 @@ class HintManager(QObject): star_args_optional=True, maxsplit=2) @cmdutils.argument('win_id', win_id=True) def start(self, rapid=False, group=webelem.Group.all, target=Target.normal, - *args, win_id, mode=None): + *args, win_id, mode=None, chronicle=False): """Start hinting. Args: @@ -691,6 +691,7 @@ class HintManager(QObject): self._context.target = target self._context.rapid = rapid self._context.hint_mode = mode + self._context.chronicle = chronicle try: self._context.baseurl = tabbed_browser.current_url() except qtutils.QtValueError: @@ -860,6 +861,8 @@ class HintManager(QObject): return handler = functools.partial(url_handlers[self._context.target], url, self._context) + if self._context.chronicle: + objreg.get('web-history').add_from_tab(url, url, "") else: raise ValueError("No suitable handler found!") From bf4113584631be919b2a6f79a861f65e4c6997b7 Mon Sep 17 00:00:00 2001 From: Rahid Date: Fri, 18 Nov 2016 23:10:50 +0100 Subject: [PATCH 2/6] Added chronicle flag to init function, docs --- qutebrowser/browser/hints.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/qutebrowser/browser/hints.py b/qutebrowser/browser/hints.py index 7ef136ed7..ad852ac76 100644 --- a/qutebrowser/browser/hints.py +++ b/qutebrowser/browser/hints.py @@ -152,6 +152,7 @@ class HintContext: to_follow: The link to follow when enter is pressed. args: Custom arguments for userscript/spawn rapid: Whether to do rapid hinting. + chronicle: Whether to add yanked or spawned link to the history. filterstr: Used to save the filter string for restoring in rapid mode. tab: The WebTab object we started hinting in. group: The group of web elements to hint. @@ -164,6 +165,7 @@ class HintContext: self.baseurl = None self.to_follow = None self.rapid = False + self.chronicle = False self.filterstr = None self.args = [] self.tab = None @@ -609,6 +611,8 @@ class HintManager(QObject): rapid: Whether to do rapid hinting. This is only possible with targets `tab` (with background-tabs=true), `tab-bg`, `window`, `run`, `hover`, `userscript` and `spawn`. + chronicle: Whether to add spawned or yanked linked to the + browsing history. group: The element types to hint. - `all`: All clickable elements. From 058c3e6541be297533102f9bc3897296330ea15e Mon Sep 17 00:00:00 2001 From: Rahid Date: Fri, 18 Nov 2016 23:45:12 +0100 Subject: [PATCH 3/6] Trailing spaces --- qutebrowser/browser/hints.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/qutebrowser/browser/hints.py b/qutebrowser/browser/hints.py index ad852ac76..f1d84daa3 100644 --- a/qutebrowser/browser/hints.py +++ b/qutebrowser/browser/hints.py @@ -611,7 +611,7 @@ class HintManager(QObject): rapid: Whether to do rapid hinting. This is only possible with targets `tab` (with background-tabs=true), `tab-bg`, `window`, `run`, `hover`, `userscript` and `spawn`. - chronicle: Whether to add spawned or yanked linked to the + chronicle: Whether to add spawned or yanked linked to the browsing history. group: The element types to hint. @@ -866,7 +866,7 @@ class HintManager(QObject): handler = functools.partial(url_handlers[self._context.target], url, self._context) if self._context.chronicle: - objreg.get('web-history').add_from_tab(url, url, "") + objreg.get('web-history').add_from_tab(url, url, "") else: raise ValueError("No suitable handler found!") From 918b3e2d122aac2b81b71d5fc48b93b5ec2d79fd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Maciej=20Wo=C5=82czyk?= Date: Mon, 21 Nov 2016 15:33:38 +0100 Subject: [PATCH 4/6] History flag: test added, short version changed, minor fixes --- qutebrowser/browser/hints.py | 15 ++++++++------- tests/end2end/features/history.feature | 7 +++++++ 2 files changed, 15 insertions(+), 7 deletions(-) diff --git a/qutebrowser/browser/hints.py b/qutebrowser/browser/hints.py index f1d84daa3..f32389025 100644 --- a/qutebrowser/browser/hints.py +++ b/qutebrowser/browser/hints.py @@ -152,7 +152,7 @@ class HintContext: to_follow: The link to follow when enter is pressed. args: Custom arguments for userscript/spawn rapid: Whether to do rapid hinting. - chronicle: Whether to add yanked or spawned link to the history. + history: Whether to add yanked or spawned link to the history. filterstr: Used to save the filter string for restoring in rapid mode. tab: The WebTab object we started hinting in. group: The group of web elements to hint. @@ -165,7 +165,7 @@ class HintContext: self.baseurl = None self.to_follow = None self.rapid = False - self.chronicle = False + self.history = False self.filterstr = None self.args = [] self.tab = None @@ -603,15 +603,16 @@ class HintManager(QObject): @cmdutils.register(instance='hintmanager', scope='tab', name='hint', star_args_optional=True, maxsplit=2) @cmdutils.argument('win_id', win_id=True) + @cmdutils.argument('history', flag="s") def start(self, rapid=False, group=webelem.Group.all, target=Target.normal, - *args, win_id, mode=None, chronicle=False): + *args, win_id, mode=None, history=False): """Start hinting. Args: rapid: Whether to do rapid hinting. This is only possible with targets `tab` (with background-tabs=true), `tab-bg`, `window`, `run`, `hover`, `userscript` and `spawn`. - chronicle: Whether to add spawned or yanked linked to the + history: Whether to add spawned or yanked link to the browsing history. group: The element types to hint. @@ -695,7 +696,7 @@ class HintManager(QObject): self._context.target = target self._context.rapid = rapid self._context.hint_mode = mode - self._context.chronicle = chronicle + self._context.history = history try: self._context.baseurl = tabbed_browser.current_url() except qtutils.QtValueError: @@ -865,8 +866,8 @@ class HintManager(QObject): return handler = functools.partial(url_handlers[self._context.target], url, self._context) - if self._context.chronicle: - objreg.get('web-history').add_from_tab(url, url, "") + if self._context.history: + objreg.get('web-history').add_url(url, "") else: raise ValueError("No suitable handler found!") diff --git a/tests/end2end/features/history.feature b/tests/end2end/features/history.feature index 05a896be2..0ea1a5352 100644 --- a/tests/end2end/features/history.feature +++ b/tests/end2end/features/history.feature @@ -58,6 +58,13 @@ Feature: Page history And I run :history-clear Then the history file should be empty + Scenario: History with yanked URL and 'add to history' flag + When I open data/hints/html/simple.html + And I hint with args "--history links yank" and follow a + Then the history file should contain: + http://localhost:(port)/data/hints/html/simple.html Simple link + http://localhost:(port)/data/hello.txt + ## Bugs @qtwebengine_skip From 9d19c3aee6fb15e62f7fcc7c7e594cc95c147c37 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Maciej=20Wo=C5=82czyk?= Date: Tue, 22 Nov 2016 17:27:34 +0100 Subject: [PATCH 5/6] Changed add to history option name --- qutebrowser/browser/hints.py | 13 ++++++------- tests/end2end/features/history.feature | 2 +- 2 files changed, 7 insertions(+), 8 deletions(-) diff --git a/qutebrowser/browser/hints.py b/qutebrowser/browser/hints.py index f32389025..3c2b3e50e 100644 --- a/qutebrowser/browser/hints.py +++ b/qutebrowser/browser/hints.py @@ -152,7 +152,7 @@ class HintContext: to_follow: The link to follow when enter is pressed. args: Custom arguments for userscript/spawn rapid: Whether to do rapid hinting. - history: Whether to add yanked or spawned link to the history. + addhistory: Whether to add yanked or spawned link to the history. filterstr: Used to save the filter string for restoring in rapid mode. tab: The WebTab object we started hinting in. group: The group of web elements to hint. @@ -165,7 +165,7 @@ class HintContext: self.baseurl = None self.to_follow = None self.rapid = False - self.history = False + self.addhistory = False self.filterstr = None self.args = [] self.tab = None @@ -603,16 +603,15 @@ class HintManager(QObject): @cmdutils.register(instance='hintmanager', scope='tab', name='hint', star_args_optional=True, maxsplit=2) @cmdutils.argument('win_id', win_id=True) - @cmdutils.argument('history', flag="s") def start(self, rapid=False, group=webelem.Group.all, target=Target.normal, - *args, win_id, mode=None, history=False): + *args, win_id, mode=None, addhistory=False): """Start hinting. Args: rapid: Whether to do rapid hinting. This is only possible with targets `tab` (with background-tabs=true), `tab-bg`, `window`, `run`, `hover`, `userscript` and `spawn`. - history: Whether to add spawned or yanked link to the + addhistory: Whether to add spawned or yanked link to the browsing history. group: The element types to hint. @@ -696,7 +695,7 @@ class HintManager(QObject): self._context.target = target self._context.rapid = rapid self._context.hint_mode = mode - self._context.history = history + self._context.addhistory = addhistory try: self._context.baseurl = tabbed_browser.current_url() except qtutils.QtValueError: @@ -866,7 +865,7 @@ class HintManager(QObject): return handler = functools.partial(url_handlers[self._context.target], url, self._context) - if self._context.history: + if self._context.addhistory: objreg.get('web-history').add_url(url, "") else: raise ValueError("No suitable handler found!") diff --git a/tests/end2end/features/history.feature b/tests/end2end/features/history.feature index 0ea1a5352..fa1fa8fe5 100644 --- a/tests/end2end/features/history.feature +++ b/tests/end2end/features/history.feature @@ -60,7 +60,7 @@ Feature: Page history Scenario: History with yanked URL and 'add to history' flag When I open data/hints/html/simple.html - And I hint with args "--history links yank" and follow a + And I hint with args "--addhistory links yank" and follow a Then the history file should contain: http://localhost:(port)/data/hints/html/simple.html Simple link http://localhost:(port)/data/hello.txt From 81cbd4c8a0470c2cd16b53e2cb293fd73806369b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Maciej=20Wo=C5=82czyk?= Date: Tue, 22 Nov 2016 17:39:13 +0100 Subject: [PATCH 6/6] Hyphen in variable name fixed --- qutebrowser/browser/hints.py | 12 ++++++------ tests/end2end/features/history.feature | 2 +- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/qutebrowser/browser/hints.py b/qutebrowser/browser/hints.py index 3c2b3e50e..778609fb7 100644 --- a/qutebrowser/browser/hints.py +++ b/qutebrowser/browser/hints.py @@ -152,7 +152,7 @@ class HintContext: to_follow: The link to follow when enter is pressed. args: Custom arguments for userscript/spawn rapid: Whether to do rapid hinting. - addhistory: Whether to add yanked or spawned link to the history. + add_history: Whether to add yanked or spawned link to the history. filterstr: Used to save the filter string for restoring in rapid mode. tab: The WebTab object we started hinting in. group: The group of web elements to hint. @@ -165,7 +165,7 @@ class HintContext: self.baseurl = None self.to_follow = None self.rapid = False - self.addhistory = False + self.add_history = False self.filterstr = None self.args = [] self.tab = None @@ -604,14 +604,14 @@ class HintManager(QObject): star_args_optional=True, maxsplit=2) @cmdutils.argument('win_id', win_id=True) def start(self, rapid=False, group=webelem.Group.all, target=Target.normal, - *args, win_id, mode=None, addhistory=False): + *args, win_id, mode=None, add_history=False): """Start hinting. Args: rapid: Whether to do rapid hinting. This is only possible with targets `tab` (with background-tabs=true), `tab-bg`, `window`, `run`, `hover`, `userscript` and `spawn`. - addhistory: Whether to add spawned or yanked link to the + add_history: Whether to add spawned or yanked link to the browsing history. group: The element types to hint. @@ -695,7 +695,7 @@ class HintManager(QObject): self._context.target = target self._context.rapid = rapid self._context.hint_mode = mode - self._context.addhistory = addhistory + self._context.add_history = add_history try: self._context.baseurl = tabbed_browser.current_url() except qtutils.QtValueError: @@ -865,7 +865,7 @@ class HintManager(QObject): return handler = functools.partial(url_handlers[self._context.target], url, self._context) - if self._context.addhistory: + if self._context.add_history: objreg.get('web-history').add_url(url, "") else: raise ValueError("No suitable handler found!") diff --git a/tests/end2end/features/history.feature b/tests/end2end/features/history.feature index fa1fa8fe5..f4f57dcb7 100644 --- a/tests/end2end/features/history.feature +++ b/tests/end2end/features/history.feature @@ -60,7 +60,7 @@ Feature: Page history Scenario: History with yanked URL and 'add to history' flag When I open data/hints/html/simple.html - And I hint with args "--addhistory links yank" and follow a + And I hint with args "--add-history links yank" and follow a Then the history file should contain: http://localhost:(port)/data/hints/html/simple.html Simple link http://localhost:(port)/data/hello.txt