mirror of
https://github.com/webrecorder/pywb.git
synced 2025-03-15 00:03:28 +01:00
support both frames and non-frames mode
add automatic framing when in framed mode
This commit is contained in:
parent
b4f30a770f
commit
11202c462f
@ -1,16 +1,12 @@
|
||||
|
||||
#_wayback_banner
|
||||
#_wb_plain_banner, #_wb_frame_top_banner
|
||||
{
|
||||
display: block !important;
|
||||
top: 0px !important;
|
||||
left: 0px !important;
|
||||
font-family: "Open Sans", "Helvetica Neue", Helvetica, Arial, sans-serif !important;
|
||||
position: fixed !important;
|
||||
/* padding: 4px !important; */
|
||||
height: 40px !important;
|
||||
width: 100% !important;
|
||||
font-size: 24px !important;
|
||||
/* border: 1px solid !important; */
|
||||
background-color: lightYellow !important;
|
||||
color: black !important;
|
||||
text-align: center !important;
|
||||
@ -18,6 +14,20 @@
|
||||
line-height: normal !important;
|
||||
}
|
||||
|
||||
#_wb_plain_banner
|
||||
{
|
||||
position: absolute !important;
|
||||
padding: 4px !important;
|
||||
border: 1px solid !important;
|
||||
}
|
||||
|
||||
#_wb_frame_top_banner
|
||||
{
|
||||
position: fixed !important;
|
||||
border: 0px;
|
||||
height: 40px !important;
|
||||
}
|
||||
|
||||
.wb_iframe_div
|
||||
{
|
||||
width: 100%;
|
||||
@ -35,18 +45,3 @@
|
||||
height: 100%;
|
||||
border: 4px solid firebrick;
|
||||
}
|
||||
|
||||
.wb_iframe_all
|
||||
{
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
border: none;
|
||||
background-color: firebrick;
|
||||
padding: 44px 4px 4px 4px;
|
||||
box-sizing: border-box;
|
||||
-moz-box-sizing: border-box;
|
||||
-webkit-box-sizing: border-box;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
@ -18,9 +18,8 @@ This file is part of pywb.
|
||||
*/
|
||||
|
||||
function init_banner() {
|
||||
var BANNER_ID = "_wayback_banner";
|
||||
|
||||
var banner = document.getElementById(BANNER_ID);
|
||||
var PLAIN_BANNER_ID = "_wb_plain_banner";
|
||||
var FRAME_BANNER_ID = "_wb_frame_top_banner";
|
||||
|
||||
if (wbinfo.is_embed) {
|
||||
return;
|
||||
@ -30,9 +29,17 @@ function init_banner() {
|
||||
return;
|
||||
}
|
||||
|
||||
if (wbinfo.is_frame) {
|
||||
bid = FRAME_BANNER_ID;
|
||||
} else {
|
||||
bid = PLAIN_BANNER_ID;
|
||||
}
|
||||
|
||||
var banner = document.getElementById(bid);
|
||||
|
||||
if (!banner) {
|
||||
banner = document.createElement("wb_div");
|
||||
banner.setAttribute("id", BANNER_ID);
|
||||
banner.setAttribute("id", bid);
|
||||
banner.setAttribute("lang", "en");
|
||||
|
||||
text = "This is an archived page ";
|
||||
@ -90,9 +97,11 @@ var detect_on_init = function() {
|
||||
|
||||
add_event("readystatechange", detect_on_init, document);
|
||||
|
||||
/*
|
||||
if ((window.self == window.top) && !wbinfo.is_embed && window.location.href.indexOf("/rewrite/fr_/") == -1) {
|
||||
new_loc = window.location.href.replace("/rewrite/", "/rewrite/fr_/");
|
||||
window.location.replace(new_loc);
|
||||
|
||||
if (wbinfo.is_frame_mp && wbinfo.canon_url &&
|
||||
(window.self == window.top) &&
|
||||
window.location.href != wbinfo.canon_url) {
|
||||
|
||||
console.log('frame');
|
||||
window.location.replace(wbinfo.canon_url);
|
||||
}
|
||||
*/
|
||||
|
@ -69,7 +69,7 @@ WB_wombat_init = (function() {
|
||||
}
|
||||
|
||||
//============================================
|
||||
var rewrite_url = rewrite_url_debug;
|
||||
var rewrite_url = rewrite_url_;
|
||||
|
||||
function rewrite_url_debug(url) {
|
||||
rewritten = rewrite_url_(url);
|
||||
|
@ -7,6 +7,7 @@
|
||||
wbinfo.is_embed = false;
|
||||
wbinfo.prefix = "{{ wbrequest.wb_prefix }}";
|
||||
wbinfo.capture_url = "{{ url }}";
|
||||
wbinfo.is_frame = true;
|
||||
</script>
|
||||
<script src='{{ wbrequest.host_prefix }}/{{ static_path }}/wb.js'> </script>
|
||||
<script>
|
||||
@ -30,7 +31,6 @@ function pop_state(url) {
|
||||
}
|
||||
|
||||
function update_url(event) {
|
||||
console.log(event);
|
||||
if (event.source == window.frames[0]) {
|
||||
push_state(event.data);
|
||||
}
|
||||
|
@ -11,7 +11,10 @@
|
||||
<script>
|
||||
wbinfo = {}
|
||||
wbinfo.capture_str = "{{ cdx.timestamp | format_ts }}";
|
||||
wbinfo.prefix = "{{ wbrequest.wb_prefix }}";
|
||||
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.canon_url = "{{ canon_url }}";
|
||||
</script>
|
||||
<script src='{{ wbrequest.host_prefix }}/{{ static_path }}/wb.js'> </script>
|
||||
<link rel='stylesheet' href='{{ wbrequest.host_prefix }}/{{ static_path }}/wb.css'/>
|
||||
|
@ -4,6 +4,7 @@ from pywb.framework.archivalrouter import ArchivalRouter, Route
|
||||
from pywb.framework.proxy import ProxyArchivalRouter
|
||||
from pywb.framework.wbrequestresponse import WbRequest
|
||||
from pywb.framework.memento import MementoRequest
|
||||
from pywb.framework.basehandlers import BaseHandler
|
||||
|
||||
from pywb.warc.recordloader import ArcWarcRecordLoader
|
||||
from pywb.warc.resolvingloader import ResolvingLoader
|
||||
@ -200,6 +201,10 @@ def create_wb_router(passed_config={}):
|
||||
|
||||
for name, value in collections.iteritems():
|
||||
|
||||
if isinstance(value, BaseHandler):
|
||||
routes.append(Route(name, value))
|
||||
continue
|
||||
|
||||
result = init_collection(value, config)
|
||||
route_config, query_handler, ds_rules_file = result
|
||||
|
||||
|
@ -55,13 +55,6 @@ class RewriteHandler(WbUrlHandler): # pragma: no cover
|
||||
req_headers)
|
||||
code = response.status_code
|
||||
|
||||
# remove transfer-encoding as raw stream
|
||||
# is already de-chunked
|
||||
try:
|
||||
del response.headers['transfer-encoding']
|
||||
except KeyError:
|
||||
pass
|
||||
|
||||
headers = response.headers.items()
|
||||
stream = response.raw
|
||||
|
||||
@ -126,18 +119,6 @@ class RewriteHandler(WbUrlHandler): # pragma: no cover
|
||||
return WbResponse(status_headers, gen)
|
||||
|
||||
|
||||
def get_head_insert_func(self, wbrequest, cdx):
|
||||
# no head insert specified
|
||||
if not self.head_insert_view:
|
||||
return None
|
||||
|
||||
def make_head_insert(rule):
|
||||
return (self.head_insert_view.
|
||||
render_to_string(wbrequest=wbrequest,
|
||||
cdx=cdx,
|
||||
rule=rule))
|
||||
return make_head_insert
|
||||
|
||||
def create_rewrite_app(): # pragma: no cover
|
||||
routes = [Route('rewrite', RewriteHandler()),
|
||||
Route('static/default', StaticHandler('pywb/static/'))
|
||||
|
@ -118,9 +118,13 @@ def add_env_globals(glb):
|
||||
#=================================================================
|
||||
class HeadInsertView(J2TemplateView):
|
||||
def create_insert_func(self, wbrequest, cdx):
|
||||
|
||||
canon_url = wbrequest.wb_prefix + wbrequest.wb_url.to_str(mod='')
|
||||
|
||||
def make_head_insert(rule):
|
||||
return (self.render_to_string(wbrequest=wbrequest,
|
||||
cdx=cdx,
|
||||
canon_url=canon_url,
|
||||
rule=rule))
|
||||
return make_head_insert
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user