- From: Shane McCarron via cvs-syncmail <cvsmail@w3.org>
- Date: Mon, 05 Jul 2010 19:02:26 +0000
- To: public-dap-commits@w3.org
Update of /sources/public/2009/dap/ReSpec.js/js In directory hutz:/tmp/cvs-serv6064/js Modified Files: respec.js Log Message: Added generation of various RDFa when the doRDFa configuration parameter is set to true. Defaults to false. Index: respec.js =================================================================== RCS file: /sources/public/2009/dap/ReSpec.js/js/respec.js,v retrieving revision 1.126 retrieving revision 1.127 diff -u -d -r1.126 -r1.127 --- respec.js 30 Jun 2010 15:03:11 -0000 1.126 +++ respec.js 5 Jul 2010 19:02:24 -0000 1.127 @@ -201,7 +201,7 @@ } // if (this.doMicroData) this.makeMicroData(); - // if (this.doRDFa) this.makeRDFa(); + if (this.doRDFa) this.makeRDFa(); this.unHTML5(); this.removeRespec(); @@ -218,6 +218,42 @@ } document.body.style.display = "inherit"; }, + + makeRDFa: function () { + var abs = document.getElementById("abstract"); + if (abs) { + var rel = 'dcterms:abstract' ; + var ref = abs.getAttribute('property') ; + if (ref) { + rel = ref + ' ' + rel ; + } + abs.setAttribute('property', rel) ; + abs.setAttribute('datatype', '') ; + } + // annotate sections with Section data + var secs = document.querySelectorAll("section"); + for (var i = 0; i < secs.length; i++) { + // if the section has an id, use that. if not, look at the first child for an id + var about = '' ; + // the first child should be a header - that's what we will annotate + var fc = secs[i].firstElementChild; + var ref = secs[i].getAttribute('id') ; + if ( ref ) { + about = '#' + ref ; + } else { + if (fc) { + ref = fc.getAttribute('id') ; + if (ref) { + about = '#' + ref; + } + } + } + if (about != '') { + secs[i].setAttribute('typeof', 'bibo:Chapter') ; + secs[i].setAttribute('about', about) ; + } + } + }, saveMenu: null, showSaveOptions: function () { @@ -254,11 +290,23 @@ str += ">\n"; str += "<html"; var ats = document.documentElement.attributes; + var prefixAtr = '' ; + for (var i = 0; i < ats.length; i++) { var an = ats[i].name; if (an == "xmlns" || an == "xml:lang") continue; + if (an == "prefix") { + prefixAtr = ats[i].value; + contine; + } str += " " + an + "=\"" + this._esc(ats[i].value) + "\""; } + if (this.doRDFa) { + if (prefixAtr != '') prefixAtr += ' '; + prefixAtr += "dcterms: http://purl.org/dc/terms/ bibo: http://purl.org/ontology/bibo/ foaf: http://xmlns.com/foaf/0.1/"; + str += " prefix=\"" + this._esc(prefixAtr) + "\""; + } + str += ">\n"; str += document.documentElement.innerHTML; str += "</html>"; @@ -345,6 +393,7 @@ if (!cfg.maxTocLevel) cfg.maxTocLevel = 0; if (!cfg.diffTool) cfg.diffTool = 'http://www3.aptest.com/standards/htmldiff/htmldiff.pl'; if (!cfg.noRecTrack) cfg.noRecTrack = false; + if (!cfg.doRDFa) cfg.doRDFa = false ; for (var k in cfg) this[k] = cfg[k]; this.isRecTrack = cfg.noRecTrack ? false : this.recTrackStatus.indexOf(this.specStatus) >= 0; this.isNoTrack = this.noTrackStatus.indexOf(this.specStatus) >= 0; @@ -384,6 +433,11 @@ rootAttr: function () { document.documentElement.setAttribute("lang", "en"); document.documentElement.setAttribute("dir", "ltr"); + if (this.doRDFa) { + document.documentElement.setAttribute("about", ""); + document.documentElement.setAttribute("property", "dcterms:language"); + document.documentElement.setAttribute("content", "en"); + } }, addCSS: function () { @@ -467,37 +521,63 @@ var header = ""; if (people.length == 0) return header; + var rl = '' ; + var rt = '' ; + var rm = '' ; + var rn = '' ; + var rwu = '' ; + var rpu = '' ; + if ( this.doRDFa ) { + if ( name == 'Editor' ) { + rn = " property='foaf:name'"; + rm = " rel='foaf:mbox'"; + rwu = " rel='foaf:workplaceHomepage'"; + rpu = " rel='foaf:homepage'"; + } + } if (people.length > 1) { - header += "<dt>" + name + "s:</dt>"; + header += "<dt" + rl + ">" + name + "s:</dt>"; } else { header += "<dt>" + name + ":</dt>"; } + for (var i = 0; i < people.length; i++) { + var id = 'editor_' + i ; var pers = people[i]; - header += "<dd>"; + if (this.doRDFa) { + header += "<dd rel='bibo:editor' resource='[_:" + id + "]'><span typeof='foaf:Person' about='[_:" + id + "]'>"; + } else { + header += "<dd>"; + } if (pers.url) { - header += "<a href='" + pers.url + "'>" + pers.name + "</a>"; + if (this.doRDFa) { + header += "<a" + rpu + " href='" + pers.url + "'><span about='[_:" + id + "]'" + rn + ">" + pers.name + "</span></a>"; + } else { + header += "<a href='" + pers.url + "'>"+ pers.name + "</a>"; + } } else { - header += pers.name; + header += "<span" + rn + ">" + pers.name + "</span>"; } if (pers.company) { header += ", "; if (pers.companyURL) { - header += "<a href='" + pers.companyURL + "'>" + - pers.company + "</a>"; + header += "<a" + rwu + " href='" + pers.companyURL + "'>" + pers.company + "</a>"; } else { header += pers.company; } } if (pers.mailto) { - header += " <a href='mailto:" + pers.mailto + "'>" + pers.mailto + "</a> "; + header += " <a" + rm + " href='mailto:" + pers.mailto + "'>" + pers.mailto + "</a> "; } if (pers.note) { header += " ( " + pers.note + " )"; } - header += "</dd>"; + if (this.doRDFa) { + header += "</span>\n"; + } + header += "</dd>\n"; } return header; }, @@ -513,7 +593,11 @@ if (!this.previousURI) { this.previousURI = "http://www.w3.org/TR/" + this.previousPublishDate.getFullYear() + "/" + pmat + "-" + this.shortName + "-" + this._concatDate(this.previousPublishDate) + "/"; } - prevVersion = "<a href='" + this.previousURI + "'>" + this.previousURI + "</a>"; + if (this.doRDFa) { + prevVersion = "<a rel='dcterms:replaces' href='" + this.previousURI + "'>" + this.previousURI + "</a>"; + } else { + prevVersion = "<a href='" + this.previousURI + "'>" + this.previousURI + "</a>"; + } // var latestURI = "http://www.w3.org/TR/" + this.shortName + "/"; // latestVersion = "<a href='" + latestURI + "'>" + latestURI + "</a>"; } @@ -528,14 +612,25 @@ header += "<a href='http://www.w3.org/'><img width='72' height='48' src='http://www.w3.org/Icons/w3c_home' alt='W3C'/></a>"; if (this.specStatus == 'XGR') header += "<a href='http://www.w3.org/2005/Incubator/XGR/'><img alt='W3C Incubator Report' src='http://www.w3.org/2005/Incubator/images/XGR' height='48' width='160'/></a>"; - header += - "<h1 class='title' id='title'>" + this.title + "</h1>" ; - if (this.subtitle) { - header += "<h2 id='subtitle'>" + this.subtitle + "</h2>" ; + if ( this.doRDFa ) { + header += + "<h1 rel='dcterms:title' class='title' id='title'>" + this.title + "</h1>" ; + if (this.subtitle) { + header += "<h2 rel='bibo:subtitle' id='subtitle'>" + this.subtitle + "</h2>" ; + } + header += + "<h2 property='dcterms:issued' content='" + this.publishDate + "'>" + (this.specStatus == "unofficial" ? "" : "W3C ") + + this.status2text[this.specStatus] + " " + this._humanDate(this.publishDate) + "</h2><dl>"; + } else { + header += + "<h1 class='title' id='title'>" + this.title + "</h1>" ; + if (this.subtitle) { + header += "<h2 id='subtitle'>" + this.subtitle + "</h2>" ; + } + header += + "<h2>" + (this.specStatus == "unofficial" ? "" : "W3C ") + + this.status2text[this.specStatus] + " " + this._humanDate(this.publishDate) + "</h2><dl>"; } - header += - "<h2>" + (this.specStatus == "unofficial" ? "" : "W3C ") + - this.status2text[this.specStatus] + " " + this._humanDate(this.publishDate) + "</h2><dl>"; if (!this.isNoTrack) { header += "<dt>This version:</dt><dd><a href='" + thisVersion + "'>" + thisVersion + "</a></dd>" + "<dt>Latest published version:</dt><dd>" + latestVersion + "</dd>"; @@ -603,14 +698,24 @@ else header += "This document is licensed under a <a class='subfoot' href='http://creativecommons.org/licenses/by/3.0/' rel='license'>Creative Commons Attribution 3.0 License</a>."; } else { + if (this.doRDFa) { + header += + "<a rel='license' href='http://www.w3.org/Consortium/Legal/ipr-notice#Copyright'>Copyright</a> © " ; + } else { header += "<a href='http://www.w3.org/Consortium/Legal/ipr-notice#Copyright'>Copyright</a> © " ; + } if (this.copyrightStart) { header += this.copyrightStart + '-'; } header += this.publishDate.getFullYear(); if (this.additionalCopyrightHolders) header += " " + this.additionalCopyrightHolders + " &"; - header += " <a href='http://www.w3.org/'><acronym title='World Wide Web Consortium'>W3C</acronym></a><sup>®</sup> " + + if (this.doRDFa) { + header += " <a rel='dcterms:publisher' href='http://www.w3.org/'><acronym title='World Wide Web Consortium'>W3C</acronym></a><sup>®</sup> "; + } else { + header += " <a href='http://www.w3.org/'><acronym title='World Wide Web Consortium'>W3C</acronym></a><sup>®</sup> " ; + } + header += "(<a href='http://www.csail.mit.edu/'><acronym title='Massachusetts Institute of Technology'>MIT</acronym></a>, " + "<a href='http://www.ercim.eu/'><acronym title='European Research Consortium for Informatics and Mathematics'>ERCIM</acronym></a>, " + "<a href='http://www.keio.ac.jp/'>Keio</a>), All Rights Reserved. " + @@ -976,10 +1081,20 @@ refs.sort(); if (refs.length) { var dl = sn.element("dl", { "class": "bibliography" }, sec); + if (this.doRDFa) { + dl.setAttribute('about', '') ; + } for (var j = 0; j < refs.length; j++) { var ref = refs[j]; sn.element("dt", { id: "bib-" + ref }, dl, "[" + ref + "]"); var dd = sn.element("dd", {}, dl); + if (this.doRDFa) { + if (type == 'Normative') { + dd.setAttribute('rel','dcterms:requires'); + } else { + dd.setAttribute('rel','dcterms:references'); + } + } if (berjon.biblio[ref]) dd.innerHTML = berjon.biblio[ref] + "\n"; } }
Received on Monday, 5 July 2010 19:02:28 UTC