Make session interval configurable.

This commit is contained in:
Imran Sobir 2017-03-16 12:11:16 +05:00
parent fb97c6dffc
commit 724e6b29c3
4 changed files with 14 additions and 6 deletions

View File

@ -33,6 +33,7 @@ import urllib.parse
from PyQt5.QtCore import QUrlQuery from PyQt5.QtCore import QUrlQuery
import qutebrowser import qutebrowser
from qutebrowser.config import config
from qutebrowser.utils import (version, utils, jinja, log, message, docutils, from qutebrowser.utils import (version, utils, jinja, log, message, docutils,
objreg) objreg)
from qutebrowser.misc import objects from qutebrowser.misc import objects
@ -246,7 +247,8 @@ def qute_history(url):
return 'text/html', json.dumps(list(history)) return 'text/html', json.dumps(list(history))
else: else:
return 'text/html', jinja.render('history.html', title='History') return 'text/html', jinja.render('history.html', title='History',
session_interval=config.get('ui', 'history-session-interval'))
@add_handler('javascript') @add_handler('javascript')

View File

@ -291,6 +291,12 @@ def data(readonly=False):
)), )),
('ui', sect.KeyValue( ('ui', sect.KeyValue(
('history-session-interval',
SettingValue(typ.Int(), '30'),
"The maximum time in minutes between two history items for them "
"to be considered being from the same session. Use -1 to "
"disable separation."),
('zoom-levels', ('zoom-levels',
SettingValue(typ.List(typ.Perc(minval=0)), SettingValue(typ.List(typ.Perc(minval=0)),
'25%,33%,50%,67%,75%,90%,100%,110%,125%,150%,175%,' '25%,33%,50%,67%,75%,90%,100%,110%,125%,150%,175%,'

View File

@ -68,6 +68,8 @@ table {
<a href="#" id="load" style="display: none">Show more</a> <a href="#" id="load" style="display: none">Show more</a>
<script type="text/javascript" src="qute://javascript/history.js"></script> <script type="text/javascript" src="qute://javascript/history.js"></script>
<script type="text/javascript"> <script type="text/javascript">
window.SESSION_INTERVAL = {{session_interval}} * 60 * 1000;
window.onload = function() { window.onload = function() {
var loadLink = document.getElementById('load'); var loadLink = document.getElementById('load');
loadLink.style.display = null; loadLink.style.display = null;

View File

@ -26,9 +26,6 @@ window.loadHistory = (function() {
// The time to load next. // The time to load next.
var nextTime = null; var nextTime = null;
// The cutoff interval for session-separator (30 minutes in milliseconds).
var SESSION_CUTOFF = 30 * 60 * 1000;
// The URL to fetch data from. // The URL to fetch data from.
var DATA_URL = "qute://history/data"; var DATA_URL = "qute://history/data";
@ -77,9 +74,10 @@ window.loadHistory = (function() {
} }
// Create session-separator and new tbody if necessary // Create session-separator and new tbody if necessary
if (tbody.lastChild !== null && lastItemDate !== null) { if (tbody.lastChild !== null && lastItemDate !== null &&
window.SESSION_INTERVAL > 0) {
var interval = lastItemDate.getTime() - date.getTime(); var interval = lastItemDate.getTime() - date.getTime();
if (interval > SESSION_CUTOFF) { if (interval > window.SESSION_INTERVAL) {
// Add session-separator // Add session-separator
var sessionSeparator = document.createElement("td"); var sessionSeparator = document.createElement("td");
sessionSeparator.className = "session-separator"; sessionSeparator.className = "session-separator";