*** DONE Stage 1: Dump the pages from Trac wiki to files CLOSED: [2019-10-16 Wed 19:58]
Commands to dump the wiki files and tar them up
cd webapps/trac/bin ./trac-admin ../trac wiki dump ~/will-trac-wiki-dump cd ~ tar czf will-trac-wiki-dump.tar.gz will-trac-wiki-dump
*** TODO Stage 2: Import wiki pages into github repo There are two options here:
Convert to markdown
pandoc --from mediawiki --to markdown -o WikiStart.md WikiStart
Make a simple wrapper [[file:test-trac2down.py][test-track2down.py]] to convert all the dumped wiki files:
import sys import re from pathlib import Path sys.path.append("../../../Source/tracboat/src/tracboat") import trac2down
try: input_path = Path(sys.argv[1]) save_path = Path(sys.argv[2]) except (IndexError, ValueError, TypeError): sys.exit(f"Usage: {sys.argv[0]} INPUT_PATH SAVE_PATH")
wikinames = [p.name for p in input_path.glob("*")]
def fixup_wikilinks(text, targets):
"""Add double [[...]] around wikilinks (given as targets
)
Most prosaic method possible - simply loop over the explicit list of targets. Tries to be careful in avoiding code blocks, but will still be fooled by inline code """ lines = [] is_code_block = False for line in text.split('\n'):
if not line.startswith(' '):
if line.startswith("````"):
is_code_block = not is_code_block
if not is_code_block:
for target in targets:
line = line.replace(target, f"[[{target}]]")
# line = re.sub(r'\!(([A-Z][a-z0-9]+){2,})', r'[[\1]]', line)
lines.append(line)
return "\n".join(lines)
for p in input_path.glob("*"):
with open(p) as f: text = trac2down.convert(f.read(), ".") text = fixup_wikilinks(text, wikinames)
trac2down.save_file(text, p.name, None, None, None, save_path)
python test-trac2down.py ../will-trac-wiki-dump ../wiki-migration-test.wiki
** Allowing math equations
** Continuous integration, etc with Github Actions