From a15aa9eade99d74d4b47a8c473c331e13359322c Mon Sep 17 00:00:00 2001 From: Imran Sobir Date: Thu, 9 Feb 2017 17:18:57 +0500 Subject: [PATCH] Hide next links to future. --- qutebrowser/browser/qutescheme.py | 7 ++++--- qutebrowser/html/history.html | 8 +++++--- tests/unit/browser/test_qutescheme.py | 10 ++++++++++ 3 files changed, 19 insertions(+), 6 deletions(-) diff --git a/qutebrowser/browser/qutescheme.py b/qutebrowser/browser/qutescheme.py index 1b51f405b..602dce336 100644 --- a/qutebrowser/browser/qutescheme.py +++ b/qutebrowser/browser/qutescheme.py @@ -207,9 +207,10 @@ def qute_history(url): html = jinja.render('history.html', title='History', history=history, - curr_date=curr_date.strftime("%a, %d %B %Y"), - next_date=next_date.strftime("%Y-%m-%d"), - prev_date=prev_date.strftime("%Y-%m-%d")) + curr_date=curr_date, + next_date=next_date, + prev_date=prev_date, + today=datetime.date.today()) return 'text/html', html diff --git a/qutebrowser/html/history.html b/qutebrowser/html/history.html index 35bb79b39..e117d7e80 100644 --- a/qutebrowser/html/history.html +++ b/qutebrowser/html/history.html @@ -70,7 +70,7 @@ tr:nth-child(odd) { {% block content %} -

Browsing history {{curr_date}}

+

Browsing history {{curr_date.strftime("%a, %d %B %Y")}}

@@ -83,7 +83,9 @@ tr:nth-child(odd) {
-Previous -Next +Previous +{% if today >= next_date %} +Next +{% endif %} {% endblock %} diff --git a/tests/unit/browser/test_qutescheme.py b/tests/unit/browser/test_qutescheme.py index 08a3eaf1b..5db896c83 100644 --- a/tests/unit/browser/test_qutescheme.py +++ b/tests/unit/browser/test_qutescheme.py @@ -99,3 +99,13 @@ class TestHistoryHandler: assert "today" not in data assert "tomorrow" in data assert "yesterday" not in data + + def test_no_next_link_to_future(self): + """Ensure there's no next link pointing to the future.""" + url = QUrl("qute://history") + _mimetype, data = qutescheme.qute_history(url) + assert "Next" not in data + + url = QUrl("qute://history?date=" + self.next_date.strftime("%Y-%m-%d")) + _mimetype, data = qutescheme.qute_history(url) + assert "Next" not in data