|
|
@ -63,14 +63,17 @@ with open(os.path.join(wd, 'login.txt'), 'r') as login: # read login user & pwd
|
|
|
|
site.login(username=user, password=pwd) # login to wiki
|
|
|
|
site.login(username=user, password=pwd) # login to wiki
|
|
|
|
|
|
|
|
|
|
|
|
# read template files
|
|
|
|
# read template files
|
|
|
|
with open(os.path.join(wd, 'templates/document.html')) as pub_html:
|
|
|
|
with open(os.path.join(wd, 'templates/index.html')) as document_html:
|
|
|
|
pub_template = Template(pub_html.read())
|
|
|
|
index_template = Template(document_html.read())
|
|
|
|
|
|
|
|
|
|
|
|
with open(os.path.join(wd, 'templates/document_part.html')) as pub_html:
|
|
|
|
with open(os.path.join(wd, 'templates/document.html')) as document_html:
|
|
|
|
pub_part_template = Template(pub_html.read())
|
|
|
|
document_template = Template(document_html.read())
|
|
|
|
|
|
|
|
|
|
|
|
all_document_parts = '' # to append all content
|
|
|
|
with open(os.path.join(wd, 'templates/document_part.html')) as document_html:
|
|
|
|
|
|
|
|
document_part_template = Template(document_html.read())
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
all_document_parts = '' # to append all content
|
|
|
|
|
|
|
|
documentslist = []
|
|
|
|
for answer in site.ask(query):
|
|
|
|
for answer in site.ask(query):
|
|
|
|
publication_title = ''
|
|
|
|
publication_title = ''
|
|
|
|
# print(answer, answer.keys())
|
|
|
|
# print(answer, answer.keys())
|
|
|
@ -87,19 +90,32 @@ for answer in site.ask(query):
|
|
|
|
pagetext_html = pandoc(pwd=wd, content=pagetext, format_in='mediawiki', format_out='html')
|
|
|
|
pagetext_html = pandoc(pwd=wd, content=pagetext, format_in='mediawiki', format_out='html')
|
|
|
|
img_local = os.path.join(imgdir, img_info.get('filename'))
|
|
|
|
img_local = os.path.join(imgdir, img_info.get('filename'))
|
|
|
|
# render html for that part of the document
|
|
|
|
# render html for that part of the document
|
|
|
|
document_part_html = pub_part_template.render(
|
|
|
|
document_part_html = document_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,)
|
|
|
|
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 document_template content
|
|
|
|
pub_html = pub_template.render(title=printout_dict.get('Title'),
|
|
|
|
document_html = document_template.render(title=printout_dict.get('Title'),
|
|
|
|
date=printout_dict.get('Date'),
|
|
|
|
date=printout_dict.get('Date'),
|
|
|
|
content=all_document_parts) # render document template
|
|
|
|
content=all_document_parts) # render document template
|
|
|
|
htmlpage_fn = "{}.html".format(printout_dict.get('Title').replace(" ", ""))
|
|
|
|
htmlpage_fn = "{}.html".format(printout_dict.get('Title').replace(" ", ""))
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
documentslist.append({'file': htmlpage_fn,
|
|
|
|
|
|
|
|
'title': printout_dict.get('Title'),
|
|
|
|
|
|
|
|
'date': printout_dict.get('Date')
|
|
|
|
|
|
|
|
})
|
|
|
|
|
|
|
|
# print(documentslist)
|
|
|
|
|
|
|
|
|
|
|
|
with open(os.path.join(static_html, htmlpage_fn), 'w') as htmlfile:
|
|
|
|
with open(os.path.join(static_html, htmlpage_fn), 'w') as htmlfile:
|
|
|
|
htmlfile.write(pub_html)
|
|
|
|
htmlfile.write(document_html)
|
|
|
|
|
|
|
|
|
|
|
|
all_document_parts = '' # Reset all_document_parts
|
|
|
|
all_document_parts = '' # Reset all_document_parts
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
index_html = index_template.render(index='Index',
|
|
|
|
|
|
|
|
documentslist=documentslist)
|
|
|
|
|
|
|
|
with open(os.path.join(static_html, 'index.html'), 'w') as htmlfile:
|
|
|
|
|
|
|
|
htmlfile.write(index_html)
|
|
|
|