ioanatomici 5 years ago
commit ce9798e94a

@ -1,6 +1,7 @@
import os, json, sys import os, json, sys
from mwclient import Site from mwclient import Site
from jinja2 import Template from jinja2 import Template
from shutil import copy
import html5lib import html5lib
from functions import Colors from functions import Colors
import argparse import argparse
@ -29,6 +30,16 @@ print(args)
site = Site(host=args.host, path=args.path) site = Site(host=args.host, path=args.path)
wd = os.path.dirname(os.path.abspath(__file__)) # working directory wd = os.path.dirname(os.path.abspath(__file__)) # working directory
wd_name = os.path.split(wd)[-1] # name of dir running script 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 with open('login.txt', 'r') as login: # read login user & pwd
loginlines = login.read() loginlines = login.read()
user, pwd = loginlines.split('\n') user, pwd = loginlines.split('\n')
@ -116,8 +127,7 @@ def dumppage(p, template, rewrite_images=True):
htmlsrc = rewritelinks(htmlsrc) htmlsrc = rewritelinks(htmlsrc)
if rewrite_images: if rewrite_images:
htmlsrc = rewriteimgs(htmlsrc) htmlsrc = rewriteimgs(htmlsrc)
# TODO: ANdre structure of archive: from ./archive/0 to: ./archive ./0 html = template.render(page=p, body=htmlsrc, staticpath='.')
html = template.render(page=p, body=htmlsrc, staticpath=f'../{wd_name}')
with open(os.path.join(args.output, filenameforpage(p)), 'w') as f: with open(os.path.join(args.output, filenameforpage(p)), 'w') as f:
f.write(html) f.write(html)
# print(html, file=f) # print(html, file=f)
@ -132,7 +142,7 @@ for cat in publish.members():
template = Template(templatefile.read()) template = Template(templatefile.read())
except FileNotFoundError: except FileNotFoundError:
with open('templates/default.html') as templatefile: with open('templates/default.html') as templatefile:
template = Template(templatefile.read()) template = Template(templatefile.read())
for p in cat.members(): for p in cat.members():
print(p) print(p)
dumppage(p, template, rewrite_images=not args.skipimages) dumppage(p, template, rewrite_images=not args.skipimages)
@ -141,7 +151,7 @@ for cat in publish.members():
else: else:
print("Dumping page {}".format(cat.page_title)) print("Dumping page {}".format(cat.page_title))
with open('templates/default.html') as templatefile: with open('templates/default.html') as templatefile:
template = Template(templatefile.read()) template = Template(templatefile.read())
dumppage(cat, template, rewrite_images=not args.skipimages) dumppage(cat, template, rewrite_images=not args.skipimages)

@ -1,26 +1,33 @@
body { body {
background-color: #F4EBE8; background-color: #F4EBE8;
font-family: Roboto Mono;
} }
.projtextcont{ .projtextcont{
display: block; display: block;
/*align-items: center; /*align-items: center;
justify-content: center*/ justify-content: center*/
color:#371F10;
margin-left:200px; margin-left:200px;
font-family: Roboto Mono;
} }
.projtext{ .projtext{
width: 50%; width: 85%;
height: 50%;
display: block; display: block;
} }
h1{ h1{
display: block; display: block;
width:50%;
}
h2{
display: block;
width:70%;
text-align: justify;
} }
.pagelink{ .pagelink{
@ -59,4 +66,8 @@ h1{
font-size: 13px; font-size: 13px;
background-color: white; background-color: white;
visibility: hidden; visibility: hidden;
}s }
.pagelink:hover .pagename{
visibility: visible;
}

@ -2,6 +2,7 @@
<html lang="en"> <html lang="en">
<head> <head>
<meta charset="utf-8"> <meta charset="utf-8">
<link rel="stylesheet" href="{{ staticpath }}/static/archive.css" />
<link rel="stylesheet" href="{{ staticpath }}/static/about.css" /> <link rel="stylesheet" href="{{ staticpath }}/static/about.css" />
<script type="text/javascript" src="{{ staticpath }}/static/archive.js"></script> <script type="text/javascript" src="{{ staticpath }}/static/archive.js"></script>
<link href='https://fonts.googleapis.com/css?family=Roboto+Mono' rel='stylesheet' type='text/css'> <link href='https://fonts.googleapis.com/css?family=Roboto+Mono' rel='stylesheet' type='text/css'>

Loading…
Cancel
Save