1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
1.2 +++ b/tools/mappings.sh Tue Jul 16 23:52:15 2013 +0200
1.3 @@ -0,0 +1,24 @@
1.4 +#!/bin/sh
1.5 +
1.6 +PROGNAME=`basename $0`
1.7 +THISDIR=`dirname $0`
1.8 +
1.9 +MAPPINGS=$*
1.10 +
1.11 +if [ ! "$MAPPINGS" ]; then
1.12 + echo "$PROGNAME <mapping file>..."
1.13 + exit 1
1.14 +fi
1.15 +
1.16 +ID_MAPPING="mapping-id-to-page.txt"
1.17 +TINY_ID_MAPPING="mapping-tiny-to-id.txt"
1.18 +TINY_MAPPING="mapping-tiny-to-page.txt"
1.19 +TAB=`printf '\t'`
1.20 +
1.21 +# Combine the space mappings into a common mapping from page identifiers to
1.22 +# page names.
1.23 +sort -n -u $MAPPINGS > "$ID_MAPPING"
1.24 +
1.25 +# Produce a common mapping from tiny URL identifiers to page names.
1.26 +cut -f 1 "$ID_MAPPING" | uniq | "$THISDIR/tiny.py" - > "$TINY_ID_MAPPING"
1.27 +join -t "$TAB" -1 2 -2 1 "$TINY_ID_MAPPING" "$ID_MAPPING" | cut -f 2,3 | LC_ALL=C sort > "$TINY_MAPPING"