Overview main page: img link to publication pages

master
Castro0o 5 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
# remove links to wiki File: pages
for a in tree.findall(".//a[@class='image']"): # select img wrapping a
href = a.attrib.get('href')
if a.findall(".//img"): # ensure a has child: img
if page.name == 'Overview main page': if page.name == 'Overview main page':
img = a.find(".//img") for div_parent in tree.findall(".//div[@class='tooltip']"):
img_src = img.attrib['src'] anchor_of_img = div_parent.find(".//div/a")
a.attrib['href'] = img_src if anchor_of_img.find(".//img") is not None: # <a> needs child <img>
a_tag = div_parent.find(".//p/span/a")
publication_href = a_tag.attrib.get('href')
anchor_of_img.attrib['href'] = publication_href
else: else:
for a in tree.findall(".//a[@class='image']"): # select img wrapping a
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