ConfluenceConverter

Annotated tools/mappings.sh

144:06641676740f
2017-06-16 Paul Boddie Attempt to add Confluence 6 support with modified export and document formats.
paul@95 1
#!/bin/sh
paul@95 2
paul@97 3
PROGNAME=`basename $0`
paul@97 4
THISDIR=`dirname $0`
paul@97 5
paul@98 6
SPACES=$*
paul@97 7
paul@98 8
if [ ! "$SPACES" ]; then
paul@98 9
	echo "$PROGNAME <space directory>..."
paul@97 10
	exit 1
paul@97 11
fi
paul@97 12
paul@95 13
ID_MAPPING="mapping-id-to-page.txt"
paul@95 14
TINY_ID_MAPPING="mapping-tiny-to-id.txt"
paul@95 15
TINY_MAPPING="mapping-tiny-to-page.txt"
paul@95 16
TAB=`printf '\t'`
paul@95 17
paul@95 18
# Combine the space mappings into a common mapping from page identifiers to
paul@95 19
# page names.
paul@98 20
sort -n -u `find $SPACES -name MAPPING` > "$ID_MAPPING"
paul@95 21
paul@95 22
# Produce a common mapping from tiny URL identifiers to page names.
paul@97 23
cut -f 1 "$ID_MAPPING" | uniq | "$THISDIR/tiny.py" - > "$TINY_ID_MAPPING"
paul@95 24
join -t "$TAB" -1 2 -2 1 "$TINY_ID_MAPPING" "$ID_MAPPING" | cut -f 2,3 | LC_ALL=C sort > "$TINY_MAPPING"