From 758c821d5a7322a96948675e7912df3fbb4da362 Mon Sep 17 00:00:00 2001 From: rolux Date: Wed, 11 Jan 2012 13:21:26 +0530 Subject: [PATCH] make layer collapsed/expanded state sticky --- pandora/0xdb.jsonc | 5 +++++ pandora/app/views.py | 2 +- pandora/item/tasks.py | 3 ++- pandora/item/views.py | 8 +++----- pandora/padma.jsonc | 7 +++++++ pandora/urls.py | 2 +- static/js/pandora/item.js | 4 ++++ 7 files changed, 23 insertions(+), 8 deletions(-) diff --git a/pandora/0xdb.jsonc b/pandora/0xdb.jsonc index 1d210b6bd..2598999cf 100644 --- a/pandora/0xdb.jsonc +++ b/pandora/0xdb.jsonc @@ -639,6 +639,11 @@ "showHome": true, "showIconBrowser": false, "showInfo": true, + "showLayers": { + "privatenotes": true, + "publicnotes": true, + "subtitles": true + }, "showMapControls": false, "showMapLabels": false, "showFolder": { diff --git a/pandora/app/views.py b/pandora/app/views.py index 2a428f9a5..ec0460cf9 100644 --- a/pandora/app/views.py +++ b/pandora/app/views.py @@ -74,7 +74,7 @@ def opensearch_xml(request): def robots_txt(request, url): return HttpResponse( - 'User-agent: *\nDisallow:\nSitemap: %s\n' % request.build_absolute_uri('/sitemap.xml.gz'), + 'User-agent: *\nDisallow:\nSitemap: %s\n' % request.build_absolute_uri('/sitemap.xml'), 'text/plain' ) diff --git a/pandora/item/tasks.py b/pandora/item/tasks.py index b7114b08e..12ae40619 100644 --- a/pandora/item/tasks.py +++ b/pandora/item/tasks.py @@ -113,6 +113,7 @@ def update_sitemap(base_url): el = ET.SubElement(video, "video:duration") el.text = "%s" % duration + with open(sitemap[:-3], 'wb') as f: + f.write('\n' + ET.tostring(urlset)) with gzip.open(sitemap, 'wb') as f: f.write('\n' + ET.tostring(urlset)) - diff --git a/pandora/item/views.py b/pandora/item/views.py index f5fb6c165..fca883cc8 100644 --- a/pandora/item/views.py +++ b/pandora/item/views.py @@ -855,16 +855,14 @@ def oembed(request): ) return HttpResponse(json.dumps(oembed, indent=2), 'application/json') -def sitemap_xml_gz(request): - sitemap = os.path.abspath(os.path.join(settings.MEDIA_ROOT, 'sitemap.xml.gz')) - age = time.mktime(time.localtime()) - os.stat(sitemap).st_ctime +def sitemap_xml(request): + sitemap = os.path.abspath(os.path.join(settings.MEDIA_ROOT, 'sitemap.xml')) if not os.path.exists(sitemap): tasks.update_sitemap(request.build_absolute_uri('/')) - elif age > 24*60*60: + elif time.mktime(time.localtime()) - os.stat(sitemap).st_ctime > 24*60*60: tasks.update_sitemap.delay(request.build_absolute_uri('/')) response = HttpFileResponse(sitemap) response['Content-Type'] = 'application/xml' - response['Content-Encoding'] = 'x-gzip' return response def item(request, id): diff --git a/pandora/padma.jsonc b/pandora/padma.jsonc index 8325cf658..dfd6440e7 100644 --- a/pandora/padma.jsonc +++ b/pandora/padma.jsonc @@ -547,6 +547,13 @@ "showHome": true, "showIconBrowser": false, "showInfo": true, + "showLayers": { + "places": true, + "events": true, + "keywords": true, + "descriptions": true, + "transcripts": true + }, "showMapControls": false, "showMapLabels": false, "showFolder": { diff --git a/pandora/urls.py b/pandora/urls.py index 5a1814383..7baa86b58 100644 --- a/pandora/urls.py +++ b/pandora/urls.py @@ -31,7 +31,7 @@ urlpatterns = patterns('', (r'^opensearch.xml$', 'app.views.opensearch_xml'), (r'^oembed$', 'item.views.oembed'), (r'^robots.txt$', 'app.views.robots_txt'), - (r'^sitemap.xml.gz$', 'item.views.sitemap_xml_gz'), + (r'^sitemap.xml$', 'item.views.sitemap_xml'), (r'', include('item.urls')), ) #if settings.DEBUG: diff --git a/static/js/pandora/item.js b/static/js/pandora/item.js index 793ed8b9a..d4cea5fcb 100644 --- a/static/js/pandora/item.js +++ b/static/js/pandora/item.js @@ -231,6 +231,7 @@ pandora.ui.item = function() { : '', showAnnotations: pandora.user.ui.showAnnotations, showLargeTimeline: true, + showLayers: pandora.user.ui.showLayers, subtitles: videoOptions.subtitles, tooltips: true, video: videoOptions.video, @@ -328,6 +329,9 @@ pandora.ui.item = function() { toggleannotations: function(data) { pandora.UI.set('showAnnotations', data.showAnnotations); }, + togglelayer: function(data) { + pandora.UI.set('showLayers.' + data.layer, !data.collapsed); + }, pandora_showannotations: function(data) { pandora.$ui.editor.options({showAnnotations: data.value}); }