diff options
| author | Mitchell Riedstra <mitch@riedstra.dev> | 2024-01-05 23:18:49 -0500 |
|---|---|---|
| committer | Mitchell Riedstra <mitch@riedstra.dev> | 2024-01-05 23:18:49 -0500 |
| commit | bd5a00c61b355c857b5c99323592ca432dea5d0a (patch) | |
| tree | 7e8ac7730527c1ad71e3fdac85840948fd23f45f /ui/src | |
| parent | c71b37eb23d4c8af7ab983de34c6da5be9363f3a (diff) | |
| download | paste-bd5a00c61b355c857b5c99323592ca432dea5d0a.tar.gz paste-bd5a00c61b355c857b5c99323592ca432dea5d0a.tar.xz | |
wip
Diffstat (limited to 'ui/src')
| -rw-r--r-- | ui/src/app.d.ts | 9 | ||||
| -rw-r--r-- | ui/src/app.html | 12 | ||||
| -rw-r--r-- | ui/src/routes/+layout.svelte | 148 | ||||
| -rw-r--r-- | ui/src/routes/+page.js | 9 | ||||
| -rw-r--r-- | ui/src/routes/+page.svelte | 14 | ||||
| -rw-r--r-- | ui/src/routes/list/+page.js | 22 | ||||
| -rw-r--r-- | ui/src/routes/list/+page.svelte | 55 | ||||
| -rw-r--r-- | ui/src/routes/login/+page.svelte | 21 | ||||
| -rw-r--r-- | ui/src/routes/new/+page.svelte | 66 | ||||
| -rw-r--r-- | ui/src/routes/view/[id]/+page.js | 11 | ||||
| -rw-r--r-- | ui/src/routes/view/[id]/+page.svelte | 79 |
11 files changed, 0 insertions, 446 deletions
diff --git a/ui/src/app.d.ts b/ui/src/app.d.ts deleted file mode 100644 index 26a9569..0000000 --- a/ui/src/app.d.ts +++ /dev/null @@ -1,9 +0,0 @@ -// See https://kit.svelte.dev/docs/types#app -// for information about these interfaces -// and what to do when importing types -declare namespace App { - // interface Error {} - // interface Locals {} - // interface PageData {} - // interface Platform {} -} diff --git a/ui/src/app.html b/ui/src/app.html deleted file mode 100644 index effe0d0..0000000 --- a/ui/src/app.html +++ /dev/null @@ -1,12 +0,0 @@ -<!DOCTYPE html> -<html lang="en"> - <head> - <meta charset="utf-8" /> - <link rel="icon" href="%sveltekit.assets%/favicon.png" /> - <meta name="viewport" content="width=device-width" /> - %sveltekit.head% - </head> - <body data-sveltekit-preload-data="hover"> - <div style="display: contents">%sveltekit.body%</div> - </body> -</html> diff --git a/ui/src/routes/+layout.svelte b/ui/src/routes/+layout.svelte deleted file mode 100644 index 4f83f18..0000000 --- a/ui/src/routes/+layout.svelte +++ /dev/null @@ -1,148 +0,0 @@ -<script> - import { browser } from '$app/environment'; - const loggedIn = browser ? window.localStorage.getItem('loggedIn') === "true": false -</script> -<body> - <nav> - <a href="/">Home</a> - {#if loggedIn } - | - <a href="/new">New</a> - <a href="/api/v1/logout" class="nav-right">Logout</a> - {:else} - <a href="/login" class="nav-right">Login</a> - {/if} - </nav> - - - <div class="container"> - <slot></slot> - </div> -</body> - -<style> -nav { - border-bottom: 3px solid #000; - padding-bottom: 10px; -} -.nav-right { - display: block; - float: right; -} -a { - text-decoration: none; - color: #268bd2; -} -a:visited { - color: #d22653; - /* - * Previous colors: - * #aa26d2; - * #888; - */ -} -a:hover { - text-decoration: underline; -} - -code { - /* color: #9672d5; */ - color: #222; - /* background-color: #ff000020; */ - /* padding: 2px; */ - border: 1px solid; - padding: 2px; - font-size: .8em; - font-family: "Roboto Mono", "Monaco", "Lucida Console", "DejaVu Sans Mono", "monospace"; -} - -pre code, textarea { - color: #000; - background-color: #FFFFEA; - display: block; - padding: 10px; - border: 1px solid; - line-height: 1.1; - overflow: auto; -} - -.code { - color: #000; - background-color: #FFFFEA; - display: block; - padding: 10px; - border: 1px solid; - line-height: 1.1; - overflow: auto; - border: 1px solid; - padding: 2px; - font-size: .8em; - font-family: "Roboto Mono", "Monaco", "Lucida Console", "DejaVu Sans Mono", "monospace"; -} - -textarea { - width: 100%; -} - -blockquote { - border-left: 4px solid #aaa; - padding-left: 1em; -} - -/* - * The following was shamelessly ripped from: - * http://bettermotherfuckingwebsite.com/ - * And subsequently modified to suit my needs - */ - -body { - margin: 40px auto; - max-width: 80%; - line-height: 1.6; - font-size: 1em; - color: #444; - padding: 0 10px; - /* Added because some browsers don't default to white */ - background-color: #fff; -} - -img { - width: 100%; - height: auto; -} - -h1,h2,h3 { - line-height: 1.2 -} - -@media screen and (min-width: 960px) { - body { - max-width: 768px; - } -} - -@media print { - .hide-print { display: none; } - nav { - display: none; - } - body { - background-color: transparent; - line-height: 1; - font-size: 10pt; - /* margin: 5px auto; */ - margin: 5px 5px 5px 5px; - max-width: 100%; - } - - pre code { - color: #000; - background-color: inherit; - display: block; - padding: 10px; - border: none; - } - -} - -</style> diff --git a/ui/src/routes/+page.js b/ui/src/routes/+page.js deleted file mode 100644 index 8777d48..0000000 --- a/ui/src/routes/+page.js +++ /dev/null @@ -1,9 +0,0 @@ -/* -export function load({params}) { - return { - post: { - - } - } -} -*/
\ No newline at end of file diff --git a/ui/src/routes/+page.svelte b/ui/src/routes/+page.svelte deleted file mode 100644 index 4cf6b97..0000000 --- a/ui/src/routes/+page.svelte +++ /dev/null @@ -1,14 +0,0 @@ -<script> - // import Login from './login/+page.svelte'; - import View from './list/+page.svelte'; -</script> - -<h1>Simple Pastebin</h1> - - -<!-- <Login /> --> -<p> - Below is a listing of recent pastes: -</p> - -<View /> diff --git a/ui/src/routes/list/+page.js b/ui/src/routes/list/+page.js deleted file mode 100644 index 85435b1..0000000 --- a/ui/src/routes/list/+page.js +++ /dev/null @@ -1,22 +0,0 @@ - - - -/** @type {import('./$types').PageLoad} */ -// export async function load({ fetch, params }) { -// const res = await fetch(`/api/v1/list`); -// const item = await res.json(); -// -// return { item }; -// } - - -/** @type {import('./$types').PageLoad} */ -// export async function load({ params }) { -// const req = await fetch(`http://localhost:6130/api/v1/list`) -// const reqJson = await req.json(); -// -// return { -// req: req, -// reqJson: reqJson, -// }; -// } diff --git a/ui/src/routes/list/+page.svelte b/ui/src/routes/list/+page.svelte deleted file mode 100644 index 1986665..0000000 --- a/ui/src/routes/list/+page.svelte +++ /dev/null @@ -1,55 +0,0 @@ -<script> - import { goto } from '$app/navigation'; - - let Err = null; - let data; - - console.log(data); - // $: console.log(data) - - - fetch(`/api/v1/list`) - .then((res) => { - console.log(`Got res: ${res}`) - console.log(res) - return res.json() - }) - .then((jsonResp) => { - console.log(`jsonResp: ${jsonResp}`) - console.log(jsonResp) - if (jsonResp.Code === 401) { - console.log(`status code === 401: ${jsonResp.Code}`) - window.localStorage.removeItem('loggedIn'); - window.localStorage.setItem('loggedIn', 'false'); - goto('/login'); - } else if (jsonResp.Code !== 200) { - Err = `Received code: ${jsonResp.Code} message: ${jsonResp.Msg}` - } else { - window.localStorage.removeItem('loggedIn'); - window.localStorage.setItem('loggedIn', 'true'); - data = jsonResp.Data - } - }) - .catch((error) => { - console.log(error) - Err = `Encountered error: ${error}`; - }) - - -</script> - -{#if data} -<ul> - {#each data as paste (paste.id)} - <li> - <a href="/view/{paste.id}"> - ID: {paste.id} ({paste.size} bytes) - </a> - </li> - {/each} -</ul> -{:else if Err} -{Err} -{:else} - Loading.... -{/if} diff --git a/ui/src/routes/login/+page.svelte b/ui/src/routes/login/+page.svelte deleted file mode 100644 index f427d41..0000000 --- a/ui/src/routes/login/+page.svelte +++ /dev/null @@ -1,21 +0,0 @@ - - -<h2>Login</h2> - -<div class="contianer"> - <form action="/api/v1/login" method="post"> - - <label for="username">Username: </label> - <input type="text" name="username" id="username" /> - - <br /> - - <label for="password">Password: </label> - <input type="password" name="password" id="password" /> - - <br /> - - <button type="submit">Login</button> - - </form> -</div> diff --git a/ui/src/routes/new/+page.svelte b/ui/src/routes/new/+page.svelte deleted file mode 100644 index 10557af..0000000 --- a/ui/src/routes/new/+page.svelte +++ /dev/null @@ -1,66 +0,0 @@ -<script> - import { goto } from '$app/navigation'; - let content = ''; - - // $: console.log("Content is: ", content) - - async function save() { - const res = await fetch("/api/v1/new", { - method: 'POST', - body: JSON.stringify({ - content: content, - }) - }) - - const resp = await res.json() - console.log(resp) - - if ('Code' in resp && resp.Code === 200) { - goto('view/' + resp.Data.Id) - } - - } - -</script> - - -<div class="content"> - -<h1>New Paste</h1> - -<label for="content">Content:</label> -<br /> -<br /> -<textarea name="content" id="content" cols="80" rows="20" bind:value={content}></textarea> - -<br /> -<br /> -<button type="submit" on:click={save}>Save</button> - -</div> - - - -<style> -/* TODO: Figure out why the styles don't get propagated down here - from the +layout up above */ -textarea { - margin: 0px auto; - width: 100%; - max-width: 100%; - min-width: 75%; - color: #000; - background-color: #FFFFEA; - display: block; - padding: 10px; - border: 1px solid; - line-height: 1.1; - overflow: auto; - border: 1px solid; - padding: 2px; - font-size: .8em; - font-family: "Roboto Mono", "Monaco", "Lucida Console", "DejaVu Sans Mono", "monospace"; -} - - -</style> diff --git a/ui/src/routes/view/[id]/+page.js b/ui/src/routes/view/[id]/+page.js deleted file mode 100644 index a457936..0000000 --- a/ui/src/routes/view/[id]/+page.js +++ /dev/null @@ -1,11 +0,0 @@ -/** @type {import('./$types').PageLoad} */ -export async function load({ params }) { - const req = await fetch(`/api/v1/view/${params.id}`) - const reqJson = await req.json(); - - return { - id: params.id, - req: req, - reqJson: reqJson, - }; -} diff --git a/ui/src/routes/view/[id]/+page.svelte b/ui/src/routes/view/[id]/+page.svelte deleted file mode 100644 index 1a7377c..0000000 --- a/ui/src/routes/view/[id]/+page.svelte +++ /dev/null @@ -1,79 +0,0 @@ - -<script> - import { goto } from '$app/navigation'; - - /** @type {import('./$types').PageData} */ - export let data; - - console.log(data); - - - let copyPromise = null; - let timer = 0; - - function copy() { - copyPromise = navigator.clipboard.writeText(data.reqJson.Data.Content); - timer = 3; - setTimeout(function() { - for (; timer >= 0 ; timer --); - return - }, 1000) - } - - - async function del() { - let res = await fetch(`/api/v1/del/${data.id}`, { - method: "DELETE", - }) - - const resp = await res.json() - console.log(resp) - - if ('Code' in resp && resp.Code === 200) { - goto('/') - } - } - -</script> - -<h2>ID: {data.id}</h2> - -{#if timer > 0} -{#await copyPromise} -{:then} - <p> - Successfully copied! - </p> -{:catch error} - <p> - Failed to copy: {error} - </p> -{/await} -{/if} - -<button on:click={copy}>Copy to clipboard!</button> - -<button on:click={del}>Delete</button> - -<pre id="content" class="code">{data.reqJson.Data.Content}</pre> - - -<style> -/* TODO: Figure out why the styles don't get propagated down here - from the +layout up above */ -.code { - color: #000; - background-color: #FFFFEA; - display: block; - padding: 10px; - border: 1px solid; - line-height: 1.1; - overflow: auto; - border: 1px solid; - padding: 2px; - font-size: .8em; - font-family: "Roboto Mono", "Monaco", "Lucida Console", "DejaVu Sans Mono", "monospace"; -} - - -</style> |
