|
|
|
@ -15,7 +15,7 @@ p.add_argument("--conditions", "-c", metavar='',
|
|
|
|
|
default='[[File:+]][[Title::+]][[Part::+]][[Date::+]]',
|
|
|
|
|
help='The query conditions')
|
|
|
|
|
p.add_argument("--printouts", "-p", metavar='',
|
|
|
|
|
default='?Title|?Date|?Part|?Partof',
|
|
|
|
|
default='?Title|?Date|?Part|?Partof|?Creator',
|
|
|
|
|
help='Selection of properties to printout')
|
|
|
|
|
p.add_argument("--sort", "-s", metavar='',
|
|
|
|
|
default='Date,Title,Part',
|
|
|
|
@ -89,7 +89,8 @@ for answer in site.ask(query):
|
|
|
|
|
pagetext = page.text()
|
|
|
|
|
pagetext_html = pandoc(pwd=wd, content=pagetext, format_in='mediawiki', format_out='html')
|
|
|
|
|
img_local = os.path.join(imgdir, img_info.get('filename'))
|
|
|
|
|
# render html for that part of the document
|
|
|
|
|
|
|
|
|
|
# RENDER document part
|
|
|
|
|
document_part_html = document_part_template.render(
|
|
|
|
|
printout_dict=printout_dict,
|
|
|
|
|
imgsrc=os.path.join(imgdir, img_info.get('filename')),
|
|
|
|
@ -97,25 +98,28 @@ for answer in site.ask(query):
|
|
|
|
|
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 document_template content
|
|
|
|
|
if printout_dict['Part'] == printout_dict['Partof']:
|
|
|
|
|
# RENDER DOCUMENT
|
|
|
|
|
# by passing all_document_parts html to document_template content
|
|
|
|
|
document_html = document_template.render(title=printout_dict.get('Title'),
|
|
|
|
|
date=printout_dict.get('Date'),
|
|
|
|
|
content=all_document_parts) # render document template
|
|
|
|
|
htmlpage_fn = "{}.html".format(printout_dict.get('Title').replace(" ", ""))
|
|
|
|
|
with open(os.path.join(static_html, htmlpage_fn), 'w') as htmlfile:
|
|
|
|
|
htmlfile.write(document_html)
|
|
|
|
|
all_document_parts = '' # Reset all_document_parts
|
|
|
|
|
|
|
|
|
|
# add info to documentslist for index creation
|
|
|
|
|
# TODO: possibly needs to be a SortedDict
|
|
|
|
|
documentslist.append({'file': htmlpage_fn,
|
|
|
|
|
'title': printout_dict.get('Title'),
|
|
|
|
|
'date': printout_dict.get('Date')
|
|
|
|
|
'date': printout_dict.get('Date'),
|
|
|
|
|
'creator': printout_dict.get('Creator')
|
|
|
|
|
})
|
|
|
|
|
# print(documentslist)
|
|
|
|
|
|
|
|
|
|
with open(os.path.join(static_html, htmlpage_fn), 'w') as htmlfile:
|
|
|
|
|
htmlfile.write(document_html)
|
|
|
|
|
|
|
|
|
|
all_document_parts = '' # Reset all_document_parts
|
|
|
|
|
|
|
|
|
|
# RENDER index.html from documentslist
|
|
|
|
|
index_html = index_template.render(index='Index',
|
|
|
|
|
query=query,
|
|
|
|
|
documentslist=documentslist)
|
|
|
|
|
with open(os.path.join(static_html, 'index.html'), 'w') as htmlfile:
|
|
|
|
|
htmlfile.write(index_html)
|
|
|
|
|