Skip to content

Commit

Permalink
www: override info.cern.ch and cernvax.cern.ch to allow for loading d…
Browse files Browse the repository at this point in the history
…efault.html from proxy server!

proxy serves default.html and rewritten content from pywb, filtering out most headers to avoid breaking browser
add icon for www
pywb: use blank header, /all/ endpoint
app: set default dims to 1024x768, add per-browser override configurable in config.yaml
addresses oldweb-today#20
  • Loading branch information
ikreymer committed Dec 24, 2015
1 parent 454a1d4 commit effbc82
Show file tree
Hide file tree
Showing 12 changed files with 95 additions and 9 deletions.
6 changes: 4 additions & 2 deletions app/config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -66,10 +66,12 @@ browsers:
- id: www
name: 'WWW'
os: 'NextSTEP'
icon: 'firefox.png'
icon: 'next-www.png'
path: www
version: '1.0'
about: ''
about: 'https://en.wikipedia.org/wiki/WorldWideWeb'
req_width: 1120
req_height: 856

# mosaic
- id: mosaic
Expand Down
6 changes: 6 additions & 0 deletions app/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,12 @@ def new_container(self, browser_id, env=None, default_host=None):
if not browser:
browser = self.browser_paths.get(self.default_browser)

if browser.get('req_width'):
env['SCREEN_WIDTH'] = browser.get('req_width')

if browser.get('req_height'):
env['SCREEN_HEIGHT'] = browser.get('req_height')

container = self.cli.create_container(image=self.image_prefix + '/' + browser['id'],
ports=[self.VNC_PORT, self.CMD_PORT],
environment=env,
Expand Down
5 changes: 5 additions & 0 deletions app/static/dropdown.css
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,11 @@
line-height: 0;
}

#browser-icon {
width: 32px;
height: 32px;
}

#browser-text {
line-height: 58px;
}
Expand Down
Binary file added app/static/icons/next-www.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion app/static/main.css
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ iframe {

/* replay page */

#page-replay {overflow: hidden;}
#page-replay {overflow: inherit;}

/* fonts */

Expand Down
2 changes: 2 additions & 0 deletions browsers/www/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@ COPY tars.iso.dmg /home/browser/

COPY previous.cfg /home/browser/.previous/previous.cfg

COPY proxy.py /home/browser/proxy.py

COPY run.sh /app/run.sh
RUN sudo chmod a+x /app/run.sh

Expand Down
4 changes: 2 additions & 2 deletions browsers/www/NS33.tar.gz
Git LFS file not shown
66 changes: 66 additions & 0 deletions browsers/www/proxy.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
from bottle import request, route, HTTPResponse, run
from argparse import ArgumentParser

import requests

pywb_prefix = 'localhost'
proxy_host = '10.0.2.2'
start_ts = '1990'
start_url = ''

ALLOWED_HEADERS = ('content-type', 'content-length', 'location', 'date',
'last-modified', 'set-cookie', 'server', 'content-encoding')

@route('/default.html')
def do_default():
return do_proxy(start_ts + '/' + start_url)


@route('/all/<url:re:.*>')
def do_proxy(url):
headers = {'User-Agent': request.environ.get('HTTP_USER_AGENT'),
'Host': proxy_host,
'Accept-Encoding': 'identity',
}

r = requests.get(url=pywb_prefix + url, headers=headers,
stream=True,
allow_redirects=False)

resp_headers = []
for n, v in r.headers.iteritems():
if n == 'content-type':
v = v.split(';')[0].strip()

if n.lower() in ALLOWED_HEADERS:
resp_headers.append((n, v))

resp = HTTPResponse(body=r.iter_content(8192),
status=str(r.status_code) + ' ' + r.reason,
headers=resp_headers)

return resp


if __name__ == "__main__":
parser = ArgumentParser('netcapsule http1.0 proxy')
parser.add_argument('--pywb-prefix')
parser.add_argument('--start-url')
parser.add_argument('--start-ts')
parser.add_argument('--port', type=int)

r = parser.parse_args()

global pywb_prefix
pywb_prefix = r.pywb_prefix

global start_ts
start_ts = r.start_ts

global start_url
start_url = r.start_url

port = r.port or 8081

run(host='0.0.0.0', port=port)

3 changes: 3 additions & 0 deletions browsers/www/run.sh
Original file line number Diff line number Diff line change
Expand Up @@ -14,5 +14,8 @@ sudo chown browser ./.previous/previous.cfg
#fluxbox -display $DISPLAY -log /tmp/fluxbox.log &
#fvwm -d $DISPLAY &

PYWB_IP=$(grep netcapsule_pywb_1 /etc/hosts | cut -f 1 | head -n 1)
sudo python proxy.py --start-url $URL --pywb-prefix http://$PYWB_IP:8080/all/ --start-ts $TS --port 80 &

run_browser Previous

4 changes: 2 additions & 2 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -59,8 +59,8 @@ app:
- ${RANDOM_URL_LIST}:/app/urls.txt

environment:
- SCREEN_WIDTH=1120
- SCREEN_HEIGHT=856
- SCREEN_WIDTH=1024
- SCREEN_HEIGHT=768

ports:
- 9020:9020
Expand Down
6 changes: 4 additions & 2 deletions pywb/config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ collections:


# Memento Aggregator Collection: Specify paths to Timegate, Timemap
memento_reconstruct:
all:
index_paths:
# for LANL aggregator
#timegate: http://timetravel.mementoweb.org/api/json/
Expand All @@ -25,6 +25,8 @@ collections:

wb_handler_class: !!python/name:archivereplayview.MementoHandler

head_insert_html: ./templates/blank.html

# fallback: live

live:
Expand Down Expand Up @@ -55,7 +57,7 @@ proxy_options:

# Select one of these
#use_default_coll: 'single_archive'
use_default_coll: 'memento_reconstruct'
use_default_coll: 'all'

cookie_resolver: ip
use_client_rewrite: false
Expand Down
Empty file added pywb/templates/blank.html
Empty file.

0 comments on commit effbc82

Please sign in to comment.