Allow multiple affiliations for authors

This commit is contained in:
Ludwig Schubert
2018-06-22 11:54:43 -07:00
parent a06cb5794c
commit 5217fd9943
5 changed files with 40 additions and 15 deletions
+11 -10
View File
@@ -32,20 +32,20 @@
{
"author":"Chris Olah",
"authorURL":"https://colah.github.io/",
"affiliation":"Google Brain",
"affiliationURL":"https://g.co/brain"
},
{
"author":"Shan Carter",
"authorURL":"https://shancarter.com/",
"affiliation":"Google Brain",
"affiliationURL":"https://g.co/brain"
"affiliations": [{"name": "Google Brain", "url": "https://g.co/brain"}]
},
{
"author":"Ludwig Schubert",
"authorURL":"https://shancarter.com/",
"affiliation":"Google Brain",
"affiliationURL":"https://g.co/brain"
"affiliations": [{"name": "Google Brain", "url": "https://g.co/brain"}]
},
{
"author":"Shan Carter",
"authorURL":"https://shancarter.com/",
"affiliations": [
{"name": "Google Brain", "url": "https://g.co/brain"},
{"name": "NYT", "url": "https://nytimes.com"}
]
}
],
"katex": {
@@ -59,6 +59,7 @@
<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<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-byline></d-byline>
<d-article>
<a class="marker" href="#section-1" id="section-1"><span>1</span></a>
<h2>A Brief Survey of Techniques</h2>
+1 -1
View File
@@ -1,6 +1,6 @@
{
"name": "distill-template",
"version": "2.2.19",
"version": "2.2.22",
"description": "Template for creating Distill articles.",
"main": "dist/template.v2.js",
"bin": {
+3 -3
View File
@@ -27,9 +27,9 @@ export function bylineTemplate(frontMatter) {
<div class="name">${author.name}</div>`}
</p>
<p class="affiliation">
${author.affiliationURL ? `
<a class="affiliation" href="${author.affiliationURL}">${author.affiliation}</a>` : `
<div class="affiliation">${author.affiliation}</div>`}
${author.affiliations.map(affiliation =>
affiliation.url ? `<a class="affiliation" href="${affiliation.url}">${affiliation.name}</a>` : `<div class="affiliation">${affiliation.name}</div>`
).join(', ')}
</p>
`).join('')}
</div>
+24 -1
View File
@@ -12,13 +12,36 @@
// See the License for the specific language governing permissions and
// limitations under the License.
export function _moveLegacyAffiliationFormatIntoArray(frontMatter) {
// authors used to have propoerties "affiliation" and "affiliationURL".
// We now encourage using an array for affiliations containing objects with
// properties "name" and "url".
for (let author of frontMatter.authors) {
const hasOldStyle = Boolean(author.affiliation)
const hasNewStyle = Boolean(author.affiliations)
if (!hasOldStyle) continue;
if (hasNewStyle) {
console.warn(`Author ${author.author} has both old-style ("affiliation" & "affiliationURL") and new style ("affiliations") affiliation information!`)
} else {
let newAffiliation = {
"name": author.affiliation
}
if (author.affiliationURL) newAffiliation.url = author.affiliationURL;
author.affiliations = [newAffiliation];
}
}
console.log(frontMatter)
return frontMatter
}
export function parseFrontmatter(element) {
const scriptTag = element.querySelector('script');
if (scriptTag) {
const type = scriptTag.getAttribute('type');
if (type.split('/')[1] == 'json') {
const content = scriptTag.textContent;
return JSON.parse(content);
const parsed = JSON.parse(content);
return _moveLegacyAffiliationFormatIntoArray(parsed);
} else {
console.error('Distill only supports JSON frontmatter tags anymore; no more YAML.');
}
+1
View File
@@ -58,6 +58,7 @@ class Author {
this.personalURL = object.authorURL; // 'https://colah.github.io'
this.affiliation = object.affiliation; // 'Google Brain'
this.affiliationURL = object.affiliationURL; // 'https://g.co/brain'
this.affiliations = object.affiliations || []; // new-style affiliations
}
// 'Chris'