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,
"showIconBrowser": false,
"showInfo": true,
"showLayers": {
"privatenotes": true,
"publicnotes": true,
"subtitles": true
},
"showMapControls": false,
"showMapLabels": false,
"showFolder": {

View file

@ -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'
)

View file

@ -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('<?xml version="1.0" encoding="UTF-8"?>\n' + ET.tostring(urlset))
with gzip.open(sitemap, 'wb') as f:
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')
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):

View file

@ -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": {

View file

@ -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:

View file

@ -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});
}