Make session interval configurable.
This commit is contained in:
parent
fb97c6dffc
commit
724e6b29c3
@ -33,6 +33,7 @@ import urllib.parse
|
||||
from PyQt5.QtCore import QUrlQuery
|
||||
|
||||
import qutebrowser
|
||||
from qutebrowser.config import config
|
||||
from qutebrowser.utils import (version, utils, jinja, log, message, docutils,
|
||||
objreg)
|
||||
from qutebrowser.misc import objects
|
||||
@ -246,7 +247,8 @@ def qute_history(url):
|
||||
|
||||
return 'text/html', json.dumps(list(history))
|
||||
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')
|
||||
|
@ -291,6 +291,12 @@ def data(readonly=False):
|
||||
)),
|
||||
|
||||
('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',
|
||||
SettingValue(typ.List(typ.Perc(minval=0)),
|
||||
'25%,33%,50%,67%,75%,90%,100%,110%,125%,150%,175%,'
|
||||
|
@ -68,6 +68,8 @@ table {
|
||||
<a href="#" id="load" style="display: none">Show more</a>
|
||||
<script type="text/javascript" src="qute://javascript/history.js"></script>
|
||||
<script type="text/javascript">
|
||||
window.SESSION_INTERVAL = {{session_interval}} * 60 * 1000;
|
||||
|
||||
window.onload = function() {
|
||||
var loadLink = document.getElementById('load');
|
||||
loadLink.style.display = null;
|
||||
|
@ -26,9 +26,6 @@ window.loadHistory = (function() {
|
||||
// The time to load next.
|
||||
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.
|
||||
var DATA_URL = "qute://history/data";
|
||||
|
||||
@ -77,9 +74,10 @@ window.loadHistory = (function() {
|
||||
}
|
||||
|
||||
// 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();
|
||||
if (interval > SESSION_CUTOFF) {
|
||||
if (interval > window.SESSION_INTERVAL) {
|
||||
// Add session-separator
|
||||
var sessionSeparator = document.createElement("td");
|
||||
sessionSeparator.className = "session-separator";
|
||||
|
Loading…
Reference in New Issue
Block a user