mirror of
git://xwords.git.sourceforge.net/gitroot/xwords/xwords
synced 2025-01-03 23:04:08 +01:00
61 lines
1.1 KiB
Bash
Executable file
61 lines
1.1 KiB
Bash
Executable file
#!/bin/sh
|
|
|
|
set -u -e
|
|
|
|
usage() {
|
|
echo "usage: $0 /path/to/dicts"
|
|
echo " write to stdout an html file that serves up all .xwd files inside /path/to/dicts"
|
|
exit 1
|
|
}
|
|
|
|
do_lang() {
|
|
LANG=$1
|
|
echo "<tr><td><a name=\"$LANG\">$LANG</a></td></tr>"
|
|
|
|
cd $LANG
|
|
for DICT in $(ls *.xwd); do
|
|
echo "<tr>"
|
|
echo "<td> <a href=\"./$LANG/$DICT\">${DICT%.xwd}</a></td>"
|
|
SIZE=$(ls -l $DICT | awk '{print $5}')
|
|
echo "<td>${SIZE}</td>"
|
|
HEXCOUNT=$(hd $DICT | head -n 1 | awk '{print $6 $7 $8 $9}' | tr [a-f] [A-F])
|
|
DECCOUNT=$(echo "ibase=16;$HEXCOUNT" | bc)
|
|
echo "<td>${DECCOUNT}</td>"
|
|
echo "</tr>"
|
|
done
|
|
|
|
cd ..
|
|
}
|
|
|
|
[ $# -eq 1 ] || usage
|
|
|
|
WD=$(pwd)
|
|
cd $1
|
|
|
|
DIRS=""
|
|
for DIR in $(ls); do
|
|
if [ -d $DIR ] && ls $DIR/*.xwd >/dev/null 2>&1; then
|
|
DIRS="$DIRS $DIR"
|
|
fi
|
|
done
|
|
|
|
|
|
echo "<html><body>"
|
|
|
|
echo "<p>Download dictionaries for:"
|
|
for DIR in $DIRS; do
|
|
echo " <a href=\"#$DIR\">$DIR</a>"
|
|
done
|
|
echo ".</p>"
|
|
|
|
echo "<table>"
|
|
echo "<tr><th>File</th><th>Size</th><th>Wordcount</th></tr>"
|
|
for DIR in $DIRS; do
|
|
do_lang $DIR
|
|
done
|
|
echo "</table>"
|
|
|
|
echo "</body></html>"
|
|
|
|
cd $WD
|
|
|