make layer collapsed/expanded state sticky

This commit is contained in:
rolux 2012-01-11 13:21:26 +05:30
parent 52643a9218
commit 758c821d5a
7 changed files with 23 additions and 8 deletions

View file

@ -639,6 +639,11 @@
"showHome": true, "showHome": true,
"showIconBrowser": false, "showIconBrowser": false,
"showInfo": true, "showInfo": true,
"showLayers": {
"privatenotes": true,
"publicnotes": true,
"subtitles": true
},
"showMapControls": false, "showMapControls": false,
"showMapLabels": false, "showMapLabels": false,
"showFolder": { "showFolder": {

View file

@ -74,7 +74,7 @@ def opensearch_xml(request):
def robots_txt(request, url): def robots_txt(request, url):
return HttpResponse( 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' 'text/plain'
) )

View file

@ -113,6 +113,7 @@ def update_sitemap(base_url):
el = ET.SubElement(video, "video:duration") el = ET.SubElement(video, "video:duration")
el.text = "%s" % duration el.text = "%s" % duration
with open(sitemap[:-3], 'wb') as f:
f.write('<?xml version="1.0" encoding="UTF-8"?>\n' + ET.tostring(urlset))
with gzip.open(sitemap, 'wb') as f: with gzip.open(sitemap, 'wb') as f:
f.write('<?xml version="1.0" encoding="UTF-8"?>\n' + ET.tostring(urlset)) f.write('<?xml version="1.0" encoding="UTF-8"?>\n' + ET.tostring(urlset))

View file

@ -855,16 +855,14 @@ def oembed(request):
) )
return HttpResponse(json.dumps(oembed, indent=2), 'application/json') return HttpResponse(json.dumps(oembed, indent=2), 'application/json')
def sitemap_xml_gz(request): def sitemap_xml(request):
sitemap = os.path.abspath(os.path.join(settings.MEDIA_ROOT, 'sitemap.xml.gz')) sitemap = os.path.abspath(os.path.join(settings.MEDIA_ROOT, 'sitemap.xml'))
age = time.mktime(time.localtime()) - os.stat(sitemap).st_ctime
if not os.path.exists(sitemap): if not os.path.exists(sitemap):
tasks.update_sitemap(request.build_absolute_uri('/')) 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('/')) tasks.update_sitemap.delay(request.build_absolute_uri('/'))
response = HttpFileResponse(sitemap) response = HttpFileResponse(sitemap)
response['Content-Type'] = 'application/xml' response['Content-Type'] = 'application/xml'
response['Content-Encoding'] = 'x-gzip'
return response return response
def item(request, id): def item(request, id):

View file

@ -547,6 +547,13 @@
"showHome": true, "showHome": true,
"showIconBrowser": false, "showIconBrowser": false,
"showInfo": true, "showInfo": true,
"showLayers": {
"places": true,
"events": true,
"keywords": true,
"descriptions": true,
"transcripts": true
},
"showMapControls": false, "showMapControls": false,
"showMapLabels": false, "showMapLabels": false,
"showFolder": { "showFolder": {

View file

@ -31,7 +31,7 @@ urlpatterns = patterns('',
(r'^opensearch.xml$', 'app.views.opensearch_xml'), (r'^opensearch.xml$', 'app.views.opensearch_xml'),
(r'^oembed$', 'item.views.oembed'), (r'^oembed$', 'item.views.oembed'),
(r'^robots.txt$', 'app.views.robots_txt'), (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')), (r'', include('item.urls')),
) )
#if settings.DEBUG: #if settings.DEBUG:

View file

@ -231,6 +231,7 @@ pandora.ui.item = function() {
: '', : '',
showAnnotations: pandora.user.ui.showAnnotations, showAnnotations: pandora.user.ui.showAnnotations,
showLargeTimeline: true, showLargeTimeline: true,
showLayers: pandora.user.ui.showLayers,
subtitles: videoOptions.subtitles, subtitles: videoOptions.subtitles,
tooltips: true, tooltips: true,
video: videoOptions.video, video: videoOptions.video,
@ -328,6 +329,9 @@ pandora.ui.item = function() {
toggleannotations: function(data) { toggleannotations: function(data) {
pandora.UI.set('showAnnotations', data.showAnnotations); pandora.UI.set('showAnnotations', data.showAnnotations);
}, },
togglelayer: function(data) {
pandora.UI.set('showLayers.' + data.layer, !data.collapsed);
},
pandora_showannotations: function(data) { pandora_showannotations: function(data) {
pandora.$ui.editor.options({showAnnotations: data.value}); pandora.$ui.editor.options({showAnnotations: data.value});
} }