mirror of
git://xwords.git.sourceforge.net/gitroot/xwords/xwords
synced 2025-01-26 07:58:52 +01:00
script to build html page for downloading dicts
This commit is contained in:
parent
d5d81fea5b
commit
6b58c9031f
1 changed files with 54 additions and 0 deletions
54
xwords4/dawg/mkindex.sh
Executable file
54
xwords4/dawg/mkindex.sh
Executable file
|
@ -0,0 +1,54 @@
|
|||
#!/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>$LANG</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 "<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
|
||||
|
Loading…
Add table
Reference in a new issue