Overview main page: img link to publication pages

pull/9/head
Castro0o 4 years ago
parent 11fe0bf03b
commit e1fb598cf4

@ -68,23 +68,20 @@ def filenameforlink(href):
def rewriteimglinks(tree, page): def rewriteimglinks(tree, page):
#on Overview_main_page # invoke after img src has been rewritten
# add link to publication on <a><img> # To: remove links to wiki File on all pages
# but Overview_main_page page where link to publication page is added
# invoke after img src have be rewritten if page.name == 'Overview main page':
# remove links to wiki File: pages for div_parent in tree.findall(".//div[@class='tooltip']"):
for a in tree.findall(".//a[@class='image']"): # select img wrapping a anchor_of_img = div_parent.find(".//div/a")
href = a.attrib.get('href') if anchor_of_img.find(".//img") is not None: # <a> needs child <img>
if a.findall(".//img"): # ensure a has child: img a_tag = div_parent.find(".//p/span/a")
if page.name == 'Overview main page': publication_href = a_tag.attrib.get('href')
img = a.find(".//img") anchor_of_img.attrib['href'] = publication_href
img_src = img.attrib['src'] else:
a.attrib['href'] = img_src for a in tree.findall(".//a[@class='image']"): # select img wrapping a
else: if a.findall(".//img"): # ensure a has child: img
a.attrib['href'] = 'javascript:void(0);' # disable href a.attrib['href'] = 'javascript:void(0);' # disable href
print(a)
print(ET.tostring(a, method="html", encoding="unicode"))
return tree return tree
def rewritelinks(html): def rewritelinks(html):

Loading…
Cancel
Save