Skip to content

Commit

Permalink
Merge pull request #222 from tobie/use-refs-api
Browse files Browse the repository at this point in the history
Rely on a calls to an API for spec references rather than bundling the whole ref file.
  • Loading branch information
darobin committed May 21, 2013
2 parents 347c25a + d08efee commit 33c0843
Show file tree
Hide file tree
Showing 8 changed files with 37 additions and 9,463 deletions.
9,205 changes: 0 additions & 9,205 deletions bibref/biblio.js

This file was deleted.

4 changes: 1 addition & 3 deletions examples/previousVersions.html
Expand Up @@ -22,8 +22,7 @@
"MEMES": "<a href='http://w3cmemes.tumblr.com/'>W3C Memes</a>",
"REX": "<strong>Overridden!</strong>",
"WEE": {
title: "weee!",
previousVersions: [{key: "TESTING", href: "http://test"}]
title: "weee!"
}
}
};
Expand All @@ -35,7 +34,6 @@
This is just a very basic document. [[!REX]] Yeah for memes [[MEMES]].
[[DOM4]], [[XML10]], [[\WHATEVER]], [[!DAHUT-TEST1]],
[[!WEE]],
[[!WEE-TESTING]],
[[!DAHUT-TEST2]],
[[!DAHUT-TEST3]],
[[!DAHUT-TEST4]],
Expand Down
111 changes: 0 additions & 111 deletions js/core/biblio/previous-versions.js

This file was deleted.

1 change: 0 additions & 1 deletion js/profile-w3c-common.js
Expand Up @@ -4,7 +4,6 @@ define([
, "core/base-runner"
, "core/override-configuration"
, "core/default-root-attr"
, "core/biblio/previous-versions"
// , "core/local-biblio"
, "core/markdown"
, "core/style"
Expand Down
55 changes: 35 additions & 20 deletions js/w3c/legacy.js
Expand Up @@ -9,6 +9,9 @@
// RESPEC
var sn;
(function () {
window.setBerjonBiblio = function(payload) {
berjon.biblio = payload;
};
if (typeof(berjon) == "undefined") window.berjon = {};
function _errEl () {
var id = "respec-err";
Expand Down Expand Up @@ -47,7 +50,7 @@ var sn;
}
berjon.respec = function () {};
berjon.respec.prototype = {
loadAndRun: function (cb, msg, conf, doc, cb, msg) {
loadAndRun: function (conf, doc, cb, msg) {
var scripts = document.querySelectorAll("script[src]");
// XXX clean this up
var rs, base = "";
Expand All @@ -60,7 +63,12 @@ var sn;
}
// base = respecConfig.respecBase;
var loaded = [];
var deps = ["js/simple-node.js", "js/shortcut.js", "bibref/biblio.js"];
var refs = this.getRefKeys(conf);
refs = refs.normativeReferences.concat(refs.informativeReferences);
var deps = [base + "js/simple-node.js", base + "js/shortcut.js"];
if (refs.length) {
deps.push("http://specref.jit.su/bibrefs?callback=setBerjonBiblio&refs=" + refs.join(','));
}
var head = document.getElementsByTagName('head')[0];
var obj = this;
var loadHandler = function (ev) {
Expand All @@ -71,8 +79,6 @@ var sn;
"x": "http://www.w3.org/1999/xhtml"
}, document);
obj.run(conf, doc, cb, msg);
msg.pub("end", "w3c/legacy");
cb();
}
};
// the fact that we hand-load is temporary, and will be fully replaced by RequireJS
Expand All @@ -83,7 +89,7 @@ var sn;
var dep = deps[i];
var sel = document.createElement('script');
sel.type = 'text/javascript';
sel.src = base + dep;
sel.src = dep;
sel.setAttribute("class", "remove");
sel.onload = loadHandler;
head.appendChild(sel);
Expand All @@ -95,8 +101,6 @@ var sn;
"x": "http://www.w3.org/1999/xhtml"
}, document);
obj.run(conf, doc, cb, msg);
msg.pub("end", "w3c/legacy");
cb();
}
},

Expand All @@ -116,6 +120,8 @@ var sn;
catch (e) {
msg.pub("error", "Processing error: " + e);
}
msg.pub("end", "w3c/legacy");
cb();
},

overrideBiblio: function (conf) {
Expand Down Expand Up @@ -415,29 +421,38 @@ var sn;
if (cfg.hasOwnProperty(k)) this[k] = cfg[k];
}
},

// --- INLINE PROCESSING ----------------------------------------------------------------------------------
bibref: function (conf, doc, cb, msg) {
// this is in fact the bibref processing portion
var badrefs = {}
, badrefcount = 0
, informs = conf.informativeReferences

getRefKeys: function (conf) {
var informs = conf.informativeReferences
, norms = conf.normativeReferences
, aliases = {}
, del = []
;

function getKeys(obj) {
var res = [];
for (var k in obj) res.push(k);
return res;
}

var del = [];
for (var k in informs) if (norms[k]) del.push(k);
for (var i = 0; i < del.length; i++) delete informs[del[i]];

informs = getKeys(informs);
norms = getKeys(norms);
return {
informativeReferences: getKeys(informs),
normativeReferences: getKeys(norms)
};
},

// --- INLINE PROCESSING ----------------------------------------------------------------------------------
bibref: function (conf, doc, cb, msg) {
// this is in fact the bibref processing portion
var badrefs = {}
, badrefcount = 0
, refs = this.getRefKeys(conf)
, informs = refs.informativeReferences
, norms = refs.normativeReferences
, aliases = {}
;

if (!informs.length && !norms.length && !this.refNote) return;
var refsec = sn.element("section", { id: "references", "class": "appendix" }, document.body);
Expand Down Expand Up @@ -666,7 +681,7 @@ define([], function () {
return {
run: function (conf, doc, cb, msg) {
msg.pub("start", "w3c/legacy");
(new berjon.respec()).loadAndRun(cb, msg, conf, doc, cb, msg);
(new berjon.respec()).loadAndRun(conf, doc, cb, msg);
}
};
});
1 change: 0 additions & 1 deletion tests/SpecRunner.html
Expand Up @@ -13,7 +13,6 @@

<!-- SPECS -->
<script src="spec/SpecHelper.js"></script>
<script src="spec/core/biblio/previous-versions-spec.js"></script>
<script src="spec/core/default-root-attr-spec.js"></script>
<script src="spec/core/style-spec.js"></script>
<script src="spec/core/override-configuration-spec.js"></script>
Expand Down
120 changes: 0 additions & 120 deletions tests/spec/core/biblio/previous-versions-spec.js

This file was deleted.

0 comments on commit 33c0843

Please sign in to comment.