|
|
|
@ -1,6 +1,7 @@
|
|
|
|
|
import os, json, sys
|
|
|
|
|
from mwclient import Site
|
|
|
|
|
from jinja2 import Template
|
|
|
|
|
from shutil import copy
|
|
|
|
|
import html5lib
|
|
|
|
|
from functions import Colors
|
|
|
|
|
import argparse
|
|
|
|
@ -29,6 +30,16 @@ 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
|
|
|
|
|
|
|
|
|
|
# copy static/ to ../archive/static
|
|
|
|
|
repo_static_path = './static'
|
|
|
|
|
archive_static_path = os.path.join(args.output, repo_static_path)
|
|
|
|
|
os.makedirs(archive_static_path, exist_ok=True) # create static/ dir in archive
|
|
|
|
|
for static_file in os.listdir(path='./static'):
|
|
|
|
|
copy(src=os.path.join(repo_static_path, static_file),
|
|
|
|
|
dst=os.path.join(archive_static_path, static_file))
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
with open('login.txt', 'r') as login: # read login user & pwd
|
|
|
|
|
loginlines = login.read()
|
|
|
|
|
user, pwd = loginlines.split('\n')
|
|
|
|
@ -116,8 +127,7 @@ def dumppage(p, template, rewrite_images=True):
|
|
|
|
|
htmlsrc = rewritelinks(htmlsrc)
|
|
|
|
|
if rewrite_images:
|
|
|
|
|
htmlsrc = rewriteimgs(htmlsrc)
|
|
|
|
|
# TODO: ANdre structure of archive: from ./archive/0 to: ./archive ./0
|
|
|
|
|
html = template.render(page=p, body=htmlsrc, staticpath=f'../{wd_name}')
|
|
|
|
|
html = template.render(page=p, body=htmlsrc, staticpath='.')
|
|
|
|
|
with open(os.path.join(args.output, filenameforpage(p)), 'w') as f:
|
|
|
|
|
f.write(html)
|
|
|
|
|
# print(html, file=f)
|
|
|
|
|