links from image to wiki

andre
Castro0o 5 years ago
parent 03bb5ab272
commit b9d8bfa4b5

@ -36,6 +36,7 @@ def unpack_response(response):
d = {}
printouts = response['printouts']
page = response['fulltext']
fullurl = response['fullurl']
d['page'] = page
for prop in printouts:
p_item = response['printouts'][prop]
@ -52,7 +53,7 @@ def unpack_response(response):
else:
val = list(prop_val.values())[0]
d[prop] = val
return d
return d, fullurl
def update_json(imgsjson_fn, img_dict, img_fn):

@ -73,8 +73,8 @@ all_document_parts = '' # to append all content
for answer in site.ask(query):
publication_title = ''
print(answer, answer.keys())
printout_dict = unpack_response(answer)
# print(answer, answer.keys())
printout_dict, fullurl = unpack_response(answer)
# pprint(printout_dict)
img_info = images_info[printout_dict['page']] # find corresponding image in images.json
page = site.pages[[printout_dict['page']]] # request that page from wiki
@ -85,7 +85,8 @@ for answer in site.ask(query):
document_part_html = pub_part_template.render(
printout_dict=printout_dict,
imgsrc=os.path.join(imgdir, img_info.get('filename')),
text=pagetext_html)
text=pagetext_html,
fullurl=fullurl,)
all_document_parts += document_part_html # append resulting html from document part to the previous parts
if printout_dict['Part'] == printout_dict['Partof']: # when Part == Partof
# pass all_document_parts html to pub_template content

@ -1,7 +1,9 @@
<div class="part">
<div class="img">
<img src="{{ imgsrc }}" />
<a href="https:{{ fullurl }}">
<img src="{{ imgsrc }}" />
</a>
</div>
<div class="text">

Loading…
Cancel
Save