diff --git a/pywb/default_config.yaml b/pywb/default_config.yaml index c031928a..be51bc3c 100644 --- a/pywb/default_config.yaml +++ b/pywb/default_config.yaml @@ -6,8 +6,8 @@ collections_root: collections paths: - archive_paths: warcs - index_paths: cdx + archive_paths: archive + index_paths: indexes static_path: static templates_dir: templates @@ -28,20 +28,20 @@ paths: proxy_cert_download_html: proxy_cert_download.html proxy_select_html: proxy_select.html -head_insert_html: ui/head_insert.html -frame_insert_html: ui/frame_insert.html +head_insert_html: templates/head_insert.html +frame_insert_html: templates/frame_insert.html banner_html: banner.html -home_html: ui/index.html +home_html: templates/index.html -query_html: ui/query.html -search_html: ui/search.html +query_html: templates/query.html +search_html: templates/search.html -error_html: ui/error.html -not_found_html: ui/not_found.html +error_html: templates/error.html +not_found_html: templates/not_found.html -proxy_cert_download_html: ui/proxy_cert_download.html -proxy_select_html: ui/proxy_select.html +proxy_cert_download_html: templates/proxy_cert_download.html +proxy_select_html: templates/proxy_select.html template_globals: static_path: static/default diff --git a/pywb/ui/banner.html b/pywb/templates/banner.html similarity index 100% rename from pywb/ui/banner.html rename to pywb/templates/banner.html diff --git a/pywb/ui/error.html b/pywb/templates/error.html similarity index 100% rename from pywb/ui/error.html rename to pywb/templates/error.html diff --git a/pywb/ui/frame_insert.html b/pywb/templates/frame_insert.html similarity index 100% rename from pywb/ui/frame_insert.html rename to pywb/templates/frame_insert.html diff --git a/pywb/ui/head_insert.html b/pywb/templates/head_insert.html similarity index 100% rename from pywb/ui/head_insert.html rename to pywb/templates/head_insert.html diff --git a/pywb/ui/index.html b/pywb/templates/index.html similarity index 100% rename from pywb/ui/index.html rename to pywb/templates/index.html diff --git a/pywb/ui/not_found.html b/pywb/templates/not_found.html similarity index 100% rename from pywb/ui/not_found.html rename to pywb/templates/not_found.html diff --git a/pywb/ui/proxy_cert_download.html b/pywb/templates/proxy_cert_download.html similarity index 100% rename from pywb/ui/proxy_cert_download.html rename to pywb/templates/proxy_cert_download.html diff --git a/pywb/ui/proxy_select.html b/pywb/templates/proxy_select.html similarity index 100% rename from pywb/ui/proxy_select.html rename to pywb/templates/proxy_select.html diff --git a/pywb/ui/query.html b/pywb/templates/query.html similarity index 100% rename from pywb/ui/query.html rename to pywb/templates/query.html diff --git a/pywb/ui/search.html b/pywb/templates/search.html similarity index 100% rename from pywb/ui/search.html rename to pywb/templates/search.html diff --git a/pywb/webapp/handlers.py b/pywb/webapp/handlers.py index c00214bc..d3649add 100644 --- a/pywb/webapp/handlers.py +++ b/pywb/webapp/handlers.py @@ -35,7 +35,7 @@ class SearchPageWbUrlHandler(WbUrlHandler): self.response_class = WbResponse if self.is_frame_mode: - html = config.get('frame_insert_html', 'ui/frame_insert.html') + html = config.get('frame_insert_html', 'templates/frame_insert.html') self.frame_insert_view = (J2TemplateView. create_template(html, 'Frame Insert')) diff --git a/pywb/webapp/views.py b/pywb/webapp/views.py index 13cff6ce..aa90db7e 100644 --- a/pywb/webapp/views.py +++ b/pywb/webapp/views.py @@ -157,7 +157,7 @@ class HeadInsertView(J2TemplateView): def init_from_config(config): view = config.get('head_insert_view') if not view: - html = config.get('head_insert_html', 'ui/head_insert.html') + html = config.get('head_insert_html', 'templates/head_insert.html') if html: banner_html = config.get('banner_html', 'banner.html') diff --git a/setup.py b/setup.py index 3783c4b7..a4ae576e 100755 --- a/setup.py +++ b/setup.py @@ -34,7 +34,7 @@ class PyTest(TestCommand): setup( name='pywb', - version='0.9.0-beta', + version='0.9.0b', url='https://github.com/ikreymer/pywb', author='Ilya Kreymer', author_email='ikreymer@gmail.com', @@ -56,7 +56,7 @@ setup( 'pywb.apps' ], package_data={ - 'pywb': ['static/flowplayer/*', 'static/*.*', 'ui/*', '*.yaml'], + 'pywb': ['static/flowplayer/*', 'static/*.*', 'templates/*', '*.yaml'], }, data_files=[ ('sample_archive/cdx', glob.glob('sample_archive/cdx/*')), @@ -90,7 +90,7 @@ setup( cdx-indexer = pywb.warc.cdxindexer:main live-rewrite-server = pywb.apps.live_rewrite_server:main proxy-cert-auth = pywb.framework.certauth:main - wb-manager = pywb.manager.manager:main_wrap_exc + wayback-manager = pywb.manager.manager:main_wrap_exc """, classifiers=[ 'Development Status :: 4 - Beta', diff --git a/tests/test_auto_colls.py b/tests/test_auto_colls.py index a293508e..e4446ae8 100644 --- a/tests/test_auto_colls.py +++ b/tests/test_auto_colls.py @@ -17,6 +17,10 @@ from pytest import raises from mock import patch +#============================================================================= +ARCHIVE_DIR = 'archive' +INDEX_DIR = 'indexes' + #============================================================================= root_dir = None orig_cwd = None @@ -40,14 +44,6 @@ def teardown_module(): os.chdir(orig_cwd) -#============================================================================= -mock_input_value = '' - -def mock_raw_input(*args): - global mock_input_value - return mock_input_value - - #============================================================================= class TestManagedColls(object): def setup(self): @@ -62,6 +58,9 @@ class TestManagedColls(object): for dir_ in dirlist: assert os.path.isdir(os.path.join(base, dir_)) + def _get_sample_warc(self, name): + return os.path.join(get_test_dir(), 'warcs', name) + def test_create_first_coll(self): """ Test first collection creation, with all required dirs """ @@ -73,12 +72,12 @@ class TestManagedColls(object): test = os.path.join(colls, 'test') assert os.path.isdir(test) - self._check_dirs(test, ['cdx', 'warcs', 'static', 'templates']) + self._check_dirs(test, [INDEX_DIR, ARCHIVE_DIR, 'static', 'templates']) def test_add_warcs(self): """ Test adding warc to new coll, check replay """ - warc1 = os.path.join(get_test_dir(), 'warcs', 'example.warc.gz') + warc1 = self._get_sample_warc('example.warc.gz') main(['add', 'test', warc1]) @@ -89,7 +88,7 @@ class TestManagedColls(object): def test_another_coll(self): """ Test adding warc to a new coll, check replay """ - warc1 = os.path.join(get_test_dir(), 'warcs', 'example.warc.gz') + warc1 = self._get_sample_warc('example.warc.gz') main(['init', 'foo']) @@ -102,8 +101,8 @@ class TestManagedColls(object): def test_add_more_warcs(self): """ Test adding additional warcs, check replay of added content """ - warc1 = os.path.join(get_test_dir(), 'warcs', 'iana.warc.gz') - warc2 = os.path.join(get_test_dir(), 'warcs', 'example-extra.warc') + warc1 = self._get_sample_warc('iana.warc.gz') + warc2 = self._get_sample_warc('example-extra.warc') main(['add', 'test', warc1, warc2]) @@ -127,15 +126,15 @@ class TestManagedColls(object): main(['init', 'nested']) - nested_root = os.path.join(self.root_dir, 'collections', 'nested', 'warcs') + nested_root = os.path.join(self.root_dir, 'collections', 'nested', ARCHIVE_DIR) nested_a = os.path.join(nested_root, 'A') nested_b = os.path.join(nested_root, 'B', 'sub') os.makedirs(nested_a) os.makedirs(nested_b) - warc1 = os.path.join(get_test_dir(), 'warcs', 'iana.warc.gz') - warc2 = os.path.join(get_test_dir(), 'warcs', 'example.warc.gz') + warc1 = self._get_sample_warc('iana.warc.gz') + warc2 = self._get_sample_warc('example.warc.gz') shutil.copy2(warc1, nested_a) shutil.copy2(warc2, nested_b) @@ -146,7 +145,7 @@ class TestManagedColls(object): os.path.join(nested_b, 'example.warc.gz') ]) - nested_cdx = os.path.join(self.root_dir, 'collections', 'nested', 'cdx', 'index.cdx') + nested_cdx = os.path.join(self.root_dir, 'collections', 'nested', INDEX_DIR, 'index.cdx') with open(nested_cdx) as fh: nested_cdx_index = fh.read() @@ -165,7 +164,7 @@ class TestManagedColls(object): to ensure equality of indexes """ # ensure merged index is same as full reindex - coll_dir = os.path.join(self.root_dir, 'collections', 'test', 'cdx') + coll_dir = os.path.join(self.root_dir, 'collections', 'test', INDEX_DIR) orig = os.path.join(coll_dir, 'index.cdx') bak = os.path.join(coll_dir, 'index.bak') @@ -263,7 +262,7 @@ class TestManagedColls(object): fh.write('config.yaml overriden search page: ') fh.write('{{ wbrequest.user_metadata | tojson }}\n') - os.rename(os.path.join(self.root_dir, 'collections', 'test', 'cdx'), + os.rename(os.path.join(self.root_dir, 'collections', 'test', INDEX_DIR), os.path.join(self.root_dir, 'collections', 'test', 'cdx2')) self._create_app() @@ -297,7 +296,6 @@ class TestManagedColls(object): def test_add_template_input_yes(self): """ Test answer 'yes' to overwrite """ - mock_raw_input_value = 'y' main(['template', 'foo', '--add', 'query_html']) @@ -379,14 +377,14 @@ class TestManagedColls(object): def test_err_no_such_coll(self): """ Test error adding warc to non-existant collection """ - warc1 = os.path.join(get_test_dir(), 'warcs', 'example.warc.gz') + warc1 = self._get_sample_warc('example.warc.gz') with raises(IOError): main(['add', 'bar', warc1]) def test_err_wrong_warcs(self): - warc1 = os.path.join(get_test_dir(), 'warcs', 'example.warc.gz') - invalid_warc = os.path.join(self.root_dir, 'collections', 'test', 'warcs', 'invalid.warc.gz') + warc1 = self._get_sample_warc('example.warc.gz') + invalid_warc = os.path.join(self.root_dir, 'collections', 'test', ARCHIVE_DIR, 'invalid.warc.gz') # Empty warc list, argparse calls exit with raises(SystemExit): @@ -411,14 +409,14 @@ class TestManagedColls(object): self._create_app() # No WARCS - warcs_path = os.path.join(colls, 'foo', 'warcs') + warcs_path = os.path.join(colls, 'foo', ARCHIVE_DIR) shutil.rmtree(warcs_path) with raises(IOError): main(['add', 'foo', 'somewarc']) # No CDX - cdx_path = os.path.join(colls, 'foo', 'cdx') + cdx_path = os.path.join(colls, 'foo', INDEX_DIR) shutil.rmtree(cdx_path) with raises(Exception): diff --git a/tests/test_config.yaml b/tests/test_config.yaml index a2d0e9f6..fde10382 100644 --- a/tests/test_config.yaml +++ b/tests/test_config.yaml @@ -70,31 +70,31 @@ archive_paths: ['./invalid/path/to/ignore/', './sample_archive/warcs/'] # ==== Optional UI: HTML/Jinja2 Templates ==== # template for
insert into replayed html content -head_insert_html: ui/head_insert.html +head_insert_html: templates/head_insert.html # template to for 'calendar' query, # eg, a listing of captures in response to a ../*/