diff options
Diffstat (limited to 'src/pages')
| -rw-r--r-- | src/pages/board/[board].astro | 11 | ||||
| -rw-r--r-- | src/pages/board/[board]/[tid].astro | 11 | ||||
| -rw-r--r-- | src/pages/boards.astro | 22 | ||||
| -rw-r--r-- | src/pages/create/[board].astro | 67 | ||||
| -rw-r--r-- | src/pages/create/thread.ts | 32 | 
5 files changed, 51 insertions, 92 deletions
| diff --git a/src/pages/board/[board].astro b/src/pages/board/[board].astro index 23a5551..a529d3c 100644 --- a/src/pages/board/[board].astro +++ b/src/pages/board/[board].astro @@ -1,6 +1,8 @@  ---  import Default from '../../layouts/Default.astro';  import Thread from '../../components/Thread.svelte' +import '../../styles/thread.css' +import '../../styles/blackbox.css?'  import type Thread from '../../models/Thread';  import { api } from '../../lib/api.ts'; @@ -18,8 +20,17 @@ for(let thread of threads)  <Default>    <h1><a href="/boards"> {board} </a></h1> +  <div class="blackbox"> +    <button style="left: 50%; position: relative; transform: translate(-50%, 0);" onclick=`window.location='/create/${board}'`>Create Thread</button> +  </div>    {threads.map((thread) => (      <Thread thread={thread} board={board} />    ))}  </Default> + +<style is:inline> +  :root { +    --wdt: 600px; +  } +</style> diff --git a/src/pages/board/[board]/[tid].astro b/src/pages/board/[board]/[tid].astro index 80e7fbe..4aa34ef 100644 --- a/src/pages/board/[board]/[tid].astro +++ b/src/pages/board/[board]/[tid].astro @@ -1,7 +1,7 @@  ---  import Default from '../../../layouts/Default.astro';  import Thread from '../../../components/Thread.svelte' -import Comment from '../../../components/Comment.svelte' +import '../../../styles/thread.css'  import type Thread from '../../../models/Thread';  import { api } from '../../../lib/api'; @@ -14,13 +14,8 @@ if(data.status === 404) return Astro.redirect('/404');  const thread: Thread = await data.json();  await processThreadIn(board, thread, true); -const comments: Comment[] = thread.comments;  ---  <Default> -  <Thread thread={thread} board={board}> -    {comments.map((comment) => ( -      <Comment comment={comment} /> -    ))} -  </Thread> -</Default> +  <Thread thread={thread} board={board} comments=true /> +</Default>
\ No newline at end of file diff --git a/src/pages/boards.astro b/src/pages/boards.astro index ab3158f..f10fa3a 100644 --- a/src/pages/boards.astro +++ b/src/pages/boards.astro @@ -1,32 +1,26 @@  ---  import Default from '../layouts/Default.astro'; +import '../styles/blackbox.css'  import { api } from '../lib/api.ts';  const data = await api('get', 'boards');  const boards: string[] = await data.json();  --- -<Default> -  <div class="blackbox"> -    <h3>Boards</h3> +<Default title="Boards"> +  <h1>Boards</h1> +  <div class="blackbox">      <ul>        {boards.map((board) => ( -      <li><a href=`/board/${board}`>{board}</a></li> +        <li><a href=`/board/${board}`>{board}</a></li>        ))}      </ul>    </div>  </Default> -<style> -  .blackbox { -    width: 300px; -    height: 210px; -    border: 10px solid black; -    padding: 10px; -    padding-top: 0px; -    margin: 10px; -    margin-left: 0px; -    background-color: white; +<style is:inline> +  :root { +    --wdt: 300px;    }  </style> diff --git a/src/pages/create/[board].astro b/src/pages/create/[board].astro index 45f8b0d..9c2308f 100644 --- a/src/pages/create/[board].astro +++ b/src/pages/create/[board].astro @@ -1,54 +1,25 @@  --- -import Default from '../../layouts/Default.astro' +import Default from '../../layouts/Default.astro'; +import Form from '../../components/Form.astro'; +  const { board } = Astro.params;  --- -<h1>{board}</h1> -  <Default> -  <form id="form" method="post" action="/create/thread" onsubmit="document.getElementById('submit-button').disabled = true"> -    <textarea name="ThreadName" placeholder="Thread Name" style="height: 1.5rem; width: 350px;"></textarea> <br> -    <textarea name="ThreadText" placeholder="Thread Contents" style="height: 150px; width: 350px;"></textarea> -    <br> <input id="submit-button" type="submit" value="Create Thread" /> -    <input id="image" type="file" accept=".png,.jpg,.gif,.bmp,.mp4" /> - -  </form> -  <script define:vars={{ board }}> -    document.forms['form'].addEventListener('submit', async (event) => { -      event.preventDefault(); - -      let form = new FormData(event.target); -      let reader = new FileReader(); - -      reader.onload = e => { -        form.append('image', -          (e != null) ? e.target.result.toString() : '' -        ); -      } - -      reader.onloadend = () => { -        fetch(event.target.action, { -          method: event.target.method, -          body: new URLSearchParams(form) -        }).then((r) => { -          if(r.status == 200) { -            alert('Thread Successfuly Posted'); -            window.location.assign(`/board/${board}`); -          } -          else alert('An Error has Accured'); -        }); -      } - -      form.append('board', board); - -      let image = document.getElementById("image").files[0]; -      if(image) { -        reader.readAsDataURL(image); -      } else { -        reader.onload(null); -        reader.onloadend(); -      } - -    }); -  </script> +  <h1>{board}</h1> + +  <Form board={board} tid="niggers"> +    <form id="form" method="post" action="/create/thread" onsubmit="document.getElementById('submit-button').disabled = true"> +      <textarea name="ThreadName" placeholder="Thread Name" style="height: 1.5rem; width: 350px;"></textarea> <br> +      <textarea name="ThreadText" placeholder="Thread Contents" style="height: 150px; width: 350px;"></textarea> +      <br> <input id="submit-button" type="submit" value="Create Thread" /> +      <input id="image" type="file" accept=".png,.jpg,.gif,.bmp,.mp4" /> +    </form> +  </Form>  </Default> + +<style> +  :root { +    --wdt: 360px; +  } +</style> diff --git a/src/pages/create/thread.ts b/src/pages/create/thread.ts index 0af3471..0a0b7d1 100644 --- a/src/pages/create/thread.ts +++ b/src/pages/create/thread.ts @@ -1,28 +1,16 @@ -import type { APIRoute } from 'astro'; -import { v4 as uuidV4 } from 'uuid'; +import { api } from '../../lib/api'; +import { processThreadOut } from '../../lib/thread'; -import type Thread from '../../models/Thread' -import { api } from '../../lib/api' +export async function post({ request }) { +  const form = await request.formData(); -export async function post({ params, request }): APIRoute { -    const form = await request.formData(); +  console.log(form); -    let t: Thread = {}; -    t.id = uuidV4().toString(); -    t.ThreadName = form.get('ThreadName').toString(); -    // data["ThreadCreator"] = locals.userid; -    t.ThreadCreator = ''; -    t.ThreadText = form.get('ThreadText').toString(); -    t.Comments = []; -    t.CreationDate = Date.now(); -    // data["ImageId"] = await post_img(base64image, writeFileSync); -    // data["FileType"] = get_img_type(base64image); -    t.ImageId = form.get('image').toString(); -    t.FileType = ''; +  let t: Thread = await processThreadOut(form); -    // await api('post', `thread/${form.get('board')}`, JSON.stringify(data)); +  await api('post', `thread/${form.get('board')}`, JSON.stringify(t)); -    return new Response(null, { -        status: 200 -    }); +  return new Response(t.id, { +    status: 200 +  });  } | 
