diff options
author | kartofen <mladenovnasko0@gmail.com> | 2022-10-24 23:19:33 +0300 |
---|---|---|
committer | kartofen <mladenovnasko0@gmail.com> | 2022-10-24 23:19:33 +0300 |
commit | 9dfd6aa77518b3a1e6bfd926a3b7719c32a8c97f (patch) | |
tree | d10fc76ef816160871e3955aa75821bc5d5088d4 /src/components | |
parent | 4ca81621e5b31922565b4149ebad1deb5161071a (diff) |
use the new api
Diffstat (limited to 'src/components')
-rw-r--r-- | src/components/Form.astro | 16 | ||||
-rw-r--r-- | src/components/Post.astro | 9 | ||||
-rw-r--r-- | src/components/Thread.astro | 25 |
3 files changed, 22 insertions, 28 deletions
diff --git a/src/components/Form.astro b/src/components/Form.astro index 540a4d4..93192a0 100644 --- a/src/components/Form.astro +++ b/src/components/Form.astro @@ -1,20 +1,17 @@ --- -import { sha256 } from 'js-sha256'; - export interface Props { board: string; tid?: string } const { board, tid } = Astro.props; -const iphash = sha256(Astro.clientAddress); --- <div class="blackbox"> <slot /> </div> -<script define:vars={{ board, iphash, tid }}> +<script define:vars={{ board, tid }}> document.forms['form'].addEventListener('submit', async (event) => { event.preventDefault(); @@ -34,16 +31,17 @@ const iphash = sha256(Astro.clientAddress); }).then(async (r) => { if(r.status == 200) { alert('Thread Successfuly Posted'); - let id = await r.text(); - if(id == 'close') window.top.close(); - window.location.assign(`/board/${board}/${id}`); + let t = await r.text(); + if(t == 'close') window.top.close(); + window.location.assign(`/board/${board}`); + } + else { + alert(`An Error has Accured: ${r.status} ${t}`); } - else alert('An Error has Accured'); }) } form.append('board', board); - form.append('iphash', iphash); if(tid) form.append('tid', tid); let image = document.getElementById("image").files[0]; diff --git a/src/components/Post.astro b/src/components/Post.astro index 6805846..1aa7a0d 100644 --- a/src/components/Post.astro +++ b/src/components/Post.astro @@ -1,27 +1,24 @@ --- -import { creatorColor, formatTime } from '../lib/util'; +import { formatTime } from '../lib/util'; export interface Props { id: string; date: number; - creator: string; box: string; board: string } -const { id, date, creator, box, board = '' } = Astro.props; +const { id, date, box, board = '' } = Astro.props; --- <div class={box} id={id}> <span style="line-height: 2rem;"> {(board != '') ? ( <a href=`/board/${board}/${id}` style="font-family: mono">{id}</a> ) : ( - <span style="font=family: mono">{id}</span> + <span style="font-family: mono">{id}</span> )} at {formatTime(date)} <br> - -> <span style=`${creatorColor(creator)}; font-family: mono`> - {creator} </span> <br> </span> <hr> <slot /> diff --git a/src/components/Thread.astro b/src/components/Thread.astro index 6fae3de..7b60227 100644 --- a/src/components/Thread.astro +++ b/src/components/Thread.astro @@ -6,10 +6,9 @@ import Image from './Image.astro'; export interface Props { thread: Thread; board: string; - comments: boolean; } -const { thread, board, comments = false } = Astro.props; +const { thread, board } = Astro.props; let replies: string[] = []; const listReplies = (id: string, getReplies: boolean = false): any => { @@ -17,7 +16,7 @@ const listReplies = (id: string, getReplies: boolean = false): any => { replies = []; thread.comments.forEach(comment => { - if(comment.commentText.includes(id)) + if(comment.content.includes(id)) replies.push(comment.id); }) @@ -27,9 +26,9 @@ const listReplies = (id: string, getReplies: boolean = false): any => { --- {(thread.id != "rules") && ( <> - <Post id={thread.id} date={thread.creationDate} creator={thread.threadCreator} box="threadbox" board={(!comments) ? board : ''}> + <Post id={thread.id} date={thread.timestamp} box="threadbox" board={(thread.comments == undefined) ? board : ''}> - {comments && (listReplies(thread.id) && ( + {thread.comments != undefined && (listReplies(thread.id) && ( <span class="small-mono"> {listReplies(thread.id, true).map((id) => ( <> <a href=`/board/${board}/${thread.id}#${id}` onmouseover=`onMouseOver('${id}')` onmouseleave=`onMouseLeave('${id}')`>>>{id}</a> @@ -38,13 +37,13 @@ const listReplies = (id: string, getReplies: boolean = false): any => { ))} - <h3>{thread.threadName}</h3> - <Image image={thread.imageId} fileType={thread.fileType} /> - <p set:html={thread.threadText} /> + <h3>{thread.title}</h3> + <Image image={thread.image} fileType={thread.imagetype} /> + <p set:html={thread.content} /> - {comments && ( <> + {thread.comments != undefined && ( <> {thread.comments.map((comment) => ( <> - <Post id={comment.id} date={comment.creationDate} creator={comment.commentCreator} box="commentbox"> + <Post id={comment.id} date={comment.timestamp} box="commentbox"> {listReplies(comment.id) && ( <span class="small-mono"> @@ -54,8 +53,8 @@ const listReplies = (id: string, getReplies: boolean = false): any => { </span> <hr> )} - <Image image={comment.imageId} fileType={comment.fileType} /> - <p set:html={comment.commentText} /> + <Image image={comment.image} fileType={comment.imagetype} /> + <p set:html={comment.content} /> </Post> </> ))} @@ -64,7 +63,7 @@ const listReplies = (id: string, getReplies: boolean = false): any => { </Post> </> )} -{comments && ( <> +{thread.comments != undefined && ( <> <script is:inline> function onMouseOver(id) { document.getElementById(id).classList.add('targeted'); |