aboutsummaryrefslogtreecommitdiff
path: root/src/pages
diff options
context:
space:
mode:
Diffstat (limited to 'src/pages')
-rw-r--r--src/pages/board/[board].astro2
-rw-r--r--src/pages/board/[board]/[tid].astro4
-rw-r--r--src/pages/create/[board].astro4
-rw-r--r--src/pages/create/[board]/[tid].astro2
-rw-r--r--src/pages/create/comment.ts14
-rw-r--r--src/pages/create/thread.ts14
6 files changed, 17 insertions, 23 deletions
diff --git a/src/pages/board/[board].astro b/src/pages/board/[board].astro
index eaea03e..de76964 100644
--- a/src/pages/board/[board].astro
+++ b/src/pages/board/[board].astro
@@ -15,8 +15,6 @@ const data = await api('get', `board/${board}`);
if(data.status === 404) return Astro.redirect('/404');
const threads: Thread[] = await data.json();
-for(let thread of threads)
- await processThreadIn(board, thread);
---
<ThreadLayout>
diff --git a/src/pages/board/[board]/[tid].astro b/src/pages/board/[board]/[tid].astro
index e9b345a..fa2f104 100644
--- a/src/pages/board/[board]/[tid].astro
+++ b/src/pages/board/[board]/[tid].astro
@@ -10,12 +10,12 @@ import { api } from '../../../lib/api';
import { processThreadIn } from '../../../lib/thread';
const { board, tid } = Astro.params;
-const data = await api('get', `thread/${board}/${tid}`);
+const data = await api('get', `board/${board}/${tid}`);
if(data.status === 404) return Astro.redirect('/404');
const thread: Thread = await data.json();
-await processThreadIn(board, thread, true);
+processThreadIn(board, thread);
---
<ThreadLayout>
diff --git a/src/pages/create/[board].astro b/src/pages/create/[board].astro
index 152277c..3cbe1ab 100644
--- a/src/pages/create/[board].astro
+++ b/src/pages/create/[board].astro
@@ -12,8 +12,8 @@ const { board } = Astro.params;
<Form board={board} tid="">
<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>
+ <textarea name="title" placeholder="Thread Name" style="height: 1.5rem; width: 350px;"></textarea> <br>
+ <textarea name="content" 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>
diff --git a/src/pages/create/[board]/[tid].astro b/src/pages/create/[board]/[tid].astro
index f26c0d4..6f9cb8b 100644
--- a/src/pages/create/[board]/[tid].astro
+++ b/src/pages/create/[board]/[tid].astro
@@ -12,7 +12,7 @@ const { board, tid } = Astro.params;
<Form board={board} tid={tid}>
<form id="form" method="post" action="/create/comment" onsubmit="document.getElementById('submit-button').disabled = true">
- <textarea name="CommentText" placeholder="Comment Contents" style="height: 150px; width: 350px;"></textarea>
+ <textarea name="content" placeholder="Comment Contents" style="height: 150px; width: 350px;"></textarea>
<br> <input id="submit-button" type="submit" value="Create Comment" />
<input id="image" type="file" accept=".png,.jpg,.gif,.bmp,.mp4" />
</form>
diff --git a/src/pages/create/comment.ts b/src/pages/create/comment.ts
index f8d4c82..ebc0323 100644
--- a/src/pages/create/comment.ts
+++ b/src/pages/create/comment.ts
@@ -3,15 +3,13 @@ import { processCommentOut } from '../../lib/thread';
import Comment from '../../models/Thread';
export async function post({ request }) {
- const form = await request.formData();
+ const form = await request.formData();
- let c: Comment = await processCommentOut(form);
+ let c: Comment = processCommentOut(form);
- console.log(c);
+ let r = await api('post', `board/${form.get('board')}/${form.get('tid')}`, JSON.stringify(c));
- await api('post', `comment/${form.get('board')}/${form.get('tid')}`, JSON.stringify(c));
-
- return new Response('close', {
- status: 200
- });
+ return new Response((r.status == 200) ? 'close' : await r.text(), {
+ status: r.status
+ });
}
diff --git a/src/pages/create/thread.ts b/src/pages/create/thread.ts
index b3a02be..12702ba 100644
--- a/src/pages/create/thread.ts
+++ b/src/pages/create/thread.ts
@@ -3,15 +3,13 @@ import { processThreadOut } from '../../lib/thread';
import Thread from '../../models/Thread';
export async function post({ request }) {
- const form = await request.formData();
+ const form = await request.formData();
- let t: Thread = await processThreadOut(form);
+ let t: Thread = processThreadOut(form);
- console.log(t);
+ let r = await api('post', `board/${form.get('board')}`, JSON.stringify(t));
- await api('post', `thread/${form.get('board')}`, JSON.stringify(t));
-
- return new Response(t.id, {
- status: 200
- });
+ return new Response(await r.text(), {
+ status: r.status
+ });
}