changeset: 119:063b7e46bc1f
tag: tip
user: [email protected]
date: Tue May 29 18:10:07 2012 -0700
files: guide/index.html index.html js/core/base-runner.js js/core/tmpl.js js/respec-docs/profile-respec-docs.js
description:
Fixed some minor issues, and made the system IE10 compatible:
* Fixed links to allow proper pre-reqs to load for respec processing on
the root index and guide pages. (These pages were not being styled correctly
due to respec processing failures.)
* Added a few helps to make respec more robust to a lack of configuration file
(base-runner.js)
* Implemented a cross-browser compatible workaround for loading HTML fragments,
which unfortunately didn't work in IE because of a interop-bug in how
"about:blank" documents are asynchronously initialized.
* Fixed usage of require.js to properly implement dependency chains as implied
by the existing code comments. These would only work in IE when I "soft"
refreshed the page because the needed dependencies were already in the cache;
on a full refresh or cold visit, the tmpl.js file would load before the
prereq code was done and mess things up. This was an accident waiting to
happen in the other browsers as well, which I simulated by adding some
network latency for base-runner.js and observing the failure in chrome and
firefox too. Couldn't find the particular line in the require.js file that
states this specificially, but the ONLY guarantee that require.js makes is
that all of the required files in the list will be loaded before the callback
--not that the files in the required list will all be loaded in the specified
order. But now you know. :-)
use simple async s
diff -r 43c64d5b5b73 -r 063b7e46bc1f guide/index.html
--- a/guide/index.html Thu May 17 17:04:18 2012 +0200
+++ b/guide/index.html Tue May 29 18:10:07 2012 -0700
@@ -1,9 +1,9 @@
-<!DOCTYPE html>
+<!DOCTYPE html>
<html xmlns='http://www.w3.org/1999/xhtml' xml:lang='en' lang='en'>
<head>
<meta http-equiv='Content-Type' content='text/html; charset=utf-8'/>
<title>The Guide</title>
- <script src='/guide/docs-config.js' class='remove'></script>
+ <script src='docs-config.js' class='remove'></script>
<script data-main='respec-docs/profile-respec-docs' src='../js/require.js' class='remove'></script>
</head>
<body>
diff -r 43c64d5b5b73 -r 063b7e46bc1f index.html
--- a/index.html Thu May 17 17:04:18 2012 +0200
+++ b/index.html Tue May 29 18:10:07 2012 -0700
@@ -1,9 +1,9 @@
-<!DOCTYPE html>
+<!DOCTYPE html>
<html xmlns='http://www.w3.org/1999/xhtml' xml:lang='en' lang='en'>
<head>
<meta http-equiv='Content-Type' content='text/html; charset=utf-8'/>
<title>Welcome!</title>
- <script src='/guide/docs-config.js' class='remove'></script>
+ <script src='guide/docs-config.js' class='remove'></script>
<script data-main='respec-docs/profile-respec-docs' src='js/require.js' class='remove'></script>
</head>
<body>
@@ -13,8 +13,8 @@
<h2>Welcome to ReSpec</h2>
<p>
This is the server from which ReSpec v2 is made available. Chances are you're looking for the
- <a href='/js/'>actual Javascript code</a>, perhaps for <a href='/js/profiles/'>an existing profile</a>,
- or if human-readable documentation is more your type, <a href='/guide/'>the guide</a> might be
+ <a href='js/'>actual Javascript code</a>, perhaps for <a href='js/profiles/'>an existing profile</a>,
+ or if human-readable documentation is more your type, <a href='guide/'>the guide</a> might be
a better bet.
</p>
<p>
diff -r 43c64d5b5b73 -r 063b7e46bc1f js/core/base-runner.js
--- a/js/core/base-runner.js Thu May 17 17:04:18 2012 +0200
+++ b/js/core/base-runner.js Tue May 29 18:10:07 2012 -0700
@@ -14,6 +14,10 @@
GLOBAL.error = function (str) {
console.error("E: " + str);
+ // Since errors can not successfully continue execution (something will
+ // break downstream, for example not supplying an editor as in
+ // conf.editors in headers.js), throw to stop ReSpec processing.
+ throw new Error("ReSpec2 configuration error--please see console output for details");
};
GLOBAL.progress = function (str) {
@@ -29,7 +33,8 @@
runAll: function (plugs) {
// the first in the plugs is going to be us
plugs.shift();
- if (!respecConfig) respecConfig = {};
+ // Use window.* to avoid a ReferenceError when respecConfig does not exist.
+ if (!window.respecConfig) respecConfig = {};
// the base URL is used by some modules
var $scripts = $("script"),
diff -r 43c64d5b5b73 -r 063b7e46bc1f js/core/tmpl.js
--- a/js/core/tmpl.js Thu May 17 17:04:18 2012 +0200
+++ b/js/core/tmpl.js Tue May 29 18:10:07 2012 -0700
@@ -24,14 +24,21 @@
// loads templates as parsed HTML given a string
loadFromHTML: function (str, doc) {
- var $body = $("body", doc),
- $ifr = $("<iframe/>").css({display: "none"}).attr("src", "about:blank");
- if ($body.length) $ifr.appendTo($body);
- else $("head", doc).after($ifr);
- var iDoc = $ifr[0].contentWindow.document;
- iDoc.documentElement.innerHTML = str;
- this.loadAllTemplates(iDoc);
- $ifr.remove();
+ // IE does not sychronously load a document element + head/body into about:blank.
+ // There appeared to be [generally] a faster way to do this, so implementing that
+ // instead
+ var divorcedHTMLDoc = doc.implementation.createHTMLDocument("loading...");
+ divorcedHTMLDoc.documentElement.innerHTML = str;
+ this.loadAllTemplates(divorcedHTMLDoc);
+ // [OLD TECHNIQUE]
+ //var $body = $("body", doc),
+ // $ifr = $("<iframe/>").css({display: "none"}).attr("src", "about:blank");
+ //if ($body.length) $ifr.appendTo($body);
+ //else $("head", doc).after($ifr);
+ //var iDoc = $ifr[0].contentWindow.document;
+ //iDoc.documentElement.innerHTML = str;
+ //this.loadAllTemplates(iDoc);
+ //$ifr.remove();
},
ieDummy: 1
};
diff -r 43c64d5b5b73 -r 063b7e46bc1f js/respec-docs/profile-respec-docs.js
--- a/js/respec-docs/profile-respec-docs.js Thu May 17 17:04:18 2012 +0200
+++ b/js/respec-docs/profile-respec-docs.js Tue May 29 18:10:07 2012 -0700
@@ -3,27 +3,36 @@
"core/base-runner",
"core/utils",
"core/override-configuration",
-
- // modules that are used by the profile
- "core/default-root-attr",
- "respec-docs/style",
- "core/style",
- "respec-docs/headers",
- "core/data-include",
- "core/inlines",
- // "core/webidl",
- "core/examples",
- "w3c/bibref",
- "core/structure",
- "core/dfn",
- "robineko/add-container",
- // these at the end
- "core/remove-respec"
],
- function (runner) {
- var args = arguments;
- require.ready(function () {
- runner.runAll(Array.prototype.slice.call(args));
+ function preReqsComplete() {
+ var preReqObjectsArray = Array.prototype.slice.call(arguments);
+ require([
+ // modules that are used by the profile
+ "core/default-root-attr",
+ "respec-docs/style",
+ "core/style",
+ "respec-docs/headers",
+ "core/data-include",
+ "core/inlines",
+ // "core/webidl",
+ "core/examples",
+ "w3c/bibref",
+ "core/structure",
+ "core/dfn",
+ "robineko/add-container",
+ ],
+ function reqsComplete() {
+ var reqObjectsArray = Array.prototype.slice.call(arguments);
+ require([
+ // these at the end
+ "core/remove-respec"
+ ],
+ function postReqsComplete() {
+ var postReqObjectsArray = Array.prototype.slice.call(arguments);
+ require.ready(function() {
+ preReqObjectsArray[0].runAll(preReqObjectsArray.concat(reqObjectsArray,postReqObjectsArray));
+ });
+ });
});
}
);
changeset: 120:ce9f0cc50fed
tag: tip
user: [email protected]
date: Tue May 29 18:19:29 2012 -0700
files: guide/basic-layout.html guide/building-static.html guide/dev-basics.html guide/dev-plugins.html guide/dev-profiles.html guide/essential-boilerplate.html guide/inline.html guide/structure.html guide/upgrade-from-v1.html guide/webidl.html
description:
Removed the "/guide/" prefix to the respec reqs documents from these files so
they all load correctly.
diff -r 063b7e46bc1f -r ce9f0cc50fed guide/basic-layout.html
--- a/guide/basic-layout.html Tue May 29 18:10:07 2012 -0700
+++ b/guide/basic-layout.html Tue May 29 18:19:29 2012 -0700
@@ -1,9 +1,9 @@
-<!DOCTYPE html>
+<!DOCTYPE html>
<html xmlns='http://www.w3.org/1999/xhtml' xml:lang='en' lang='en'>
<head>
<meta http-equiv='Content-Type' content='text/html; charset=utf-8'/>
<title>Basic Layout</title>
- <script src='/guide/docs-config.js' class='remove'></script>
+ <script src='docs-config.js' class='remove'></script>
<script data-main='respec-docs/profile-respec-docs' src='../js/require.js' class='remove'></script>
</head>
<body>
diff -r 063b7e46bc1f -r ce9f0cc50fed guide/building-static.html
--- a/guide/building-static.html Tue May 29 18:10:07 2012 -0700
+++ b/guide/building-static.html Tue May 29 18:19:29 2012 -0700
@@ -1,9 +1,9 @@
-<!DOCTYPE html>
+<!DOCTYPE html>
<html xmlns='http://www.w3.org/1999/xhtml' xml:lang='en' lang='en'>
<head>
<meta http-equiv='Content-Type' content='text/html; charset=utf-8'/>
<title>Static Snapshots</title>
- <script src='/guide/docs-config.js' class='remove'></script>
+ <script src='docs-config.js' class='remove'></script>
<script data-main='respec-docs/profile-respec-docs' src='../js/require.js' class='remove'></script>
</head>
<body>
diff -r 063b7e46bc1f -r ce9f0cc50fed guide/dev-basics.html
--- a/guide/dev-basics.html Tue May 29 18:10:07 2012 -0700
+++ b/guide/dev-basics.html Tue May 29 18:19:29 2012 -0700
@@ -1,9 +1,9 @@
-<!DOCTYPE html>
+<!DOCTYPE html>
<html xmlns='http://www.w3.org/1999/xhtml' xml:lang='en' lang='en'>
<head>
<meta http-equiv='Content-Type' content='text/html; charset=utf-8'/>
<title>Development Basics</title>
- <script src='/guide/docs-config.js' class='remove'></script>
+ <script src='docs-config.js' class='remove'></script>
<script data-main='respec-docs/profile-respec-docs' src='../js/require.js' class='remove'></script>
</head>
<body>
diff -r 063b7e46bc1f -r ce9f0cc50fed guide/dev-plugins.html
--- a/guide/dev-plugins.html Tue May 29 18:10:07 2012 -0700
+++ b/guide/dev-plugins.html Tue May 29 18:19:29 2012 -0700
@@ -1,9 +1,9 @@
-<!DOCTYPE html>
+<!DOCTYPE html>
<html xmlns='http://www.w3.org/1999/xhtml' xml:lang='en' lang='en'>
<head>
<meta http-equiv='Content-Type' content='text/html; charset=utf-8'/>
<title>Plugins</title>
- <script src='/guide/docs-config.js' class='remove'></script>
+ <script src='docs-config.js' class='remove'></script>
<script data-main='respec-docs/profile-respec-docs' src='../js/require.js' class='remove'></script>
</head>
<body>
diff -r 063b7e46bc1f -r ce9f0cc50fed guide/dev-profiles.html
--- a/guide/dev-profiles.html Tue May 29 18:10:07 2012 -0700
+++ b/guide/dev-profiles.html Tue May 29 18:19:29 2012 -0700
@@ -1,9 +1,9 @@
-<!DOCTYPE html>
+<!DOCTYPE html>
<html xmlns='http://www.w3.org/1999/xhtml' xml:lang='en' lang='en'>
<head>
<meta http-equiv='Content-Type' content='text/html; charset=utf-8'/>
<title>Profiles</title>
- <script src='/guide/docs-config.js' class='remove'></script>
+ <script src='docs-config.js' class='remove'></script>
<script data-main='respec-docs/profile-respec-docs' src='../js/require.js' class='remove'></script>
</head>
<body>
diff -r 063b7e46bc1f -r ce9f0cc50fed guide/essential-boilerplate.html
--- a/guide/essential-boilerplate.html Tue May 29 18:10:07 2012 -0700
+++ b/guide/essential-boilerplate.html Tue May 29 18:19:29 2012 -0700
@@ -1,9 +1,9 @@
-<!DOCTYPE html>
+<!DOCTYPE html>
<html xmlns='http://www.w3.org/1999/xhtml' xml:lang='en' lang='en'>
<head>
<meta http-equiv='Content-Type' content='text/html; charset=utf-8'/>
<title>Boilerplate</title>
- <script src='/guide/docs-config.js' class='remove'></script>
+ <script src='docs-config.js' class='remove'></script>
<script data-main='respec-docs/profile-respec-docs' src='../js/require.js' class='remove'></script>
</head>
<body>
diff -r 063b7e46bc1f -r ce9f0cc50fed guide/inline.html
--- a/guide/inline.html Tue May 29 18:10:07 2012 -0700
+++ b/guide/inline.html Tue May 29 18:19:29 2012 -0700
@@ -1,9 +1,9 @@
-<!DOCTYPE html>
+<!DOCTYPE html>
<html xmlns='http://www.w3.org/1999/xhtml' xml:lang='en' lang='en'>
<head>
<meta http-equiv='Content-Type' content='text/html; charset=utf-8'/>
<title>Inlines</title>
- <script src='/guide/docs-config.js' class='remove'></script>
+ <script src='docs-config.js' class='remove'></script>
<script data-main='respec-docs/profile-respec-docs' src='../js/require.js' class='remove'></script>
</head>
<body>
diff -r 063b7e46bc1f -r ce9f0cc50fed guide/structure.html
--- a/guide/structure.html Tue May 29 18:10:07 2012 -0700
+++ b/guide/structure.html Tue May 29 18:19:29 2012 -0700
@@ -1,9 +1,9 @@
-<!DOCTYPE html>
+<!DOCTYPE html>
<html xmlns='http://www.w3.org/1999/xhtml' xml:lang='en' lang='en'>
<head>
<meta http-equiv='Content-Type' content='text/html; charset=utf-8'/>
<title>Structure</title>
- <script src='/guide/docs-config.js' class='remove'></script>
+ <script src='docs-config.js' class='remove'></script>
<script data-main='respec-docs/profile-respec-docs' src='../js/require.js' class='remove'></script>
</head>
<body>
diff -r 063b7e46bc1f -r ce9f0cc50fed guide/upgrade-from-v1.html
--- a/guide/upgrade-from-v1.html Tue May 29 18:10:07 2012 -0700
+++ b/guide/upgrade-from-v1.html Tue May 29 18:19:29 2012 -0700
@@ -1,9 +1,9 @@
-<!DOCTYPE html>
+<!DOCTYPE html>
<html xmlns='http://www.w3.org/1999/xhtml' xml:lang='en' lang='en'>
<head>
<meta http-equiv='Content-Type' content='text/html; charset=utf-8'/>
<title>Upgrading</title>
- <script src='/guide/docs-config.js' class='remove'></script>
+ <script src='docs-config.js' class='remove'></script>
<script data-main='respec-docs/profile-respec-docs' src='../js/require.js' class='remove'></script>
</head>
<body>
diff -r 063b7e46bc1f -r ce9f0cc50fed guide/webidl.html
--- a/guide/webidl.html Tue May 29 18:10:07 2012 -0700
+++ b/guide/webidl.html Tue May 29 18:19:29 2012 -0700
@@ -1,9 +1,9 @@
-<!DOCTYPE html>
+<!DOCTYPE html>
<html xmlns='http://www.w3.org/1999/xhtml' xml:lang='en' lang='en'>
<head>
<meta http-equiv='Content-Type' content='text/html; charset=utf-8'/>
<title>WebIDL</title>
- <script src='/guide/docs-config.js' class='remove'></script>
+ <script src='docs-config.js' class='remove'></script>
<script data-main='respec-docs/profile-respec-docs' src='../js/require.js' class='remove'></script>
</head>
<body>