From 7ced7b88b127378162755096898ad4ba582b177a Mon Sep 17 00:00:00 2001 From: sanj Date: Mon, 20 Sep 2010 04:16:09 +0530 Subject: [PATCH] texts --- vurbanism/flyovers/models.py | 29 ++++++ vurbanism/static/js/vurbanism.js | 7 ++ vurbanism/templates/flyovers.html | 168 ++++-------------------------- 3 files changed, 54 insertions(+), 150 deletions(-) diff --git a/vurbanism/flyovers/models.py b/vurbanism/flyovers/models.py index ab386c4..30db426 100644 --- a/vurbanism/flyovers/models.py +++ b/vurbanism/flyovers/models.py @@ -112,6 +112,10 @@ class Video(models.Model): youtube_id = self.get_youtube_id() info = youtube.getMovieInfo(youtube_id) info['title'] = '' #Nasty, to avoid UnicodeDecodeError's when trying to do json.dumps on some video titles. FIXME. + + #this is just ugly -- this shud be fixed by oxweb -- please remove when necessary: + info['thumbnail'] = "http://img.youtube.com/vi/%s/0.jpg" % (info['id'][:-22],) + ret = { 'info': info, 'flyover': { @@ -171,6 +175,17 @@ class Text(models.Model): def __unicode__(self): return self.text + " - " + self.category.name + def get_dict(self): + ret = { + 'text': self.text, + 'flyover': { + 'id': self.flyover.id, + 'name': self.flyover.name + } + } + return ret + + class TextCategory(models.Model): name = models.CharField(max_length=255) description = models.TextField(blank=True, null=True) @@ -178,4 +193,18 @@ class TextCategory(models.Model): def __unicode__(self): return self.name + def get_dict(self): + texts = [] + flyovers = [] + for t in Text.objects.filter(category=self): + texts.append(t.get_dict()) + flyovers.append(t.flyover.geojson_as_dict()) + return { + 'texts': texts, + 'flyovers': { + 'type': 'FeatureCollection', + 'features': flyovers + } + } + # Create your models here. diff --git a/vurbanism/static/js/vurbanism.js b/vurbanism/static/js/vurbanism.js index 6a0c283..7e2c88c 100644 --- a/vurbanism/static/js/vurbanism.js +++ b/vurbanism/static/js/vurbanism.js @@ -161,11 +161,13 @@ $(function() { map.zoomToExtent(maxExtent); // console.log(maxExtent); switch(type.toLowerCase()) { + case "image": var html = tmpl("tmpl_images", {'images': json.images}); $('#media').html(html); $('.imageWrapper a').colorbox(); break; + case "video": var html = tmpl("tmpl_videos", {'videos': json.videos}); $('#media').html(html); @@ -181,6 +183,11 @@ $(function() { var embedCode = data.info.embed; $.colorbox({html: embedCode}); }); + + case "text": + var html = tmpl("tmpl_texts", {'texts': json.texts}); + $('#media').html(html); + default: $.noop(); } diff --git a/vurbanism/templates/flyovers.html b/vurbanism/templates/flyovers.html index 265b5c4..230d891 100644 --- a/vurbanism/templates/flyovers.html +++ b/vurbanism/templates/flyovers.html @@ -1,152 +1,11 @@ - + + + + + Vertical Urbanism: Flyovers in Mumbai @@ -176,7 +35,7 @@ a img {
<% for (var i=0; i @@ -185,6 +44,15 @@ a img {
+
@@ -205,19 +73,19 @@ a img { Unfinished Construction Construction - Text1 + Media Regulation Fencing In The Way - Text2 + Technical Greenspace Posters Routes - Text3 + Stories Life underneath