Make appcache actually work

This commit is contained in:
Lance Stout 2014-01-06 19:44:02 -08:00
parent d3d6df5d99
commit 00ee3e5c67
4 changed files with 24 additions and 28 deletions

View File

@ -1,6 +1,6 @@
<!DOCTYPE html>
<html>
<head manifest="/manifest.cache">
<html manifest="/manifest.cache">
<head>
<title>Otalk</title>
<link rel="stylesheet" type="text/css" href="#{cssFileName}" />
<script src="#{jsFileName}"></script>

View File

@ -5,12 +5,12 @@ CACHE:
#{jsFileName}
#{cssFileName}
images/logo.png
images/icon_128x128.png
/images/logo.png
/images/icon_128x128.png
js/zepto.js
/js/zepto.js
js/login.js
js/logout.js
/js/logout.js
NETWORK:
*

View File

@ -1,6 +1,6 @@
{
"name": "otalk.im",
"version": "0.0.5",
"version": "0.0.6",
"description": "Otalk: WebRTC Enabled XMPP Client, in the Browser",
"repository": {
"type": "git",

View File

@ -45,18 +45,21 @@ if (config.isDev) {
clientApp.config.beforeBuildJS = function () {
var clientFolder = __dirname + '/clientapp';
templatizer(clientFolder + '/templates', clientFolder + '/templates.js');
var pkginfo = JSON.parse(fs.readFileSync('./package.json'));
var cacheManifest = fs.readFileSync('clientapp/templates/misc/manifest.cache', 'utf-8');
cacheManifest = cacheManifest
.replace('#{version}', pkginfo.version + ' ' + Date.now())
.replace('#{jsFileName}', '/' + clientApp.jsFileName())
.replace('#{cssFileName}', '/' + clientApp.cssFileName());
fs.writeFileSync('./public/x-manifest.cache', cacheManifest);
};
}
var pkginfo = JSON.parse(fs.readFileSync('./package.json'));
var manifestTemplate = fs.readFileSync('./clientapp/templates/misc/manifest.cache', 'utf-8');
var cacheManifest = manifestTemplate
.replace('#{version}', pkginfo.version)
.replace('#{jsFileName}', '/' + clientApp.jsFileName())
.replace('#{cssFileName}', '/' + clientApp.cssFileName());
var webappManifest = fs.readFileSync('./public/x-manifest.webapp');
app.set('view engine', 'jade');
app.get('/login', function (req, res) {
@ -73,21 +76,14 @@ app.get('/oauth/callback', function (req, res) {
});
app.get('/manifest.webapp', function (req, res, next) {
fs.readFile('./public/x-manifest.webapp', function doneReadingManifest(err, manifestContents) {
if (err) return next(err);
res.set('Content-Type', 'application/x-web-app-manifest+json');
res.send(manifestContents);
});
res.set('Content-Type', 'application/x-web-app-manifest+json');
res.send(webappManifest);
});
app.get('/manifest.cache', function (req, res, next) {
fs.readFile('./public/x-manifest.cache', function doneReadingManifestCache(err, manifestCacheContents) {
if (err) return next(err);
res.set('Content-Type', 'text/cache-manifest');
res.send(manifestCacheContents);
});
res.set('Content-Type', 'text/cache-manifest');
res.set('Cache-Control', 'public, max-age=0');
res.send(cacheManifest);
});
app.get('/oembed', function (req, res) {