mirror of
https://github.com/webrecorder/pywb.git
synced 2025-03-24 06:59:52 +01:00
cleanup, setup runnable testwb, or pluggable 'globalwb'
This commit is contained in:
parent
c3767cd31b
commit
246b3fba43
@ -51,7 +51,7 @@ class RemoteCDXServer:
|
|||||||
return response
|
return response
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def getQueryParams(wburl, limit = '150000', collapseTime = '10', replayClosest = '200'):
|
def getQueryParams(wburl, limit = '150000', collapseTime = '10', replayClosest = '4000'):
|
||||||
return {
|
return {
|
||||||
|
|
||||||
ArchivalUrl.QUERY:
|
ArchivalUrl.QUERY:
|
||||||
|
@ -24,4 +24,14 @@ class QueryHandler:
|
|||||||
|
|
||||||
raise wbexceptions.NotFoundException('WB Does Not Have Url: ' + wburl.url)
|
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))
|
||||||
|
|
||||||
|
|
||||||
|
@ -1,27 +1,14 @@
|
|||||||
from query import QueryHandler
|
from query import QueryHandler, EchoEnv, EchoRequest
|
||||||
from replay import FullHandler
|
from replay import FullHandler
|
||||||
import wbexceptions
|
import wbexceptions
|
||||||
|
import indexreader
|
||||||
|
|
||||||
from wbrequestresponse import WbResponse, StatusAndHeaders
|
from wbrequestresponse import WbResponse, StatusAndHeaders
|
||||||
from archivalrouter import ArchivalRequestRouter
|
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 = """
|
headInsert = """
|
||||||
|
|
||||||
<!-- WB Insert -->
|
<!-- WB Insert -->
|
||||||
@ -30,26 +17,36 @@ headInsert = """
|
|||||||
<!-- End WB Insert -->
|
<!-- End WB Insert -->
|
||||||
"""
|
"""
|
||||||
|
|
||||||
replay = testwb.createReplay(headInsert)
|
|
||||||
|
|
||||||
## ===========
|
## ===========
|
||||||
parser = ArchivalRequestRouter(
|
def createDefaultWB(headInsert):
|
||||||
|
query = QueryHandler(indexreader.RemoteCDXServer('http://web.archive.org/cdx/search/cdx'))
|
||||||
|
return ArchivalRequestRouter(
|
||||||
{
|
{
|
||||||
't0' : [EchoEnv()],
|
'echo' : [EchoEnv()],
|
||||||
't1' : [WBHandler()],
|
'req' : [EchoRequest()],
|
||||||
't2' : [query],
|
'cdx' : [query],
|
||||||
't3' : [query, replay],
|
'web' : [query],
|
||||||
'web': FullHandler(query, replay)
|
|
||||||
},
|
},
|
||||||
hostpaths = ['http://localhost:9090/'])
|
hostpaths = ['http://localhost:9090/'])
|
||||||
## ===========
|
## ===========
|
||||||
|
|
||||||
|
|
||||||
|
try:
|
||||||
|
import globalwb
|
||||||
|
wbparser = globalwb.createDefaultWB(headInsert)
|
||||||
|
except:
|
||||||
|
print " *** Test Wayback Inited *** "
|
||||||
|
wbparser = createDefaultWB(headInsert)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
def application(env, start_response):
|
def application(env, start_response):
|
||||||
response = None
|
response = None
|
||||||
|
|
||||||
try:
|
try:
|
||||||
response = parser.handleRequest(env)
|
response = wbparser.handleRequest(env)
|
||||||
|
|
||||||
if not response:
|
if not response:
|
||||||
raise wbexceptions.NotFoundException(env['REQUEST_URI'] + ' was not found')
|
raise wbexceptions.NotFoundException(env['REQUEST_URI'] + ' was not found')
|
||||||
|
2
setup.py
2
setup.py
@ -11,7 +11,7 @@ setuptools.setup(name='pywb',
|
|||||||
long_description=open('README.md').read(),
|
long_description=open('README.md').read(),
|
||||||
license='GPL',
|
license='GPL',
|
||||||
packages=['pywb'],
|
packages=['pywb'],
|
||||||
install_requires=['rfc3987', 'chardet', 'redis'],
|
install_requires=['uwsgi', 'rfc3987', 'chardet', 'redis'],
|
||||||
# test_suite='?', # not sure how to run doctests here
|
# test_suite='?', # not sure how to run doctests here
|
||||||
zip_safe=False)
|
zip_safe=False)
|
||||||
|
|
||||||
|
@ -23,8 +23,6 @@ function initBanner()
|
|||||||
if (!banner) {
|
if (!banner) {
|
||||||
banner = document.createElement("wb_div");
|
banner = document.createElement("wb_div");
|
||||||
banner.setAttribute("id", BANNER_ID);
|
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!"
|
banner.innerHTML = "PyWb Test Banner!"
|
||||||
document.body.insertBefore(banner, document.body.firstChild);
|
document.body.insertBefore(banner, document.body.firstChild);
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user