Compare commits
No commits in common. "2753be8450196eab2fa54a84cb1015514b857578" and "40eb55bb0440bccbcf679aa55501e86839724bc9" have entirely different histories.
2753be8450
...
40eb55bb04
3 changed files with 36 additions and 69 deletions
|
@ -7,7 +7,7 @@
|
|||
<title>Sandpoints Edit Page</title>
|
||||
|
||||
<link rel='stylesheet' href='global.css'>
|
||||
<script defer src='../metadata/index.js'></script>
|
||||
<script defer src='metasp.js'></script>
|
||||
<script defer src='build/bundle.js'></script>
|
||||
</head>
|
||||
|
||||
|
|
|
@ -10,11 +10,10 @@
|
|||
let relpermalink = "";
|
||||
let protocol = "";
|
||||
let title = "Foo bar";
|
||||
let hases = [];
|
||||
let hasesCandidates = [];
|
||||
let frontmatter = {};
|
||||
let frontmatterLoaded = false;
|
||||
frontmatter["triad"] = [];
|
||||
let hases = [];
|
||||
let hasesCandidates = [];
|
||||
let frontmatter = {};
|
||||
frontmatter["triad"] = [];
|
||||
frontmatter["ascriptions"] = [];
|
||||
frontmatter["notsand"] = [];
|
||||
|
||||
|
@ -39,11 +38,11 @@
|
|||
tiers: [],
|
||||
candidates: METASP[newFmKey].tiers,
|
||||
};
|
||||
hasesCandidates = hasesCandidates.filter((h) => h != newFmKey);
|
||||
hasesCandidates = [...hasesCandidates, oldFmKey];
|
||||
hasesCandidates = hasesCandidates.filter((h) => h != newFmKey);
|
||||
}
|
||||
|
||||
function loadHugoPageMetadata(editHash) {
|
||||
function loadHugoPageMetadata() {
|
||||
var el = document.createElement("script");
|
||||
el.onload = () => {
|
||||
v = repo.content;
|
||||
|
@ -54,8 +53,7 @@
|
|||
relpath = repo.path;
|
||||
relpermalink = repo.relpermalink;
|
||||
protocol = document.location.protocol.substring(0, 4);
|
||||
let 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);
|
||||
Object.entries(repo.frontmatter).forEach(([fmKey, fmValue]) => {
|
||||
let fmKeyType = "";
|
||||
if (fmKey.toLowerCase().startsWith("has_")) {
|
||||
|
@ -79,7 +77,7 @@
|
|||
if (fmValue.includes(t.file)) {
|
||||
tiers.push(t);
|
||||
} else {
|
||||
candidates.push(t);
|
||||
candidates.push(t);
|
||||
}
|
||||
});
|
||||
frontmatter[fmKeyType].push({
|
||||
|
@ -110,9 +108,8 @@
|
|||
|
||||
let tkey = Object.keys(repo.frontmatter).filter((t) => t.toLowerCase() == "title")[0];
|
||||
title = repo.frontmatter[tkey];
|
||||
frontmatterLoaded = true;
|
||||
};
|
||||
el.src = `../js/repo/${editHash}.js`;
|
||||
el.src = `../js/repo/${location.hash.substring(1)}.js`;
|
||||
document.body.appendChild(el);
|
||||
}
|
||||
|
||||
|
@ -155,40 +152,13 @@
|
|||
}
|
||||
}
|
||||
|
||||
function newFrontmatter() {
|
||||
return Object.entries(frontmatter).filter(val => val[1].length == 0).map(key => key[0])
|
||||
}
|
||||
|
||||
function checkTriad() {
|
||||
let ct = Object.entries(frontmatter).filter(i => i[1].length == 0 && i[0] == "triad")
|
||||
return ct.length == 0 ? false : true
|
||||
}
|
||||
|
||||
function newTriad() {
|
||||
newHasTiers({"detail": ["triad", 0, "authors", "editors"]})
|
||||
}
|
||||
|
||||
function dispatchHash() {
|
||||
var searchParams = new URLSearchParams(location.search);
|
||||
let editHash = searchParams.get('edit')
|
||||
if (editHash) {
|
||||
loadHugoPageMetadata(editHash)
|
||||
} else {
|
||||
let newPage = searchParams.get('new')
|
||||
console.log(newPage)
|
||||
}
|
||||
}
|
||||
|
||||
onMount(() => {
|
||||
dispatchHash();
|
||||
// loadHugoPageMetadata();
|
||||
console.dir(frontmatter);
|
||||
});
|
||||
|
||||
$: hashChanged = ()=> dispatchHash();
|
||||
onMount(() => {
|
||||
loadHugoPageMetadata();
|
||||
console.dir(frontmatter);
|
||||
});
|
||||
</script>
|
||||
|
||||
<svelte:window on:keyup={keyUp} on:hashchange={hashChanged} />
|
||||
<svelte:window on:keyup={keyUp} />
|
||||
<main id="sandpoints">
|
||||
<form>
|
||||
<div class="formgrid">
|
||||
|
@ -224,9 +194,6 @@
|
|||
{/if}
|
||||
{/each}
|
||||
{/each}
|
||||
{#if frontmatterLoaded && checkTriad()}
|
||||
<div on:click="{newTriad}">NEW TRIAD TIER</div>
|
||||
{/if}
|
||||
</span>
|
||||
<div class="formgrid">
|
||||
<label for="pagecontent">Content:</label>
|
||||
|
|
|
@ -1,23 +1,23 @@
|
|||
<script>
|
||||
import { createEventDispatcher } from "svelte";
|
||||
export let index;
|
||||
export let fmItem;
|
||||
export let fmKeyType;
|
||||
const dispatch = createEventDispatcher();
|
||||
import { createEventDispatcher } from "svelte";
|
||||
export let index;
|
||||
export let fmItem;
|
||||
export let fmKeyType;
|
||||
const dispatch = createEventDispatcher();
|
||||
|
||||
function removeTier(tier) {
|
||||
dispatch("addToCandidatesRemoveFromTiers", [fmKeyType, index, fmItem.fmKey, tier]);
|
||||
}
|
||||
function removeTier(tier) {
|
||||
dispatch("addToCandidatesRemoveFromTiers", [fmKeyType, index, fmItem.fmKey, tier]);
|
||||
}
|
||||
|
||||
function swapTier(tier, n) {
|
||||
fmItem.tiers.some((t, i) => {
|
||||
if (t == tier) {
|
||||
fmItem.tiers[i] = fmItem.tiers[i + n];
|
||||
fmItem.tiers[i + n] = tier;
|
||||
return true;
|
||||
}
|
||||
});
|
||||
}
|
||||
function swapTier(tier, n) {
|
||||
fmItem.tiers.some((t, i) => {
|
||||
if (t == tier) {
|
||||
fmItem.tiers[i] = fmItem.tiers[i + n];
|
||||
fmItem.tiers[i + n] = tier;
|
||||
return true;
|
||||
}
|
||||
});
|
||||
}
|
||||
</script>
|
||||
|
||||
{#if fmItem.tiers && fmItem.tiers.length > 0}
|
||||
|
@ -38,14 +38,14 @@
|
|||
type="button"
|
||||
class="buttondown"
|
||||
on:click={swapTier(tier, 1)}
|
||||
disabled={i + 1 == fmItem.tiers.length ? true : false}>⇓</button
|
||||
>
|
||||
disabled={i + 1 == fmItem.tiers.length ? true : false}>⇓</button
|
||||
>
|
||||
<button
|
||||
type="button"
|
||||
class="buttonup"
|
||||
on:click={swapTier(tier, -1)}
|
||||
disabled={i == 0 ? true : false}>⇑</button
|
||||
>
|
||||
disabled={i == 0 ? true : false}>⇑</button
|
||||
>
|
||||
<button type="button" on:click={removeTier(tier)}>×</button>
|
||||
</div>
|
||||
</div>
|
||||
|
|
Loading…
Add table
Reference in a new issue