Dynamically-generated manifests.
This commit is contained in:
4
app.yaml
4
app.yaml
@@ -12,6 +12,10 @@ handlers:
|
|||||||
http_headers:
|
http_headers:
|
||||||
X-Content-Type-Options: nosniff
|
X-Content-Type-Options: nosniff
|
||||||
|
|
||||||
|
- url: /manifest.json
|
||||||
|
script: manifest.app
|
||||||
|
secure: always
|
||||||
|
|
||||||
- url: /baby/.*
|
- url: /baby/.*
|
||||||
static_files: static/babystats.html
|
static_files: static/babystats.html
|
||||||
upload: static/babystats.html
|
upload: static/babystats.html
|
||||||
|
|||||||
23
manifest.py
Normal file
23
manifest.py
Normal file
@@ -0,0 +1,23 @@
|
|||||||
|
import json
|
||||||
|
import webapp2
|
||||||
|
|
||||||
|
|
||||||
|
class Manifest(webapp2.RequestHandler):
|
||||||
|
|
||||||
|
def get(self):
|
||||||
|
self.response.headers['Content-Type'] = 'application/json'
|
||||||
|
json.dump({
|
||||||
|
'name': self.request.get('name'),
|
||||||
|
'display': 'standalone',
|
||||||
|
'icons': [
|
||||||
|
{
|
||||||
|
'src': '/static/icon.png',
|
||||||
|
'sizes': '256x256',
|
||||||
|
},
|
||||||
|
],
|
||||||
|
}, self.response.out)
|
||||||
|
|
||||||
|
|
||||||
|
app = webapp2.WSGIApplication([
|
||||||
|
('/manifest.json', Manifest),
|
||||||
|
])
|
||||||
@@ -147,6 +147,10 @@ BabyStats.prototype.checkInit_ = function() {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
this.manifest_ = document.createElement('link');
|
||||||
|
this.manifest_.rel = 'manifest';
|
||||||
|
document.head.appendChild(this.manifest_);
|
||||||
|
|
||||||
this.buildCells_();
|
this.buildCells_();
|
||||||
this.buildLayout_();
|
this.buildLayout_();
|
||||||
|
|
||||||
@@ -251,6 +255,8 @@ BabyStats.prototype.handleMessage_ = function(isEvent, message) {
|
|||||||
}
|
}
|
||||||
document.title = message.message.child_name;
|
document.title = message.message.child_name;
|
||||||
this.displayChildName_.textContent = message.message.child_name;
|
this.displayChildName_.textContent = message.message.child_name;
|
||||||
|
this.manifest_.href =
|
||||||
|
'/manifest.json?name=' + encodeURIComponent(this.childName_.value);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
|
|||||||
Reference in New Issue
Block a user