Compare commits

...

8 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 Schubert 4fac022efc Merge pull request #74 from distillpub/hoverboxPadding
Restore padding for d-hover-box
2018-03-06 09:09:46 -08:00
Shan Carter dcf01cbc0f Update styles-layout.css 2018-02-27 16:10:15 -08:00
Arvind Satyanarayan 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
Ludwig Schubert 6f7df48fc2 2.2.19 2017-12-04 16:50:48 -08:00
Ludwig Schubert 71450e9ba8 Fix crash when a citation has no authors in Meta tags transform 2017-12-04 16:50:39 -08:00
9 changed files with 75 additions and 46 deletions
+1 -1
View File
@@ -1,6 +1,6 @@
{
"name": "distill-template",
"version": "2.2.18",
"version": "2.2.19",
"lockfileVersion": 1,
"requires": true,
"dependencies": {
+1 -1
View File
@@ -1,6 +1,6 @@
{
"name": "distill-template",
"version": "2.2.18",
"version": "2.2.19",
"description": "Template for creating Distill articles.",
"main": "dist/template.v2.js",
"bin": {
+5 -12
View File
@@ -30,23 +30,16 @@ span {
z-index: 10000;
}
.dt-hover-box {
margin: 0 auto;
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;
.footnote-container {
padding: 10px;
}
</style>
<d-hover-box>
<slot id="slot"></slot>
<div class="footnote-container">
<slot id="slot"></slot>
</div>
</d-hover-box>
<sup>
+30 -8
View File
@@ -3,6 +3,7 @@ import { Template } from '../mixins/template';
// This overlay is not secure.
// It is only meant as a social deterrent.
const productionHostname = 'distill.pub';
const T = Template('d-interstitial', `
<style>
@@ -109,13 +110,11 @@ p small {
export class Interstitial extends T(HTMLElement) {
connectedCallback() {
const passwordInput = this.root.querySelector('#interstitial-password-input');
passwordInput.oninput = (event) => this.passwordChanged(event);
if (typeof(Storage) !== 'undefined') {
if (localStorage.getItem('distill-interstitial-password-correct') === 'true') {
console.log('Loaded that correct password was entered before; skipping interstitial.');
this.parentElement.removeChild(this);
}
if (this.shouldRemoveSelf()) {
this.parentElement.removeChild(this);
} else {
const passwordInput = this.root.querySelector('#interstitial-password-input');
passwordInput.oninput = (event) => this.passwordChanged(event);
}
}
@@ -126,9 +125,32 @@ export class Interstitial extends T(HTMLElement) {
this.parentElement.removeChild(this);
if (typeof(Storage) !== 'undefined') {
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');
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');
+15 -9
View File
@@ -73,6 +73,8 @@ export function mergeFromYMLFrontmatter(target, source) {
target.publishedDate = source.publishedDate;
} else if (source.publishedDate.constructor === String) {
target.publishedDate = new Date(source.publishedDate);
} else {
console.error('Don\'t know what to do with published date: ' + source.publishedDate);
}
}
target.description = source.description;
@@ -303,15 +305,19 @@ export class FrontMatter {
target.url = this.url;
target.githubUrl = this.githubUrl;
target.previewURL = this.previewURL;
target.volume = this.volume;
target.issue = this.issue;
target.publishedDateRFC = this.publishedDateRFC;
target.publishedYear = this.publishedYear;
target.publishedMonth = this.publishedMonth;
target.publishedDay = this.publishedDay;
target.publishedMonthPadded = this.publishedMonthPadded;
target.publishedDayPadded = this.publishedDayPadded;
target.updatedDateRFC = this.updatedDateRFC;
if (this.publishedDate) {
target.volume = this.volume;
target.issue = this.issue;
target.publishedDateRFC = this.publishedDateRFC;
target.publishedYear = this.publishedYear;
target.publishedMonth = this.publishedMonth;
target.publishedDay = this.publishedDay;
target.publishedMonthPadded = this.publishedMonthPadded;
target.publishedDayPadded = this.publishedDayPadded;
}
if (this.updatedDate) {
target.updatedDateRFC = this.updatedDateRFC;
}
target.concatenatedAuthors = this.concatenatedAuthors;
target.bibtexAuthors = this.bibtexAuthors;
target.slug = this.slug;
+1 -1
View File
@@ -79,7 +79,7 @@ distill-footer {
}
}
@media(min-width: 1280px) {
@media(min-width: 1180px) {
.base-grid,
distill-header,
d-title,
+15 -13
View File
@@ -124,26 +124,28 @@ function appendHtml(el, html) {
}
function citation_meta_content(ref){
// Special test for arxiv
var content = `citation_title=${ref.title};`;
ref.author.split(' and ').forEach(name => {
name = name.trim();
let last, firsts;
if (name.indexOf(',') != -1){
last = name.split(',')[0].trim();
firsts = name.split(',')[1].trim();
} else {
last = name.split(' ').slice(-1)[0].trim();
firsts = name.split(' ').slice(0,-1).join(' ');
}
content += `citation_author=${firsts} ${last};`;
});
if (ref.author && ref.author !== '') {
ref.author.split(' and ').forEach(name => {
name = name.trim();
let last, firsts;
if (name.indexOf(',') != -1){
last = name.split(',')[0].trim();
firsts = name.split(',')[1].trim();
} else {
last = name.split(' ').slice(-1)[0].trim();
firsts = name.split(' ').slice(0,-1).join(' ');
}
content += `citation_author=${firsts} ${last};`;
});
}
if ('year' in ref) {
content += `citation_publication_date=${ref.year};`;
}
// Special test for arxiv
let arxiv_id_search = /https?:\/\/arxiv\.org\/pdf\/([0-9]*\.[0-9]*)\.pdf/.exec(ref.url);
arxiv_id_search = arxiv_id_search || /https?:\/\/arxiv\.org\/abs\/([0-9]*\.[0-9]*)/.exec(ref.url);
arxiv_id_search = arxiv_id_search || /arXiv preprint arXiv:([0-9]*\.[0-9]*)/.exec(ref.journal);
+2
View File
@@ -50,6 +50,8 @@ export default function(dom, data) {
interstitial.password = data.password;
body.insertBefore(interstitial, body.firstChild);
}
} else if (!hasPassword && interstitial) {
interstitial.parentElement.removeChild(this);
}
let appendix = dom.querySelector('d-appendix');