Skip to content

Commit

Permalink
First commit
Browse files Browse the repository at this point in the history
  • Loading branch information
bennlich committed Apr 9, 2015
0 parents commit a8f8a68
Show file tree
Hide file tree
Showing 105 changed files with 23,903 additions and 0 deletions.
Empty file added __init__.py
Empty file.
29 changes: 29 additions & 0 deletions about.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
{% extends "base1skinnycolumn.html" %}

{% block column %}
<table>
<tr>
<th>About</th>
</tr>
<tr>
<td><p>
ButOneApp is a button for the android phone. Pressing it uploads a tiny package of data with your username, tag, and gps location to this website. To view the uploaded tags, click on Home in the upper-left corner of your browser.
</p></td>
</tr>
<tr>
<th>Credits</th>
</tr>
<tr>
<td><p style="text-align: center">Concept by <a href="http://venice2point0.blogspot.com">Fabio Carrera</a></p></td>
</tr>
<tr>
<td><p style="text-align: center">Coded by <a href="http://www.corrugatedpress.com">Ben Lichtner</a></p></td>
</tr>
<tr>
<td><p>Send bug reports, feature requests, and everything else to:</p></td>
</tr>
<tr>
<td><p style="text-align: center; color: #555555;">bennlich (at) gmail (dot) com</p></td>
</tr>
</table>
{% endblock %}
25 changes: 25 additions & 0 deletions base1fatcolumn.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
<html>
<head>
<link type="text/css" rel="stylesheet" href="/butone/stylesheets/main.css" />
</head>
<body>
<a href="/" style="text-decoration:none; color:#000000;"><h1 style="letter-spacing: 5px; text-align:center; margin: 10 auto;">ButOneApp</h1></a>
<div class="wrapper">
<div class="columnFat">
{% block column %}
{% endblock %}
</div>
</div>
<div class="nav">
<div class="navItem">
<a href="/butone/">Home</a>
</div>
<div class="navItem">
<a href="/butone/about">About</a>
</div>
<div class="navItem">
<a href="/butone/download">Download</a> <i>(alpha)</i>
</div>
</div>
</body>
</html>
29 changes: 29 additions & 0 deletions base1skinnycolumn.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
<html>
<head>
<link type="text/css" rel="stylesheet" href="/butone/stylesheets/main.css" />
</head>
<body>
{% block header %}
<a href="/" style="text-decoration:none; color:#000000;"><h1 style="letter-spacing: 5px; text-align:center; margin: 10 auto;">ButOneApp</h1></a>
{% endblock %}
<div class="skinnyWrapper">
<div class="column">
{% block column %}
{% endblock %}
</div>
</div>
{% block nav %}
<div class="nav">
<div class="navItem">
<a href="/butone/">Home</a>
</div>
<div class="navItem">
<a href="/butone/about">About</a>
</div>
<div class="navItem">
<a href="/butone/download">Download</a> <i>(alpha)</i>
</div>
</div>
{% endblock %}
</body>
</html>
33 changes: 33 additions & 0 deletions base2column.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
<html>
<head>
<link type="text/css" rel="stylesheet" href="/butone/stylesheets/main.css" />
</head>
<body>
{% block header %}
<a href="/" style="text-decoration:none; color:#000000;"><h1 style="letter-spacing: 5px; text-align:center; margin: 10 auto;">ButOneApp</h1></a>
{% endblock %}
<div class="wrapper">
<div class="column">
{% block leftcolumn %}
{% endblock %}
</div>
<div class="column">
{% block rightcolumn %}
{% endblock %}
</div>
</div>
{% block nav %}
<div class="nav">
<div class="navItem">
<a href="/butone/">Home</a>
</div>
<div class="navItem">
<a href="/butone/about">About</a>
</div>
<div class="navItem">
<a href="/butone/download">Download</a> <i>(alpha)</i>
</div>
</div>
{% endblock %}
</body>
</html>
45 changes: 45 additions & 0 deletions browse.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
{% extends "base1fatcolumn.html" %}

{% block column %}
<div class="columnHeader">
<h1>{{ dataType }}s of the {{ filterName }}: {{ filterValue }}
{% ifequal dataType "tag" %}
(<a href="http://maps.google.com?q=http://geotageverything.appspot.com/kml/{{ filterValue|replacestring:" ,_" }}/">map</a>
<a href="/kml/{{ filterValue|replacestring:" ,_" }}/">kml</a>)</h1>
{% endifequal %}
{% ifequal dataType "user" %}
(<a href="http://maps.google.com?q=http://geotageverything.appspot.com/kml/null/{{ filterValue|replacestring:" ,_" }}">map</a>
<a href="/kml/null/{{ filterValue|replacestring:" ,_" }}">kml</a>)</h1>
{% endifequal %}
</div>
{% for geotag_list in displayData %}
{% for geotag in geotag_list %}
{% ifequal dataType "user" %}
{% ifchanged %}
<div class="columnHeader">
<b><a href="/browse/user/{{ geotag.user }}">{{ geotag.user }}</a></b>
(<a href="http://maps.google.com?q=http://geotageverything.appspot.com/kml/{{ geotag.user|replacestring:" ,_" }}/{{ geotag.tag|replacestring:" ,_" }}">map</a>
<a href="/kml/{{ geotag.user|replacestring:" ,_" }}/{{ geotag.tag|replacestring:" ,_" }}">kml</a>) at
</div>
{% endifchanged %}
{% endifequal %}
{% ifequal dataType "tag" %}
{% ifchanged %}
<div class="columnHeader">
<b><a href="/browse/tag/{{ geotag.tag }}">{{ geotag.tag }}</a></b>
(<a href="http://maps.google.com?q=http://geotageverything.appspot.com/kml/{{ geotag.user|replacestring:" ,_" }}/{{ geotag.tag|replacestring:" ,_" }}">map</a>
<a href="/kml/{{ geotag.user|replacestring:" ,_" }}/{{ geotag.tag|replacestring:" ,_" }}">kml</a>) at
</div>
{% endifchanged %}
{% endifequal %}
<div class="columnEntry">
{{ forloop.counter }})
time: <b>{{ geotag.date|escape|slicestring:"5,10" }} {{ geotag.date|escape|slicestring:"11,16" }}</b>
<a href="http://maps.google.com?q={{ geotag.lat }},{{ geotag.lon }}+({{ geotag.tag }})">
lat: <b>{{ geotag.lat }}</b>
lon: <b>{{ geotag.lon }}</b>
</a>
</div>
{% endfor %}
{% endfor %}
{% endblock %}
175 changes: 175 additions & 0 deletions butone.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,175 @@
import os
import logging
from google.appengine.ext.webapp import template

import cgi

from google.appengine.api import users
from google.appengine.ext import webapp
from google.appengine.ext.webapp.util import run_wsgi_app
from google.appengine.ext import db

"""Load custom Django template filters"""
webapp.template.register_template_library('butone.customfilters')

class Geotag(db.Model):
user = db.StringProperty()
tag = db.StringProperty()
lat = db.StringProperty()
lon = db.StringProperty()
date = db.DateTimeProperty(auto_now_add=True)

class MainPage(webapp.RequestHandler):
def get(self):

geotags_query = Geotag.all()
geotags = []
users = []
tags = []

for geotag in geotags_query:
user = geotag.user
tag = geotag.tag
if (user not in users): users.append(user)
if (tag not in tags): tags.append(tag)

users.sort()
tags.sort()

template_values = {
'geotags': geotags,
'users': users,
'tags': tags
}

path = os.path.join(os.path.dirname(__file__), 'index.html')
self.response.out.write(template.render(path, template_values))

class Upload(webapp.RequestHandler):
def post(self):
lat = self.request.get("lat")
lon = self.request.get("lon")
tag = self.request.get("tag")
user = self.request.get("username")

geotag = Geotag()
geotag.lat = lat;
geotag.lon = lon;
geotag.tag = tag;
geotag.user = user;
geotag.put()

class BrowseHandler(webapp.RequestHandler):
def get(self, filterName, filterValue):

filterName = filterName.replace("%20"," ");
filterValue = filterValue.replace("%20", " ");

# Prepare the query based on the groups of the regex
geotags_query = Geotag.all()
geotags_query.filter(filterName + " =", filterValue)
geotags_query.order("date")

# Prepare the data to pass to the template
geotags = [geotag for geotag in geotags_query]
displayData = []
dataType = ""
mapsQuery = ""

# logging.debug("filterName: %s, filterValue: %s", filterName, filterValue)

if (filterName == "user"):
tags = list(set([geotag.tag for geotag in geotags]))
dataType = "tag"
displayData = [[geotag for geotag in geotags if geotag.tag == tag] for tag in tags]
mapsQuery = ""
elif (filterName == "tag"):
users = list(set([geotag.user for geotag in geotags]))
dataType = "user"
displayData = [[geotag for geotag in geotags if geotag.user == user] for user in users]

template_values = { 'geotags': geotags,
'filterName': filterName,
'filterValue': filterValue,
'dataType': dataType,
'displayData': displayData }

path = os.path.join(os.path.dirname(__file__), 'browse.html')
self.response.out.write(template.render(path, template_values))

class AboutPage(webapp.RequestHandler):
def get(self):

template_values = {
}

path = os.path.join(os.path.dirname(__file__), 'about.html')
self.response.out.write(template.render(path, template_values))

class DownloadPage(webapp.RequestHandler):
def get(self):

template_values = {
}

path = os.path.join(os.path.dirname(__file__), 'download.html')
self.response.out.write(template.render(path, template_values))

class CreateMap(webapp.RequestHandler):
def get(self, user, tag):
a = 1

class CreateKml(webapp.RequestHandler):
def get(self, user, tag):
# Prepare the query based on the groups of the regex
geotags_query = Geotag.all()
if (user != "" and user != "null"):
logging.debug('The user is %s',user)
geotags_query.filter("user =", user.replace("_"," "))
if (tag != ""):
geotags_query.filter("tag =", tag.replace("_"," "))

geotags = [geotag for geotag in geotags_query]

template_values = {'geotags': geotags}

self.response.headers['Content-Type'] = 'application/vnd.google-earth.kml+xml'

path = os.path.join(os.path.dirname(__file__), 'tagmap.kml')
self.response.out.write(template.render(path, template_values))

class TaxiApp(webapp.RequestHandler):
def get(self):
template_values = {
}

path = os.path.join(os.path.dirname(__file__), 'taxiapp.html')
self.response.out.write(template.render(path, template_values))

class Generate(webapp.RequestHandler):
def get(self):
geotag = Geotag()
geotag.lat = "5";
geotag.lon = "5";
geotag.tag = "Debug Tag";
geotag.user = "Debug User";
geotag.put()

application = webapp.WSGIApplication(
[('/butone/', MainPage),
('/butone/upload', Upload),
(r'/butone/browse/(.*)/(.*)', BrowseHandler),
('/butone/about', AboutPage),
(r'/butone/map/(.*)/(.*)', CreateMap),
(r'/butone/kml/(.*)/(.*)', CreateKml),
('/butone/generate', Generate),
('/butone/download', DownloadPage),
('/butone/taxiapp', TaxiApp)
],
debug=True)

def main():
run_wsgi_app(application)

if __name__ == "__main__":
main()
1 change: 1 addition & 0 deletions console/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
"""App Engine Console package"""
1 change: 1 addition & 0 deletions console/app/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
"""App Engine Console main application package"""
Loading

0 comments on commit a8f8a68

Please sign in to comment.