Compare commits

...

20 Commits

Author SHA1 Message Date
Shan Carter 49deb31aeb 2.2.13 2017-11-21 14:56:21 -08:00
Shan Carter b5a00b7f43 Fixing wrong/old version number 2017-11-21 14:56:16 -08:00
Shan Carter 0f8f0f5962 Merge 2017-11-21 14:53:38 -08:00
Shan Carter 094f0d4c58 2.2.11 2017-11-21 14:51:44 -08:00
Shan Carter cd4594f320 Fixing NaN !== NaN problem in d-slider.js 2017-11-21 14:51:35 -08:00
Ludwig Schubert be585691c5 2.2.12 2017-11-15 11:50:01 -08:00
Ludwig Schubert b25fd66fd7 Remove stray comment in CSS 2017-11-14 22:52:36 -08:00
Ludwig Schubert 010eed6280 2.2.11 2017-11-14 12:52:42 -08:00
Ludwig Schubert 3a643ab7ad Style fixes; moving away from contain: content to avoid cutting off hover boxes. 2017-11-14 12:52:34 -08:00
Ludwig Schubert d0463ff769 2.2.10 2017-11-08 14:37:57 -08:00
Ludwig Schubert 3bccc25805 Register Controller listeners before tags customElements get registered. 2017-11-08 14:37:48 -08:00
Ludwig Schubert a54f434a52 2.2.9 2017-11-08 10:16:20 -08:00
Ludwig Schubert 2ab9a24a79 explicitly trigger controller load event 2017-11-08 10:16:10 -08:00
Ludwig Schubert 399e832441 2.2.8 2017-11-08 09:43:37 -08:00
Ludwig Schubert e18d011fa8 Move controller registration to components; out of article tag as we now can have e.g. citations outside of article in title 2017-11-08 09:43:29 -08:00
Ludwig Schubert 70d8507938 Make polyfills link absolute. Release 2.2.7 2017-11-07 15:46:54 -08:00
Ludwig Schubert 2e6a0dda6d Upgrade katex to 0.8 2017-11-07 15:41:08 -08:00
Ludwig Schubert 315e888810 Add DOI to bibtex citation; minor style fix 2017-11-07 15:13:04 -08:00
Ludwig Schubert 4745281c2b 2.2.5 2017-10-24 17:02:06 -07:00
Ludwig Schubert ebffcb4416 Fix typo 2017-10-24 17:02:03 -07:00
22 changed files with 119 additions and 83 deletions
+1 -1
View File
@@ -42,7 +42,7 @@
</d-front-matter> </d-front-matter>
<d-title> <d-title>
<figure style="grid-column: page; margin: 1rem 0;"><img src="momentum.png" style="width:100%; border: 1px solid rgba(0, 0, 0, 0.2);"/></figure> <figure style="grid-column: page; margin: 1rem 0;"><img src="momentum.png" style="width:100%; border: 1px solid rgba(0, 0, 0, 0.2);"/></figure>
<p>We often think of Momentum as a means of dampening oscillations and speeding up the iterations, leading to faster convergence. But it has other interesting behavior. It allows a larger range of step-sizes to be used, and creates its own oscillations. What is going on?</p> <p>We often think of Momentum<d-cite key="mercier2011humans"></d-cite> as a means of dampening oscillations and speeding up the iterations, leading to faster convergence. But it has other interesting behavior. It allows a larger range of step-sizes to be used, and creates its own oscillations. What is going on?</p>
</d-title> </d-title>
<d-article> <d-article>
<a class="marker" href="#section-1" id="section-1"><span>1</span></a> <a class="marker" href="#section-1" id="section-1"><span>1</span></a>
+11 -11
View File
@@ -1,6 +1,6 @@
{ {
"name": "distill-template", "name": "distill-template",
"version": "2.2.4", "version": "2.2.13",
"lockfileVersion": 1, "lockfileVersion": 1,
"requires": true, "requires": true,
"dependencies": { "dependencies": {
@@ -3987,11 +3987,11 @@
} }
}, },
"katex": { "katex": {
"version": "0.7.1", "version": "0.8.3",
"resolved": "https://registry.npmjs.org/katex/-/katex-0.7.1.tgz", "resolved": "https://registry.npmjs.org/katex/-/katex-0.8.3.tgz",
"integrity": "sha1-BrtSmO+tBeHnIoA1uo4VkfMGG48=", "integrity": "sha512-0VKw+G/wvgLKMy4fhhKdPGjXehYF3l3PBRdzkvBivK5wMtAH9xRHImQaGk9gaukBTdOfZ1Biq8kL5vgkUsBT0Q==",
"requires": { "requires": {
"match-at": "0.1.0" "match-at": "0.1.1"
} }
}, },
"kind-of": { "kind-of": {
@@ -4190,9 +4190,9 @@
"dev": true "dev": true
}, },
"match-at": { "match-at": {
"version": "0.1.0", "version": "0.1.1",
"resolved": "https://registry.npmjs.org/match-at/-/match-at-0.1.0.tgz", "resolved": "https://registry.npmjs.org/match-at/-/match-at-0.1.1.tgz",
"integrity": "sha1-9WHncJ/5oQW4XMYsa47nwVvyTzE=" "integrity": "sha512-h4Yd392z9mST+dzc+yjuybOGFNOZjmXIPKWjxBd1Bb23r4SmDOsk2NYCU2BMUBGbSpZqwVsZYNq26QS3xfaT3Q=="
}, },
"memory-fs": { "memory-fs": {
"version": "0.4.1", "version": "0.4.1",
@@ -5157,9 +5157,9 @@
} }
}, },
"rollup": { "rollup": {
"version": "0.49.2", "version": "0.50.0",
"resolved": "https://registry.npmjs.org/rollup/-/rollup-0.49.2.tgz", "resolved": "https://registry.npmjs.org/rollup/-/rollup-0.50.0.tgz",
"integrity": "sha512-9mySqItSwq5/dXYQyFGrrzqV282EZfz4kSCU2m4e6OjgqLmIsp9zK6qNQ6wbBWR4EhASEqQMBQ/IF45jaNPAtw==", "integrity": "sha512-7RqCBQ9iwsOBPkjYgoIaeUij606mSkDMExP0NT7QDI3bqkHYQHrQ83uoNIXwPcQm/vP2VbsUz3kiyZZ1qPlLTQ==",
"dev": true "dev": true
}, },
"rollup-plugin-babili": { "rollup-plugin-babili": {
+4 -4
View File
@@ -1,6 +1,6 @@
{ {
"name": "distill-template", "name": "distill-template",
"version": "2.2.4", "version": "2.2.13",
"description": "Template for creating Distill articles.", "description": "Template for creating Distill articles.",
"main": "dist/template.v2.js", "main": "dist/template.v2.js",
"bin": { "bin": {
@@ -12,7 +12,7 @@
"url": "https://github.com/distillpub/distill-template/issues" "url": "https://github.com/distillpub/distill-template/issues"
}, },
"scripts": { "scripts": {
"start": "rollup -c rollup.config.dev.js -w", "dev": "rollup -c rollup.config.dev.js -w",
"serve": "python3 -m http.server --bind 127.0.0.1 8888", "serve": "python3 -m http.server --bind 127.0.0.1 8888",
"test": "mocha", "test": "mocha",
"lint": "eslint", "lint": "eslint",
@@ -34,7 +34,7 @@
"marked": "^0.3.6", "marked": "^0.3.6",
"mocha": "^3.5.3", "mocha": "^3.5.3",
"prismjs": "^1.6.0", "prismjs": "^1.6.0",
"rollup": "latest", "rollup": "^0.50.0",
"rollup-plugin-babili": "^3.1.0", "rollup-plugin-babili": "^3.1.0",
"rollup-plugin-buble": "^0.15.0", "rollup-plugin-buble": "^0.15.0",
"rollup-plugin-commonjs": "^7.0.0", "rollup-plugin-commonjs": "^7.0.0",
@@ -61,6 +61,6 @@
"escape-html": "^1.0.3", "escape-html": "^1.0.3",
"intersection-observer": "^0.4.0", "intersection-observer": "^0.4.0",
"jsdom-wc": "^11.0.0-alpha-1", "jsdom-wc": "^11.0.0-alpha-1",
"katex": "^0.7.1" "katex": "^0.8.3"
} }
} }
+24 -9
View File
@@ -2,7 +2,7 @@ import { Controller } from './controller';
/* Transforms */ /* Transforms */
import { makeStyleTag } from './styles/styles'; import { makeStyleTag } from './styles/styles';
import { Polyfills, polyfills } from './helpers/polyfills'; import { Polyfills } from './helpers/polyfills';
/* Components */ /* Components */
import { Abstract } from './components/d-abstract'; import { Abstract } from './components/d-abstract';
@@ -48,10 +48,22 @@ const distillMain = function() {
makeStyleTag(document); makeStyleTag(document);
console.info('Runlevel 1: Static Distill styles have been added.'); console.info('Runlevel 1: Static Distill styles have been added.');
console.info('Runlevel 1->2.'); console.info('Runlevel 1->2.');
window.distillRunlevel = 2; window.distillRunlevel += 1;
/* 3. Register components */ /* 3. Register Controller listener functions */
/* Article will register controller which takes control from there */ /* Needs to happen before components to their connected callbacks have a controller to talk to. */
for (const [functionName, callback] of Object.entries(Controller.listeners)) {
if (typeof callback === 'function') {
document.addEventListener(functionName, callback);
} else {
console.error('Runlevel 2: Controller listeners need to be functions!');
}
}
console.info('Runlevel 2: We can now listen to controller events.');
console.info('Runlevel 2->3.');
window.distillRunlevel += 1;
/* 4. Register components */
const components = [ const components = [
Abstract, Appendix, Article, Bibliography, Byline, Cite, CitationList, Code, Abstract, Appendix, Article, Bibliography, Byline, Cite, CitationList, Code,
Footnote, FootnoteList, FrontMatter, HoverBox, Title, DMath, References, TOC, Figure, Footnote, FootnoteList, FrontMatter, HoverBox, Title, DMath, References, TOC, Figure,
@@ -71,12 +83,15 @@ const distillMain = function() {
customElements.define(component.is, component); customElements.define(component.is, component);
} }
console.info('Runlevel 2: Distill Template finished registering custom elements.'); console.info('Runlevel 3: Distill Template finished registering custom elements.');
console.info('Runlevel 2->3.'); console.info('Runlevel 3->4.');
window.distillRunlevel = 3; window.distillRunlevel += 1;
console.info('Distill Template initialisation complete.');
// If template was added after DOMContentLoaded we may have missed that event.
// Controller will check for that case, so trigger the event explicitly:
Controller.listeners.DOMContentLoaded(); Controller.listeners.DOMContentLoaded();
console.info('Runlevel 4: Distill Template initialisation complete.');
}; };
window.distillRunlevel = 0; window.distillRunlevel = 0;
@@ -84,7 +99,7 @@ window.distillRunlevel = 0;
if (Polyfills.browserSupportsAllFeatures()) { if (Polyfills.browserSupportsAllFeatures()) {
console.info('Runlevel 0: No need for polyfills.'); console.info('Runlevel 0: No need for polyfills.');
console.info('Runlevel 0->1.'); console.info('Runlevel 0->1.');
window.distillRunlevel = 1; window.distillRunlevel += 1;
distillMain(); distillMain();
} else { } else {
console.info('Runlevel 0: Distill Template is loading polyfills.'); console.info('Runlevel 0: Distill Template is loading polyfills.');
+1 -2
View File
@@ -1,11 +1,10 @@
import { Template } from '../mixins/template'; import { Template } from '../mixins/template';
import { body } from '../helpers/layout';
const T = Template('d-appendix', ` const T = Template('d-appendix', `
<style> <style>
d-appendix { d-appendix {
contain: content; contain: layout style;
font-size: 0.8em; font-size: 0.8em;
line-height: 1.7em; line-height: 1.7em;
margin-top: 60px; margin-top: 60px;
+1 -17
View File
@@ -1,5 +1,5 @@
// import { Template } from '../mixins/template'; // import { Template } from '../mixins/template';
import { Controller } from '../controller'; // import { Controller } from '../controller';
const isOnlyWhitespace = /^\s*$/; const isOnlyWhitespace = /^\s*$/;
@@ -29,20 +29,4 @@ export class Article extends HTMLElement {
}).observe(this, {childList: true}); }).observe(this, {childList: true});
} }
connectedCallback() {
document.onreadystatechange = function () {
console.log('onreadystatechange:');
console.log(document.readyState);
};
console.info('Article tag connected, we can now listen to controller events.');
console.info('Runlevel 3->4.');
for (const [functionName, callback] of Object.entries(Controller.listeners)) {
if (typeof callback === 'function') {
document.addEventListener(functionName, callback);
} else {
console.error('Controller listeners need to be functions!');
}
}
}
} }
+1 -2
View File
@@ -2,8 +2,7 @@ import { bibliography_cite } from '../helpers/citation';
const styles = ` const styles = `
d-citation-list { d-citation-list {
contain: content; contain: layout style;
overflow: hidden;
} }
d-citation-list .references { d-citation-list .references {
+18 -1
View File
@@ -38,6 +38,21 @@ d-hover-box {
margin-top: 1.9em; margin-top: 1.9em;
} }
ul {
margin: 0;
padding: 0;
list-style-type: none;
}
ul li {
padding: 15px 10px 15px 10px;
border-bottom: 1px solid rgba(0,0,0,0.1)
}
ul li:last-of-type {
border-bottom: none;
}
</style> </style>
<d-hover-box id="hover-box"></d-hover-box> <d-hover-box id="hover-box"></d-hover-box>
@@ -106,7 +121,9 @@ export class Cite extends T(HTMLElement) {
set entries(entries) { set entries(entries) {
if (this.hoverBox) { if (this.hoverBox) {
this.hoverBox.innerHTML = entries.map(hover_cite).join('<br><br>'); this.hoverBox.innerHTML = `<ul>
${entries.map(hover_cite).map(html => `<li>${html}</li>`).join('\n')}
</ul>`;
} }
} }
+1 -2
View File
@@ -4,8 +4,7 @@ const T = Template('d-footnote-list', `
<style> <style>
d-footnote-list { d-footnote-list {
contain: content; contain: layout style;
overflow: hidden;
} }
d-footnote-list > * { d-footnote-list > * {
+3 -3
View File
@@ -20,6 +20,8 @@ const T = Template('d-hover-box', `
.panel { .panel {
position: absolute; position: absolute;
font-size: 1rem;
line-height: 1.5em;
top: 0; top: 0;
left: 0; left: 0;
width: 100%; width: 100%;
@@ -27,11 +29,9 @@ const T = Template('d-hover-box', `
background-color: rgb(250, 250, 250); background-color: rgb(250, 250, 250);
box-shadow: 0 0 7px rgba(0, 0, 0, 0.1); box-shadow: 0 0 7px rgba(0, 0, 0, 0.1);
border-radius: 4px; border-radius: 4px;
padding: 10px;
box-sizing: border-box; box-sizing: border-box;
} }
</style> </style>
<div class="container"> <div class="container">
@@ -52,7 +52,7 @@ export class HoverBox extends T(HTMLElement) {
} }
listen(element) { listen(element) {
console.log(element) // console.log(element)
this.bindDivEvents(this); this.bindDivEvents(this);
this.bindTriggerEvents(element); this.bindTriggerEvents(element);
// this.style.display = "block"; // this.style.display = "block";
+1 -1
View File
@@ -20,7 +20,7 @@ export function renderTOC(element, headings) {
<style> <style>
d-toc { d-toc {
contain: content; contain: layout style;
display: block; display: block;
} }
+12 -4
View File
@@ -6,6 +6,10 @@ import optionalComponents from './transforms/optional-components';
const frontMatter = new FrontMatter(); const frontMatter = new FrontMatter();
function domContentLoaded() {
return ['interactive', 'complete'].indexOf(document.readyState) !== -1;
}
export const Controller = { export const Controller = {
frontMatter: frontMatter, frontMatter: frontMatter,
@@ -120,7 +124,7 @@ export const Controller = {
} }
const prerendered = document.body.hasAttribute('distill-prerendered'); const prerendered = document.body.hasAttribute('distill-prerendered');
if (!prerendered) { if (!prerendered && domContentLoaded()) {
optionalComponents(document, frontMatter); optionalComponents(document, frontMatter);
const appendix = document.querySelector('distill-appendix'); const appendix = document.querySelector('distill-appendix');
@@ -141,18 +145,22 @@ export const Controller = {
}, },
DOMContentLoaded() { DOMContentLoaded() {
if (Controller.loaded || ['interactive', 'complete'].indexOf(document.readyState) === -1) { if (Controller.loaded) {
console.warn('Controller received DOMContentLoaded but was already loaded!');
return;
} else if (!domContentLoaded()) {
console.warn('Controller received DOMContentLoaded before appropriate document.readyState!');
return; return;
} else { } else {
Controller.loaded = true; Controller.loaded = true;
console.log('Controller running DOMContentLoaded'); console.log('Runlevel 4: Controller running DOMContentLoaded');
} }
const frontMatterTag = document.querySelector('d-front-matter'); const frontMatterTag = document.querySelector('d-front-matter');
const data = parseFrontmatter(frontMatterTag); const data = parseFrontmatter(frontMatterTag);
Controller.listeners.onFrontMatterChanged({detail: data}); Controller.listeners.onFrontMatterChanged({detail: data});
// console.debug('Resolving "citations" dependency due to initial DOM load.'); // Resolving "citations" dependency due to initial DOM load
frontMatter.citations = collect_citations(); frontMatter.citations = collect_citations();
frontMatter.citationsCollected = true; frontMatter.citationsCollected = true;
for (const waitingCallback of Controller.waitingOn.citations.slice()) { for (const waitingCallback of Controller.waitingOn.citations.slice()) {
+1 -2
View File
@@ -3,8 +3,7 @@ import { serializeFrontmatterToBibtex } from '../helpers/bibtex';
const styles = ` const styles = `
<style> <style>
distill-appendix { distill-appendix {
contain: content; contain: layout style;
overflow: hidden;
} }
distill-appendix .citation { distill-appendix .citation {
+2 -6
View File
@@ -72,18 +72,14 @@ distill-header .nav a {
${logo} ${logo}
Distill Distill
</a> </a>
<div class="nav"> <nav class="nav">
<a href="/about/">About</a> <a href="/about/">About</a>
<a href="/prize/">Prize</a> <a href="/prize/">Prize</a>
<a href="/journal/">Submit</a> <a href="/journal/">Submit</a>
</div> </nav>
</div> </div>
`, false); `, false);
// <div class="nav">
// <a href="https://github.com/distillpub">GitHub</a>
// <!-- https://twitter.com/distillpub -->
// </div>
export class DistillHeader extends T(HTMLElement) { export class DistillHeader extends T(HTMLElement) {
+2 -1
View File
@@ -28,6 +28,7 @@ export function serializeFrontmatterToBibtex(frontMatter) {
title = {${frontMatter.title}}, title = {${frontMatter.title}},
journal = {${frontMatter.journal.title}}, journal = {${frontMatter.journal.title}},
year = {${frontMatter.publishedYear}}, year = {${frontMatter.publishedYear}},
note = {${frontMatter.url}} note = {${frontMatter.url}},
doi = {${frontMatter.doi}}
}`; }`;
} }
+1 -1
View File
@@ -146,7 +146,7 @@ export function bibliography_cite(ent, fancy){
export function hover_cite(ent){ export function hover_cite(ent){
if (ent){ if (ent){
var cite = ''; var cite = '';
cite += '<b>' + ent.title + '</b>'; cite += '<strong>' + ent.title + '</strong>';
cite += link_string(ent); cite += link_string(ent);
cite += '<br>'; cite += '<br>';
+21 -7
View File
@@ -1,9 +1,9 @@
d-article { d-article {
contain: content; contain: layout style;
overflow-x: hidden;
border-top: 1px solid rgba(0, 0, 0, 0.1); border-top: 1px solid rgba(0, 0, 0, 0.1);
padding-top: 2rem; padding-top: 2rem;
color: rgba(0, 0, 0, 0.8); color: rgba(0, 0, 0, 0.8);
overflow: hidden;
} }
d-article > * { d-article > * {
@@ -169,14 +169,29 @@ d-article span.equation-mimic {
d-article > d-code, d-article > d-code,
d-article section > d-code { d-article section > d-code {
display: block; display: block;
overflow-x: scroll;
} }
d-article > d-math[block], d-article > d-math[block],
d-article section > d-math[block] { d-article section > d-math[block] {
display: block; display: block;
overflow-x: scroll; }
@media (max-width: 768px) {
d-article > d-code,
d-article section > d-code,
d-article > d-math[block],
d-article section > d-math[block] {
overflow-x: scroll;
-ms-overflow-style: none; // IE 10+
overflow: -moz-scrollbars-none; // Firefox
}
d-article > d-code::-webkit-scrollbar,
d-article section > d-code::-webkit-scrollbar,
d-article > d-math[block]::-webkit-scrollbar,
d-article section > d-math[block]::-webkit-scrollbar {
display: none; // Safari and Chrome
}
} }
d-article .citation { d-article .citation {
@@ -190,8 +205,7 @@ d-include {
} }
d-figure { d-figure {
contain: content; contain: layout style;
overflow: hidden;
} }
/* KaTeX */ /* KaTeX */
+2 -1
View File
@@ -1,6 +1,7 @@
d-byline { d-byline {
border-top: 1px solid rgba(0, 0, 0, 0.1);
contain: content; contain: content;
overflow: hidden;
border-top: 1px solid rgba(0, 0, 0, 0.1);
font-size: 0.8rem; font-size: 0.8rem;
line-height: 1.8em; line-height: 1.8em;
padding: 1.5rem 0; padding: 1.5rem 0;
+3 -3
View File
@@ -1,7 +1,7 @@
d-title { d-title {
padding: 2rem 0 1.5rem; padding: 2rem 0 1.5rem;
contain: content; contain: layout style;
overflow: hidden; overflow-x: hidden;
} }
@media(min-width: 768px) { @media(min-width: 768px) {
@@ -52,4 +52,4 @@ d-title .status span {
border-bottom: 1px solid #80cbc4; border-bottom: 1px solid #80cbc4;
font-size: 11px; font-size: 11px;
text-transform: uppercase; text-transform: uppercase;
} }
+6 -3
View File
@@ -105,14 +105,16 @@ figure svg text,
figure svg tspan { figure svg tspan {
} }
figcaption { figcaption,
.figcaption {
color: rgba(0, 0, 0, 0.6); color: rgba(0, 0, 0, 0.6);
font-size: 12px; font-size: 12px;
line-height: 1.5em; line-height: 1.5em;
} }
@media(min-width: 1024px) { @media(min-width: 1024px) {
figcaption { figcaption,
.figcaption {
font-size: 13px; font-size: 13px;
} }
} }
@@ -129,7 +131,8 @@ figcaption a {
color: rgba(0, 0, 0, 0.6); color: rgba(0, 0, 0, 0.6);
} }
figcaption b { figcaption b,
figcaption strong, {
font-weight: 600; font-weight: 600;
color: rgba(0, 0, 0, 1.0); color: rgba(0, 0, 0, 1.0);
} }
+1 -1
View File
@@ -42,7 +42,7 @@ const addBackIn = `
window.addEventListener('WebComponentsReady', function() { window.addEventListener('WebComponentsReady', function() {
console.warn('WebComponentsReady'); console.warn('WebComponentsReady');
const loaderTag = document.createElement('script'); const loaderTag = document.createElement('script');
loaderTag.src = 'http://localhost:8888/dist/template.v2.js'; loaderTag.src = 'https://distill.pub/template.v2.js';
document.head.insertBefore(loaderTag, document.head.firstChild); document.head.insertBefore(loaderTag, document.head.firstChild);
}); });
`; `;
+2 -1
View File
@@ -181,6 +181,7 @@ export class Slider extends T(HTMLElement) {
static get observedAttributes() {return ['min', 'max', 'value', 'step', 'ticks', 'origin', 'tickValues', 'tickLabels']; } static get observedAttributes() {return ['min', 'max', 'value', 'step', 'ticks', 'origin', 'tickValues', 'tickLabels']; }
attributeChangedCallback(attr, oldValue, newValue) { attributeChangedCallback(attr, oldValue, newValue) {
if (isNaN(newValue) || newValue === undefined || newValue === null) return;
if (attr == 'min') { if (attr == 'min') {
this.min = +newValue; this.min = +newValue;
this.setAttribute('aria-valuemin', this.min); this.setAttribute('aria-valuemin', this.min);
@@ -194,7 +195,7 @@ export class Slider extends T(HTMLElement) {
} }
if (attr == 'origin') { if (attr == 'origin') {
this.origin = +newValue; this.origin = +newValue;
this.update(this.value); // this.update(this.value);
} }
if (attr == 'step') { if (attr == 'step') {
if (newValue > 0) { if (newValue > 0) {