From 4b09546c7ff035d14235f2e380956d47e417312f Mon Sep 17 00:00:00 2001 From: Castro0o Date: Thu, 2 Apr 2020 10:25:25 +0200 Subject: [PATCH] option --local; documentation --- README.md | 33 ++++++++++++++++++++++++++++++--- dumpwiki.py | 6 ++++++ static/archive.css | 0 3 files changed, 36 insertions(+), 3 deletions(-) create mode 100644 static/archive.css diff --git a/README.md b/README.md index 6341f57..ac971df 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,3 @@ -# Wiki to HTML pages script -![](https://pzwiki.wdka.nl/mw-mediadesign/images/8/82/Workflow-wiki2html.svg) ## Depencencies * python3 @@ -20,7 +18,9 @@ * Install: * Debian/Ubuntu: `sudo apt install pandoc` * Mac: `brew install pandoc` - +* [html5lib](https://github.com/html5lib/html5lib-python) + * Install: + * `pip3 install html5lib` ## login.txt `login.txt` is a local and individual file, ignored by git, where you place you itch wiki username and password, in separate lines. @@ -31,7 +31,32 @@ myusername mypassword ``` +## Create archive from wiki: + +### on sandbox server +`python dumpwiki.py` + +### locally on your own machine: +create archive folder: `mkdir archive` + +run script outputting to archive folder and displaying the images from the wiki: + +`python dumpwiki.py --output archive --local` + +### Categories and Templates: +For each Wiki Category in [Category Publish](https://hub.xpub.nl/sandbox/itchwiki/index.php/Category:Publish) +there should be an HTML [jinja2 template](https://jinja.palletsprojects.com/en/2.11.x/) +, with the same name of the category this repository `templates/` + +If not the `templates/default.html` will be used to render the pages under that Category. + + + +--- + + +# query2html.py ## Run `cd special-issue-11-wiki2html/` @@ -100,3 +125,5 @@ It is to convert pdfs to jpgs: convert -quality 100 -density 300 [name-of-pdf] %02d.jpg +# Wiki to HTML pages script +![](https://pzwiki.wdka.nl/mw-mediadesign/images/8/82/Workflow-wiki2html.svg) diff --git a/dumpwiki.py b/dumpwiki.py index 9853c58..2e83c53 100644 --- a/dumpwiki.py +++ b/dumpwiki.py @@ -16,6 +16,7 @@ p.add_argument("--host", metavar='', default="hub.xpub.nl/sandbox", help='wiki 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("--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") args = p.parse_args() @@ -58,6 +59,11 @@ def rewritelinks (html): if href.startswith("/sandbox/itchwiki/index.php/"): new_href = filenameforlink(href) a.attrib['href'] = new_href + if args.local is True: + for img in t.findall(".//img[@src]"): + src = img.attrib.get("src") + if not src.startswith('http'): + img.attrib['src'] = 'https://hub.xpub.nl' + src html = ET.tostring(t, method="html", encoding="unicode") return html diff --git a/static/archive.css b/static/archive.css new file mode 100644 index 0000000..e69de29