diff --git a/functions.py b/functions.py index 9b3b365..a92447f 100644 --- a/functions.py +++ b/functions.py @@ -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): diff --git a/query2html.py b/query2html.py index c1a39b7..2fe82e0 100644 --- a/query2html.py +++ b/query2html.py @@ -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 diff --git a/templates/document_part.html b/templates/document_part.html index ee58f18..5524bae 100644 --- a/templates/document_part.html +++ b/templates/document_part.html @@ -1,7 +1,9 @@