Compare commits

...
6 Commits
Author SHA1 Message Date
Ludwig Schubert 7ff8796266 Improve interstitial behavior
Remove if no password during pre-render
Remove if no password during onFrontMatterChanged
Remove self if on production host
2018-03-06 16:13:05 -08:00
Ludwig Schubert 0bc2ce69da Remove hover-box padding. Add footnote-container with padding. 2018-03-06 14:31:42 -08:00
Ludwig SchubertandGitHub 4fac022efc Merge pull request #74 from distillpub/hoverboxPadding
Restore padding for d-hover-box
2018-03-06 09:09:46 -08:00
Shan CarterandGitHub dcf01cbc0f Update styles-layout.css 2018-02-27 16:10:15 -08:00
Arvind SatyanarayanandGitHub c6cd820bc3 Restore padding for d-hover-box
Fixes #73.
2018-02-07 14:23:42 -08:00
Ludwig Schubert 6941ba780d Front matter only writes derived publish dates to data when publishedDate is available. 2017-12-05 11:42:50 -08:00
6 changed files with 58 additions and 31 deletions
+5 -12
View File
@@ -30,23 +30,16 @@ span {
z-index: 10000; z-index: 10000;
} }
.dt-hover-box { .footnote-container {
margin: 0 auto; padding: 10px;
width: 704px;
max-width: 100vw;
background-color: #FFF;
opacity: 0.95;
border: 1px solid rgba(0, 0, 0, 0.25);
padding: 8px 16px;
border-radius: 3px;
box-shadow: 0px 2px 10px 2px rgba(0, 0, 0, 0.2);
box-sizing: border-box;
} }
</style> </style>
<d-hover-box> <d-hover-box>
<slot id="slot"></slot> <div class="footnote-container">
<slot id="slot"></slot>
</div>
</d-hover-box> </d-hover-box>
<sup> <sup>
+30 -8
View File
@@ -3,6 +3,7 @@ import { Template } from '../mixins/template';
// This overlay is not secure. // This overlay is not secure.
// It is only meant as a social deterrent. // It is only meant as a social deterrent.
const productionHostname = 'distill.pub';
const T = Template('d-interstitial', ` const T = Template('d-interstitial', `
<style> <style>
@@ -109,13 +110,11 @@ p small {
export class Interstitial extends T(HTMLElement) { export class Interstitial extends T(HTMLElement) {
connectedCallback() { connectedCallback() {
const passwordInput = this.root.querySelector('#interstitial-password-input'); if (this.shouldRemoveSelf()) {
passwordInput.oninput = (event) => this.passwordChanged(event); this.parentElement.removeChild(this);
if (typeof(Storage) !== 'undefined') { } else {
if (localStorage.getItem('distill-interstitial-password-correct') === 'true') { const passwordInput = this.root.querySelector('#interstitial-password-input');
console.log('Loaded that correct password was entered before; skipping interstitial.'); passwordInput.oninput = (event) => this.passwordChanged(event);
this.parentElement.removeChild(this);
}
} }
} }
@@ -126,9 +125,32 @@ export class Interstitial extends T(HTMLElement) {
this.parentElement.removeChild(this); this.parentElement.removeChild(this);
if (typeof(Storage) !== 'undefined') { if (typeof(Storage) !== 'undefined') {
console.log('Saved that correct password was entered.'); console.log('Saved that correct password was entered.');
localStorage.setItem('distill-interstitial-password-correct', 'true'); localStorage.setItem(this.localStorageIdentifier(), 'true');
} }
} }
} }
shouldRemoveSelf() {
// should never be visible in production
if (window && window.location.hostname === productionHostname) {
console.warn('Interstitial found on production, hiding it.');
return true
}
// should only have to enter password once
if (typeof(Storage) !== 'undefined') {
if (localStorage.getItem(this.localStorageIdentifier()) === 'true') {
console.log('Loaded that correct password was entered before; skipping interstitial.');
return true;
}
}
// otherwise, leave visible
return false;
}
localStorageIdentifier() {
const prefix = 'distill-drafts'
const suffix = 'interstitial-password-correct';
return prefix + (window ? window.location.pathname : '-') + suffix
}
} }
+5 -1
View File
@@ -120,7 +120,11 @@ export const Controller = {
const interstitial = document.querySelector('d-interstitial'); const interstitial = document.querySelector('d-interstitial');
if (interstitial) { if (interstitial) {
interstitial.password = frontMatter.password; if (typeof frontMatter.password !== 'undefined') {
interstitial.password = frontMatter.password;
} else {
interstitial.parentElement.removeChild(interstitial);
}
} }
const prerendered = document.body.hasAttribute('distill-prerendered'); const prerendered = document.body.hasAttribute('distill-prerendered');
+15 -9
View File
@@ -73,6 +73,8 @@ export function mergeFromYMLFrontmatter(target, source) {
target.publishedDate = source.publishedDate; target.publishedDate = source.publishedDate;
} else if (source.publishedDate.constructor === String) { } else if (source.publishedDate.constructor === String) {
target.publishedDate = new Date(source.publishedDate); target.publishedDate = new Date(source.publishedDate);
} else {
console.error('Don\'t know what to do with published date: ' + source.publishedDate);
} }
} }
target.description = source.description; target.description = source.description;
@@ -303,15 +305,19 @@ export class FrontMatter {
target.url = this.url; target.url = this.url;
target.githubUrl = this.githubUrl; target.githubUrl = this.githubUrl;
target.previewURL = this.previewURL; target.previewURL = this.previewURL;
target.volume = this.volume; if (this.publishedDate) {
target.issue = this.issue; target.volume = this.volume;
target.publishedDateRFC = this.publishedDateRFC; target.issue = this.issue;
target.publishedYear = this.publishedYear; target.publishedDateRFC = this.publishedDateRFC;
target.publishedMonth = this.publishedMonth; target.publishedYear = this.publishedYear;
target.publishedDay = this.publishedDay; target.publishedMonth = this.publishedMonth;
target.publishedMonthPadded = this.publishedMonthPadded; target.publishedDay = this.publishedDay;
target.publishedDayPadded = this.publishedDayPadded; target.publishedMonthPadded = this.publishedMonthPadded;
target.updatedDateRFC = this.updatedDateRFC; target.publishedDayPadded = this.publishedDayPadded;
}
if (this.updatedDate) {
target.updatedDateRFC = this.updatedDateRFC;
}
target.concatenatedAuthors = this.concatenatedAuthors; target.concatenatedAuthors = this.concatenatedAuthors;
target.bibtexAuthors = this.bibtexAuthors; target.bibtexAuthors = this.bibtexAuthors;
target.slug = this.slug; target.slug = this.slug;
+1 -1
View File
@@ -79,7 +79,7 @@ distill-footer {
} }
} }
@media(min-width: 1280px) { @media(min-width: 1180px) {
.base-grid, .base-grid,
distill-header, distill-header,
d-title, d-title,
+2
View File
@@ -50,6 +50,8 @@ export default function(dom, data) {
interstitial.password = data.password; interstitial.password = data.password;
body.insertBefore(interstitial, body.firstChild); body.insertBefore(interstitial, body.firstChild);
} }
} else if (!hasPassword && interstitial) {
interstitial.parentElement.removeChild(this);
} }
let appendix = dom.querySelector('d-appendix'); let appendix = dom.querySelector('d-appendix');