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
Develop #243
Changes from 4 commits
ae5d94d
efa6a8f
3b83276
2679444
fc52048
3e000ff
eb4555e
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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'"; | ||
|
@@ -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>"; | ||
|
@@ -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); | ||
|
@@ -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" | ||
|
@@ -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); | ||
|
@@ -268,6 +283,9 @@ define( | |
} | ||
conf.longStatus = this.status2long[conf.specStatus]; | ||
conf.textStatus = this.status2text[conf.specStatus]; | ||
if ( this.status2rdf[conf.specStatus]) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Whitespace after There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Good catch. Fixed. |
||
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); | ||
|
@@ -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"); | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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(); }; | ||
|
@@ -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]"); | ||
|
@@ -254,13 +248,23 @@ var sn; | |
return str; | ||
}, | ||
|
||
toXML: function () { | ||
toXML: function ( mode ) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. TBH, I find this There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I was trying to avoid duplicating code. toXML is largely the same, but in XHTML5 mode you don't need to 'unhtml5' the markup. |
||
if ( mode != 5 ) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Coding style of this project seems to not ask for whitespace around the content of parentheses, so:
rather than:
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Fixed. |
||
// 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) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Whitespace after There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Fixed. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. FYI. Generally fixing the code hides the original comment (when you push the new commit). |
||
if (this.doRDFa) { | ||
if (this.doRDFa == "1.1") { | ||
// use the standard RDFa 1.1 doctype | ||
|
@@ -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 | ||
|
@@ -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 ) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Whitespace. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Fixed. |
||
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 | ||
|
@@ -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]; | ||
} | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks like you're returning the function rather than the result of applying the function here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You are right - weird that the test passed. Fixed.