new ascriptions and tiers.. nowhere finished...
This commit is contained in:
parent
847a228f5a
commit
a1d2c00a03
1 changed files with 85 additions and 65 deletions
108
src/App.svelte
108
src/App.svelte
|
@ -13,7 +13,6 @@
|
||||||
let hases = [];
|
let hases = [];
|
||||||
let hasesCandidates = [];
|
let hasesCandidates = [];
|
||||||
let frontmatter = {};
|
let frontmatter = {};
|
||||||
let frontmatterLoaded = false;
|
|
||||||
frontmatter["triad"] = [];
|
frontmatter["triad"] = [];
|
||||||
frontmatter["ascriptions"] = [];
|
frontmatter["ascriptions"] = [];
|
||||||
frontmatter["notsand"] = [];
|
frontmatter["notsand"] = [];
|
||||||
|
@ -32,8 +31,27 @@
|
||||||
return Array.from(diff);
|
return Array.from(diff);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function newTier(fmKeyType, fmKey, fmValue = "") {
|
||||||
|
console.log("newTier", fmKeyType, fmKey);
|
||||||
|
let tiers = [];
|
||||||
|
let candidates = [];
|
||||||
|
METASP[fmKey].tiers.forEach((t) => {
|
||||||
|
if (fmValue.includes(t.file)) {
|
||||||
|
tiers.push(t);
|
||||||
|
} else {
|
||||||
|
candidates.push(t);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
frontmatter[fmKeyType].push({
|
||||||
|
fmKey: fmKey,
|
||||||
|
tiers: tiers,
|
||||||
|
candidates: candidates,
|
||||||
|
});
|
||||||
|
frontmatter = { ...frontmatter };
|
||||||
|
}
|
||||||
|
|
||||||
function newHasTiers(arrgs) {
|
function newHasTiers(arrgs) {
|
||||||
let [fmKeyType, index, oldFmKey, newFmKey] = arrgs.detail;
|
const [fmKeyType, index, oldFmKey, newFmKey] = arrgs.detail;
|
||||||
frontmatter[fmKeyType][index] = {
|
frontmatter[fmKeyType][index] = {
|
||||||
fmKey: newFmKey,
|
fmKey: newFmKey,
|
||||||
tiers: [],
|
tiers: [],
|
||||||
|
@ -41,10 +59,11 @@
|
||||||
};
|
};
|
||||||
hasesCandidates = hasesCandidates.filter((h) => h != newFmKey);
|
hasesCandidates = hasesCandidates.filter((h) => h != newFmKey);
|
||||||
hasesCandidates = [...hasesCandidates, oldFmKey];
|
hasesCandidates = [...hasesCandidates, oldFmKey];
|
||||||
|
toggleNewTriadButton();
|
||||||
}
|
}
|
||||||
|
|
||||||
function loadHugoPageMetadata(editHash) {
|
function loadHugoPageMetadata(editHash) {
|
||||||
var el = document.createElement("script");
|
let el = document.createElement("script");
|
||||||
el.onload = () => {
|
el.onload = () => {
|
||||||
v = repo.content;
|
v = repo.content;
|
||||||
if (v.startsWith("\n")) {
|
if (v.startsWith("\n")) {
|
||||||
|
@ -54,8 +73,8 @@
|
||||||
relpath = repo.path;
|
relpath = repo.path;
|
||||||
relpermalink = repo.relpermalink;
|
relpermalink = repo.relpermalink;
|
||||||
protocol = document.location.protocol.substring(0, 4);
|
protocol = document.location.protocol.substring(0, 4);
|
||||||
let notSelf = Object.entries(METASP).filter(n => n[1].singular == relpath.split("/")[0])[0][0]
|
const notSelf = Object.entries(METASP).filter((n) => n[1].singular == relpath.split("/")[0])[0][0];
|
||||||
hases = Object.keys(METASP).filter(k => k != notSelf);
|
hases = Object.keys(METASP).filter((k) => k != notSelf);
|
||||||
Object.entries(repo.frontmatter).forEach(([fmKey, fmValue]) => {
|
Object.entries(repo.frontmatter).forEach(([fmKey, fmValue]) => {
|
||||||
let fmKeyType = "";
|
let fmKeyType = "";
|
||||||
if (fmKey.toLowerCase().startsWith("has_")) {
|
if (fmKey.toLowerCase().startsWith("has_")) {
|
||||||
|
@ -73,20 +92,7 @@
|
||||||
|
|
||||||
if (["triad", "ascriptions"].includes(fmKeyType)) {
|
if (["triad", "ascriptions"].includes(fmKeyType)) {
|
||||||
if (Array.isArray(fmValue)) {
|
if (Array.isArray(fmValue)) {
|
||||||
let tiers = [];
|
newTier(fmKeyType, fmKey, fmValue);
|
||||||
let candidates = [];
|
|
||||||
METASP[fmKey].tiers.forEach((t) => {
|
|
||||||
if (fmValue.includes(t.file)) {
|
|
||||||
tiers.push(t);
|
|
||||||
} else {
|
|
||||||
candidates.push(t);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
frontmatter[fmKeyType].push({
|
|
||||||
fmKey: fmKey,
|
|
||||||
tiers: tiers,
|
|
||||||
candidates: candidates,
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
} else if (fmKeyType == "journal") {
|
} else if (fmKeyType == "journal") {
|
||||||
frontmatter["journal"] || (frontmatter["journal"] = []);
|
frontmatter["journal"] || (frontmatter["journal"] = []);
|
||||||
|
@ -99,7 +105,18 @@
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
hasesCandidates = diffArrr(hases, [
|
hasesCandidates = reckonHasesCandidates();
|
||||||
|
const tkey = Object.keys(repo.frontmatter).filter((t) => t.toLowerCase() == "title")[0];
|
||||||
|
title = repo.frontmatter[tkey];
|
||||||
|
|
||||||
|
toggleNewTriadButton();
|
||||||
|
};
|
||||||
|
el.src = `../js/repo/${editHash}.js`;
|
||||||
|
document.body.appendChild(el);
|
||||||
|
}
|
||||||
|
|
||||||
|
function reckonHasesCandidates() {
|
||||||
|
return diffArrr(hases, [
|
||||||
...frontmatter["triad"].map((t) => {
|
...frontmatter["triad"].map((t) => {
|
||||||
return t.fmKey;
|
return t.fmKey;
|
||||||
}),
|
}),
|
||||||
|
@ -107,17 +124,9 @@
|
||||||
return t.fmKey;
|
return t.fmKey;
|
||||||
}),
|
}),
|
||||||
]);
|
]);
|
||||||
|
|
||||||
let tkey = Object.keys(repo.frontmatter).filter((t) => t.toLowerCase() == "title")[0];
|
|
||||||
title = repo.frontmatter[tkey];
|
|
||||||
frontmatterLoaded = true;
|
|
||||||
};
|
|
||||||
el.src = `../js/repo/${editHash}.js`;
|
|
||||||
document.body.appendChild(el);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function addToCandidatesRemoveFromTiers(arrgs) {
|
function addToCandidatesRemoveFromTiers(arrgs) {
|
||||||
let [fmKeyType, index, fmKey, tier] = arrgs.detail;
|
const [fmKeyType, index, fmKey, tier] = arrgs.detail;
|
||||||
frontmatter[fmKeyType][index]["fmKey"] = fmKey;
|
frontmatter[fmKeyType][index]["fmKey"] = fmKey;
|
||||||
frontmatter[fmKeyType][index]["tiers"] = frontmatter[fmKeyType][index]["tiers"].filter(
|
frontmatter[fmKeyType][index]["tiers"] = frontmatter[fmKeyType][index]["tiers"].filter(
|
||||||
(t) => t !== tier
|
(t) => t !== tier
|
||||||
|
@ -126,7 +135,7 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
function addToTiersRemoveFromCandidates(arrgs) {
|
function addToTiersRemoveFromCandidates(arrgs) {
|
||||||
let [fmKeyType, index, , value] = arrgs.detail;
|
const [fmKeyType, index, , value] = arrgs.detail;
|
||||||
const tier = frontmatter[fmKeyType][index]["candidates"].filter((t) => t.file == value);
|
const tier = frontmatter[fmKeyType][index]["candidates"].filter((t) => t.file == value);
|
||||||
if (tier.length > 0) {
|
if (tier.length > 0) {
|
||||||
frontmatter[fmKeyType][index]["tiers"] = [...frontmatter[fmKeyType][index]["tiers"], tier[0]];
|
frontmatter[fmKeyType][index]["tiers"] = [...frontmatter[fmKeyType][index]["tiers"], tier[0]];
|
||||||
|
@ -156,26 +165,34 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
function newFrontmatter() {
|
function newFrontmatter() {
|
||||||
return Object.entries(frontmatter).filter(val => val[1].length == 0).map(key => key[0])
|
return Object.entries(frontmatter)
|
||||||
|
.filter((val) => val[1].length == 0)
|
||||||
|
.map((key) => key[0]);
|
||||||
}
|
}
|
||||||
|
|
||||||
function checkTriad() {
|
function toggleNewTriadButton() {
|
||||||
let ct = Object.entries(frontmatter).filter(i => i[1].length == 0 && i[0] == "triad")
|
const ct = Object.entries(frontmatter).filter((i) => i[1].length == 0 && i[0] == "triad");
|
||||||
return ct.length == 0 ? false : true
|
if (document.getElementById("newtier")) {
|
||||||
|
if (ct.length == 0) {
|
||||||
|
document.getElementById("newtier").style.display = "none";
|
||||||
|
} else {
|
||||||
|
document.getElementById("newtier").style.display = "block";
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function newTriad() {
|
function newTriad() {
|
||||||
newHasTiers({"detail": ["triad", 0, "authors", "editors"]})
|
newHasTiers({ detail: ["triad", 0, "authors", "editors"] });
|
||||||
}
|
}
|
||||||
|
|
||||||
function dispatchHash() {
|
function dispatchHash() {
|
||||||
var searchParams = new URLSearchParams(location.search);
|
const searchParams = new URLSearchParams(location.search);
|
||||||
let editHash = searchParams.get('edit')
|
const editHash = searchParams.get("edit");
|
||||||
if (editHash) {
|
if (editHash) {
|
||||||
loadHugoPageMetadata(editHash)
|
loadHugoPageMetadata(editHash);
|
||||||
} else {
|
} else {
|
||||||
let newPage = searchParams.get('new')
|
let newPage = searchParams.get("new");
|
||||||
console.log(newPage)
|
console.log(newPage);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -185,7 +202,7 @@
|
||||||
console.dir(frontmatter);
|
console.dir(frontmatter);
|
||||||
});
|
});
|
||||||
|
|
||||||
$: hashChanged = ()=> dispatchHash();
|
$: hashChanged = () => dispatchHash();
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<svelte:window on:keyup={keyUp} on:hashchange={hashChanged} />
|
<svelte:window on:keyup={keyUp} on:hashchange={hashChanged} />
|
||||||
|
@ -224,9 +241,12 @@
|
||||||
{/if}
|
{/if}
|
||||||
{/each}
|
{/each}
|
||||||
{/each}
|
{/each}
|
||||||
{#if frontmatterLoaded && checkTriad()}
|
<div class="buttons news">
|
||||||
<div on:click="{newTriad}">NEW TRIAD TIER</div>
|
<div id="newtier" class="button" on:click={newTriad}>NEW TIER</div>
|
||||||
{/if}
|
<div id="newascription" class="button" on:click={() => newTier("ascriptions", "editors")}>
|
||||||
|
NEW ASCRIPTION
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
</span>
|
</span>
|
||||||
<div class="formgrid">
|
<div class="formgrid">
|
||||||
<label for="pagecontent">Content:</label>
|
<label for="pagecontent">Content:</label>
|
||||||
|
|
Loading…
Add table
Reference in a new issue