mirror of
https://github.com/webrecorder/pywb.git
synced 2025-03-24 06:59:52 +01:00
banner: remove client side 'capture_str' formatting, just output wbinfo.timestamp,
allow js to format as needed, also helps with #41 update tests to only look at timestamp
This commit is contained in:
parent
103a1c6455
commit
ef8d910d01
@ -66,7 +66,10 @@ function init_banner() {
|
|||||||
|
|
||||||
text = "<span id='_wb_label'>" + text + "</span>";
|
text = "<span id='_wb_label'>" + text + "</span>";
|
||||||
|
|
||||||
var capture_str = (wbinfo ? wbinfo.capture_str : "");
|
var capture_str = "";
|
||||||
|
if (wbinfo && wbinfo.timestamp) {
|
||||||
|
capture_str = ts_to_date(wbinfo.timestamp, true);
|
||||||
|
}
|
||||||
|
|
||||||
text += "<b id='_wb_capture_info'>" + capture_str + "</b>";
|
text += "<b id='_wb_capture_info'>" + capture_str + "</b>";
|
||||||
|
|
||||||
@ -75,6 +78,27 @@ function init_banner() {
|
|||||||
document.body.insertBefore(banner, document.body.firstChild);
|
document.body.insertBefore(banner, document.body.firstChild);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function ts_to_date(ts, is_gmt)
|
||||||
|
{
|
||||||
|
if (ts.length < 14) {
|
||||||
|
return ts;
|
||||||
|
}
|
||||||
|
|
||||||
|
var datestr = (ts.substring(0, 4) + "-" +
|
||||||
|
ts.substring(4, 6) + "-" +
|
||||||
|
ts.substring(6, 8) + "T" +
|
||||||
|
ts.substring(8, 10) + ":" +
|
||||||
|
ts.substring(10, 12) + ":" +
|
||||||
|
ts.substring(12, 14) + "-00:00");
|
||||||
|
|
||||||
|
var date = new Date(datestr);
|
||||||
|
if (is_gmt) {
|
||||||
|
return date.toGMTString();
|
||||||
|
} else {
|
||||||
|
return date.toLocaleString();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
function add_event(name, func, object) {
|
function add_event(name, func, object) {
|
||||||
if (object.addEventListener) {
|
if (object.addEventListener) {
|
||||||
object.addEventListener(name, func);
|
object.addEventListener(name, func);
|
||||||
@ -116,7 +140,6 @@ if (wbinfo.is_frame_mp && wbinfo.canon_url &&
|
|||||||
}
|
}
|
||||||
|
|
||||||
return {'labels': labels,
|
return {'labels': labels,
|
||||||
'add_event': add_event,
|
'ts_to_date': ts_to_date};
|
||||||
'remove_event': remove_event};
|
|
||||||
|
|
||||||
})();
|
})();
|
||||||
|
@ -19,21 +19,6 @@ function make_inner_url(url, ts)
|
|||||||
}
|
}
|
||||||
|
|
||||||
function push_state(url, timestamp, capture_str, is_live) {
|
function push_state(url, timestamp, capture_str, is_live) {
|
||||||
/* var curr_href = null;
|
|
||||||
|
|
||||||
if (window.frames[0].WB_wombat_location) {
|
|
||||||
curr_href = window.frames[0].WB_wombat_location.href;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (url != curr_href) {
|
|
||||||
update_status(capture_str, is_live);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!timestamp) {
|
|
||||||
timestamp = extract_ts(window.frames[0].location.href);
|
|
||||||
}
|
|
||||||
*/
|
|
||||||
var state = {}
|
var state = {}
|
||||||
state.timestamp = timestamp;
|
state.timestamp = timestamp;
|
||||||
state.outer_url = make_outer_url(url, state.timestamp);
|
state.outer_url = make_outer_url(url, state.timestamp);
|
||||||
@ -94,27 +79,6 @@ function update_status(str, is_live) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function ts_to_date(ts, is_gmt)
|
|
||||||
{
|
|
||||||
if (ts.length < 14) {
|
|
||||||
return ts;
|
|
||||||
}
|
|
||||||
|
|
||||||
var datestr = (ts.substring(0, 4) + "-" +
|
|
||||||
ts.substring(4, 6) + "-" +
|
|
||||||
ts.substring(6, 8) + "T" +
|
|
||||||
ts.substring(8, 10) + ":" +
|
|
||||||
ts.substring(10, 12) + ":" +
|
|
||||||
ts.substring(12, 14) + "-00:00");
|
|
||||||
|
|
||||||
var date = new Date(datestr);
|
|
||||||
if (is_gmt) {
|
|
||||||
return date.toGMTString();
|
|
||||||
} else {
|
|
||||||
return date.toLocaleString();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
window.onpopstate = function(event) {
|
window.onpopstate = function(event) {
|
||||||
var curr_state = event.state;
|
var curr_state = event.state;
|
||||||
|
|
||||||
@ -149,15 +113,14 @@ function iframe_loaded(event) {
|
|||||||
if (iframe.wbinfo) {
|
if (iframe.wbinfo) {
|
||||||
ts = iframe.wbinfo.timestamp;
|
ts = iframe.wbinfo.timestamp;
|
||||||
is_live = iframe.wbinfo.is_live;
|
is_live = iframe.wbinfo.is_live;
|
||||||
capture_str = iframe.wbinfo.capture_str;
|
|
||||||
} else {
|
} else {
|
||||||
ts = extract_ts(iframe.location.href);
|
ts = extract_ts(iframe.location.href);
|
||||||
if (!ts) {
|
if (!ts) {
|
||||||
is_live = true;
|
is_live = true;
|
||||||
ts = extract_ts_cookie(iframe.document.cookie);
|
ts = extract_ts_cookie(iframe.document.cookie);
|
||||||
}
|
}
|
||||||
capture_str = ts_to_date(ts, true);
|
|
||||||
}
|
}
|
||||||
|
capture_str = _wb_js.ts_to_date(ts, true);
|
||||||
|
|
||||||
update_wb_url(url, ts, capture_str, is_live);
|
update_wb_url(url, ts, capture_str, is_live);
|
||||||
}
|
}
|
||||||
|
@ -3,7 +3,6 @@
|
|||||||
<!-- Start WB Insert -->
|
<!-- Start WB Insert -->
|
||||||
<script>
|
<script>
|
||||||
wbinfo = {}
|
wbinfo = {}
|
||||||
wbinfo.capture_str = " ";
|
|
||||||
wbinfo.is_embed = false;
|
wbinfo.is_embed = false;
|
||||||
wbinfo.prefix = "{{ wbrequest.wb_prefix }}";
|
wbinfo.prefix = "{{ wbrequest.wb_prefix }}";
|
||||||
wbinfo.capture_url = "{{ url }}";
|
wbinfo.capture_url = "{{ url }}";
|
||||||
|
@ -13,7 +13,6 @@
|
|||||||
<script>
|
<script>
|
||||||
wbinfo = {}
|
wbinfo = {}
|
||||||
wbinfo.timestamp = "{{ cdx.timestamp }}";
|
wbinfo.timestamp = "{{ cdx.timestamp }}";
|
||||||
wbinfo.capture_str = "{{ cdx.timestamp | format_ts }}";
|
|
||||||
wbinfo.prefix = "{{ wbrequest.wb_prefix }}";
|
wbinfo.prefix = "{{ wbrequest.wb_prefix }}";
|
||||||
wbinfo.is_embed = {{"true" if wbrequest.wb_url.is_embed else "false"}};
|
wbinfo.is_embed = {{"true" if wbrequest.wb_url.is_embed else "false"}};
|
||||||
wbinfo.is_frame_mp = {{"true" if wbrequest.wb_url.mod == 'mp_' else "false"}};
|
wbinfo.is_frame_mp = {{"true" if wbrequest.wb_url.mod == 'mp_' else "false"}};
|
||||||
|
@ -35,7 +35,8 @@ class RewriteHandler(SearchPageWbUrlHandler):
|
|||||||
except Exception as exc:
|
except Exception as exc:
|
||||||
url = wbrequest.wb_url.url
|
url = wbrequest.wb_url.url
|
||||||
msg = 'Could not load the url from the live web: ' + url
|
msg = 'Could not load the url from the live web: ' + url
|
||||||
raise LiveResourceException(msg=msg, url=url)
|
#raise LiveResourceException(msg=msg, url=url)
|
||||||
|
raise
|
||||||
|
|
||||||
def _live_request_headers(self, wbrequest):
|
def _live_request_headers(self, wbrequest):
|
||||||
return {}
|
return {}
|
||||||
|
@ -41,7 +41,7 @@ class template_filter(object):
|
|||||||
@template_filter
|
@template_filter
|
||||||
def format_ts(value, format_='%a, %b %d %Y %H:%M:%S'):
|
def format_ts(value, format_='%a, %b %d %Y %H:%M:%S'):
|
||||||
value = timestamp_to_datetime(value)
|
value = timestamp_to_datetime(value)
|
||||||
return value.strftime(format_) + ' GMT'
|
return value.strftime(format_)
|
||||||
|
|
||||||
|
|
||||||
@template_filter('urlsplit')
|
@template_filter('urlsplit')
|
||||||
|
@ -96,7 +96,7 @@ class TestWb:
|
|||||||
resp = self.testapp.get('/pywb/20140127171238mp_/http://www.iana.org/')
|
resp = self.testapp.get('/pywb/20140127171238mp_/http://www.iana.org/')
|
||||||
self._assert_basic_html(resp)
|
self._assert_basic_html(resp)
|
||||||
|
|
||||||
assert 'Mon, Jan 27 2014 17:12:38' in resp.body
|
assert '"20140127171238"' in resp.body
|
||||||
assert 'wb.js' in resp.body
|
assert 'wb.js' in resp.body
|
||||||
assert 'WB_wombat_init' in resp.body
|
assert 'WB_wombat_init' in resp.body
|
||||||
assert '/pywb/20140127171238mp_/http://www.iana.org/time-zones"' in resp.body
|
assert '/pywb/20140127171238mp_/http://www.iana.org/time-zones"' in resp.body
|
||||||
@ -105,7 +105,7 @@ class TestWb:
|
|||||||
resp = self.testapp.get('/pywb-nonframe/20140127171238/http://www.iana.org/')
|
resp = self.testapp.get('/pywb-nonframe/20140127171238/http://www.iana.org/')
|
||||||
self._assert_basic_html(resp)
|
self._assert_basic_html(resp)
|
||||||
|
|
||||||
assert 'Mon, Jan 27 2014 17:12:38' in resp.body
|
assert '"20140127171238"' in resp.body
|
||||||
assert 'wb.js' in resp.body
|
assert 'wb.js' in resp.body
|
||||||
assert '/pywb-nonframe/20140127171238/http://www.iana.org/time-zones"' in resp.body
|
assert '/pywb-nonframe/20140127171238/http://www.iana.org/time-zones"' in resp.body
|
||||||
|
|
||||||
@ -113,7 +113,7 @@ class TestWb:
|
|||||||
resp = self.testapp.get('/pywb-nosurt/20140103030321mp_/http://example.com?example=1')
|
resp = self.testapp.get('/pywb-nosurt/20140103030321mp_/http://example.com?example=1')
|
||||||
self._assert_basic_html(resp)
|
self._assert_basic_html(resp)
|
||||||
|
|
||||||
assert 'Fri, Jan 03 2014 03:03:21' in resp.body
|
assert '"20140103030321"' in resp.body
|
||||||
assert 'wb.js' in resp.body
|
assert 'wb.js' in resp.body
|
||||||
assert '/pywb-nosurt/20140103030321mp_/http://www.iana.org/domains/example' in resp.body
|
assert '/pywb-nosurt/20140103030321mp_/http://www.iana.org/domains/example' in resp.body
|
||||||
|
|
||||||
@ -121,7 +121,7 @@ class TestWb:
|
|||||||
resp = self.testapp.get('/pywb/20140603030341mp_/http://example.com?example=2')
|
resp = self.testapp.get('/pywb/20140603030341mp_/http://example.com?example=2')
|
||||||
self._assert_basic_html(resp)
|
self._assert_basic_html(resp)
|
||||||
|
|
||||||
assert 'Tue, Jun 03 2014 03:03:41' in resp.body
|
assert '"20140603030341"' in resp.body
|
||||||
assert 'wb.js' in resp.body
|
assert 'wb.js' in resp.body
|
||||||
assert '/pywb/20140603030341mp_/http://www.iana.org/domains/example' in resp.body
|
assert '/pywb/20140603030341mp_/http://www.iana.org/domains/example' in resp.body
|
||||||
|
|
||||||
@ -129,7 +129,7 @@ class TestWb:
|
|||||||
resp = self.testapp.get('/pywb/20130729195151mp_/http://www.example.com/')
|
resp = self.testapp.get('/pywb/20130729195151mp_/http://www.example.com/')
|
||||||
self._assert_basic_html(resp)
|
self._assert_basic_html(resp)
|
||||||
|
|
||||||
assert 'Mon, Jul 29 2013 19:51:51' in resp.body
|
assert '"20130729195151"' in resp.body
|
||||||
assert 'wb.js' in resp.body
|
assert 'wb.js' in resp.body
|
||||||
assert '/pywb/20130729195151mp_/http://www.iana.org/domains/example"' in resp.body
|
assert '/pywb/20130729195151mp_/http://www.iana.org/domains/example"' in resp.body
|
||||||
|
|
||||||
@ -215,7 +215,7 @@ class TestWb:
|
|||||||
|
|
||||||
#check resp
|
#check resp
|
||||||
self._assert_basic_html(resp)
|
self._assert_basic_html(resp)
|
||||||
assert 'Mon, Jan 27 2014 17:12:51' in resp.body
|
assert '"20140127171251"' in resp.body
|
||||||
assert '/pywb/20140127171251mp_/http://www.iana.org/domains/example' in resp.body
|
assert '/pywb/20140127171251mp_/http://www.iana.org/domains/example' in resp.body
|
||||||
|
|
||||||
def test_redirect_relative_3(self):
|
def test_redirect_relative_3(self):
|
||||||
@ -337,7 +337,7 @@ class TestWb:
|
|||||||
resp = self.testapp.get('/x-ignore-this-x', extra_environ = dict(REQUEST_URI = 'http://www.iana.org/domains/idn-tables', SCRIPT_NAME = ''))
|
resp = self.testapp.get('/x-ignore-this-x', extra_environ = dict(REQUEST_URI = 'http://www.iana.org/domains/idn-tables', SCRIPT_NAME = ''))
|
||||||
self._assert_basic_html(resp)
|
self._assert_basic_html(resp)
|
||||||
|
|
||||||
assert 'Sun, Jan 26 2014 20:11:27' in resp.body
|
assert '"20140126201127"' in resp.body
|
||||||
assert 'wb.js' in resp.body
|
assert 'wb.js' in resp.body
|
||||||
|
|
||||||
def test_proxy_replay_auth_filtered(self):
|
def test_proxy_replay_auth_filtered(self):
|
||||||
@ -347,7 +347,7 @@ class TestWb:
|
|||||||
|
|
||||||
self._assert_basic_html(resp)
|
self._assert_basic_html(resp)
|
||||||
|
|
||||||
assert 'Sun, Jan 26 2014 20:06:24' in resp.body
|
assert '"20140126200624"' in resp.body
|
||||||
assert 'wb.js' in resp.body
|
assert 'wb.js' in resp.body
|
||||||
|
|
||||||
def test_proxy_replay_auth(self):
|
def test_proxy_replay_auth(self):
|
||||||
@ -357,7 +357,7 @@ class TestWb:
|
|||||||
|
|
||||||
self._assert_basic_html(resp)
|
self._assert_basic_html(resp)
|
||||||
|
|
||||||
assert 'Mon, Jan 27 2014 17:12:38' in resp.body
|
assert '"20140127171238"' in resp.body
|
||||||
assert 'wb.js' in resp.body
|
assert 'wb.js' in resp.body
|
||||||
|
|
||||||
def test_proxy_replay_auth_no_coll(self):
|
def test_proxy_replay_auth_no_coll(self):
|
||||||
|
Loading…
x
Reference in New Issue
Block a user