From ac5fbdfe67e93839ec86d3757087b27317a18dc2 Mon Sep 17 00:00:00 2001 From: drowe67 Date: Sat, 25 May 2013 05:19:41 +0000 Subject: [PATCH] Initial import of foxy Fox Hunting Google Maps App git-svn-id: https://svn.code.sf.net/p/freetel/code@1271 01035d8c-6547-0410-b346-abe4f91aad63 --- README.txt | 126 ++++++++++++ cgi-bin/addbearing.cgi | 31 +++ cgi-bin/cleardb.cgi | 26 +++ cgi-bin/delbearing.cgi | 36 ++++ cgi-bin/getbearings.cgi | 30 +++ foxy.css | 70 +++++++ foxy.html | 443 ++++++++++++++++++++++++++++++++++++++++ 7 files changed, 762 insertions(+) create mode 100644 README.txt create mode 100755 cgi-bin/addbearing.cgi create mode 100755 cgi-bin/cleardb.cgi create mode 100755 cgi-bin/delbearing.cgi create mode 100755 cgi-bin/getbearings.cgi create mode 100644 foxy.css create mode 100644 foxy.html diff --git a/README.txt b/README.txt new file mode 100644 index 00000000..0803375a --- /dev/null +++ b/README.txt @@ -0,0 +1,126 @@ +README.txt for foxy +David Rowe +May 25 2013 + + +Introduction +------------ + +Simple Google Maps application to plot Fox Hunt bearings. + +* Screen shot: foxy_screenshot.png + +* Based on Google maps V3 API. + +* Light weight: On the server we have just a few CGIs and a text file + database. A browser cookie is used for storing configuration + information. The CGIs are a few lines of shell script, so can run + on any machine. Installation involves copying a few files and + setting a few permissions. + + +Using Foxy +---------- + +1/ Point your browser at http://yourserver/foxy.html + +2/ Enter the bearing in the text box and left click to add a bearing. + +3/ Left click on a bearing to get information. Right click to delete +a bearing. + + +Implementation Notes +-------------------- + +Foxy is implemented in Javascript (foxy.html). A simple text database +file /var/www/foxy/bearings.txt is used to store bearing +information. Very simple 1 page CGIs written in shell script are used +to access the bearing database. + +A browser cookie is used to store config information like the current +map centre. + +All the CGI scripts assume a hard coded path of /var/www/bearings for +the bearings.txt database. + + +Files +----- + + foxy.html - Javascript code for Foxy + foxy.css - style sheet + +"cgi-bin" directory: + + addbearing.cgi - adds a bearing to bearings.txt + delbearing.cgi - deletes a bearing from bearings.txt + getbearings.cgi - reads bearings.txt database + cleardb.cgi - clears database, removing all bearings + + +Software +-------- + +You need: + +1/ A web server. Apache is assumed in the /usr/lib/cgi-bin path below. + The paths may be different for other web servers. Note the path + to /var/www/foxy is hard coded in the CGI scripts so it's + best not to change that. + + +Installation +------------ + +1/ Server PC + + $ svn co https://freetel.svn.sourceforge.net/svnroot/freetel/foxy + $ cd foxy + $ sudo mkdir /var/www/foxy + $ sudo chmod 777 /var/www/foxy + $ cp foxy.css foxy.html /var/www/foxy + $ sudo cp cgi-bin/* /usr/lib/cgi-bin + +Tests +----- + +1/ Test reading and writing bearings.txt database with your browser: + + http://localhost/cgi-bin/addbearing.cgi?lat=123&lng=456&bearing=90 + + $ cat /var/www/foxy/bearings.txt + 123,456,90 + + http://localhost/cgi-bin/delbearing.cgi?lat=123&lng=456 + + $ cat /var/www/foxy/bearings.txt + (empty file) + +Debugging +--------- + +1/ Monitor Apache log: + + $ tail -f /var/log/apache2/access.log + +2/ Use Firebug on Firefox to single step, set breakpoints etc. + +3/ Check bearings.txt database, each line is (lat, lng, IP): + + # cat /var/www/foxy/bearings.txt + + -34.88548650005714,138.55225324630737,90 + -34.88006501016277,138.55394840240479,180 + -34.87893842193011,138.55278968811035,265 + -34.882511765792316,138.55210304260254,10 + +4/ The "foxy001" cookie stores our state. On Firefox 3.5 you + can remove the foxy cookie using Edit-Preferences-Privacy, then + click on "remove individual cookies". + +5/ To manually reset to defaults: + + * move to another page (cookie is saved when we exit page) + * rm -f /var/www/foxy/bearings.txt + * Delete cookie using step (4) above diff --git a/cgi-bin/addbearing.cgi b/cgi-bin/addbearing.cgi new file mode 100755 index 00000000..95f95c6d --- /dev/null +++ b/cgi-bin/addbearing.cgi @@ -0,0 +1,31 @@ +#!/bin/sh +# addbearing.cgi +# David Rowe 25 May 2013 +# +# CGI to add a new bearing + +cat < + + + + + +EOF + +lat=`echo "$QUERY_STRING" | sed -n "s/.*lat=\(.*\)&lng.*/\1/p"` +lng=`echo "$QUERY_STRING" | sed -n "s/.*lng=\(.*\)&bearing.*/\1/p"` +bearing=`echo "$QUERY_STRING" | sed -n "s/.*bearing=\(.*\)/\1/p"` + +echo $lat,$lng,$bearing >> /var/www/foxy/bearings.txt + +echo $QUERY_STRING "
" +echo "
" +echo $lat $lng $bearing + +cat < + +EOF diff --git a/cgi-bin/cleardb.cgi b/cgi-bin/cleardb.cgi new file mode 100755 index 00000000..1d39234c --- /dev/null +++ b/cgi-bin/cleardb.cgi @@ -0,0 +1,26 @@ +#!/bin/sh +# cleardb.cgi +# David Rowe 25 May 2013 +# +# CGI to delete entire bearing database + +cat < + + + + + +EOF + +# path to node database text file + +P=/var/www/foxy +rm $P/bearings.txt + +cat < + +EOF diff --git a/cgi-bin/delbearing.cgi b/cgi-bin/delbearing.cgi new file mode 100755 index 00000000..19168dfe --- /dev/null +++ b/cgi-bin/delbearing.cgi @@ -0,0 +1,36 @@ +#!/bin/sh +# delbearing.cgi +# David Rowe 25 May 2012 +# +# CGI to delete a bearing + +cat < + + + + + +EOF + +lat=`echo "$QUERY_STRING" | sed -n "s/lat=\(.*\)&.*/\1/pg"` +lng=`echo "$QUERY_STRING" | sed -n "s/.*lng=\(.*\)/\1/pg"` + +# path to node database text file + +P=/var/www/foxy + +cat $P/bearings.txt | sed "/$lat,$lng.*/ d" > $P/bearings.tmp +cp $P/bearings.tmp $P/bearings.txt +rm $P/bearings.tmp + +#echo $QUERY_STRING "
" +#echo "
" +#echo $lat $lng + +cat < + +EOF diff --git a/cgi-bin/getbearings.cgi b/cgi-bin/getbearings.cgi new file mode 100755 index 00000000..05f7c47f --- /dev/null +++ b/cgi-bin/getbearings.cgi @@ -0,0 +1,30 @@ +#!/bin/sh +# getbearings.cgi +# David Rowe 25 May 2013 +# +# CGI to return list of bearings from the bearings.txt database text file +# We use a CGI rather than fetching the text file directly +# so we can stop Firefox from caching + +cat < + + + + + + +EOF + +BEARINGS=/var/www/foxy/bearings.txt + +if [ -f $BEARINGS ] ; then + cat $BEARINGS +fi + +cat < + +EOF diff --git a/foxy.css b/foxy.css new file mode 100644 index 00000000..d72344f5 --- /dev/null +++ b/foxy.css @@ -0,0 +1,70 @@ +html,body{ + margin:0; + padding:0; + width:100%; + height:100%; + font-family:Arial, Helvetica, sans-serif; +} + +div#header{ + vertical-align:middle; + border-bottom:1px solid #000; +} +div#main-map{ + width:70%; + height:100%; + float:left; +} +div#side{ + width:30%; + float:left; +} + +div#dataPanel{ + width:90%; + height:50%; + overflow:auto; + border:2px solid #DDDDDD; +} +input{ + width:90%; +} + +input.navi{ + font-size:12px; + height:30px; + margin-bottom:10px; +} +div ul{ + margin-top:30px; + margin-bottom:30px; +} +div ul li{ + display: inline; + list-style-type: none; + padding-right: 40px; + font-size:18px; + font-weight:bold; +} + +div ul li.title{ + font-size:22px; + color:#888; +} + +div#header p{ + color:#888; + font-size:14px; + padding-left:20px; +} +span.instruction{ + font-weight:bold; + +} + +.message-box { text-align: center; padding: 5px; color:#545454; width:80%; margin:5px auto; font-size:12px;} +.clean { background-color: #efefef; border-top: 2px solid #dedede; border-bottom: 2px solid #dedede; } +.info { background-color: #f7fafd; border-top: 2px solid #b5d3ff; border-bottom: 2px solid #b5d3ff; } +.ok { background-color: #d7f7c4; border-top: 2px solid #82cb2f; border-bottom: 2px solid #82cb2f; } +.alert { background-color: #fef5be; border-top: 2px solid #fdd425; border-bottom: 2px solid #fdd425; } +.error { background-color: #ffcdd1; border-top: 2px solid #e10c0c; border-bottom: 2px solid #e10c0c; } \ No newline at end of file diff --git a/foxy.html b/foxy.html new file mode 100644 index 00000000..10bbcedf --- /dev/null +++ b/foxy.html @@ -0,0 +1,443 @@ + + + + + + +Foxy + + + + + + + + + +
+
+ +
+ +

Help

+ + +
Foxy README
+ +
+

Contol Panel

+
+ + + + + + + + + + + + + + + + + +
+ Bearing
Clear Database
Debug Messages
+
+ + +
+

Tests

+
    +
  1. Test bearings.txt database
    +
+
+ +
+

Debugging Output

+
    +
+
+
+ + + + -- 2.25.1