mirror of
https://github.com/wassname/template.git
synced 2026-09-09 11:38:29 +08:00
Merging
This commit is contained in:
@@ -10,6 +10,9 @@ export default function(dom, data) {
|
||||
let parsed = bibtexParse.toJSON(rawBib);
|
||||
if(parsed) {
|
||||
parsed.forEach(e => {
|
||||
for (var k in e.entryTags){
|
||||
e.entryTags[k] = e.entryTags[k].replace(/[\t\n ]+/g, " ");
|
||||
}
|
||||
bibliography[e.citationKey] = e.entryTags;
|
||||
bibliography[e.citationKey].type = e.entryType;
|
||||
});
|
||||
|
||||
+68
-34
@@ -15,9 +15,10 @@ export default function(dom, data) {
|
||||
var cite_string = inline_cite_short(keys);
|
||||
var cite_hover_str = "";
|
||||
keys.map((key,n) => {
|
||||
if (n>0) cite_hover_str += "<br>";
|
||||
cite_hover_str += bibliography_cite(data.bibliography[key], true);
|
||||
if (n>0) cite_hover_str += "<br><br>";
|
||||
cite_hover_str += hover_cite(data.bibliography[key]);
|
||||
});
|
||||
cite_hover_str = cite_hover_str.replace(/"/g, "'")
|
||||
el.innerHTML = `<span id="citation-${n}" class="citation" data-hover="${cite_hover_str}">${cite_string}</span>`;
|
||||
}
|
||||
});
|
||||
@@ -62,41 +63,52 @@ export default function(dom, data) {
|
||||
return keys.map(cite_string).join(", ");
|
||||
}
|
||||
|
||||
function author_string(ent, template, sep, finalSep){
|
||||
var names = ent.author.split(" and ");
|
||||
let name_strings = names.map(name => {
|
||||
var last = name.split(",")[0].trim();
|
||||
var firsts = name.split(",")[1];
|
||||
var initials = "";
|
||||
if (firsts != undefined) {
|
||||
initials = firsts.trim().split(" ").map(s => s.trim()[0]);
|
||||
initials = initials.join(".")+".";
|
||||
}
|
||||
return template.replace("F", firsts)
|
||||
.replace("L", last)
|
||||
.replace("I", initials);
|
||||
});
|
||||
if (names.length > 1) {
|
||||
var str = name_strings.slice(0, names.length-1).join(sep);
|
||||
str += (finalSep || sep) + name_strings[names.length-1];
|
||||
return str;
|
||||
} else {
|
||||
return name_strings[0];
|
||||
}
|
||||
}
|
||||
|
||||
function venue_string(ent) {
|
||||
var cite = (ent.journal || ent.booktitle || "")
|
||||
if ("volume" in ent){
|
||||
var issue = ent.issue || ent.number;
|
||||
issue = (issue != undefined)? "("+issue+")" : "";
|
||||
cite += ", Vol " + ent.volume + issue;
|
||||
}
|
||||
if ("pages" in ent){
|
||||
cite += ", pp. " + ent.pages
|
||||
}
|
||||
cite += ". "
|
||||
if ("publisher" in ent){
|
||||
cite += ent.publisher + ".";
|
||||
}
|
||||
return cite;
|
||||
}
|
||||
|
||||
function bibliography_cite(ent, fancy){
|
||||
if (ent){
|
||||
var names = ent.author.split(" and ");
|
||||
var cite = "";
|
||||
let name_strings = names.map(name => {
|
||||
var last = name.split(",")[0].trim();
|
||||
var firsts = name.split(",")[1];
|
||||
if (firsts != undefined) {
|
||||
var initials = firsts.trim().split(" ").map(s => s.trim()[0]);
|
||||
return last + ", " + initials.join(".")+".";
|
||||
}
|
||||
return last;
|
||||
});
|
||||
if (names.length > 1) {
|
||||
cite += name_strings.slice(0, names.length-1).join(", ");
|
||||
cite += " and " + name_strings[names.length-1];
|
||||
} else {
|
||||
cite += name_strings[0]
|
||||
}
|
||||
var cite = author_string(ent, "L, I", ", ", " and ");
|
||||
cite += ", " + ent.year + ". "
|
||||
if (fancy){
|
||||
cite += "<b>" + ent.title + "</b>. "
|
||||
} else {
|
||||
cite += ent.title + ". "
|
||||
}
|
||||
cite += (ent.journal || ent.booktitle || "")
|
||||
if ("volume" in ent){
|
||||
var issue = ent.issue || ent.number;
|
||||
issue = (issue != undefined)? "("+issue+")" : "";
|
||||
cite += ", Vol " + ent.volume + issue;
|
||||
}
|
||||
if ("pages" in ent){
|
||||
cite += ", pp. " + ent.pages
|
||||
}
|
||||
cite += ". "
|
||||
cite += ent.title + ". ";
|
||||
cite += venue_string(ent);
|
||||
if (fancy && ent.url && ent.url.slice(-4) == ".pdf") {
|
||||
cite = `${cite} <a href="${ent.url}">[pdf]</a>`
|
||||
}
|
||||
@@ -106,6 +118,28 @@ export default function(dom, data) {
|
||||
}
|
||||
}
|
||||
|
||||
function hover_cite(ent){
|
||||
if (ent){
|
||||
var cite = "";
|
||||
cite += "<b>" + ent.title + "</b>";
|
||||
if (ent.url && ent.url.slice(-4) == ".pdf") {
|
||||
cite = `${cite}  <a href="${ent.url}" style="text-decoration:inherit"><b>[PDF]</b></a>`
|
||||
}
|
||||
if (ent.url && ent.url.slice(-5) == ".html") {
|
||||
cite = `${cite}  <a href="${ent.url}" style="text-decoration:inherit"><b>[HTML]</b></a>`
|
||||
}
|
||||
cite += "<br>"
|
||||
cite += author_string(ent, "I L", ", ") + ".<br>";
|
||||
cite += venue_string(ent).trim() + " " + ent.year + ". "
|
||||
if ("doi" in ent) {
|
||||
cite += `<br> <a href="https://doi.org/${ent.doi}" style="text-decoration:inherit; font-size: 80%;">DOI: ${ent.doi}</a>`
|
||||
}
|
||||
return cite
|
||||
} else {
|
||||
return "?";
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//https://scholar.google.com/scholar?q=allintitle%3ADocument+author%3Aolah
|
||||
function get_URL(ent){
|
||||
|
||||
@@ -32,8 +32,8 @@ function DistillHoverBox(key, pos){
|
||||
top: ${top}px;
|
||||
left: ${left}px;
|
||||
padding: ${padding}px;
|
||||
border-radius: ${pretty? 6 : 0}px;
|
||||
box-shadow: 0px 0px 18px 6px #777;" >
|
||||
border-radius: ${pretty? 3 : 0}px;
|
||||
box-shadow: 0px 0px 18px 3px #777;" >
|
||||
${DistillHoverBox.contentMap[key]}
|
||||
</div>`;
|
||||
|
||||
|
||||
@@ -11,6 +11,11 @@ body {
|
||||
margin: 0;
|
||||
}
|
||||
|
||||
dt-article .citation {
|
||||
color: #668;
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
/*
|
||||
html, body, div, span, applet, object, iframe,
|
||||
h1, h2, h3, h4, h5, h6, p, blockquote, pre,
|
||||
|
||||
Reference in New Issue
Block a user