added voting
e
This commit is contained in:
parent
d8670ecf81
commit
e211b2cc50
13 changed files with 92 additions and 201 deletions
|
@ -74,7 +74,7 @@
|
|||
<img src='/logo_sanifae.svg' alt='Sanifae Logo'>
|
||||
</a>
|
||||
{#if data.username && data.username != 'false'}
|
||||
<a href='/users/{data.username}'>
|
||||
<a href='/user/{data.username}'>
|
||||
{data.username}
|
||||
</a>
|
||||
<a href='/logout'>
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
<script>
|
||||
import Post from '$lib/Post.svelte';
|
||||
import Post from '$lib/components/Post.svelte';
|
||||
|
||||
/** @type {import('./$types').PageData} */
|
||||
export let data;
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
<script>
|
||||
import Area from '$lib/Area.svelte';
|
||||
import Area from '$lib/components/Area.svelte';
|
||||
import { handleSubmit } from '$lib/util.js';
|
||||
|
||||
export let form = {};
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
import { backend } from '../../../lib/db.js';
|
||||
import { backend } from '../../../lib/db/db.js';
|
||||
|
||||
/** @type {import('./$types').RequestHandler} */
|
||||
export async function GET({ url, cookies, params }) {
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
import { backend } from '../../lib/db.js';
|
||||
import { backend } from '../../lib/db/db.js';
|
||||
import { checkLength, checkRegex } from '../../lib/util.js';
|
||||
|
||||
/** @type {import('./$types').Actions} */
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
<script>
|
||||
import Area from '$lib/Area.svelte';
|
||||
import Area from '$lib/components/Area.svelte';
|
||||
|
||||
import { handleSubmit } from '$lib/util.js';
|
||||
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
<script>
|
||||
import Post from '$lib/Post.svelte';
|
||||
import Post from '$lib/components/Post.svelte';
|
||||
|
||||
/** @type {import('./$types').PageData} */
|
||||
export let data;
|
||||
|
|
20
src/routes/user/[user]/+page.js
Normal file
20
src/routes/user/[user]/+page.js
Normal file
|
@ -0,0 +1,20 @@
|
|||
/** @type {import('./$types').PageLoad} */
|
||||
export async function load({ fetch, params, url }) {
|
||||
var search = url.searchParams;
|
||||
|
||||
var voteType = search.get('vote');
|
||||
|
||||
var id = search.get('page') * 1;
|
||||
|
||||
var user = params.user + '';
|
||||
|
||||
await new Promise(resolve => setTimeout(resolve, 100));
|
||||
|
||||
const res = await fetch(`/api/postBulk?user=${user}&page=${id}`);
|
||||
const postJson = await res.json();
|
||||
|
||||
const resUser = await fetch(`/api/userGet?user=${user}`);
|
||||
const postJsonUser = await resUser.json();
|
||||
|
||||
return { postJson, id, postJsonUser };
|
||||
}
|
49
src/routes/user/[user]/+page.svelte
Normal file
49
src/routes/user/[user]/+page.svelte
Normal file
|
@ -0,0 +1,49 @@
|
|||
<script>
|
||||
import Post from '$lib/components/Post.svelte';
|
||||
import Area from '$lib/components/Area.svelte';
|
||||
|
||||
/** @type {import('./$types').PageData} */
|
||||
export let data;
|
||||
|
||||
let userData = data.postJsonUser.data;
|
||||
</script>
|
||||
|
||||
<Area>
|
||||
<span slot="header">
|
||||
<a href='/users/{userData.username}'>
|
||||
{userData.username}
|
||||
</a>
|
||||
</span>
|
||||
<span slot="main">
|
||||
<p>
|
||||
<b>Reputation:</b> {userData.reputation}
|
||||
</p>
|
||||
<p>
|
||||
<b>Upvotes:</b> {userData.upvotes}
|
||||
</p>
|
||||
<p>
|
||||
<b>Downvotes:</b> {userData.downvotes}
|
||||
</p>
|
||||
</span>
|
||||
<span slot="footer">
|
||||
|
||||
</span>
|
||||
</Area>
|
||||
|
||||
<h2>Posts</h2>
|
||||
|
||||
{#each data.postJson.data as post}
|
||||
<Post
|
||||
success={post.success}
|
||||
username={post.username}
|
||||
content={post.content}
|
||||
upvotes={post.upvotes}
|
||||
downvotes={post.downvotes}
|
||||
id={post.id}
|
||||
></Post>
|
||||
{/each}
|
||||
|
||||
<p>
|
||||
<a data-sveltekit-reload href='?page={data.id+1}'>Next page</a>
|
||||
</p>
|
||||
<p></p>
|
Loading…
Add table
Add a link
Reference in a new issue