1
0
mirror of https://github.com/webrecorder/pywb.git synced 2025-03-15 00:03:28 +01:00

static files:

- formatted them according to project
 - query.js: ensured correct timestamp to date function is used
templates:
 - head_insert.html: is_framed check is no longer a string it is a boolean, corrected redirect check
tests:
 - test_html_rewriter.py: added missing rewrite modifier test checking i.style containing a background image html encoded
 warcserver:
  - added missing quote_plus import and cleaned up imports
This commit is contained in:
John Berlin 2019-09-04 14:28:54 -04:00
parent 61b6ff21e1
commit e34606cecb
No known key found for this signature in database
GPG Key ID: 6EF5E4B442011B02
4 changed files with 12 additions and 18 deletions

View File

@ -256,7 +256,7 @@ r"""
<i style="background-image: url(&quot;/web/20131226101010oe_/http://foo.example.com/&quot;)"></i> <i style="background-image: url(&quot;/web/20131226101010oe_/http://foo.example.com/&quot;)"></i>
>>> parse('<i style=\'background-image: url(&#x27;http://foo.example.com/&#x27;)\'></i>') >>> parse('<i style=\'background-image: url(&#x27;http://foo.example.com/&#x27;)\'></i>')
<i style="background-image: url('/web/20131226101010/http://foo.example.com/')"></i> <i style="background-image: url('/web/20131226101010oe_/http://foo.example.com/')"></i>
>>> parse("<i style='background-image: url(&apos;http://foo.example.com/&apos;)'></i>") >>> parse("<i style='background-image: url(&apos;http://foo.example.com/&apos;)'></i>")
<i style="background-image: url(&apos;/web/20131226101010oe_/http://foo.example.com/&apos;)"></i> <i style="background-image: url(&apos;/web/20131226101010oe_/http://foo.example.com/&apos;)"></i>

View File

@ -249,14 +249,12 @@ RenderCalendar.prototype.makeCDXRequest = function() {
var queryWorker = new window.Worker(this.staticPrefix + '/queryWorker.js'); var queryWorker = new window.Worker(this.staticPrefix + '/queryWorker.js');
var cdxRecordMsg = 'cdxRecord'; var cdxRecordMsg = 'cdxRecord';
var done = 'finished'; var done = 'finished';
var months = this.text.months; var months = this.text.months;
queryWorker.onmessage = function(msg) { queryWorker.onmessage = function(msg) {
var data = msg.data; var data = msg.data;
var terminate = false; var terminate = false;
if (data.type === cdxRecordMsg) { if (data.type === cdxRecordMsg) {
data.timeInfo.month = months[data.timeInfo.month]; data.timeInfo.month = months[data.timeInfo.month];
// render the results sent to us from the worker // render the results sent to us from the worker
@ -586,9 +584,14 @@ RenderCalendar.prototype.renderDateCalPart = function(
* Updates the advanced view with the supplied cdx information * Updates the advanced view with the supplied cdx information
* @param {Object} cdxObj - CDX object for this capture * @param {Object} cdxObj - CDX object for this capture
*/ */
RenderCalendar.prototype.renderAdvancedSearchPart = function (cdxObj) { RenderCalendar.prototype.renderAdvancedSearchPart = function(cdxObj) {
// display the URL of the result // display the URL of the result
var displayedInfo = [{ tag: 'small', innerText: this.text.dateTime + this.ts_to_date(cdxObj.timestamp) }]; var displayedInfo = [
{
tag: 'small',
innerText: this.text.dateTime + this.tsToDate(cdxObj.timestamp)
}
];
// display additional information about the result under the URL // display additional information about the result under the URL
if (cdxObj.mime) { if (cdxObj.mime) {
displayedInfo.push({ displayedInfo.push({
@ -1024,7 +1027,7 @@ RenderCalendar.prototype.dateOrdinal = function(d) {
* @param {boolean} [is_gmt] - Should the timestamp be converted to a gmt string * @param {boolean} [is_gmt] - Should the timestamp be converted to a gmt string
* @returns {string} * @returns {string}
*/ */
RenderCalendar.prototype.tsToDate = function ts_to_date(ts, is_gmt) { RenderCalendar.prototype.tsToDate = function(ts, is_gmt) {
if (ts.length < 14) return ts; if (ts.length < 14) return ts;
var datestr = var datestr =
ts.substring(0, 4) + ts.substring(0, 4) +

View File

@ -3,7 +3,7 @@
{% set urlsplit = cdx.url | urlsplit %} {% set urlsplit = cdx.url | urlsplit %}
wbinfo = {}; wbinfo = {};
wbinfo.top_url = "{{ top_url }}"; wbinfo.top_url = "{{ top_url }}";
{% if is_framed == 'true' %} {% if is_framed %}
// Fast Top-Frame Redirect // Fast Top-Frame Redirect
if (window == window.top && wbinfo.top_url) { if (window == window.top && wbinfo.top_url) {
var loc = window.location.href.replace(window.location.hash, ""); var loc = window.location.href.replace(window.location.hash, "");

View File

@ -1,21 +1,12 @@
import logging from six.moves.urllib.parse import quote_plus
import re
import redis
import requests
from warcio.timeutils import PAD_14_DOWN, http_date_to_timestamp, pad_timestamp, timestamp_now, timestamp_to_http_date from warcio.timeutils import PAD_14_DOWN, http_date_to_timestamp, pad_timestamp, timestamp_now, timestamp_to_http_date
from pywb.utils.binsearch import iter_range from pywb.utils.binsearch import iter_range
from pywb.utils.canonicalize import canonicalize from pywb.utils.canonicalize import canonicalize
from pywb.utils.wbexception import NotFoundException, BadRequestException
from warcio.timeutils import timestamp_to_http_date, http_date_to_timestamp
from warcio.timeutils import timestamp_now, pad_timestamp, PAD_14_DOWN
from pywb.utils.format import res_template from pywb.utils.format import res_template
from pywb.utils.io import no_except_close from pywb.utils.io import no_except_close
from pywb.utils.memento import MementoUtils from pywb.utils.memento import MementoUtils
from pywb.utils.wbexception import NotFoundException from pywb.utils.wbexception import BadRequestException, NotFoundException
from pywb.warcserver.http import DefaultAdapters from pywb.warcserver.http import DefaultAdapters
from pywb.warcserver.index.cdxobject import CDXObject from pywb.warcserver.index.cdxobject import CDXObject
from pywb.warcserver.index.cdxops import cdx_sort_closest from pywb.warcserver.index.cdxops import cdx_sort_closest