diff --git a/pywb/indexreader.py b/pywb/indexreader.py index 973d3e6f..30a9e0f0 100644 --- a/pywb/indexreader.py +++ b/pywb/indexreader.py @@ -51,7 +51,7 @@ class RemoteCDXServer: return response @staticmethod - def getQueryParams(wburl, limit = '150000', collapseTime = '10', replayClosest = '200'): + def getQueryParams(wburl, limit = '150000', collapseTime = '10', replayClosest = '4000'): return { ArchivalUrl.QUERY: diff --git a/pywb/query.py b/pywb/query.py index 9f932964..c887c2c3 100644 --- a/pywb/query.py +++ b/pywb/query.py @@ -24,4 +24,14 @@ class QueryHandler: raise wbexceptions.NotFoundException('WB Does Not Have Url: ' + wburl.url) +## =========== +## Simple handlers for debuging +class EchoEnv: + def __call__(self, wbrequest, _): + return WbResponse.text_response(str(wbrequest.env)) + +class EchoRequest: + def __call__(self, wbrequest, _): + return WbResponse.text_response(str(wbrequest)) + diff --git a/pywb/wbapp.py b/pywb/wbapp.py index 439ed7ea..3e27dbee 100644 --- a/pywb/wbapp.py +++ b/pywb/wbapp.py @@ -1,27 +1,14 @@ -from query import QueryHandler +from query import QueryHandler, EchoEnv, EchoRequest from replay import FullHandler import wbexceptions +import indexreader from wbrequestresponse import WbResponse, StatusAndHeaders from archivalrouter import ArchivalRequestRouter -## =========== -class EchoEnv: - def __call__(self, wbrequest, _): - return WbResponse.text_response(str(wbrequest.env)) - -class WBHandler: - def __call__(self, wbrequest, _): - return WbResponse.text_response(str(wbrequest)) - ## =========== - -import testwb - -query = QueryHandler(testwb.createCdxServer()) - headInsert = """ @@ -30,26 +17,36 @@ headInsert = """ """ -replay = testwb.createReplay(headInsert) ## =========== -parser = ArchivalRequestRouter( +def createDefaultWB(headInsert): + query = QueryHandler(indexreader.RemoteCDXServer('http://web.archive.org/cdx/search/cdx')) + return ArchivalRequestRouter( { - 't0' : [EchoEnv()], - 't1' : [WBHandler()], - 't2' : [query], - 't3' : [query, replay], - 'web': FullHandler(query, replay) + 'echo' : [EchoEnv()], + 'req' : [EchoRequest()], + 'cdx' : [query], + 'web' : [query], }, hostpaths = ['http://localhost:9090/']) ## =========== +try: + import globalwb + wbparser = globalwb.createDefaultWB(headInsert) +except: + print " *** Test Wayback Inited *** " + wbparser = createDefaultWB(headInsert) + + + + def application(env, start_response): response = None try: - response = parser.handleRequest(env) + response = wbparser.handleRequest(env) if not response: raise wbexceptions.NotFoundException(env['REQUEST_URI'] + ' was not found') diff --git a/setup.py b/setup.py index 54dfa435..7f91ba06 100755 --- a/setup.py +++ b/setup.py @@ -11,7 +11,7 @@ setuptools.setup(name='pywb', long_description=open('README.md').read(), license='GPL', packages=['pywb'], - install_requires=['rfc3987', 'chardet', 'redis'], + install_requires=['uwsgi', 'rfc3987', 'chardet', 'redis'], # test_suite='?', # not sure how to run doctests here zip_safe=False) diff --git a/static/wb.js b/static/wb.js index ad5bd871..27fcd45c 100644 --- a/static/wb.js +++ b/static/wb.js @@ -23,8 +23,6 @@ function initBanner() if (!banner) { banner = document.createElement("wb_div"); banner.setAttribute("id", BANNER_ID); - banner.style.cssText = "display: block; width: 100%; border: 1px solid; background-color: lightYellow; text-align: center"; - banner.innerHTML = "PyWb Test Banner!" document.body.insertBefore(banner, document.body.firstChild); }