mirror of
https://github.com/wassname/template.git
synced 2026-07-19 11:28:57 +08:00
Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
7ff8796266 | ||
|
|
0bc2ce69da | ||
|
|
4fac022efc | ||
|
|
dcf01cbc0f | ||
|
|
c6cd820bc3 | ||
|
|
6941ba780d | ||
|
|
6f7df48fc2 | ||
|
|
71450e9ba8 | ||
|
|
6679b120ab | ||
|
|
8bff98944a | ||
|
|
b4c8fdc56a | ||
|
|
c75787615e | ||
|
|
c2ef8e38c3 | ||
|
|
bfcff784b1 | ||
|
|
000fa088db | ||
|
|
f221583de8 | ||
|
|
cddd538f9d | ||
|
|
6f95c37c2c | ||
|
|
db3af262f2 | ||
|
|
184e094ae9 | ||
|
|
5ede2dd9d0 | ||
|
|
2a14b4c811 | ||
|
|
350b6c6f67 | ||
|
|
49deb31aeb | ||
|
|
b5a00b7f43 | ||
|
|
0f8f0f5962 | ||
|
|
094f0d4c58 | ||
|
|
cd4594f320 |
Generated
+1
-1
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "distill-template",
|
"name": "distill-template",
|
||||||
"version": "2.2.12",
|
"version": "2.2.19",
|
||||||
"lockfileVersion": 1,
|
"lockfileVersion": 1,
|
||||||
"requires": true,
|
"requires": true,
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
|
|||||||
+1
-1
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "distill-template",
|
"name": "distill-template",
|
||||||
"version": "2.2.12",
|
"version": "2.2.19",
|
||||||
"description": "Template for creating Distill articles.",
|
"description": "Template for creating Distill articles.",
|
||||||
"main": "dist/template.v2.js",
|
"main": "dist/template.v2.js",
|
||||||
"bin": {
|
"bin": {
|
||||||
|
|||||||
@@ -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>
|
||||||
|
|||||||
@@ -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
@@ -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
@@ -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;
|
||||||
|
|||||||
+14
-4
@@ -40,6 +40,7 @@ export function inline_cite_long(keys){
|
|||||||
}
|
}
|
||||||
|
|
||||||
function author_string(ent, template, sep, finalSep){
|
function author_string(ent, template, sep, finalSep){
|
||||||
|
if (ent.author == null) { return ''; }
|
||||||
var names = ent.author.split(' and ');
|
var names = ent.author.split(' and ');
|
||||||
let name_strings = names.map(name => {
|
let name_strings = names.map(name => {
|
||||||
name = name.trim();
|
name = name.trim();
|
||||||
@@ -114,13 +115,22 @@ function doi_string(ent, new_line){
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function title_string(ent) {
|
||||||
|
return '<span class="title">' + ent.title + '</span> ';
|
||||||
|
}
|
||||||
|
|
||||||
export function bibliography_cite(ent, fancy){
|
export function bibliography_cite(ent, fancy){
|
||||||
if (ent){
|
if (ent){
|
||||||
var cite = '<span class="title">' + ent.title + '</span> ';
|
var cite = title_string(ent);
|
||||||
cite += link_string(ent) + '<br>';
|
cite += link_string(ent) + '<br>';
|
||||||
cite += author_string(ent, '${L}, ${I}', ', ', ' and ');
|
if (ent.author) {
|
||||||
if (ent.year || ent.date){
|
cite += author_string(ent, '${L}, ${I}', ', ', ' and ');
|
||||||
cite += ', ' + (ent.year || ent.date) + '. ';
|
if (ent.year || ent.date) {
|
||||||
|
cite += ', ';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (ent.year || ent.date) {
|
||||||
|
cite += (ent.year || ent.date) + '. ';
|
||||||
} else {
|
} else {
|
||||||
cite += '. ';
|
cite += '. ';
|
||||||
}
|
}
|
||||||
|
|||||||
+4
-10
@@ -14,29 +14,23 @@ d-title h1 {
|
|||||||
grid-column: text;
|
grid-column: text;
|
||||||
font-size: 40px;
|
font-size: 40px;
|
||||||
font-weight: 700;
|
font-weight: 700;
|
||||||
line-height: 1.05em;
|
line-height: 1.1em;
|
||||||
margin: 0 0 1rem;
|
margin: 0 0 0.5rem;
|
||||||
}
|
}
|
||||||
|
|
||||||
@media(min-width: 768px) {
|
@media(min-width: 768px) {
|
||||||
d-title h1 {
|
d-title h1 {
|
||||||
font-size: 60px;
|
font-size: 50px;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
d-title p {
|
d-title p {
|
||||||
font-weight: 300;
|
font-weight: 300;
|
||||||
font-size: 1.2rem;
|
font-size: 1.2rem;
|
||||||
line-height: 1.7em;
|
line-height: 1.55em;
|
||||||
grid-column: text;
|
grid-column: text;
|
||||||
}
|
}
|
||||||
|
|
||||||
@media(min-width: 768px) {
|
|
||||||
d-title p {
|
|
||||||
font-size: 1.5rem;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
d-title .status {
|
d-title .status {
|
||||||
margin-top: 0px;
|
margin-top: 0px;
|
||||||
font-size: 12px;
|
font-size: 12px;
|
||||||
|
|||||||
@@ -90,7 +90,7 @@ sub {
|
|||||||
figure {
|
figure {
|
||||||
position: relative;
|
position: relative;
|
||||||
margin-bottom: 2.5em;
|
margin-bottom: 2.5em;
|
||||||
margin-top: 2.5em;
|
margin-top: 1.5em;
|
||||||
}
|
}
|
||||||
|
|
||||||
figcaption+figure {
|
figcaption+figure {
|
||||||
|
|||||||
@@ -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,
|
||||||
|
|||||||
@@ -95,6 +95,7 @@ export default function(dom, data) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function author_string(ent, template, sep, finalSep){
|
function author_string(ent, template, sep, finalSep){
|
||||||
|
if (ent.author == null) { return ''; }
|
||||||
var names = ent.author.split(' and ');
|
var names = ent.author.split(' and ');
|
||||||
let name_strings = names.map(name => {
|
let name_strings = names.map(name => {
|
||||||
name = name.trim();
|
name = name.trim();
|
||||||
|
|||||||
+15
-13
@@ -124,26 +124,28 @@ function appendHtml(el, html) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function citation_meta_content(ref){
|
function citation_meta_content(ref){
|
||||||
// Special test for arxiv
|
|
||||||
var content = `citation_title=${ref.title};`;
|
var content = `citation_title=${ref.title};`;
|
||||||
|
|
||||||
ref.author.split(' and ').forEach(name => {
|
if (ref.author && ref.author !== '') {
|
||||||
name = name.trim();
|
ref.author.split(' and ').forEach(name => {
|
||||||
let last, firsts;
|
name = name.trim();
|
||||||
if (name.indexOf(',') != -1){
|
let last, firsts;
|
||||||
last = name.split(',')[0].trim();
|
if (name.indexOf(',') != -1){
|
||||||
firsts = name.split(',')[1].trim();
|
last = name.split(',')[0].trim();
|
||||||
} else {
|
firsts = name.split(',')[1].trim();
|
||||||
last = name.split(' ').slice(-1)[0].trim();
|
} else {
|
||||||
firsts = name.split(' ').slice(0,-1).join(' ');
|
last = name.split(' ').slice(-1)[0].trim();
|
||||||
}
|
firsts = name.split(' ').slice(0,-1).join(' ');
|
||||||
content += `citation_author=${firsts} ${last};`;
|
}
|
||||||
});
|
content += `citation_author=${firsts} ${last};`;
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
if ('year' in ref) {
|
if ('year' in ref) {
|
||||||
content += `citation_publication_date=${ref.year};`;
|
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);
|
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 || /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);
|
arxiv_id_search = arxiv_id_search || /arXiv preprint arXiv:([0-9]*\.[0-9]*)/.exec(ref.journal);
|
||||||
|
|||||||
@@ -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');
|
||||||
|
|||||||
+2
-1
@@ -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) {
|
||||||
|
|||||||
Reference in New Issue
Block a user