+
+ // The HTML can go async, it's not too hopeless if it's out of date by a few milliseconds
+ read_entire_file(html_filename, function(new_html_contents, html_mtime) {
+ var json_headers = {
+ 'X-RGLM': mtime,
+ 'X-RGNV': count_viewers(), // May be slightly out of date.
+ 'Date': (new Date).toUTCString(),
+ };
+ if (MINIMUM_VERSION) {
+ json_headers['X-RGMV'] = MINIMUM_VERSION;
+ }
+ let inline_json = {
+ 'data': JSON.parse(new_json_contents),
+ 'headers': json_headers,
+ };
+ delete inline_json['data']['internal'];
+
+ new_html_contents = new_html_contents.replace(
+ '/*REPLACE:inlinejson*/',
+ 'window.inline_json=' + JSON.stringify(inline_json) + ';');
+ zlib.gzip(new_html_contents, function(err, buffer) {
+ if (err) throw err;
+ html = {
+ plain: new_html_contents,
+ gzip: buffer,
+ };
+ });
+ });