diff --git a/dumpwiki.py b/dumpwiki.py
index 03182d3..601d692 100644
--- a/dumpwiki.py
+++ b/dumpwiki.py
@@ -45,8 +45,7 @@ with open('login.txt', 'r') as login: # read login user & pwd
# read template files
-with open('templates/title.html') as title_html:
- title_template = Template(title_html.read())
+
SLASH = "\u2044"
@@ -54,13 +53,25 @@ def filenameforpage(p):
f=p.name.replace(' ','_').replace('/', SLASH) + '.html'
return f
-title=site.Categories['Title']
-for p in title.members():
- print(p)
- htmlsrc = site.parse(page=p.name)['text']['*']
- with open(os.path.join(args.output, filenameforpage(p)), 'w') as f:
- print(htmlsrc, file=f)
- # break
+publish=site.Categories['Publish']
+for cat in publish.members():
+ if cat.namespace!=14:
+ continue
+ print('dumping category {}'.format(cat.page_title))
+ # title=site.Categories['Title']
+ try:
+ with open('templates/{}.html'.format(cat.page_title.lower())) as templatefile:
+ template = Template(templatefile.read())
+ except FileNotFoundError:
+ with open('templates/default.html') as templatefile:
+ template = Template(templatefile.read())
+ for p in cat.members():
+ print(p)
+ htmlsrc = site.parse(page=p.name)['text']['*']
+ html = template.render(page=p, body=htmlsrc)
+ with open(os.path.join(args.output, filenameforpage(p)), 'w') as f:
+ print(html, file=f)
+ # break
diff --git a/templates/default.html b/templates/default.html
new file mode 100644
index 0000000..e6c9cbf
--- /dev/null
+++ b/templates/default.html
@@ -0,0 +1,15 @@
+
+
+
+
+
+
+ {{ page.name }}
+
+
+
+ {{ page.name }}
+ {{ body|safe }}
+
+
+
diff --git a/templates/document1.html b/templates/document1.html
new file mode 100644
index 0000000..744b06a
--- /dev/null
+++ b/templates/document1.html
@@ -0,0 +1,91 @@
+
+
+
+
+
+
+ {{ title[0] }}
+
+
+ {{ title[0] }}
+
+
+
+
Metadata
+
+
+
+
+
Creator
+
{{ creator }}
+
+
Format
+
{{ format }}
+
+
Topic
+
{{topic}}
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ {% for row in imgsmatrix %}
+
+ {% for img in row %}
+
+
+
+ {% endfor %}
+
+ {% endfor %}
+
+
+
+
+{#
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+#}
\ No newline at end of file
diff --git a/templates/document2.html b/templates/document2.html
new file mode 100644
index 0000000..285e757
--- /dev/null
+++ b/templates/document2.html
@@ -0,0 +1,84 @@
+
+
+
+
+
+
+ {{ title[0] }}
+
+
+ {{ title[0] }}
+
+
+
+
+ {{ creator }}
+
+ {{ format }}
+
+ {{topic}}
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ {% for row in imgsmatrix %}
+
+ {% for img in row %}
+
+
+
+ {% endfor %}
+
+ {% endfor %}
+
+
+
+
+{#
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+#}
\ No newline at end of file
diff --git a/templates/format.html b/templates/format.html
new file mode 100644
index 0000000..cbc09cb
--- /dev/null
+++ b/templates/format.html
@@ -0,0 +1,17 @@
+
+
+
+
+
+
+
+
+ {{ page.name }}
+
+
+
+ {{ page.name }}
+ {{ body|safe }}
+
+
+
diff --git a/templates/title.html b/templates/title.html
index 9785cb3..cbc09cb 100644
--- a/templates/title.html
+++ b/templates/title.html
@@ -2,86 +2,16 @@
-
-
- {{ title[0] }}
+
+
+
+
+ {{ page.name }}
-
- {{ title[0] }} ↵
-
+
-
+ {{ page.name }}
+ {{ body|safe }}
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- {% for row in imgsmatrix %}
-
- {% for img in row %}
-
-
-
- {% endfor %}
-
- {% endfor %}
-
-