Skip to content

Commit

Permalink
move copyright/metadata
Browse files Browse the repository at this point in the history
  • Loading branch information
bakkot committed Nov 8, 2024
1 parent aaaee72 commit e2bec7a
Show file tree
Hide file tree
Showing 3 changed files with 38 additions and 48 deletions.
1 change: 1 addition & 0 deletions css/print.css
Original file line number Diff line number Diff line change
Expand Up @@ -245,6 +245,7 @@ emu-production,
emu-figure:has(> figure > img) figure,
#metadata-block {
break-inside: avoid;
border: unset;
}

p:has(+ .math-display),
Expand Down
31 changes: 0 additions & 31 deletions js/print.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,6 @@
const specContainer = document.getElementById('spec-container');
const shortname = specContainer.querySelector('h1.shortname');
const version = specContainer.querySelector('h1.version');
const title = specContainer.querySelector('h1.title');
const year = version.getAttribute('data-year');

rearrangeTables();

Expand All @@ -25,22 +23,6 @@ PDF.title = document.title;
PDF.author = 'Ecma International';
PDF.subject = shortname.innerHTML + ', ' + version.innerHTML;

Prince.registerPostLayoutFunc(() => {
/**
* Specific modifications for Ecma standards that don't apply to other
* usages of ecmarkup. In case idk a proposal has the need to publish a PDF.
* */
if (/ECMA-/.test(shortname.innerHTML)) {
const metadataBlock = document.getElementById('metadata-block');
const intro = document.getElementsByTagName('emu-intro')[0];
const scope = document.getElementById('scope') || document.getElementById('sec-scope');

intro.parentNode.insertBefore(generateEcmaCopyrightPage(), scope);
intro.appendChild(metadataBlock);
specContainer.insertBefore(title.cloneNode(true), scope);
}
});

/**
* Sets up table captions and figcaptions for tables, which provides for
* continuation table captions.
Expand All @@ -61,19 +43,6 @@ function rearrangeTables() {
});
}


function generateEcmaCopyrightPage() {
const copyrightNotice = document.createElement('div');

copyrightNotice.classList.add('copyright-notice');
copyrightNotice.innerHTML =
'<p>COPYRIGHT NOTICE</p>\n\n<p>© ' +
year +
' Ecma International</p>\n\n<p>This document may be copied, published and distributed to others, and certain derivative works of it may be prepared, copied, published, and distributed, in whole or in part, provided that the above copyright notice and this Copyright License and Disclaimer are included on all such copies and derivative works. The only derivative works that are permissible under this Copyright License and Disclaimer are: </p>\n\n<p>(i) works which incorporate all or portion of this document for the purpose of providing commentary or explanation (such as an annotated version of the document),</p>\n\n<p>(ii) works which incorporate all or portion of this document for the purpose of incorporating features that provide accessibility,</p>\n\n<p>(iii) translations of this document into languages other than English and into different formats and</p>\n\n<p>(iv) works by making use of this specification in standard conformant products by implementing (e.g. by copy and paste wholly or partly) the functionality therein.</p>\n\n<p>However, the content of this document itself may not be modified in any way, including by removing the copyright notice or references to Ecma International, except as required to translate it into languages other than English or into a different format.</p>\n\n<p>The official version of an Ecma International document is the English language version on the Ecma International website. In the event of discrepancies between a translated version and the official version, the official version shall govern.</p>\n\n<p>The limited permissions granted above are perpetual and will not be revoked by Ecma International or its successors or assigns.</p>\n\n<p>This document and the information contained herein is provided on an &ldquo;AS IS&rdquo; basis and ECMA INTERNATIONAL DISCLAIMS ALL WARRANTIES, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO ANY WARRANTY THAT THE USE OF THE INFORMATION HEREIN WILL NOT INFRINGE ANY OWNERSHIP RIGHTS OR ANY IMPLIED WARRANTIES OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE.</p>';

return copyrightNotice;
}

/**
* @typedef {Object} PrinceBox
* @property {string} type
Expand Down
54 changes: 37 additions & 17 deletions src/Spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -592,7 +592,16 @@ export default class Spec {
const wrapper = this.buildSpecWrapper();

if (this.opts.printable) {
this.log('Building covers...');
this.log('Building covers and applying other print tweaks...');
const metadataEle = this.doc.querySelector('#metadata-block');
if (metadataEle) {
this.doc.querySelector('emu-intro')!.appendChild(metadataEle);
}
const scopeEle = document.getElementById('scope') ?? document.getElementById('sec-scope');
if (!scopeEle) {
throw new Error('--printable requires a scope');
}
scopeEle.before(this.doc.querySelector('h1.title')!.cloneNode(true));

// front cover
const frontCover = document.createElement('div');
Expand Down Expand Up @@ -620,6 +629,8 @@ export default class Spec {
insideCover.innerHTML = '<p>Ecma International<br />Rue du Rhone 114 CH-1204 Geneva<br/>Tel: +41 22 849 6000<br/>Fax: +41 22 849 6001<br/>Web: https://www.ecma-international.org<br/>Ecma is the registered trademark of Ecma International.</p>';

frontCover.after(insideCover);


}

let commonEles: HTMLElement[] = [];
Expand Down Expand Up @@ -1416,7 +1427,29 @@ ${this.opts.multipage ? `<li><span>Navigate to/from multipage</span><code>m</cod
'contributors not specified, skipping copyright boilerplate. specify contributors in your frontmatter metadata',
});
} else {
this.buildCopyrightBoilerplate();
const copyrightClause = this.buildCopyrightBoilerplate();
if (this.opts.printable) {
let intro = this.doc.querySelector('emu-intro');
if (!intro) {
throw new Error('--printable requires an emu-intro');
}
intro.after(copyrightClause);
} else {
let last: HTMLElement | undefined;
utils.domWalkBackward(this.doc.body, node => {
if (last) return false;
if (node.nodeName === 'EMU-CLAUSE' || node.nodeName === 'EMU-ANNEX') {
last = node as HTMLElement;
return false;
}
});

if (last && last.parentNode) {
last.parentNode.insertBefore(copyrightClause, last.nextSibling);
} else {
this.doc.body.appendChild(copyrightClause);
}
}
}
}

Expand Down Expand Up @@ -1561,23 +1594,8 @@ ${this.opts.multipage ? `<li><span>Navigate to/from multipage</span><code>m</cod

let copyrightClause = this.doc.querySelector('.copyright-and-software-license');
if (!copyrightClause) {
let last: HTMLElement | undefined;
utils.domWalkBackward(this.doc.body, node => {
if (last) return false;
if (node.nodeName === 'EMU-CLAUSE' || node.nodeName === 'EMU-ANNEX') {
last = node as HTMLElement;
return false;
}
});

copyrightClause = this.doc.createElement('emu-annex');
copyrightClause.setAttribute('id', 'sec-copyright-and-software-license');

if (last && last.parentNode) {
last.parentNode.insertBefore(copyrightClause, last.nextSibling);
} else {
this.doc.body.appendChild(copyrightClause);
}
}
copyrightClause.setAttribute('back-matter', '');

Expand All @@ -1589,6 +1607,8 @@ ${this.opts.multipage ? `<li><span>Navigate to/from multipage</span><code>m</cod
<h2>Software License</h2>
${license}
`;

return copyrightClause;
}

private generateSDOMap() {
Expand Down

0 comments on commit e2bec7a

Please sign in to comment.