diff --git a/admin/App.svelte b/admin/App.svelte index 48e03e8..5ba87ea 100644 --- a/admin/App.svelte +++ b/admin/App.svelte @@ -7,7 +7,7 @@ -{#if process.env.DANGER_ADMIN} +{#if process.env.DANGER_ADMIN === "1"} {/if} diff --git a/admin/Header.svelte b/admin/Header.svelte index 9cce9b7..4eb2263 100644 --- a/admin/Header.svelte +++ b/admin/Header.svelte @@ -4,6 +4,7 @@ import Darkmode from '$/client/components/Darkmode.svelte'; import {link} from 'svelte-spa-router'; import { user } from "$/client/stores.js"; + import { register_enabled } from "$/client/config.js"; export let fixed = false; @@ -13,15 +14,39 @@ {#if $user.authenticated}
    +
  • +
  • +
  • +
  • {#if $user.admin } -
  • +
  • {/if} - -
  • +
{:else} - Login + + + {/if} diff --git a/admin/Layout.svelte b/admin/Layout.svelte index 8817f31..482f641 100644 --- a/admin/Layout.svelte +++ b/admin/Layout.svelte @@ -21,7 +21,7 @@
{/if} - +
diff --git a/admin/pages/DocsBrowser.svelte b/admin/pages/DocsBrowser.svelte index 6ff02c8..a76ac15 100644 --- a/admin/pages/DocsBrowser.svelte +++ b/admin/pages/DocsBrowser.svelte @@ -4,20 +4,20 @@ import Layout from '$/client/Layout.svelte'; import Icon from '$/client/components/Icon.svelte'; import Code from "$/client/components/Code.svelte"; + import HTML from "$/client/components/HTML.svelte"; import api from "$/client/api.js"; let index = {}; let docs_data; - let url; - let readme_docs; + let url = "/docs/"; export let params; const caps_to_icon = { - "_BUG_": "bug", - "_TODO_": "clipboard-check", - "_WARNING_": "alert-triangle", - "_FOOTGUN_": "bomb", - "_DEPRECATED_": "axe" + "BUG": "bug", + "TODO": "clipboard-check", + "WARNING": "alert-triangle", + "FOOTGUN": "bomb", + "DEPRECATED": "axe" } const jump = (id) => { @@ -25,9 +25,7 @@ if(node) node.scrollIntoView(); } - const jump_top = () => { - jump("top-scroll"); - } + const jump_top = () => jump("top-scroll"); const load_docs = async (to_load) => { // only load if the URL changed @@ -42,26 +40,9 @@ const load_index = async () => { const [status, data] = await api.get("/docs/api/index.json"); - index = status === 200 ? data : {}; } - const load_readme = async () => { - if(!readme_docs) { - console.log("LOAD README"); - const [status, data] = await api.blob("/docs/api/index.html"); - - if(status === 200) { - readme_docs = await data.text(); - } else { - readme_docs = `ERROR LOADING README: ${status}` - } - } - - url = "/docs/"; - console.log("URL", url, "README", readme_docs !== undefined, "PARAMS", params); - } - const type_to_syntax = { "callexpression": "()", "objectexpression": "{}", @@ -70,17 +51,13 @@ "method": "()" } - onMount(async () => { - await load_readme(); - await load_index(); - }); + onMount(load_index); $: if(params.wild) { + // load_docs will ignore any calls where params.wild doesn't change url load_docs(params.wild) - url = url; // the most irritating thing about Svelte } else { - load_readme(); - url = url; + url = "/docs/"; } @@ -204,9 +181,9 @@ -

API Docs

+

API Docs

- README + Introduction {#each Object.keys(index) as item} {item} {/each} @@ -216,9 +193,7 @@ {#if url === "/docs/"}
- {#if readme_docs} - {@html readme_docs} - {/if} +
{:else if docs_data} diff --git a/admin/pages/Home.svelte b/admin/pages/Home.svelte index 67928ce..f39b9ff 100644 --- a/admin/pages/Home.svelte +++ b/admin/pages/Home.svelte @@ -1,12 +1,12 @@