From 27cc21a58a5c17be1b639288862fe83298f76906 Mon Sep 17 00:00:00 2001 From: Castro0o Date: Thu, 9 Apr 2020 16:27:41 +0200 Subject: [PATCH 1/2] disabeling links to wiki File pages --- dumpwiki.py | 8 ++++++++ static/archive.css | 4 +++- 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/dumpwiki.py b/dumpwiki.py index 94bf171..7324d8e 100644 --- a/dumpwiki.py +++ b/dumpwiki.py @@ -53,6 +53,14 @@ def filenameforlink(href): def rewritelinks (html): t = html5lib.parseFragment(html, treebuilder = "etree", namespaceHTMLElements = False) + + # remove links to wiki File: pages + for a in t.findall(".//a[@class='image']"): # select img wrapping a + href = a.attrib.get('href') + if a.findall(".//img") and 'File:' in href: # ensure a has child: img + a.attrib['href'] = 'javascript:void(0);' # disable href + print('a wrapping img:', ET.tostring(a)) + for a in t.findall(".//*[@href]"): linkclass = a.attrib.get("class", "") href = a.attrib.get("href") diff --git a/static/archive.css b/static/archive.css index 9229388..fd416eb 100644 --- a/static/archive.css +++ b/static/archive.css @@ -11,4 +11,6 @@ a, a:visited{ a:hover { text-decoration: none; color: blue; -} \ No newline at end of file +} + +a.image {cursor: default!important;} /* KEEP THIS: it is important to avoid images to seeming like links */ \ No newline at end of file From 245b52c6285befb326af143e4386d28e614ebdb6 Mon Sep 17 00:00:00 2001 From: Castro0o Date: Thu, 9 Apr 2020 16:29:09 +0200 Subject: [PATCH 2/2] removing unecessary hyphen replacement (which i introduced) --- dumpwiki.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/dumpwiki.py b/dumpwiki.py index 7324d8e..d28893d 100644 --- a/dumpwiki.py +++ b/dumpwiki.py @@ -36,7 +36,6 @@ with open(imgsjson_fn, 'r') as imgsjson_file: SLASH = "\u2044" -HYPHEN = "\u2010" def filenameforpage(p): @@ -47,7 +46,7 @@ def filenameforlink(href): href = urlunquote(href) if href.startswith("/sandbox/itchwiki/index.php/"): href = href[len("/sandbox/itchwiki/index.php/"):] - href = href.replace(' ','_').replace('/', SLASH).replace('‐', HYPHEN) + '.html' + href = href.replace(' ','_').replace('/', SLASH) + '.html' href = urlquote(href) return href