You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@community.apache.org by ni...@apache.org on 2009/12/26 18:10:42 UTC
svn commit: r894005 [2/2] - in /comdev/nearby_people: ./ data/ docs/ lib/
nearby/ nearby/templatetags/ templates/
Added: comdev/nearby_people/nearby/foaf.py
URL: http://svn.apache.org/viewvc/comdev/nearby_people/nearby/foaf.py?rev=894005&view=auto
==============================================================================
--- comdev/nearby_people/nearby/foaf.py (added)
+++ comdev/nearby_people/nearby/foaf.py Sat Dec 26 17:10:41 2009
@@ -0,0 +1,115 @@
+# ====================================================================
+# Licensed to the Apache Software Foundation (ASF) under one or more
+# contributor license agreements. See the NOTICE file distributed with
+# this work for additional information regarding copyright ownership.
+# The ASF licenses this file to You under the Apache License, Version 2.0
+# (the "License"); you may not use this file except in compliance with
+# the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+# ====================================================================
+
+# Parses and caches foaf files
+
+from xml.dom.minidom import parse
+from settings import PEOPLE_FOAF_PATH, PEOPLE_FOAF_NAMESPACE
+import datetime
+import geo_helper
+import sys,os
+
+NS_RDF = "http://www.w3.org/1999/02/22-rdf-syntax-ns"
+NS_GEO = "http://www.w3.org/2003/01/geo/wgs84_pos#"
+NS_FOAF = "http://xmlns.com/foaf/0.1/"
+NS_DOAP = "http://usefulinc.com/ns/doap#"
+
+class FOAF(object):
+ def __init__(self, doap_file):
+ self.doap_file = doap_file
+ self.people = {}
+ self.updated_at = None
+
+ def get_nearby(self, lat, long):
+ self.ensure_data()
+
+ dists = [
+ (geo_helper.calculate_distance_and_bearing(lat,long,f["latitude"],f["longitude"])[0],f)
+ for f in self.people.values()
+ ]
+ dists.sort( lambda x,y: int(x[0]-y[0]) )
+ return dists[:20]
+
+ def ensure_data(self):
+ if not self.people:
+ self._refresh()
+ if datetime.datetime.utcnow() - self.updated_at > datetime.timedelta(hours=12):
+ self._refresh()
+
+ def _refresh(self):
+ doap = parse(self.doap_file)
+ foaf_people = doap.getElementsByTagNameNS(NS_FOAF,"Person")
+ for foaf in foaf_people:
+ uri = foaf.getAttribute("rdf:resource")
+ if not uri:
+ continue
+ print uri
+
+ surname = None
+ name = None
+ uid = None
+ lat = None
+ long = None
+
+ if uri.startswith(PEOPLE_FOAF_NAMESPACE):
+ file = os.path.join(PEOPLE_FOAF_PATH, uri.replace(PEOPLE_FOAF_NAMESPACE,""))
+ foaf = parse(file)
+
+ surnameN = foaf.getElementsByTagNameNS(NS_FOAF,"family_name")
+ nameN = foaf.getElementsByTagNameNS(NS_FOAF,"name")
+ longN = foaf.getElementsByTagNameNS(NS_GEO,"long")
+ latN = foaf.getElementsByTagNameNS(NS_GEO,"lat")
+ uidN = foaf.getElementsByTagNameNS(NS_FOAF,"Person")
+ if surnameN:
+ surname = surnameN[0].firstChild.data
+ if nameN:
+ name = nameN[0].firstChild.data
+ if longN:
+ long = longN[0].firstChild.data
+ if latN:
+ lat = latN[0].firstChild.data
+ if uidN:
+ uid = uidN[0].getAttribute("rdf:ID")
+ else:
+ # TODO - external FOAF support
+ # ....
+ pass
+
+ # People are funny about their lat and long
+ if lat:
+ if lat.endswith("N"):
+ lat = lat[:-1]
+ if lat.endswith("S"):
+ lat = lat[:-1]
+ if not lat.startswith("-"):
+ lat = "-%s" % lat
+ if long:
+ if long.endswith("E"):
+ long = long[:-1]
+ if long.endswith("W"):
+ long = long[:-1]
+ if not long.startswith("-"):
+ long = "-%s" % long
+
+ # Finish building up
+ if name and surname and uid and lat and long:
+ self.people[name] = {
+ "name": name, "surname": surname, "uid":uid,
+ "latitude": lat, "longitude": long
+ }
+
+ self.updated_at = datetime.datetime.utcnow()
Propchange: comdev/nearby_people/nearby/foaf.py
------------------------------------------------------------------------------
svn:eol-style = native
Added: comdev/nearby_people/nearby/forms.py
URL: http://svn.apache.org/viewvc/comdev/nearby_people/nearby/forms.py?rev=894005&view=auto
==============================================================================
--- comdev/nearby_people/nearby/forms.py (added)
+++ comdev/nearby_people/nearby/forms.py Sat Dec 26 17:10:41 2009
@@ -0,0 +1,40 @@
+# ====================================================================
+# Licensed to the Apache Software Foundation (ASF) under one or more
+# contributor license agreements. See the NOTICE file distributed with
+# this work for additional information regarding copyright ownership.
+# The ASF licenses this file to You under the Apache License, Version 2.0
+# (the "License"); you may not use this file except in compliance with
+# the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+# ====================================================================
+
+from django import forms
+
+class PlaceForm(forms.Form):
+ place_name = forms.CharField()
+ type = forms.TypedChoiceField(choices=(
+ ('','Default'), ('lm','Local Mentors'),
+ ('sp','Speakers'),
+ ),
+ required=False,
+ widget=forms.HiddenInput,
+ )
+ def set_type(self, type):
+ for opt,name in self.fields["type"].choices:
+ if opt == type:
+ self.initial["type"] = opt
+ def enableTypeField(self):
+ self.fields["type"].widget = forms.Select(
+ choices=self.fields["type"].choices
+ )
+
+class LocationForm(forms.Form):
+ latitude = forms.FloatField()
+ longitude = forms.FloatField()
Propchange: comdev/nearby_people/nearby/forms.py
------------------------------------------------------------------------------
svn:eol-style = native
Added: comdev/nearby_people/nearby/models.py
URL: http://svn.apache.org/viewvc/comdev/nearby_people/nearby/models.py?rev=894005&view=auto
==============================================================================
--- comdev/nearby_people/nearby/models.py (added)
+++ comdev/nearby_people/nearby/models.py Sat Dec 26 17:10:41 2009
@@ -0,0 +1,18 @@
+# ====================================================================
+# Licensed to the Apache Software Foundation (ASF) under one or more
+# contributor license agreements. See the NOTICE file distributed with
+# this work for additional information regarding copyright ownership.
+# The ASF licenses this file to You under the Apache License, Version 2.0
+# (the "License"); you may not use this file except in compliance with
+# the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+# ====================================================================
+
+from django.db import models
Propchange: comdev/nearby_people/nearby/models.py
------------------------------------------------------------------------------
svn:eol-style = native
Added: comdev/nearby_people/nearby/shortcuts.py
URL: http://svn.apache.org/viewvc/comdev/nearby_people/nearby/shortcuts.py?rev=894005&view=auto
==============================================================================
--- comdev/nearby_people/nearby/shortcuts.py (added)
+++ comdev/nearby_people/nearby/shortcuts.py Sat Dec 26 17:10:41 2009
@@ -0,0 +1,34 @@
+# ====================================================================
+# Licensed to the Apache Software Foundation (ASF) under one or more
+# contributor license agreements. See the NOTICE file distributed with
+# this work for additional information regarding copyright ownership.
+# The ASF licenses this file to You under the Apache License, Version 2.0
+# (the "License"); you may not use this file except in compliance with
+# the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+# ====================================================================
+
+from django.http import HttpRequest, HttpResponseRedirect, Http404, \
+ HttpResponseForbidden, HttpResponse
+
+from django.shortcuts import render_to_response
+from django.template import RequestContext
+
+def render(request, template_name, data_dict=None, content_type=None):
+ assert isinstance(request, HttpRequest)
+ return render_to_response(
+ template_name, data_dict or {},
+ context_instance=RequestContext(request),
+ mimetype=content_type
+ )
+
+def add_message(request, message):
+ "Adds a message to be shown on next page load."
+ request.user.message_set.create(message=message)
Propchange: comdev/nearby_people/nearby/shortcuts.py
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: comdev/nearby_people/nearby/templatetags/
------------------------------------------------------------------------------
--- svn:ignore (added)
+++ svn:ignore Sat Dec 26 17:10:41 2009
@@ -0,0 +1,2 @@
+*.swp
+*.pyc
Added: comdev/nearby_people/nearby/templatetags/__init__.py
URL: http://svn.apache.org/viewvc/comdev/nearby_people/nearby/templatetags/__init__.py?rev=894005&view=auto
==============================================================================
--- comdev/nearby_people/nearby/templatetags/__init__.py (added)
+++ comdev/nearby_people/nearby/templatetags/__init__.py Sat Dec 26 17:10:41 2009
@@ -0,0 +1,16 @@
+# ====================================================================
+# Licensed to the Apache Software Foundation (ASF) under one or more
+# contributor license agreements. See the NOTICE file distributed with
+# this work for additional information regarding copyright ownership.
+# The ASF licenses this file to You under the Apache License, Version 2.0
+# (the "License"); you may not use this file except in compliance with
+# the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+# ====================================================================
Propchange: comdev/nearby_people/nearby/templatetags/__init__.py
------------------------------------------------------------------------------
svn:eol-style = native
Added: comdev/nearby_people/nearby/templatetags/distances.py
URL: http://svn.apache.org/viewvc/comdev/nearby_people/nearby/templatetags/distances.py?rev=894005&view=auto
==============================================================================
--- comdev/nearby_people/nearby/templatetags/distances.py (added)
+++ comdev/nearby_people/nearby/templatetags/distances.py Sat Dec 26 17:10:41 2009
@@ -0,0 +1,48 @@
+# ====================================================================
+# Licensed to the Apache Software Foundation (ASF) under one or more
+# contributor license agreements. See the NOTICE file distributed with
+# this work for additional information regarding copyright ownership.
+# The ASF licenses this file to You under the Apache License, Version 2.0
+# (the "License"); you may not use this file except in compliance with
+# the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+# ====================================================================
+
+from django import template
+from django.template.defaultfilters import stringfilter
+
+register = template.Library()
+
+def format_distance(distance):
+ if distance < 1000:
+ return "%d m" % distance
+ elif distance < 50 * 1000:
+ return "%0.1f km" % (distance/1000)
+ else:
+ return "%d km" % (distance/1000)
+
+
+# As a filter
+@register.filter
+@stringfilter
+def distanceformat(value):
+ return format_distance(float(value))
+
+# As a tag
+class DistanceNode(template.Node):
+ def __init__(self, distance):
+ self.distance = distance
+ def render(self,context):
+ return self.nodelist.render( format_distance(self.distance) )
+
+@register.tag
+def distance(parser, token):
+ bits = token.split_contents()
+ return DistanceNode(bits[1])
Propchange: comdev/nearby_people/nearby/templatetags/distances.py
------------------------------------------------------------------------------
svn:eol-style = native
Added: comdev/nearby_people/nearby/tests.py
URL: http://svn.apache.org/viewvc/comdev/nearby_people/nearby/tests.py?rev=894005&view=auto
==============================================================================
--- comdev/nearby_people/nearby/tests.py (added)
+++ comdev/nearby_people/nearby/tests.py Sat Dec 26 17:10:41 2009
@@ -0,0 +1,40 @@
+# ====================================================================
+# Licensed to the Apache Software Foundation (ASF) under one or more
+# contributor license agreements. See the NOTICE file distributed with
+# this work for additional information regarding copyright ownership.
+# The ASF licenses this file to You under the Apache License, Version 2.0
+# (the "License"); you may not use this file except in compliance with
+# the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+# ====================================================================
+
+"""
+This file demonstrates two different styles of tests (one doctest and one
+unittest). These will both pass when you run "manage.py test".
+
+Replace these with more appropriate tests for your application.
+"""
+
+from django.test import TestCase
+
+class SimpleTest(TestCase):
+ def test_basic_addition(self):
+ """
+ Tests that 1 + 1 always equals 2.
+ """
+ self.failUnlessEqual(1 + 1, 2)
+
+__test__ = {"doctest": """
+Another way to test that 1 + 1 is equal to 2.
+
+>>> 1 + 1 == 2
+True
+"""}
+
Propchange: comdev/nearby_people/nearby/tests.py
------------------------------------------------------------------------------
svn:eol-style = native
Added: comdev/nearby_people/nearby/views.py
URL: http://svn.apache.org/viewvc/comdev/nearby_people/nearby/views.py?rev=894005&view=auto
==============================================================================
--- comdev/nearby_people/nearby/views.py (added)
+++ comdev/nearby_people/nearby/views.py Sat Dec 26 17:10:41 2009
@@ -0,0 +1,101 @@
+# ====================================================================
+# Licensed to the Apache Software Foundation (ASF) under one or more
+# contributor license agreements. See the NOTICE file distributed with
+# this work for additional information regarding copyright ownership.
+# The ASF licenses this file to You under the Apache License, Version 2.0
+# (the "License"); you may not use this file except in compliance with
+# the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+# ====================================================================
+
+from django.http import HttpResponseRedirect
+from settings import COMDEV_DOAP, SPEAKERS_DOAP
+
+from nearby_people.nearby.foaf import *
+from nearby_people.nearby.forms import *
+from nearby_people.nearby.shortcuts import *
+
+import geoname
+#geoname.DEBUG=1
+
+comdev_foaf = FOAF(COMDEV_DOAP)
+speakers_foaf = FOAF(SPEAKERS_DOAP)
+
+def welcome(request):
+ form = PlaceForm()
+ form.enableTypeField()
+
+ return render(request, "welcome.html", {
+ 'form': form
+ })
+
+def pick_place(request):
+ places = []
+
+ if request.POST:
+ form = PlaceForm(request.POST)
+ if form.is_valid():
+ result = geoname.search(
+ placename=form.data["place_name"],
+ fclass=["P","T"],
+ country='',
+ lang="EN",
+ maxRows=10,
+ )
+ for res in result.geoname:
+ places.append({
+ 'name':res.name,
+ 'latitude':res.lat,
+ 'longitude':res.lng,
+ 'country':res.countryCode
+ })
+ else:
+ form = PlaceForm()
+ form.set_type( request.GET.get("type","") )
+
+ return render(request, "pick_place.html", {
+ 'form': form, 'places': places
+ })
+
+def find_people(request):
+ form = LocationForm(request.GET)
+ if not form.is_valid():
+ return HttpResponseRedirect("/pick_place/?location_missing")
+
+ # What do they want?
+ foaf = comdev_foaf
+ if form.data["type"] == "sp":
+ foaf = speakers_foaf
+
+ location = form.data
+ search_latitude = float(location["latitude"])
+ search_longitude = float(location["longitude"])
+ people = foaf.get_nearby(search_latitude, search_longitude)
+
+ # Work out the people.apache.org links for people
+ for d,person in people:
+ person["link"] = "http://people.apache.org/list_%s.html#%s" % \
+ (person["surname"][0], person["uid"])
+
+ # Work out our zoom
+ min_lat = min( [float(d[1]["latitude"]) for d in people]+[search_latitude] )
+ max_lat = max( [float(d[1]["latitude"]) for d in people]+[search_latitude] )
+ min_long = min( [float(d[1]["longitude"]) for d in people]+[search_longitude] )
+ max_long = max( [float(d[1]["longitude"]) for d in people]+[search_longitude] )
+ center_lat = (min_lat+max_lat)/2
+ center_long = (min_long+max_long)/2
+
+ # All done
+ return render(request, "people.html", {
+ 'location': location, 'people':people,
+ 'center_lat': center_lat, 'center_long': center_long,
+ 'bl_lat': min_lat, 'bl_long': min_long,
+ 'tr_lat': max_lat, 'tr_long': max_long,
+ })
Propchange: comdev/nearby_people/nearby/views.py
------------------------------------------------------------------------------
svn:eol-style = native
Added: comdev/nearby_people/run.cgi
URL: http://svn.apache.org/viewvc/comdev/nearby_people/run.cgi?rev=894005&view=auto
==============================================================================
--- comdev/nearby_people/run.cgi (added)
+++ comdev/nearby_people/run.cgi Sat Dec 26 17:10:41 2009
@@ -0,0 +1,98 @@
+#!/usr/bin/env python
+# encoding: utf-8
+"""
+django.cgi
+
+A simple cgi script which uses the django WSGI to serve requests.
+
+Code copy/pasted from PEP-0333 and then tweaked to serve django.
+http://www.python.org/dev/peps/pep-0333/#the-server-gateway-side
+
+This script assumes django is on your sys.path, and that your site code is at
+/home/mycode/mysite. Copy this script into your cgi-bin directory (or do
+whatever you need to to make a cgi script executable on your system), and then
+update the paths at the bottom of this file to suit your site.
+
+This is probably the slowest way to serve django pages, as the python
+interpreter, the django code-base and your site code has to be loaded every
+time a request is served. FCGI and mod_python solve this problem, use them if
+you can.
+
+In order to speed things up it may be worth experimenting with running
+uncompressed zips on the sys.path for django and the site code, as this can be
+(theorectically) faster. See PEP-0273 (specifically Benchmarks).
+http://www.python.org/dev/peps/pep-0273/
+
+Make sure all python files are compiled in your code base. See
+http://docs.python.org/lib/module-compileall.html
+
+"""
+
+import os, sys
+# insert a sys.path.append("whatever") in here if django is not
+# on your sys.path.
+import django.core.handlers.wsgi
+
+def run_with_cgi(application):
+
+ environ = dict(os.environ.items())
+ environ['wsgi.input'] = sys.stdin
+ environ['wsgi.errors'] = sys.stderr
+ environ['wsgi.version'] = (1,0)
+ environ['wsgi.multithread'] = False
+ environ['wsgi.multiprocess'] = True
+ environ['wsgi.run_once'] = True
+
+ if environ.get('HTTPS','off') in ('on','1'):
+ environ['wsgi.url_scheme'] = 'https'
+ else:
+ environ['wsgi.url_scheme'] = 'http'
+
+ headers_set = []
+ headers_sent = []
+
+ def write(data):
+ if not headers_set:
+ raise AssertionError("write() before start_response()")
+
+ elif not headers_sent:
+ # Before the first output, send the stored headers
+ status, response_headers = headers_sent[:] = headers_set
+ sys.stdout.write('Status: %s\r\n' % status)
+ for header in response_headers:
+ sys.stdout.write('%s: %s\r\n' % header)
+ sys.stdout.write('\r\n')
+
+ sys.stdout.write(data)
+ sys.stdout.flush()
+
+ def start_response(status,response_headers,exc_info=None):
+ if exc_info:
+ try:
+ if headers_sent:
+ # Re-raise original exception if headers sent
+ raise exc_info[0], exc_info[1], exc_info[2]
+ finally:
+ exc_info = None # avoid dangling circular ref
+ elif headers_set:
+ raise AssertionError("Headers already set!")
+
+ headers_set[:] = [status,response_headers]
+ return write
+
+ result = application(environ, start_response)
+ try:
+ for data in result:
+ if data: # don't send headers until body appears
+ write(data)
+ if not headers_sent:
+ write('') # send headers now if body was empty
+ finally:
+ if hasattr(result,'close'):
+ result.close()
+
+# Change this to the directory above your site code.
+sys.path.append("/home/mycode")
+# Change mysite to the name of your site package
+os.environ['DJANGO_SETTINGS_MODULE'] = 'mysite.settings'
+run_with_cgi(django.core.handlers.wsgi.WSGIHandler())
Propchange: comdev/nearby_people/run.cgi
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: comdev/nearby_people/run.cgi
------------------------------------------------------------------------------
svn:executable = *
Added: comdev/nearby_people/settings.py
URL: http://svn.apache.org/viewvc/comdev/nearby_people/settings.py?rev=894005&view=auto
==============================================================================
--- comdev/nearby_people/settings.py (added)
+++ comdev/nearby_people/settings.py Sat Dec 26 17:10:41 2009
@@ -0,0 +1,107 @@
+# ====================================================================
+# Licensed to the Apache Software Foundation (ASF) under one or more
+# contributor license agreements. See the NOTICE file distributed with
+# this work for additional information regarding copyright ownership.
+# The ASF licenses this file to You under the Apache License, Version 2.0
+# (the "License"); you may not use this file except in compliance with
+# the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+# ====================================================================
+
+# Django settings for nearby_people project.
+import os, sys
+
+# Add our own lib directory to the Python path
+OUR_ROOT = os.path.realpath(os.path.dirname(__file__))
+sys.path = [os.path.join(OUR_ROOT, 'lib')] + sys.path
+
+# Normal settings from here
+DEBUG = False
+TEMPLATE_DEBUG = DEBUG
+
+ADMINS = ()
+MANAGERS = ADMINS
+
+DATABASE_ENGINE = '' # 'postgresql_psycopg2', 'postgresql', 'mysql', 'sqlite3' or 'oracle'.
+DATABASE_NAME = '' # Or path to database file if using sqlite3.
+DATABASE_USER = '' # Not used with sqlite3.
+DATABASE_PASSWORD = '' # Not used with sqlite3.
+DATABASE_HOST = '' # Set to empty string for localhost. Not used with sqlite3.
+DATABASE_PORT = '' # Set to empty string for default. Not used with sqlite3.
+
+# Local time zone for this installation. Choices can be found here:
+# http://en.wikipedia.org/wiki/List_of_tz_zones_by_name
+# although not all choices may be available on all operating systems.
+# If running in a Windows environment this must be set to the same as your
+# system time zone.
+TIME_ZONE = 'America/Chicago'
+
+# Language code for this installation. All choices can be found here:
+# http://www.i18nguy.com/unicode/language-identifiers.html
+LANGUAGE_CODE = 'en-us'
+
+SITE_ID = 1
+
+# If you set this to False, Django will make some optimizations so as not
+# to load the internationalization machinery.
+USE_I18N = True
+
+# Absolute path to the directory that holds media.
+# Example: "/home/media/media.lawrence.com/"
+MEDIA_ROOT = ''
+
+# URL that handles the media served from MEDIA_ROOT. Make sure to use a
+# trailing slash if there is a path component (optional in other cases).
+# Examples: "http://media.lawrence.com", "http://example.com/media/"
+MEDIA_URL = ''
+
+# URL prefix for admin media -- CSS, JavaScript and images. Make sure to use a
+# trailing slash.
+# Examples: "http://foo.com/media/", "/media/".
+ADMIN_MEDIA_PREFIX = '/media/'
+
+# Make this unique, and don't share it with anybody.
+SECRET_KEY = 'urxyidshwg$k-*j63h$=2215u24l4crufkx0719w$t$$8di&(o'
+
+# List of callables that know how to import templates from various sources.
+TEMPLATE_LOADERS = (
+ 'django.template.loaders.filesystem.load_template_source',
+ 'django.template.loaders.app_directories.load_template_source',
+# 'django.template.loaders.eggs.load_template_source',
+)
+
+MIDDLEWARE_CLASSES = (
+ 'django.middleware.common.CommonMiddleware',
+ 'django.contrib.sessions.middleware.SessionMiddleware',
+ 'django.contrib.auth.middleware.AuthenticationMiddleware',
+)
+
+ROOT_URLCONF = 'nearby_people.urls'
+
+TEMPLATE_DIRS = (
+ os.path.join(OUR_ROOT, 'templates'),
+)
+
+INSTALLED_APPS = (
+ 'django.contrib.auth',
+ 'django.contrib.contenttypes',
+ 'django.contrib.sessions',
+ 'django.contrib.sites',
+ 'nearby_people.nearby',
+)
+
+try:
+ from local_settings import *
+except ImportError:
+ print "You need to create a local_settings.py file."
+ print "You might want to:"
+ print " cp local_settings.py.example local_settings.py"
+ print " and then edit local_settings.py for your setup"
+ sys.exit(1)
Propchange: comdev/nearby_people/settings.py
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: comdev/nearby_people/templates/
------------------------------------------------------------------------------
--- svn:ignore (added)
+++ svn:ignore Sat Dec 26 17:10:41 2009
@@ -0,0 +1 @@
+*.swp
Added: comdev/nearby_people/templates/base.html
URL: http://svn.apache.org/viewvc/comdev/nearby_people/templates/base.html?rev=894005&view=auto
==============================================================================
--- comdev/nearby_people/templates/base.html (added)
+++ comdev/nearby_people/templates/base.html Sat Dec 26 17:10:41 2009
@@ -0,0 +1,41 @@
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
+ "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
+<html xmlns="http://www.w3.org/1999/xhtml">
+
+<head>
+ <title>Nearby Apache People {% block title %}{% endblock %}</title>
+ <link rel="stylesheet" href="/static/css/styles.css" type="text/css" />
+ {% block extrahead %}
+ {% endblock %}
+</head>
+
+<body class="{% block bodyclass %}{% endblock %}">
+ <div id="page">
+ <div id="heading">
+ Nearby Apache People {% block heading %}{% endblock %}
+ </div>
+ <div id="menu">
+ <ul>
+ {% if user.is_authenticated %}
+ {% else %}
+ <li><a href="/">Home</a></li>
+ <li><a href="/pick_place/">Find People</a></li>
+ {% endif %}
+ </ul>
+ </div>
+
+ <div id="content">
+ {% if messages %}
+ <ul class="messages">
+ {% for message in messages %}
+ <li>{{ message }}</li>
+ {% endfor %}
+ </ul>
+ {% endif %}
+
+ {% block content %}
+ {% endblock %}
+ </div>
+ </div>
+</body>
+</html>
Propchange: comdev/nearby_people/templates/base.html
------------------------------------------------------------------------------
svn:eol-style = native
Added: comdev/nearby_people/templates/people.html
URL: http://svn.apache.org/viewvc/comdev/nearby_people/templates/people.html?rev=894005&view=auto
==============================================================================
--- comdev/nearby_people/templates/people.html (added)
+++ comdev/nearby_people/templates/people.html Sat Dec 26 17:10:41 2009
@@ -0,0 +1,89 @@
+{% extends "base.html" %}
+{% load distances %}
+
+{% block title %} - People Near You{% endblock %}
+{% block heading %} - People Near You{% endblock %}
+{% block bodyclass %}people{% endblock %}
+{% block extrahead %}
+<script src="http://maps.google.com/maps?file=api&v=2&key=ABQIAAAAteF8gqn96L8K4RRZYtk7ZRQv7OBTi813IEDuwD3BusDViujKIBTUfK-gV5SL7dqLeRkgc0jLmyXgkg" type="text/javascript"></script>
+<script type="text/javascript">
+<!--
+ var map;
+ var mapObj;
+
+ function createMarker(name,lat,lng,link) {
+ var point = new GLatLng(lat,lng);
+ var options = { title: name }; // appears when cursor hovers over marker
+ var marker = new GMarker(point,options);
+ GEvent.addListener(marker, "click", function() {
+ var msg = name + "<br \/>";
+ msg = msg + " <a href=\"" + link + "\">" +
+ "<small>Info<\/small><\/a>";
+ marker.openInfoWindowHtml(msg);
+ });
+ return marker;
+ }
+
+ function load() {
+ mapObj = document.getElementById("map");
+
+ if (GBrowserIsCompatible()) {
+ map = new GMap2(mapObj);
+ map.addControl(new GLargeMapControl());
+ map.setCenter(new GLatLng({{center_lat}}, {{center_long}}), 14);
+
+ // Zoom to roughly the right place
+ map.panTo(new GLatLng( {{center_lat}}, {{center_long}} ));
+ map.setZoom(
+ map.getBoundsZoomLevel(new GLatLngBounds(
+ new GLatLng( {{bl_lat}}-0.05, {{bl_long}}-0.05 ),
+ new GLatLng( {{tr_lat}}+0.05, {{tr_long}}+0.05 )
+ ))
+ );
+
+ // Add our markers
+ {% for dist, person in people %}
+ marker = createMarker("{{person.name}}",{{person.latitude}},
+ {{person.longitude}},"{{person.link}}");
+ map.addOverlay(marker);
+ {% endfor %}
+
+ // Add the search marker
+ search_icon = new GIcon(G_DEFAULT_ICON);
+ search_icon.image = "http://www.google.com/intl/en_us/mapfiles/ms/icons/green-dot.png";
+ search_icon.iconSize = GSize(32,32);
+ search_point = new GMarker(
+ new GLatLng({{location.latitude}},{{location.longitude}}),
+ search_icon, false
+ );
+ map.addOverlay(search_point);
+ }
+ }
+//-->
+</script>
+<style type="text/css">
+#map {
+ border: 1px solid #bbbbbb;
+ height: 400px;
+ width: 80%;
+}
+</style>
+{% endblock %}
+{% block content %}
+
+{% if people %}
+ <h4>People near you...</h4>
+ <ul>
+ {% for dist, person in people %}
+ <li>{{dist|distanceformat}} - <a href="{{person.link}}">{{person.name}}</a></li>
+ {% endfor %}
+ </ul>
+
+ <div id="map"></div>
+ <script type="text/javascript">load()</script>
+{% else %}
+ <p>Sorry, there's no-one near you :(</p>
+ <p>Maybe <a href="/pick_place/">try somewhere else?</a></p>
+{% endif %}
+
+{% endblock %}
Propchange: comdev/nearby_people/templates/people.html
------------------------------------------------------------------------------
svn:eol-style = native
Added: comdev/nearby_people/templates/pick_place.html
URL: http://svn.apache.org/viewvc/comdev/nearby_people/templates/pick_place.html?rev=894005&view=auto
==============================================================================
--- comdev/nearby_people/templates/pick_place.html (added)
+++ comdev/nearby_people/templates/pick_place.html Sat Dec 26 17:10:41 2009
@@ -0,0 +1,30 @@
+{% extends "base.html" %}
+
+{% block title %} - Pick Where You Are{% endblock %}
+{% block heading %} - Pick Where You Are{% endblock %}
+{% block bodyclass %}pick_place{% endblock %}
+{% block content %}
+
+{% if places %}
+ <h3>We found several places with that name, we've sorted them by popularity</h3>
+ <h4>Please tell us which one you want?</h4>
+
+ <ul>
+ {% for p in places %}
+ <li><a href="/find_people/?latitude={{p.latitude}}&longitude={{p.longitude}}&type={{form.data.type}}" title="{{p.latitude|floatformat:4}} {{p.longitude|floatformat:4}}">{{p.name}} ({{p.country}})</a></li>
+ {% endfor %}
+ </ul>
+{% else %}
+ <p>To begin, please pick your location.</p>
+{% endif %}
+
+<br /><br />
+
+<form action="/pick_place/" method="post">
+{{form.as_p}}
+<p>
+ <input type="submit" value="Search" />
+</p>
+</form>
+
+{% endblock %}
Propchange: comdev/nearby_people/templates/pick_place.html
------------------------------------------------------------------------------
svn:eol-style = native
Added: comdev/nearby_people/templates/welcome.html
URL: http://svn.apache.org/viewvc/comdev/nearby_people/templates/welcome.html?rev=894005&view=auto
==============================================================================
--- comdev/nearby_people/templates/welcome.html (added)
+++ comdev/nearby_people/templates/welcome.html Sat Dec 26 17:10:41 2009
@@ -0,0 +1,18 @@
+{% extends "base.html" %}
+
+{% block title %} - Home{% endblock %}
+{% block heading %} - Welcome{% endblock %}
+{% block bodyclass %}home{% endblock %}
+{% block content %}
+<p>To begin, please pick your location.</p>
+
+<br /><br />
+
+<form action="/pick_place/" method="post">
+{{form.as_p}}
+<p>
+ <input type="submit" value="Search" />
+</p>
+</form>
+
+{% endblock %}
Propchange: comdev/nearby_people/templates/welcome.html
------------------------------------------------------------------------------
svn:eol-style = native
Added: comdev/nearby_people/urls.py
URL: http://svn.apache.org/viewvc/comdev/nearby_people/urls.py?rev=894005&view=auto
==============================================================================
--- comdev/nearby_people/urls.py (added)
+++ comdev/nearby_people/urls.py Sat Dec 26 17:10:41 2009
@@ -0,0 +1,35 @@
+# ====================================================================
+# Licensed to the Apache Software Foundation (ASF) under one or more
+# contributor license agreements. See the NOTICE file distributed with
+# this work for additional information regarding copyright ownership.
+# The ASF licenses this file to You under the Apache License, Version 2.0
+# (the "License"); you may not use this file except in compliance with
+# the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+# ====================================================================
+
+from django.conf.urls.defaults import *
+
+# Uncomment the next two lines to enable the admin:
+# from django.contrib import admin
+# admin.autodiscover()
+
+urlpatterns = patterns('',
+ (r'^$', 'nearby_people.nearby.views.welcome'),
+ (r'^pick_place/$', 'nearby_people.nearby.views.pick_place'),
+ (r'^find_people/$', 'nearby_people.nearby.views.find_people'),
+
+ # Uncomment the admin/doc line below and add 'django.contrib.admindocs'
+ # to INSTALLED_APPS to enable admin documentation:
+ # (r'^admin/doc/', include('django.contrib.admindocs.urls')),
+
+ # Uncomment the next line to enable the admin:
+ # (r'^admin/', include(admin.site.urls)),
+)
Propchange: comdev/nearby_people/urls.py
------------------------------------------------------------------------------
svn:eol-style = native