Skip to content

Commit

Permalink
Store static content in a _zim_static/ subdir instead of A/.
Browse files Browse the repository at this point in the history
We don't have anything now in `A/` or `H/` subdirs.
Remove the left over `A/` in test urls (was working thanks to libzim's
compatibility layer)
  • Loading branch information
mgautierfr committed Dec 8, 2023
1 parent 03b2dbf commit db17e4c
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 10 deletions.
2 changes: 1 addition & 1 deletion src/warc2zim/items.py
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ def __init__(self, env, filename, main_url, **kwargs):
).decode("utf-8")

def get_path(self):
return "A/" + self.filename
return "_zim_static/" + self.filename

def get_mimetype(self):
return self.mime
Expand Down
18 changes: 9 additions & 9 deletions tests/test_warc_to_zim.py
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,7 @@ def verify_warc_and_zim(self, warcfile, zimfile):

# ensure payloads match
try:
payload = zim_fh.get_item("A/" + url_no_scheme)
payload = zim_fh.get_item(url_no_scheme)
except KeyError:
payload = None

Expand Down Expand Up @@ -323,8 +323,8 @@ def test_same_domain_only(self, tmp_path):
for article in self.list_articles(zim_output):
url = article.path
# ignore the replay files, which have only one path segment
if url.startswith("A/") and len(url.split("/")) > 2:
assert url.startswith("A/example.com/")
if not url.startswith("_zim_static/"):
assert url.startswith("example.com/")

def test_skip_self_redirect(self, tmp_path):
zim_output = "self-redir.zim"
Expand Down Expand Up @@ -363,7 +363,7 @@ def test_include_domains_favicon_and_language(self, tmp_path):
for article in self.list_articles(zim_output):
url = article.path
# ignore the replay files, which have only one path segment
if url.startswith("A/") and len(url.split("/")) > 2:
if not url.startswith("_zim_static/"):
assert "reseau-canope.fr/" in url

# test detected language
Expand All @@ -372,7 +372,7 @@ def test_include_domains_favicon_and_language(self, tmp_path):
# test detected favicon
assert self.get_article(
zim_output,
"A/lesfondamentaux.reseau-canope.fr/fileadmin/template/img/favicon.ico",
"lesfondamentaux.reseau-canope.fr/fileadmin/template/img/favicon.ico",
)
assert self.get_metadata(zim_output, "Illustration_48x48@1")

Expand Down Expand Up @@ -488,10 +488,10 @@ def test_custom_css(self, tmp_path):
)
zim_output = tmp_path / zim_output

res = self.get_article(zim_output, "A/example.com/")
res = self.get_article(zim_output, "example.com/")
assert "https://warc2zim.kiwix.app/custom.css".encode("utf-8") in res

res = self.get_article(zim_output, "A/warc2zim.kiwix.app/custom.css")
res = self.get_article(zim_output, "warc2zim.kiwix.app/custom.css")
assert custom_css == res

def test_custom_css_remote(self, tmp_path):
Expand All @@ -515,8 +515,8 @@ def test_custom_css_remote(self, tmp_path):
)
zim_output = tmp_path / zim_output

res = self.get_article(zim_output, "A/example.com/")
res = self.get_article(zim_output, "example.com/")
assert "https://warc2zim.kiwix.app/custom.css".encode("utf-8") in res

res = self.get_article(zim_output, "A/warc2zim.kiwix.app/custom.css")
res = self.get_article(zim_output, "warc2zim.kiwix.app/custom.css")
assert res == requests.get(url).content

0 comments on commit db17e4c

Please sign in to comment.