From b2632d45c57e5031f29bc87f2eb05044a64e4afb Mon Sep 17 00:00:00 2001 From: David Glasser Date: Mon, 17 Mar 2014 21:56:52 -0700 Subject: [PATCH] Move boilerplate HTML from tools to webapp This breaks a strong dependency between the webapp package and the bundler. Now we can change the standard page format, add more hooks, etc without changing the tools (and hot code push works properly). This is an incompatible change to the definition of the browser-program-pre1 format: it no longer contains a "page" field pointing to a boilerplate defined using ad hoc ##FOO## substitution. Instead, the manifest can contain "head" and "body" entries for data added with compileStep.appendDocument(). (Note that in Blaze, in a template file no longer calls appendDocument.) WebApp.addHtmlAttributeHook callbacks now return attribute objects (like those that Spacebars supports) rather than strings. --- History.md | 8 ++ packages/appcache/appcache-server.js | 2 +- packages/observe-sequence/package.js | 4 +- packages/star-translate/translator.js | 3 + packages/webapp/boilerplate.html | 22 +++++ packages/webapp/package.js | 9 +- packages/webapp/webapp_server.js | 126 +++++++++++++++--------- tools/bundler.js | 76 ++++---------- tools/tests/old/test-bundler-options.js | 50 +++++++--- 9 files changed, 178 insertions(+), 122 deletions(-) create mode 100644 packages/webapp/boilerplate.html diff --git a/History.md b/History.md index a067d9aec4..3d6eb26976 100644 --- a/History.md +++ b/History.md @@ -2,6 +2,14 @@ * Log out a user's other sessions when they change their password. +* Move boilerplate HTML from tools to webapp. Changes internal + Webapp.addHtmlAttributeHook API incompatibly. + + +## v0.8.0 + +(Currently being stabilized. Features Blaze.) + ## v0.7.2 diff --git a/packages/appcache/appcache-server.js b/packages/appcache/appcache-server.js index ce579583d2..3d4bec1c4c 100644 --- a/packages/appcache/appcache-server.js +++ b/packages/appcache/appcache-server.js @@ -57,7 +57,7 @@ var browserEnabled = function(request) { WebApp.addHtmlAttributeHook(function (request) { if (browserEnabled(request)) - return 'manifest="/app.manifest"'; + return { manifest: "/app.manifest" }; else return null; }); diff --git a/packages/observe-sequence/package.js b/packages/observe-sequence/package.js index 30be5f0ca5..5009db78d2 100644 --- a/packages/observe-sequence/package.js +++ b/packages/observe-sequence/package.js @@ -7,9 +7,7 @@ Package.on_use(function (api) { api.use('deps'); api.use('minimongo'); // for idStringify api.export('ObserveSequence'); - // XXX this does also run on the server but as long as deps is not - // documented to run there let's not try - api.add_files(['observe_sequence.js'], 'client'); + api.add_files(['observe_sequence.js']); }); Package.on_test(function (api) { diff --git a/packages/star-translate/translator.js b/packages/star-translate/translator.js index 77d08756de..bff404d034 100644 --- a/packages/star-translate/translator.js +++ b/packages/star-translate/translator.js @@ -101,6 +101,9 @@ StarTranslator._writeClientProg = function (bundlePath, clientProgPath) { var clientManifest = { "format": "browser-program-pre1", "manifest": origClientManifest.manifest, + // XXX Haven't updated this for the app.html -> head/body change, but + // surely we don't need to because code in pre-star apps doesn't + // even read this file? "page": "app.html", "static": "static", "staticCacheable": "static_cacheable" diff --git a/packages/webapp/boilerplate.html b/packages/webapp/boilerplate.html new file mode 100644 index 0000000000..a4fb29f8fb --- /dev/null +++ b/packages/webapp/boilerplate.html @@ -0,0 +1,22 @@ + + +{{#each css}} {{/each}} + +{{#if inlineScriptsAllowed}} + +{{else}} + +{{/if}} +{{#each js}} +{{/each}} +{{#if inlineScriptsAllowed}} + +{{else}} + +{{/if}} +{{{head}}} + + +{{{body}}} + + diff --git a/packages/webapp/package.js b/packages/webapp/package.js index fab6a96434..2a50bf1aef 100644 --- a/packages/webapp/package.js +++ b/packages/webapp/package.js @@ -8,7 +8,9 @@ Npm.depends({connect: "2.9.0", useragent: "2.0.7"}); Package.on_use(function (api) { - api.use(['logging', 'underscore', 'routepolicy'], 'server'); + api.use(['logging', 'underscore', 'routepolicy', 'spacebars-compiler', + 'spacebars', 'htmljs'], + 'server'); api.use(['underscore'], 'client'); api.use(['application-configuration', 'follower-livedata'], { unordered: true @@ -21,5 +23,10 @@ Package.on_use(function (api) { api.export(['WebApp', 'main', 'WebAppInternals'], 'server'); api.export(['WebApp'], 'client'); api.add_files('webapp_server.js', 'server'); + // This is a spacebars template, but we process it manually with the spacebars + // compiler rather than letting the 'templating' package (which isn't fully + // supported on the server yet) handle it. That also means that it doesn't + // contain the outer "