![](https://secure.gravatar.com/avatar/df8330968b6df8cd1c1942c5fb4b720c.jpg?s=120&d=mm&r=g)
Author: jw Date: 2006-04-11 13:31:32 +0200 (Tue, 11 Apr 2006) New Revision: 1222 Added: tools/scripts/gen_map.sh Log: gen_map: script to generate google map input from pmwiki Added: tools/scripts/gen_map.sh =================================================================== --- tools/scripts/gen_map.sh (rev 0) +++ tools/scripts/gen_map.sh 2006-04-11 11:31:32 UTC (rev 1222) @@ -0,0 +1,57 @@ +#!/bin/bash +# Generate data input from the wiki as input for google maps, +# like http://jw.tks6.net/files/crux/cruxmap.html +# +# Johannes Winkelmann, jw at tks6 dot net + +URL=http://crux.nu/Public/UserMap?action=print +CMD="links -no-numbering -no-references -dump" + +intext="" +closeCity() { + echo "cities.push(city$1);" +} + +cityCount=0 +doGen() { + +$CMD $URL|grep -v "Page last"|while read line; do + if [ -z "$line" ]; then + continue + fi + if [ -n "`echo $line|grep "Retrieved from"`" ]; then + closeCity $cityCount + break + fi + if [ "$intext" = "yes" ]; then + first="$(echo $line|head -c 1)" + if [ "$first" = "%" ]; then + city=("$(echo "$line"|awk -F \| '{print $1;}'|sed -e 's|%\s*||g' -e 's|\s*$||')" \ + $(echo $line|awk -F \| '{print $2;}') + $(echo $line|awk -F \| '{print $3;}') + $(echo $line|awk -F \| '{print $4;}') + ) + + if [ $cityCount -gt 0 ]; then + closeCity $cityCount + fi + + cityCount=$((cityCount + 1)) + cities=(${cities[*]} abc) + echo "var city$cityCount = new City(\"${city[0]}\", ${city[1]}, ${city[2]}, ${city[3]});" + else + name=$(echo $line|sed -e 's/\s*|.*//' -e 's|^\s*||g') + nick=$(echo $line|sed -e 's/.*|\s*//g' -e 's|\s*$||g') + + echo "city$cityCount.people.push(new Person(\"$name\", \"$nick\"));" + fi + else + if [ "$line" = "Data start" ]; then + intext="yes" + fi + fi +done + +} + +doGen Property changes on: tools/scripts/gen_map.sh ___________________________________________________________________ Name: svn:executable + *