Merge branch 'archive_local' of XPUB/special-issue-11-wiki2html into master

pull/7/head
acastro 5 years ago committed by Gitea
commit 72e71019ea

@ -1,5 +1,3 @@
# Wiki to HTML pages script
![](https://pzwiki.wdka.nl/mw-mediadesign/images/8/82/Workflow-wiki2html.svg)
## Depencencies ## Depencencies
* python3 * python3
@ -20,7 +18,9 @@
* Install: * Install:
* Debian/Ubuntu: `sudo apt install pandoc` * Debian/Ubuntu: `sudo apt install pandoc`
* Mac: `brew install pandoc` * Mac: `brew install pandoc`
* [html5lib](https://github.com/html5lib/html5lib-python)
* Install:
* `pip3 install html5lib`
## login.txt ## 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. `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 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 ## Run
`cd special-issue-11-wiki2html/` `cd special-issue-11-wiki2html/`
@ -100,3 +125,5 @@ It is
to convert pdfs to jpgs: to convert pdfs to jpgs:
convert -quality 100 -density 300 [name-of-pdf] %02d.jpg 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)

@ -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("--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="/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("--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() args = p.parse_args()
@ -58,6 +59,11 @@ def rewritelinks (html):
if href.startswith("/sandbox/itchwiki/index.php/"): if href.startswith("/sandbox/itchwiki/index.php/"):
new_href = filenameforlink(href) new_href = filenameforlink(href)
a.attrib['href'] = new_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") html = ET.tostring(t, method="html", encoding="unicode")
return html return html

Loading…
Cancel
Save