|
|
|
@ -12,11 +12,10 @@ p = argparse.ArgumentParser(description="Dump wiki files to html",
|
|
|
|
|
formatter_class=argparse.ArgumentDefaultsHelpFormatter)
|
|
|
|
|
p.add_argument("--host", metavar='', default="hub.xpub.nl/sandbox", help='wiki host')
|
|
|
|
|
p.add_argument("--path", metavar='', default="/itchwiki/", help="Wiki path. Should end with /")
|
|
|
|
|
p.add_argument("--output", default="/var/www/html/archive", help="Output path for pages")
|
|
|
|
|
p.add_argument("--output", default="../archive", help="Output path for pages")
|
|
|
|
|
p.add_argument("--one", default=False, action="store_true", help="Output one page from each category only")
|
|
|
|
|
p.add_argument("--local", default=False, action="store_true", help="When creating a local archives. Add full URL to images")
|
|
|
|
|
p.add_argument("--imgsrc", default='archive',
|
|
|
|
|
choices=['archive', 'local', 'remote'],
|
|
|
|
|
choices=['archive', 'remote'],
|
|
|
|
|
help="What is the source of the images?")
|
|
|
|
|
|
|
|
|
|
args = p.parse_args()
|
|
|
|
@ -25,7 +24,7 @@ print(args)
|
|
|
|
|
|
|
|
|
|
site = Site(host=args.host, path=args.path)
|
|
|
|
|
wd = os.path.dirname(os.path.abspath(__file__)) # working directory
|
|
|
|
|
|
|
|
|
|
wd_name = os.path.split(wd)[-1] # name of dir running script
|
|
|
|
|
with open('login.txt', 'r') as login: # read login user & pwd
|
|
|
|
|
loginlines = login.read()
|
|
|
|
|
user, pwd = loginlines.split('\n')
|
|
|
|
@ -91,12 +90,8 @@ def rewriteimgs(html):
|
|
|
|
|
print(Colors.WARNING, f"{printout_dict['page']} is not is missing from the local downloaded images")
|
|
|
|
|
print(Colors.GREEN, 'run python3 download_imgs.py to fix the issue', Colors.ENDC)
|
|
|
|
|
sys.exit()
|
|
|
|
|
if args.imgsrc == 'local':
|
|
|
|
|
# 2 dirs above HTML files dir: archive/
|
|
|
|
|
img.attrib['src'] = f'../../images/{img_filename}'
|
|
|
|
|
if args.imgsrc == 'archive':
|
|
|
|
|
# same dir as HTML files: archive/
|
|
|
|
|
img.attrib['src'] = f'./images/{img_filename}'
|
|
|
|
|
# same dir as HTML files: archive/
|
|
|
|
|
img.attrib['src'] = f'./images/{img_filename}'
|
|
|
|
|
|
|
|
|
|
img.attrib['srcset'] = "" # rm srcset value:it prevent imgs displaying
|
|
|
|
|
img.attrib['width'] = ""
|
|
|
|
@ -122,10 +117,9 @@ for cat in publish.members():
|
|
|
|
|
htmlsrc = rewritelinks(htmlsrc)
|
|
|
|
|
htmlsrc = rewriteimgs(htmlsrc)
|
|
|
|
|
|
|
|
|
|
if args.local is True:
|
|
|
|
|
html = template.render(page=p, body=htmlsrc, staticpath='..')
|
|
|
|
|
else:
|
|
|
|
|
html = template.render(page=p, body=htmlsrc, staticpath='0')
|
|
|
|
|
# TODO: ANdre structure of archive: from ./archive/0 to: ./archive ./0
|
|
|
|
|
|
|
|
|
|
html = template.render(page=p, body=htmlsrc, staticpath=f'../{wd_name}')
|
|
|
|
|
|
|
|
|
|
with open(os.path.join(args.output, filenameforpage(p)), 'w') as f:
|
|
|
|
|
f.write(html)
|
|
|
|
|