Permalink
Browse files

Adding new website

  • Loading branch information...
1 parent 48f4195 commit 742e5f38491210240d8d85d0775dc90867542cc4 @jenikm jenikm committed Oct 31, 2011
View
@@ -10,6 +10,9 @@
# object. If you would like automatic key generation on import and
# omitting the key on export, you can remove the entire __key__
# property from the property map.
+#appcfg.py upload_data --config_file=bulkloader.yaml --filename=sightings.csv --kind=Sighting --url=http://it-came-out-of-the-sky.appspot.com/_ah/remote_api
+#python /opt/google_appengine/remote_api_shell.py -s it-came-out-of-the-sky.appspot.com
+
# If you have module(s) with your model classes, add them here. Also
# change the kind properties to model_class.
@@ -23,6 +26,35 @@ python_preamble:
- import: google.appengine.api.users
transformers:
+
+- kind: City
+ connector: csv # TODO: Choose a connector here: csv, simplexml, etc...
+ connector_options:
+ # TODO: Add connector options here--these are specific to each connector.
+ property_map:
+ - property: city_id
+ external_name: city_id
+ import_transform: int
+
+ - property: county_id
+ external_name: county_id
+ import_transform: int
+
+ - property: state_id
+ external_name: state_id
+ import_transform: int
+
+ - property: name
+ external_name: name
+
+ - property: lat
+ external_name: lat
+ import_transform: float
+
+ - property: lon
+ external_name: lon
+ import_transform: float
+
- kind: Sighting
connector: csv # TODO: Choose a connector here: csv, simplexml, etc...
connector_options:
View
Deleted file not rendered
View
Deleted file not rendered
Deleted file not rendered
Deleted file not rendered
Deleted file not rendered
Deleted file not rendered
Deleted file not rendered
Deleted file not rendered
View
Deleted file not rendered
View
Deleted file not rendered
View
Deleted file not rendered
View
Deleted file not rendered
View
Deleted file not rendered
View
Deleted file not rendered
View
Deleted file not rendered
Deleted file not rendered
Deleted file not rendered
Deleted file not rendered
Deleted file not rendered
Deleted file not rendered
Deleted file not rendered
Deleted file not rendered
Deleted file not rendered
Deleted file not rendered
Deleted file not rendered
Diff not rendered.
View
Diff not rendered.
View
Diff not rendered.
@@ -4,6 +4,7 @@
from google.appengine.ext.webapp import template
from google.appengine.ext import db
from django.core import serializers
+import datetime
views_path = 'views/'
#execfile("db.py")
@@ -20,30 +21,68 @@ class Sighting(db.Model):
occurred_at = db.DateTimeProperty
reported_at = db.DateTimeProperty
posted_at = db.DateTimeProperty
+ def summary_description_short(self):
+ shortened = self.summary_description
+ if len(self.summary_description) > 50:
+ shortened = (self.summary_description[:50] + '..')
+ return shortened
+ def created_at_formatted(self):
+ return self.occurred_at.datetime.strftime("%m-%d-%y")
+ def show_date(self):
+ return False #hasattr(self.sighting.occurred_at.datetime, 'month')
-class Main(webapp.RequestHandler):
+class City(db.Model):
+ city_id = db.IntegerProperty()
+ county_id= db.IntegerProperty()
+ state_id = db.IntegerProperty()
+ name = db.StringProperty()
+ lat = db.FloatProperty()
+ lon = db.FloatProperty()
+
+class Index(webapp.RequestHandler):
def get(self):
- template_values = {'main': 'selected' }
+ template_values = {'current_page': 'home' }
path = os.path.join(os.path.dirname(__file__), views_path + 'index.html')
self.response.out.write(template.render(path, template_values))
-class LoadSightings(webapp.RequestHandler):
+class Photos(webapp.RequestHandler):
+ def get(self):
+ template_values = {'current_page': 'photos' }
+ path = os.path.join(os.path.dirname(__file__), views_path + 'photos.html')
+ self.response.out.write(template.render(path, template_values))
+class Download(webapp.RequestHandler):
def get(self):
- self.response.out.write("DONE")
+ template_values = {'current_page': 'download' }
+ path = os.path.join(os.path.dirname(__file__), views_path + 'download.html')
+ self.response.out.write(template.render(path, template_values))
+class Search(webapp.RequestHandler):
+ def get(self):
+ city_name = self.request.get("city_name")
+ cities = City.all().filter("name = ", city_name.lower().capitalize()).fetch(limit=10)
+ sightings = []
+ if len(cities) > 0:
+ sightings = Sighting.all().filter("city_id IN ", map((lambda x: x.city_id), cities)).fetch(limit=100)
+ template_values = {'current_page': 'search', 'sightings': sightings, 'city_name': city_name }
+ path = os.path.join(os.path.dirname(__file__), views_path + 'search.html')
+ self.response.out.write(template.render(path, template_values))
-class Sightings(webapp.RequestHandler):
+class Sightings(webapp.RequestHandler):
def get(self):
template_values = {'main': 'selected' }
sighting_id = self.request.get("sighting_id")
response = -1
if sighting_id != '':
response = db.GqlQuery("SELECT * FROM Sighting WHERE sighting_id = :1", int(sighting_id)).get().to_xml()
- self.response.out.write('<?xml version="1.0"?>');
+ self.response.out.writeln('<?xml version="1.0"?>');
self.response.out.write(response)
-application = webapp.WSGIApplication([('/', Main), ('/sightings', Sightings), ('/_ah/remote_api', LoadSightings)],
+application = webapp.WSGIApplication([('/', Index),
+ ('/sightings', Sightings),
+ ('/photos', Photos),
+ ('/search', Search),
+ ('/download', Download)],
debug=True)
def main():
View
@@ -1,108 +0,0 @@
-// when the DOM is ready...
-$(document).ready(function () {
-
- var $panels = $('#slider .scrollContainer > div');
- var $container = $('#slider .scrollContainer');
-
- // if false, we'll float all the panels left and fix the width
- // of the container
- var horizontal = true;
-
- // float the panels left if we're going horizontal
- if (horizontal) {
- $panels.css({
- 'float' : 'left',
- 'position' : 'relative' // IE fix to ensure overflow is hidden
- });
-
- // calculate a new width for the container (so it holds all panels)
- $container.css('width', $panels[0].offsetWidth * $panels.length);
- }
-
- // collect the scroll object, at the same time apply the hidden overflow
- // to remove the default scrollbars that will appear
- var $scroll = $('#slider .scroll').css('overflow', 'hidden');
-
- // apply our left + right buttons
- $scroll
- .before('<img class="scrollButtons left" src="" />')
- .after('<img class="scrollButtons right" src="" />');
-
- // handle nav selection
- function selectNav() {
- $(this)
- .parents('ul:first')
- .find('a')
- .removeClass('selected')
- .end()
- .end()
- .addClass('selected');
- }
-
- $('#slider .navigation').find('a').click(selectNav);
-
- // go find the navigation link that has this target and select the nav
- function trigger(data) {
- var el = $('#slider .navigation').find('a[href$="' + data.id + '"]').get(0);
- selectNav.call(el);
- }
-
- if (window.location.hash) {
- trigger({ id : window.location.hash.substr(1) });
- } else {
- $('ul.navigation a:first').click();
- }
-
- // offset is used to move to *exactly* the right place, since I'm using
- // padding on my example, I need to subtract the amount of padding to
- // the offset. Try removing this to get a good idea of the effect
- var offset = parseInt((horizontal ?
- $container.css('paddingTop') :
- $container.css('paddingLeft'))
- || 0) * -1;
-
-
- var scrollOptions = {
- target: $scroll, // the element that has the overflow
-
- // can be a selector which will be relative to the target
- items: $panels,
-
- navigation: '.navigation a',
-
- // selectors are NOT relative to document, i.e. make sure they're unique
- prev: 'img.left',
- next: 'img.right',
-
- // allow the scroll effect to run both directions
- axis: 'xy',
-
- onAfter: trigger, // our final callback
-
- offset: offset,
-
- // duration of the sliding effect
- duration: 500,
-
- // easing - can be used with the easing plugin:
- // http://gsgd.co.uk/sandbox/jquery/easing/
- easing: 'swing'
- };
-
- // apply serialScroll to the slider - we chose this plugin because it
- // supports// the indexed next and previous scroll along with hooking
- // in to our navigation.
- $('#slider').serialScroll(scrollOptions);
-
- // now apply localScroll to hook any other arbitrary links to trigger
- // the effect
- $.localScroll(scrollOptions);
-
- // finally, if the URL has a hash, move the slider in to position,
- // setting the duration to 1 because I don't want it to scroll in the
- // very first page load. We don't always need this, but it ensures
- // the positioning is absolutely spot on when the pages loads.
- scrollOptions.duration = 1;
- $.localScroll.hash(scrollOptions);
-
-});
Oops, something went wrong.

0 comments on commit 742e5f3

Please sign in to comment.