Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Develop #243

Merged
merged 7 commits into from Jul 15, 2013
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
14 changes: 8 additions & 6 deletions docs/index.html
Expand Up @@ -159,7 +159,8 @@ <h2>General Structure</h2>
</p>
<p>
During processing, <code>section</code> elements will be converted to <code>div</code>
elements with <code>class</code> "section".
elements with <code>class</code> "section". Note that this will only happen if you request
that XHTML1 be generated. (X)HTML5 has a section element, so it will not be replaced.
</p>
<p>
Any section at the beginning that has a <code>class</code> of "introductory" will not
Expand Down Expand Up @@ -453,10 +454,10 @@ <h2>Configuration</h2>
<dt>doRDFa</dt>
<dd>
If this parameter is set, ReSpec.js will embed various RDFa attributes throughout
the generated specification. The triples generated use vocabulary items from the dcterms,
foaf, and bibo. The parameter defaults to false. If set to true
the system will generate RDFa 1.0 content. If set to "1.1" it will
generate RDFa 1.1 content.
the generated specification. The triples generated use vocabulary items from dcterms,
foaf, bibo, and w3p. The parameter defaults to "1.1". If set to "1.0"
the system will generate (old, depecated) RDFa 1.0 content. If set to "1.1" it will
generate RDFa 1.1 content. If set to "false" then no RDFa will be embedded in the document.
</dd>
<dt>noIDLSorting</dt>
<dd>
Expand Down Expand Up @@ -890,7 +891,8 @@ <h2>In the Browser</h2>
<p>
The solution that is used here is that you hit the <code>Ctrl+Shift+Alt+S</code> key combination (this is
subject to change until we agree on an option we all like). That will show a menu offering to either
"Save as HTML", "Save as HTML (Source)", "Save as XHTML", or "Save as XHTML (Source)". You can hit <code>Esc</code> to hide it.
"Save as HTML", "Save as HTML (Source)", "Save as XHTML1", "Save as XHTML1 (Source)", "Save as XHTML5", or "Save as XHTML5
(Source)". You can hit <code>Esc</code> to hide it.
</p>
<p>
Those options are very similar. The non-source ones open a new window (which may be in a new tab depending
Expand Down
11 changes: 9 additions & 2 deletions js/core/utils.js
Expand Up @@ -10,8 +10,8 @@ define(
var utils = {
// --- SET UP
run: function (conf, doc, cb, msg) {
msg.pub("start", "w3c/utils");
msg.pub("end", "w3c/utils");
msg.pub("start", "core/utils");
msg.pub("end", "core/utils");
cb();
}

Expand Down Expand Up @@ -87,6 +87,13 @@ define(
if (!(date instanceof Date)) date = this.parseSimpleDate(date);
return this.lead0(date.getDate()) + " " + this.humanMonths[date.getMonth()] + " " + date.getFullYear();
}
// given either a Date object or a date in YYYY-MM-DD format, return an ISO formatted
// date suitable for use in a xsd:datetime item
, isoDate: function (date) {
if (!(date instanceof Date)) date = this.parseSimpleDate(date);
// return "" + date.getUTCFullYear() +'-'+ this.lead0(date.getUTCMonth() + 1)+'-' + this.lead0(date.getUTCDate()) +'T'+this.lead0(date.getUTCHours())+':'+this.lead0(date.getUTCMinutes()) +":"+this.lead0(date.getUTCSeconds())+'+0000';
return date.toISOString() ;
}


// --- STYLE HELPERS ------------------------------------------------------------------------------
Expand Down
48 changes: 42 additions & 6 deletions js/w3c/headers.js
Expand Up @@ -84,10 +84,10 @@ define(
Handlebars.registerHelper("showPeople", function (name, items) {
// stuff to handle RDFa
var re = "", rp = "", rm = "", rn = "", rwu = "", rpu = "";
if (this.doRDFa) {
if (this.doRDFa != false) {
if (name === "Editor") {
re = " rel='bibo:editor'";
if (this.doRDFa == "1.1") re += " inlist=''";
if (this.doRDFa !== "1.0") re += " inlist=''";
}
else if (name === "Author") {
re = " rel='dcterms:contributor'";
Expand All @@ -101,11 +101,11 @@ define(
var ret = "";
for (var i = 0, n = items.length; i < n; i++) {
var p = items[i];
if (this.doRDFa) ret += "<dd" + re +"><span" + rp + ">";
if (this.doRDFa != false ) ret += "<dd class='p-author h-card vcard' " + re +"><span" + rp + ">";
else ret += "<dd class='p-author h-card vcard'>";
if (p.url) {
if (this.doRDFa) {
ret += "<a" + rpu + rn + " content='" + p.name + "' href='" + p.url + "'>" + p.name + "</a>";
if (this.doRDFa != false ) {
ret += "<a class='u-url url p-name fn' " + rpu + rn + " content='" + p.name + "' href='" + p.url + "'>" + p.name + "</a>";
}
else {
ret += "<a class='u-url url p-name fn' href='" + p.url + "'>"+ p.name + "</a>";
Expand All @@ -123,7 +123,7 @@ define(
ret += ", <span class='ed_mailto'><a class='u-email email' " + rm + " href='mailto:" + p.mailto + "'>" + p.mailto + "</a></span>";
}
if (p.note) ret += " (" + p.note + ")";
if (this.doRDFa) ret += "</span>\n";
if (this.doRDFa != false ) ret += "</span>\n";
ret += "</dd>\n";
}
return new Handlebars.SafeString(ret);
Expand All @@ -141,6 +141,16 @@ define(
, "IG-NOTE": "NOTE"
, "WG-NOTE": "NOTE"
}
, status2rdf: {
NOTE: "w3p:NOTE",
WD: "w3p:WD",
LC: "w3p:LastCall",
CR: "w3p:CR",
PR: "w3p:PR",
REC: "w3p:REC",
PER: "w3p:PER",
RSCND: "w3p:RSCND"
}
, status2text: {
NOTE: "Note"
, "WG-NOTE": "Working Group Note"
Expand Down Expand Up @@ -183,6 +193,11 @@ define(
, run: function (conf, doc, cb, msg) {
msg.pub("start", "w3c/headers");

if (conf.doRDFa != false) {
if (conf.doRDFa === undefined) {
conf.doRDFa = '1.1';
}
}
// validate configuration and derive new configuration values
conf.isCGBG = $.inArray(conf.specStatus, this.cgbg) >= 0;
conf.isCGFinal = conf.isCGBG && /G-FINAL$/.test(conf.specStatus);
Expand Down Expand Up @@ -268,6 +283,9 @@ define(
}
conf.longStatus = this.status2long[conf.specStatus];
conf.textStatus = this.status2text[conf.specStatus];
if (this.status2rdf[conf.specStatus]) {
conf.rdfStatus = this.status2rdf[conf.specStatus];
}
conf.showThisVersion = (!conf.isNoTrack || conf.isTagFinding);
conf.showPreviousVersion = (conf.specStatus !== "FPWD" && conf.specStatus !== "FPLC" && conf.specStatus !== "ED" &&
!conf.isNoTrack && !conf.noRecTrack);
Expand All @@ -284,8 +302,26 @@ define(
conf.isMO = (conf.specStatus === "MO");
conf.isIGNote = (conf.specStatus === "IG-NOTE");
conf.dashDate = utils.concatDate(conf.publishDate, "-");
conf.publishISODate = utils.isoDate(conf.publishDate) ;
// configuration done - yay!

// annotate html element with RFDa
if (conf.doRDFa) {
if (conf.rdfStatus) {
$("html").attr("typeof", "bibo:Document "+conf.rdfStatus ) ;
} else {
$("html").attr("typeof", "bibo:Document ") ;
}
$("html").attr("about", "") ;
$("html").attr("property", "dcterms:language") ;
$("html").attr("content", "en") ;
var prefixes = "bibo: http://purl.org/ontology/bibo/ w3p: http://www.w3.org/2001/02pd/rec54#";
if (conf.doRDFa != '1.1') {
$("html").attr("version", "XHTML+RDFa 1.0") ;
prefixes += " dcterms: http://purl.org/dc/terms/ foaf: http://xmlns.com/foaf/0.1/ xsd: http://www.w3.org/2001/XMLSchema#";
}
$("html").attr("prefix", prefixes);
}
// insert into document and mark with microformat
$("body", doc).prepend($(conf.isCGBG ? cgbgHeadersTmpl(conf) : headersTmpl(conf)))
.addClass("h-entry");
Expand Down
80 changes: 31 additions & 49 deletions js/w3c/legacy.js
Expand Up @@ -199,10 +199,14 @@ var sn;
butH.onclick = function () { obj.hideSaveOptions(); obj.toHTML(); };
var butS = sn.element("button", {}, this.saveMenu, "Save as HTML (Source)");
butS.onclick = function () { obj.hideSaveOptions(); obj.toHTMLSource(); };
var butS = sn.element("button", {}, this.saveMenu, "Save as XHTML");
butS.onclick = function () { obj.hideSaveOptions(); obj.toXHTML(); };
var butS = sn.element("button", {}, this.saveMenu, "Save as XHTML (Source)");
butS.onclick = function () { obj.hideSaveOptions(); obj.toXHTMLSource(); };
var butS = sn.element("button", {}, this.saveMenu, "Save as XHTML 1");
butS.onclick = function () { obj.hideSaveOptions(); obj.toXHTML(1); };
var butS = sn.element("button", {}, this.saveMenu, "Save as XHTML 1 (Source)");
butS.onclick = function () { obj.hideSaveOptions(); obj.toXHTMLSource(1); };
var butS = sn.element("button", {}, this.saveMenu, "Save as XHTML 5");
butS.onclick = function () { obj.hideSaveOptions(); obj.toXHTML(5); };
var butS = sn.element("button", {}, this.saveMenu, "Save as XHTML 5 (Source)");
butS.onclick = function () { obj.hideSaveOptions(); obj.toXHTMLSource(5); };
if (this.diffTool && (this.previousDiffURI || this.previousURI) ) {
var butD = sn.element("button", {}, this.saveMenu, "Diffmark");
butD.onclick = function () { obj.hideSaveOptions(); obj.toDiffHTML(); };
Expand Down Expand Up @@ -235,16 +239,6 @@ var sn;
}
str += " " + an + "=\"" + this._esc(ats[i].value) + "\"";
}
if (this.doRDFa) {
if (prefixAtr !== '') prefixAtr += ' ';
if (this.doRDFa != "1.1") {
prefixAtr += "dcterms: http://purl.org/dc/terms/ bibo: http://purl.org/ontology/bibo/ foaf: http://xmlns.com/foaf/0.1/ xsd: http://www.w3.org/2001/XMLSchema#";
} else {
prefixAtr += "bibo: http://purl.org/ontology/bibo/";
}
str += " prefix=\"" + this._esc(prefixAtr) + "\"";
str += " typeof=\"bibo:Document\"";
}

str += ">\n";
var cmt = document.createComment("[if lt IE 9]><script src='https://www.w3.org/2008/site/js/html5shiv.js'></script><![endif]");
Expand All @@ -254,13 +248,23 @@ var sn;
return str;
},

toXML: function () {
toXML: function (mode) {
if (mode != 5) {
// not doing xhtml5 so rip out the html5 stuff
$.each("section figcaption figure".split(" "), function (i, item) {
$(item).renameElement("div").addClass(item);
});
$("time").renameElement("span").addClass("time").removeAttr('datetime');
$("div[role]").removeAttr('role').removeAttr('aria-level') ;
$("style:not([type])").attr("type", "text/css");
$("script:not([type])").attr("type", "text/javascript");
}
var str = "<?xml version='1.0' encoding='UTF-8'?>\n<!DOCTYPE html";
var dt = document.doctype;
if (dt && dt.publicId) {
str += " PUBLIC '" + dt.publicId + "' '" + dt.systemId + "'";
}
else {
else if (mode != 5) {
if (this.doRDFa) {
if (this.doRDFa == "1.1") {
// use the standard RDFa 1.1 doctype
Expand All @@ -283,35 +287,9 @@ var sn;
var an = ats[i].name;
if (an == "lang") continue;
if (an == "xmlns") hasxmlns = true;
if (an == "prefix") {
prefixAtr = ats[i].value;
continue;
}
str += " " + an + "=\"" + this._esc(ats[i].value) + "\"";
}
if (!hasxmlns) str += ' xmlns="http://www.w3.org/1999/xhtml"';
if (this.doRDFa) {
if (this.doRDFa != "1.1") {
str += " xmlns:dcterms='http://purl.org/dc/terms/' xmlns:bibo='http://purl.org/ontology/bibo/' xmlns:foaf='http://xmlns.com/foaf/0.1/' xmlns:xsd='http://www.w3.org/2001/XMLSchema#'";
// there was already some prefix information
if (prefixAtr !== '') {
var list = prefixAtr.split(/\s+/) ;
for (var i = 0; i < list.length; i += 2) {
var n = list[i] ;
n = n.replace(/:$/,'');
str += ' xmlns:'+n+'="' + list[i+1] + '"';
}
}
str += ' version="XHTML+RDFa 1.0"';
} else {
if (prefixAtr !== '') {
str += " prefix='" + prefixAtr + " bibo: http://purl.org/ontology/bibo/'" ;
} else {
str += " prefix='bibo: http://purl.org/ontology/bibo/'" ;
}
}
str += " typeof=\"bibo:Document\"";
}
str += ">\n";
// walk the entire DOM tree grabbing nodes and emitting them - possibly modifying them
// if they need the funny closing tag
Expand All @@ -321,8 +299,10 @@ var sn;
selfClosing[n] = true;
});
var noEsc = [false];
var cmt = document.createComment("[if lt IE 9]><script src='https://www.w3.org/2008/site/js/html5shiv.js'></script><![endif]");
$("head").append(cmt);
if (mode == 5) {
var cmt = document.createComment("[if lt IE 9]><script src='https://www.w3.org/2008/site/js/html5shiv.js'></script><![endif]");
$("head", document).append(cmt);
}
var dumpNode = function (node) {
var out = '';
// if the node is the document node.. process the children
Expand Down Expand Up @@ -421,23 +401,25 @@ var sn;
x.document.close();
},

toXHTML: function () {
toXHTML: function (mode) {
var x = window.open();
x.document.write(this.toXML()) ;
x.document.write(this.toXML(mode)) ;
x.document.close();
},

toXHTMLSource: function () {
toXHTMLSource: function (mode) {
var x = window.open();
x.document.write("<pre>" + this._esc(this.toXML()) + "</pre>");
x.document.write("<pre>" + this._esc(this.toXML(mode)) + "</pre>");
x.document.close();
},

// --- METADATA -------------------------------------------------------
extractConfig: function () {
var cfg = respecConfig || {};
if (!cfg.diffTool) cfg.diffTool = 'http://www5.aptest.com/standards/htmldiff/htmldiff.pl';
if (!cfg.doRDFa) cfg.doRDFa = false;
// note this change - the default is now to inject RDFa 1.1. You can override it by
// setting RDFa to false
if (cfg.doRDFa === undefined) cfg.doRDFa = "1.1";
for (var k in cfg) {
if (cfg.hasOwnProperty(k)) this[k] = cfg[k];
}
Expand Down
10 changes: 6 additions & 4 deletions js/w3c/templates/cgbg-headers.html
Expand Up @@ -2,9 +2,11 @@
<p>
<a href='http://www.w3.org/'><img width='72' height='48' src='{{httpScheme}}://www.w3.org/Icons/w3c_home' alt='W3C'/></a>
</p>
<h1 class='title' id='title'>{{title}}</h1>
{{#if subtitle}}<h2 id='subtitle'>{{subtitle}}</h2>{{/if}}
<h2>{{longStatus}} <time class='dt-published' datetime='{{dashDate}}'>{{publishHumanDate}}</time></h2>
<h1 class='title p-name' id='title'{{#if doRDFa}} property='dcterms:title'{{/if}}>{{title}}</h1>
{{#if subtitle}}
<h2 {{#if doRDFa}}property='bibo:subtitle' {{/if}}id='subtitle'>{{subtitle}}</h2>
{{/if}}
<h2 {{#if doRDFa}}property="dcterms:issued" datatype="xsd:dateTime" content="{{publishISODate}}"{{/if}}>{{longStatus}} <time class='dt-published' datetime='{{dashDate}}'>{{publishHumanDate}}</time></h2>
<dl>
{{#if thisVersion}}
<dt>This version:</dt>
Expand All @@ -28,7 +30,7 @@ <h2>{{longStatus}} <time class='dt-published' datetime='{{dashDate}}'>{{publishH
{{/if}}
{{#if prevVersion}}
<dt>Previous version:</dt>
<dd><a href='{{prevVersion}}'>{{prevVersion}}</a></dd>
<dd><a {{#if doRDFa}}rel="dcterms:replaces"{{/if}} href='{{prevVersion}}'>{{prevVersion}}</a></dd>
{{/if}}
{{#unless isCGFinal}}
{{#if prevED}}
Expand Down
8 changes: 4 additions & 4 deletions js/w3c/templates/headers.html
Expand Up @@ -4,11 +4,11 @@
<a href='http://www.w3.org/'><img width='72' height='48' src='https://www.w3.org/Icons/w3c_home' alt='W3C'/></a>
{{/if}}
</p>
<h1 class='title p-name' id='title'>{{title}}</h1>
<h1 class='title p-name' id='title'{{#if doRDFa}} property='dcterms:title'{{/if}}>{{title}}</h1>
{{#if subtitle}}
<h2 id='subtitle'>{{subtitle}}</h2>
<h2 {{#if doRDFa}}property='bibo:subtitle' {{/if}}id='subtitle'>{{subtitle}}</h2>
{{/if}}
<h2>{{#if prependW3C}}W3C {{/if}}{{textStatus}} <time class='dt-published' datetime='{{dashDate}}'>{{publishHumanDate}}</time></h2>
<h2 {{#if doRDFa}}property="dcterms:issued" datatype="xsd:dateTime" content="{{publishISODate}}"{{/if}}>{{#if prependW3C}}W3C {{/if}}{{textStatus}} <time class='dt-published' datetime='{{dashDate}}'>{{publishHumanDate}}</time></h2>
<dl>
{{#unless isNoTrack}}
<dt>This version:</dt>
Expand Down Expand Up @@ -36,7 +36,7 @@ <h2>{{#if prependW3C}}W3C {{/if}}{{textStatus}} <time class='dt-published' datet
{{/if}}
{{#if showPreviousVersion}}
<dt>Previous version:</dt>
<dd><a href='{{prevVersion}}'>{{prevVersion}}</a></dd>
<dd><a {{#if doRDFa}}rel="dcterms:replaces"{{/if}} href='{{prevVersion}}'>{{prevVersion}}</a></dd>
{{/if}}
{{#if prevRecURI}}
<dt>Latest recommendation:</dt>
Expand Down
6 changes: 5 additions & 1 deletion js/w3c/templates/sotd.html
Expand Up @@ -83,7 +83,11 @@
<p>
{{#unless isIGNote}}
This document was produced by a group operating under the
<a href='http://www.w3.org/Consortium/Patent-Policy-20040205/'>5 February 2004 W3C Patent Policy</a>.
{{#if doRDFa}}
<a id="sotd_patent" about='' rel='w3p:patentRules' href='http://www.w3.org/Consortium/Patent-Policy-20040205/'>5 February 2004 W3C Patent Policy</a>.
{{else}}
<a href='http://www.w3.org/Consortium/Patent-Policy-20040205/'>5 February 2004 W3C Patent Policy</a>.
{{/if}}
{{/unless}}
{{#if recNotExpected}}The group does not expect this document to become a W3C Recommendation.{{/if}}
{{#unless isIGNote}}
Expand Down
2 changes: 2 additions & 0 deletions js/w3c/unhtml5.js
Expand Up @@ -13,6 +13,8 @@ define(
$.each("section figcaption figure".split(" "), function (i, item) {
$(item, doc).renameElement("div").addClass(item);
});
$("time", doc).renameElement("span").addClass("time").removeAttr('datetime');
$("div[role]").removeAttr('role').removeAttr('aria-level') ;
$("style:not([type])").attr("type", "text/css");
$("script:not([type])").attr("type", "text/javascript");
msg.pub("end", "w3c/unhtml5");
Expand Down