More sorting options + timestamps

This commit is contained in:
Xodrium 2023-02-12 12:06:19 -05:00
parent 010bccc89d
commit 5972139552
9 changed files with 57 additions and 18 deletions

View file

@ -41,7 +41,6 @@
fData.append('last',i == (images.length - 1));
fData.append('id',rId);
method: 'POST',
form = await fetch(`/api/fileCreate`, {
method: 'POST',
body: fData,

View file

@ -3,7 +3,12 @@
import PostButton from '$lib/components/PostButton.svelte';
import PostBody from '$lib/components/PostBody.svelte';
export let success, username, content, upvotes, downvotes, id, isAuthor;
export let success, username, content, upvotes, downvotes, id, isAuthor, time;
let date = 'Time unknown';
if (time)
date = new Date(time / 1000);
let query = (id) ? `/post/${id}` : '';
@ -53,6 +58,12 @@
img {
max-width: 250px;
}
.date {
font-size: 0.8rem;
font-style: italic;
font-weight: normal;
}
</style>
{#if success}
@ -73,6 +84,9 @@
<a href='/user/{username}'>
{username}
</a>
<span class='date'>
{date}
</span>
</span>
<span slot="main">
<PostBody content={content} />

View file

@ -1,10 +1,16 @@
<script>
import Post from '$lib/components/Post.svelte';
import Button from '$lib/components/Button.svelte'
import Button from '$lib/components/Button.svelte';
import {setLocation} from '$lib/util.js';
export let data;
</script>
<p>
<Button clickFunc={() => { window.location.search = setLocation(window.location,'sort','rating')}}>Sort by rating</Button>
<Button clickFunc={() => { window.location.search = setLocation(window.location,'sort','time')}}>Sort by time</Button>
</p>
{#if data && data.postJson && data.postJson.data}
{#each data.postJson.data as post}
<Post
@ -15,11 +21,12 @@
downvotes={post.downvotes}
id={post.id}
isAuthor={post.isAuthor}
time={post.time}
></Post>
{/each}
{/if}
<p>
<Button clickFunc={() => { window.location.search = 'page=' + ((data.id)-1) }}>Previous page</Button>
<Button clickFunc={() => { window.location.search = 'page=' + ((data.id)+1) }}>Next page</Button>
<Button clickFunc={() => { window.location.search = setLocation(window.location,'page',((data.id)-1)) }}>Previous page</Button>
<Button clickFunc={() => { window.location.search = setLocation(window.location,'page',((data.id)+1)) }}>Next page</Button>
</p>