links from image to wiki

andre
Castro0o 5 years ago
parent 03bb5ab272
commit b9d8bfa4b5

@ -36,6 +36,7 @@ def unpack_response(response):
d = {} d = {}
printouts = response['printouts'] printouts = response['printouts']
page = response['fulltext'] page = response['fulltext']
fullurl = response['fullurl']
d['page'] = page d['page'] = page
for prop in printouts: for prop in printouts:
p_item = response['printouts'][prop] p_item = response['printouts'][prop]
@ -52,7 +53,7 @@ def unpack_response(response):
else: else:
val = list(prop_val.values())[0] val = list(prop_val.values())[0]
d[prop] = val d[prop] = val
return d return d, fullurl
def update_json(imgsjson_fn, img_dict, img_fn): 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): for answer in site.ask(query):
publication_title = '' publication_title = ''
print(answer, answer.keys()) # print(answer, answer.keys())
printout_dict = unpack_response(answer) printout_dict, fullurl = unpack_response(answer)
# pprint(printout_dict) # pprint(printout_dict)
img_info = images_info[printout_dict['page']] # find corresponding image in images.json img_info = images_info[printout_dict['page']] # find corresponding image in images.json
page = site.pages[[printout_dict['page']]] # request that page from wiki 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( document_part_html = pub_part_template.render(
printout_dict=printout_dict, printout_dict=printout_dict,
imgsrc=os.path.join(imgdir, img_info.get('filename')), 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 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 if printout_dict['Part'] == printout_dict['Partof']: # when Part == Partof
# pass all_document_parts html to pub_template content # pass all_document_parts html to pub_template content

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

Loading…
Cancel
Save