From 5f36ff9952a968f1d8ecae9da41e0175457fed86 Mon Sep 17 00:00:00 2001 From: Gautham Krishna Date: Fri, 6 Oct 2023 03:52:02 +0530 Subject: [PATCH 01/57] get_user api function --- src/lib/api.ts | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/src/lib/api.ts b/src/lib/api.ts index f58ee08..0b3ab0b 100644 --- a/src/lib/api.ts +++ b/src/lib/api.ts @@ -39,3 +39,17 @@ export async function logout(session_id: string) { }); return { data, error }; } + +export async function get_user(user_id: string, session_id: string) { + const { data, error } = await GET('/user/{user_id}', { + params: { + header: { + 'session-id': session_id + }, + path: { + user_id: user_id + } + } + }); + return { data, error }; +} From d43a0a4f8f32b800f956640336237c4a6e77a69f Mon Sep 17 00:00:00 2001 From: Gautham Krishna Date: Fri, 6 Oct 2023 03:53:27 +0530 Subject: [PATCH 02/57] user page loading with validation --- src/routes/user/[slug]/+page.server.ts | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) create mode 100644 src/routes/user/[slug]/+page.server.ts diff --git a/src/routes/user/[slug]/+page.server.ts b/src/routes/user/[slug]/+page.server.ts new file mode 100644 index 0000000..9f01e25 --- /dev/null +++ b/src/routes/user/[slug]/+page.server.ts @@ -0,0 +1,23 @@ +import { error } from '@sveltejs/kit'; +import * as api from '$lib/api'; +export async function load({ params, locals }) { + if ( + /^[0-9a-f]{8}-[0-9a-f]{4}-[0-5][0-9a-f]{3}-[089ab][0-9a-f]{3}-[0-9a-f]{12}$/i.test(params.slug) + ) { + if (locals) { + const { session_id, user_id } = { + session_id: locals.user.data['session-id'], + user_id: params.slug + }; + const res = await api.get_user(user_id, locals.session_id); + if (res.error) { + // throwing error for user not found + throw error(404, 'User Not Found'); + } else { + return res.data; + } + } + } + //throwing error for invalid user id + throw error(400, 'Invalid User ID'); +} From 05386dca92ac72e45ebd86d4ee8260f488df5b01 Mon Sep 17 00:00:00 2001 From: Gautham Krishna Date: Fri, 6 Oct 2023 16:36:31 +0530 Subject: [PATCH 03/57] user link send to userpage --- src/lib/components/Navbar.svelte | 38 +++++++++++++++++--------------- 1 file changed, 20 insertions(+), 18 deletions(-) diff --git a/src/lib/components/Navbar.svelte b/src/lib/components/Navbar.svelte index 3bfad45..c5bb347 100644 --- a/src/lib/components/Navbar.svelte +++ b/src/lib/components/Navbar.svelte @@ -8,7 +8,7 @@ // Avatar Data let signedin = $page.data.user != null; - let username = $page.data.user ? $page.data.user.username : null; + let user = $page.data.user ? $page.data.user : null; let initials = $page.data.user ? $page.data.user.username.slice(0, 2) : null; // Logout function @@ -94,24 +94,26 @@ -
- -
- Theme -
-
- -
- + {#if signedin}
-
+ class="card p-4 w-72 shadow-xl border-surface-900-50-token border-2 flex-col gap" + data-popup="popupFeatured" + > + +
+ Theme +
+
+ +
+ +
+
+ {/if}
{#if signedin} From b8aa05636b910a5a1bf5e9e8457175691635bb5e Mon Sep 17 00:00:00 2001 From: Gautham Krishna Date: Fri, 6 Oct 2023 16:36:51 +0530 Subject: [PATCH 04/57] user component made --- src/lib/components/User.svelte | 49 ++++++++++++++++++++++++++++++++++ 1 file changed, 49 insertions(+) create mode 100644 src/lib/components/User.svelte diff --git a/src/lib/components/User.svelte b/src/lib/components/User.svelte new file mode 100644 index 0000000..d9b5e4d --- /dev/null +++ b/src/lib/components/User.svelte @@ -0,0 +1,49 @@ + + +
+
+
+
+
+
+ +
+
+ {username} +
+
+
+
+
+
{follower_count}
+
Followers
+
+
+
{following_count}
+
Following
+
+
+
{posts_count}
+
Posts
+
+
+
+
+ a member since {since} +
+
+
From f7ff5339973e85c870cf2d00512dfe7451b3a9e5 Mon Sep 17 00:00:00 2001 From: Gautham Krishna Date: Fri, 6 Oct 2023 16:37:31 +0530 Subject: [PATCH 05/57] basic error page made --- src/routes/user/+error.svelte | 5 +++++ 1 file changed, 5 insertions(+) create mode 100644 src/routes/user/+error.svelte diff --git a/src/routes/user/+error.svelte b/src/routes/user/+error.svelte new file mode 100644 index 0000000..8b149ac --- /dev/null +++ b/src/routes/user/+error.svelte @@ -0,0 +1,5 @@ + + +

{$page.data.status}: {$page.error?.message}

From c5fdf76993f22df9dd767ed67384cb1d5269c039 Mon Sep 17 00:00:00 2001 From: Gautham Krishna Date: Fri, 6 Oct 2023 16:44:42 +0530 Subject: [PATCH 06/57] updated basic user page --- src/routes/user/[slug]/+page.svelte | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) create mode 100644 src/routes/user/[slug]/+page.svelte diff --git a/src/routes/user/[slug]/+page.svelte b/src/routes/user/[slug]/+page.svelte new file mode 100644 index 0000000..f23ad13 --- /dev/null +++ b/src/routes/user/[slug]/+page.svelte @@ -0,0 +1,20 @@ + + +
+ +
+
+ +
+
+
From 8999d7262176349302ae8b4a5d0c7036d5648660 Mon Sep 17 00:00:00 2001 From: Gautham Krishna Date: Fri, 6 Oct 2023 17:27:58 +0530 Subject: [PATCH 07/57] increased user component reactivity --- src/lib/components/User.svelte | 37 ++++++++++++++++------------- src/routes/user/[slug]/+page.svelte | 2 +- 2 files changed, 22 insertions(+), 17 deletions(-) diff --git a/src/lib/components/User.svelte b/src/lib/components/User.svelte index d9b5e4d..ab32631 100644 --- a/src/lib/components/User.svelte +++ b/src/lib/components/User.svelte @@ -10,13 +10,13 @@
-
-
-
+
+
+
-
-
-
{follower_count}
-
Followers
-
-
-
{following_count}
-
Following
-
-
-
{posts_count}
-
Posts
+
+
+
+ +
Followers
+
{follower_count}
+
+
+ +
Following
+
{following_count}
+
+
+ +
Posts
+
{posts_count}
+
diff --git a/src/routes/user/[slug]/+page.svelte b/src/routes/user/[slug]/+page.svelte index f23ad13..a1755fa 100644 --- a/src/routes/user/[slug]/+page.svelte +++ b/src/routes/user/[slug]/+page.svelte @@ -7,7 +7,7 @@
-
+
Date: Sat, 14 Oct 2023 10:46:52 +0530 Subject: [PATCH 08/57] cookie deletion on error --- src/routes/logout/+page.server.ts | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/routes/logout/+page.server.ts b/src/routes/logout/+page.server.ts index 0c1c52b..a72337d 100644 --- a/src/routes/logout/+page.server.ts +++ b/src/routes/logout/+page.server.ts @@ -6,14 +6,16 @@ export async function load({ cookies, locals }) { const user = locals.user ? JSON.parse(atob(cookies.get('user'))) : null; const sessionid = user.data ? user.data['session-id'] : null; const response = await api.logout(sessionid); + cookies.delete('user'); + locals.user = null; if (response.error) { console.log(response.error); throw redirect(307, '/'); } console.log(response.data); - cookies.delete('user'); - locals.user = null; throw redirect(307, '/'); } + cookies.delete('user'); + locals.user = null; throw redirect(307, '/'); } From f4194194c782786a90341988b8780139c2a9b26d Mon Sep 17 00:00:00 2001 From: Gautham Krishna Date: Sat, 14 Oct 2023 10:47:27 +0530 Subject: [PATCH 09/57] ui fixed for small screens --- src/routes/login/+page.svelte | 7 ++++--- src/routes/signup/+page.svelte | 22 +++++++++++++--------- 2 files changed, 17 insertions(+), 12 deletions(-) diff --git a/src/routes/login/+page.svelte b/src/routes/login/+page.svelte index ee4f761..fbc7ed8 100644 --- a/src/routes/login/+page.svelte +++ b/src/routes/login/+page.svelte @@ -37,8 +37,8 @@ -
-
+
+
@@ -77,7 +77,8 @@
- Don't have an account ? + Don't have an account ?
+
Sign Up Here
diff --git a/src/routes/signup/+page.svelte b/src/routes/signup/+page.svelte index db77672..0eaabe5 100644 --- a/src/routes/signup/+page.svelte +++ b/src/routes/signup/+page.svelte @@ -12,12 +12,12 @@ -
-
+
+
- Sign Up + Sign Up
@@ -76,7 +76,7 @@
-
+ {#if form?.message} -
+
This account already exists
{/if} @@ -105,10 +109,10 @@
-
+
Already have an account ? - Login Here + Login Here
From 9d4b44eac90746c474b7309ee47308d40cab1274 Mon Sep 17 00:00:00 2001 From: Gautham Krishna Date: Sat, 14 Oct 2023 10:48:11 +0530 Subject: [PATCH 10/57] type errors fixed in hooks --- src/hooks.server.ts | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/hooks.server.ts b/src/hooks.server.ts index bcef03a..d162c63 100644 --- a/src/hooks.server.ts +++ b/src/hooks.server.ts @@ -1,8 +1,14 @@ import type { App } from './app'; +import type { RequestEvent } from '@sveltejs/kit'; +interface UserLocals extends RequestEvent { + locals: { + user: App.Locals['user'] | null; + }; +} /** @type {import('@sveltejs/kit').Handle} */ export const handle = ({ event, resolve }) => { const user = event.cookies.get('user'); - event.locals.user = user ? JSON.parse(atob(user)) : null; + (event as UserLocals).locals.user = user ? JSON.parse(atob(user)) : null; return resolve(event); }; From faac8dc7b2b2d1a704b6887c6d47a51636d9a7bf Mon Sep 17 00:00:00 2001 From: Gautham Krishna Date: Sat, 14 Oct 2023 10:48:32 +0530 Subject: [PATCH 11/57] Basic User page done --- src/routes/user/[slug]/+page.server.ts | 13 +++++++++---- src/routes/user/[slug]/+page.svelte | 9 ++++++++- 2 files changed, 17 insertions(+), 5 deletions(-) diff --git a/src/routes/user/[slug]/+page.server.ts b/src/routes/user/[slug]/+page.server.ts index 9f01e25..659245b 100644 --- a/src/routes/user/[slug]/+page.server.ts +++ b/src/routes/user/[slug]/+page.server.ts @@ -1,20 +1,25 @@ import { error } from '@sveltejs/kit'; import * as api from '$lib/api'; + export async function load({ params, locals }) { if ( /^[0-9a-f]{8}-[0-9a-f]{4}-[0-5][0-9a-f]{3}-[089ab][0-9a-f]{3}-[0-9a-f]{12}$/i.test(params.slug) ) { - if (locals) { + if (locals && locals.user) { const { session_id, user_id } = { - session_id: locals.user.data['session-id'], + session_id: locals.session_id, user_id: params.slug }; - const res = await api.get_user(user_id, locals.session_id); + const res = await api.get_user(user_id, session_id); if (res.error) { // throwing error for user not found throw error(404, 'User Not Found'); } else { - return res.data; + if (res.data) { + res.data['sameuser'] = locals.user.data.user.id === user_id; + + return res.data; + } } } } diff --git a/src/routes/user/[slug]/+page.svelte b/src/routes/user/[slug]/+page.svelte index a1755fa..649e89c 100644 --- a/src/routes/user/[slug]/+page.svelte +++ b/src/routes/user/[slug]/+page.svelte @@ -7,14 +7,21 @@
-
+
+ {#if data.posts_count == 0} +
+ This User has no Posts +
+ {/if}
From 9f6e85239718a8243c0940808a26a85946ecba1f Mon Sep 17 00:00:00 2001 From: Gautham Krishna Date: Sat, 14 Oct 2023 12:01:51 +0530 Subject: [PATCH 12/57] added better user drawer --- src/lib/components/Navbar.svelte | 46 +++++++++++++++++++++++++------- 1 file changed, 37 insertions(+), 9 deletions(-) diff --git a/src/lib/components/Navbar.svelte b/src/lib/components/Navbar.svelte index c5bb347..41ca8f8 100644 --- a/src/lib/components/Navbar.svelte +++ b/src/lib/components/Navbar.svelte @@ -2,7 +2,6 @@ import { Avatar, LightSwitch, popup } from '@skeletonlabs/skeleton'; import type { PopupSettings } from '@skeletonlabs/skeleton'; import { page } from '$app/stores'; - import { redirect } from '@sveltejs/kit'; let drawerOpen = false; @@ -95,20 +94,49 @@
{#if signedin} +
-
- + -
- Theme +
+
Theme
+ +
+ +
-
- +
+
-
From c770b658a40ec53da49c204e763d5eae718c5f75 Mon Sep 17 00:00:00 2001 From: Gautham Krishna Date: Sat, 14 Oct 2023 12:02:12 +0530 Subject: [PATCH 13/57] makepost component made --- src/lib/components/makepost.svelte | 68 ++++++++++++++++++++++++++++++ 1 file changed, 68 insertions(+) create mode 100644 src/lib/components/makepost.svelte diff --git a/src/lib/components/makepost.svelte b/src/lib/components/makepost.svelte new file mode 100644 index 0000000..3b48855 --- /dev/null +++ b/src/lib/components/makepost.svelte @@ -0,0 +1,68 @@ + + +
+
+
+
+ +
+ Title + +
+ +
+ Description + +
+
+ File + + + +
+
+ +
+
+
+
+
From 158d4ea06211407fe4811b4024af4bfb1c8173e1 Mon Sep 17 00:00:00 2001 From: Gautham Krishna Date: Sat, 14 Oct 2023 12:02:32 +0530 Subject: [PATCH 14/57] since comment changed for user component --- src/lib/components/User.svelte | 44 ++++++++++++++++++++++++++++++---- 1 file changed, 40 insertions(+), 4 deletions(-) diff --git a/src/lib/components/User.svelte b/src/lib/components/User.svelte index ab32631..32b2f12 100644 --- a/src/lib/components/User.svelte +++ b/src/lib/components/User.svelte @@ -1,12 +1,35 @@
@@ -47,8 +70,21 @@
-
- a member since {since} + + {#if !sameuser} + {#if is_following} +
+ +
+ {:else} +
+ +
+ {/if} + {/if}
From 9a468f3184eaee681a0221bd7ac55e28a07bb3f3 Mon Sep 17 00:00:00 2001 From: Gautham Krishna Date: Sat, 14 Oct 2023 12:02:52 +0530 Subject: [PATCH 15/57] cookie deletion only on success --- src/routes/logout/+page.server.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/routes/logout/+page.server.ts b/src/routes/logout/+page.server.ts index a72337d..ac76457 100644 --- a/src/routes/logout/+page.server.ts +++ b/src/routes/logout/+page.server.ts @@ -6,12 +6,12 @@ export async function load({ cookies, locals }) { const user = locals.user ? JSON.parse(atob(cookies.get('user'))) : null; const sessionid = user.data ? user.data['session-id'] : null; const response = await api.logout(sessionid); - cookies.delete('user'); - locals.user = null; if (response.error) { console.log(response.error); throw redirect(307, '/'); } + cookies.delete('user'); + locals.user = null; console.log(response.data); throw redirect(307, '/'); } From 4114ccbde7f07d6e159e482f8fa689ecbf025ca0 Mon Sep 17 00:00:00 2001 From: Gautham Krishna Date: Sat, 14 Oct 2023 12:03:13 +0530 Subject: [PATCH 16/57] basic feed layout --- src/routes/feed/+page.server.ts | 10 ++++++++++ src/routes/feed/+page.svelte | 11 +++++++++++ 2 files changed, 21 insertions(+) create mode 100644 src/routes/feed/+page.server.ts create mode 100644 src/routes/feed/+page.svelte diff --git a/src/routes/feed/+page.server.ts b/src/routes/feed/+page.server.ts new file mode 100644 index 0000000..4b2c271 --- /dev/null +++ b/src/routes/feed/+page.server.ts @@ -0,0 +1,10 @@ +import type { App } from '../../app'; +export async function load({ locals }: { locals: App.Locals }) { + if (locals && locals.user) { + return { + user: locals.user.data.user + }; + } else { + // throw redirect(307, '/'); + } +} diff --git a/src/routes/feed/+page.svelte b/src/routes/feed/+page.svelte new file mode 100644 index 0000000..31e8d9f --- /dev/null +++ b/src/routes/feed/+page.svelte @@ -0,0 +1,11 @@ + + +
+ +
+
+ +
From 1e1f941535bcae94767cbfd116ba4e65a23ffb32 Mon Sep 17 00:00:00 2001 From: Gautham Krishna Date: Sat, 14 Oct 2023 12:03:41 +0530 Subject: [PATCH 17/57] changed theme --- src/app.html | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/app.html b/src/app.html index e1dde07..9813995 100644 --- a/src/app.html +++ b/src/app.html @@ -1,12 +1,12 @@ - + %sveltekit.head% - +
%sveltekit.body%
From 5298235ad7ae56421e33ccbf33ead4c01f4742b5 Mon Sep 17 00:00:00 2001 From: Gautham Krishna Date: Sat, 14 Oct 2023 12:04:03 +0530 Subject: [PATCH 18/57] deafult dark theme --- src/app.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/app.html b/src/app.html index 9813995..ca08b04 100644 --- a/src/app.html +++ b/src/app.html @@ -1,5 +1,5 @@ - + From 701e34bbbca95e11b49abb07793f1ca50ea5e132 Mon Sep 17 00:00:00 2001 From: Gautham Krishna Date: Sat, 14 Oct 2023 12:05:18 +0530 Subject: [PATCH 19/57] dark theme class added --- src/app.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/app.html b/src/app.html index ca08b04..0297ac7 100644 --- a/src/app.html +++ b/src/app.html @@ -1,5 +1,5 @@ - + From 73a7902edc74bd28e75caf06a2b052bd4eaae101 Mon Sep 17 00:00:00 2001 From: Gautham Krishna Date: Wed, 18 Oct 2023 11:48:38 +0530 Subject: [PATCH 20/57] placeholder for posts --- src/lib/components/loadingpost.svelte | 12 ++++++++++++ 1 file changed, 12 insertions(+) create mode 100644 src/lib/components/loadingpost.svelte diff --git a/src/lib/components/loadingpost.svelte b/src/lib/components/loadingpost.svelte new file mode 100644 index 0000000..26b9805 --- /dev/null +++ b/src/lib/components/loadingpost.svelte @@ -0,0 +1,12 @@ +
+
+
+
+
+
+
+
+
+
+
+
From c1de9f421a6af15016560a693a454609aaec0ceb Mon Sep 17 00:00:00 2001 From: Gautham Krishna Date: Wed, 18 Oct 2023 11:49:21 +0530 Subject: [PATCH 21/57] logs removed from components --- src/lib/components/Navbar.svelte | 1 - src/lib/components/post.svelte | 2 +- 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/src/lib/components/Navbar.svelte b/src/lib/components/Navbar.svelte index 41ca8f8..af42f9e 100644 --- a/src/lib/components/Navbar.svelte +++ b/src/lib/components/Navbar.svelte @@ -35,7 +35,6 @@ class="btn-icon lg:hidden" on:click={() => { drawerOpen = !drawerOpen; - console.log(drawerOpen); }} >
-
+
From 35c5ecf1dd043456768f3e39215a336108e339a7 Mon Sep 17 00:00:00 2001 From: Gautham Krishna Date: Wed, 18 Oct 2023 11:49:32 +0530 Subject: [PATCH 22/57] api function to get posts --- src/lib/api.ts | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/src/lib/api.ts b/src/lib/api.ts index 0b3ab0b..1c9167f 100644 --- a/src/lib/api.ts +++ b/src/lib/api.ts @@ -53,3 +53,15 @@ export async function get_user(user_id: string, session_id: string) { }); return { data, error }; } + +export async function get_posts(take: number, cursor?: string) { + const { data, error } = await GET('/post/', { + params: { + header: { + take: take, + cursor: cursor + } + } + }); + return { data, error }; +} From ab16609d888277e2aa46fcd01000c9f168dc34d5 Mon Sep 17 00:00:00 2001 From: Gautham Krishna Date: Wed, 18 Oct 2023 11:49:43 +0530 Subject: [PATCH 23/57] feed page --- src/routes/feed/+page.server.ts | 3 +- src/routes/feed/+page.svelte | 52 ++++++++++++++++++++++++++++++++- 2 files changed, 53 insertions(+), 2 deletions(-) diff --git a/src/routes/feed/+page.server.ts b/src/routes/feed/+page.server.ts index 4b2c271..d1fed66 100644 --- a/src/routes/feed/+page.server.ts +++ b/src/routes/feed/+page.server.ts @@ -1,10 +1,11 @@ import type { App } from '../../app'; +import { redirect } from '@sveltejs/kit'; export async function load({ locals }: { locals: App.Locals }) { if (locals && locals.user) { return { user: locals.user.data.user }; } else { - // throw redirect(307, '/'); + throw redirect(307, '/'); } } diff --git a/src/routes/feed/+page.svelte b/src/routes/feed/+page.svelte index 31e8d9f..1713658 100644 --- a/src/routes/feed/+page.svelte +++ b/src/routes/feed/+page.svelte @@ -1,11 +1,61 @@
-
+{#await fetchMore()} +
+ +
+{:then data} + {#each data as post} + {post.id} + {/each} + +{/await} +{#each data as item} +
+ {item.id} +
+ +{/each} +
+ +
From a4047f45f9c78b3e0741f973c8e0a81d7a967996 Mon Sep 17 00:00:00 2001 From: Gautham Krishna Date: Wed, 18 Oct 2023 11:50:06 +0530 Subject: [PATCH 24/57] user sent to feed on login --- src/routes/login/+page.server.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/routes/login/+page.server.ts b/src/routes/login/+page.server.ts index 001a4ac..dd50d6f 100644 --- a/src/routes/login/+page.server.ts +++ b/src/routes/login/+page.server.ts @@ -27,7 +27,7 @@ export const actions = { if (responseData.data) { const value = btoa(JSON.stringify(responseData)); cookies.set('user', value, { path: '/', maxAge: MAX_COOKIE_AGE }); - throw redirect(300, '/'); + throw redirect(300, '/feed'); } else { return fail(400, { message: 'Response data is undefined' }); } From 1c5eb3e0f84cd7effd9b254ca7532793e093649c Mon Sep 17 00:00:00 2001 From: Gautham Krishna Date: Wed, 18 Oct 2023 11:50:25 +0530 Subject: [PATCH 25/57] added node adapter --- package-lock.json | 226 ++++++++++++++++++++++++++++++++++++++++++++++ package.json | 1 + 2 files changed, 227 insertions(+) diff --git a/package-lock.json b/package-lock.json index 4a09c0b..bf81230 100644 --- a/package-lock.json +++ b/package-lock.json @@ -16,6 +16,7 @@ "@skeletonlabs/skeleton": "2.0.0", "@skeletonlabs/tw-plugin": "0.1.0", "@sveltejs/adapter-auto": "^2.0.0", + "@sveltejs/adapter-node": "^1.3.1", "@sveltejs/kit": "^1.20.4", "@tailwindcss/forms": "0.5.6", "@tailwindcss/typography": "0.5.10", @@ -643,6 +644,171 @@ "integrity": "sha512-C16M+IYz0rgRhWZdCmK+h58JMv8vijAA61gmz2rspCSwKwzBebpdcsiUmwrtJRdphuY30i6BSLEOP8ppbNLyLg==", "dev": true }, + "node_modules/@rollup/plugin-commonjs": { + "version": "25.0.5", + "resolved": "https://registry.npmjs.org/@rollup/plugin-commonjs/-/plugin-commonjs-25.0.5.tgz", + "integrity": "sha512-xY8r/A9oisSeSuLCTfhssyDjo9Vp/eDiRLXkg1MXCcEEgEjPmLU+ZyDB20OOD0NlyDa/8SGbK5uIggF5XTx77w==", + "dev": true, + "dependencies": { + "@rollup/pluginutils": "^5.0.1", + "commondir": "^1.0.1", + "estree-walker": "^2.0.2", + "glob": "^8.0.3", + "is-reference": "1.2.1", + "magic-string": "^0.27.0" + }, + "engines": { + "node": ">=14.0.0" + }, + "peerDependencies": { + "rollup": "^2.68.0||^3.0.0||^4.0.0" + }, + "peerDependenciesMeta": { + "rollup": { + "optional": true + } + } + }, + "node_modules/@rollup/plugin-commonjs/node_modules/brace-expansion": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-2.0.1.tgz", + "integrity": "sha512-XnAIvQ8eM+kC6aULx6wuQiwVsnzsi9d3WxzV3FpWTGA19F621kwdbsAcFKXgKUHZWsy+mY6iL1sHTxWEFCytDA==", + "dev": true, + "dependencies": { + "balanced-match": "^1.0.0" + } + }, + "node_modules/@rollup/plugin-commonjs/node_modules/estree-walker": { + "version": "2.0.2", + "resolved": "https://registry.npmjs.org/estree-walker/-/estree-walker-2.0.2.tgz", + "integrity": "sha512-Rfkk/Mp/DL7JVje3u18FxFujQlTNR2q6QfMSMB7AvCBx91NGj/ba3kCfza0f6dVDbw7YlRf/nDrn7pQrCCyQ/w==", + "dev": true + }, + "node_modules/@rollup/plugin-commonjs/node_modules/glob": { + "version": "8.1.0", + "resolved": "https://registry.npmjs.org/glob/-/glob-8.1.0.tgz", + "integrity": "sha512-r8hpEjiQEYlF2QU0df3dS+nxxSIreXQS1qRhMJM0Q5NDdR386C7jb7Hwwod8Fgiuex+k0GFjgft18yvxm5XoCQ==", + "dev": true, + "dependencies": { + "fs.realpath": "^1.0.0", + "inflight": "^1.0.4", + "inherits": "2", + "minimatch": "^5.0.1", + "once": "^1.3.0" + }, + "engines": { + "node": ">=12" + }, + "funding": { + "url": "https://github.com/sponsors/isaacs" + } + }, + "node_modules/@rollup/plugin-commonjs/node_modules/is-reference": { + "version": "1.2.1", + "resolved": "https://registry.npmjs.org/is-reference/-/is-reference-1.2.1.tgz", + "integrity": "sha512-U82MsXXiFIrjCK4otLT+o2NA2Cd2g5MLoOVXUZjIOhLurrRxpEXzI8O0KZHr3IjLvlAH1kTPYSuqer5T9ZVBKQ==", + "dev": true, + "dependencies": { + "@types/estree": "*" + } + }, + "node_modules/@rollup/plugin-commonjs/node_modules/magic-string": { + "version": "0.27.0", + "resolved": "https://registry.npmjs.org/magic-string/-/magic-string-0.27.0.tgz", + "integrity": "sha512-8UnnX2PeRAPZuN12svgR9j7M1uWMovg/CEnIwIG0LFkXSJJe4PdfUGiTGl8V9bsBHFUtfVINcSyYxd7q+kx9fA==", + "dev": true, + "dependencies": { + "@jridgewell/sourcemap-codec": "^1.4.13" + }, + "engines": { + "node": ">=12" + } + }, + "node_modules/@rollup/plugin-commonjs/node_modules/minimatch": { + "version": "5.1.6", + "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-5.1.6.tgz", + "integrity": "sha512-lKwV/1brpG6mBUFHtb7NUmtABCb2WZZmm2wNiOA5hAb8VdCS4B3dtMWyvcoViccwAW/COERjXLt0zP1zXUN26g==", + "dev": true, + "dependencies": { + "brace-expansion": "^2.0.1" + }, + "engines": { + "node": ">=10" + } + }, + "node_modules/@rollup/plugin-json": { + "version": "6.0.1", + "resolved": "https://registry.npmjs.org/@rollup/plugin-json/-/plugin-json-6.0.1.tgz", + "integrity": "sha512-RgVfl5hWMkxN1h/uZj8FVESvPuBJ/uf6ly6GTj0GONnkfoBN5KC0MSz+PN2OLDgYXMhtG0mWpTrkiOjoxAIevw==", + "dev": true, + "dependencies": { + "@rollup/pluginutils": "^5.0.1" + }, + "engines": { + "node": ">=14.0.0" + }, + "peerDependencies": { + "rollup": "^1.20.0||^2.0.0||^3.0.0||^4.0.0" + }, + "peerDependenciesMeta": { + "rollup": { + "optional": true + } + } + }, + "node_modules/@rollup/plugin-node-resolve": { + "version": "15.2.3", + "resolved": "https://registry.npmjs.org/@rollup/plugin-node-resolve/-/plugin-node-resolve-15.2.3.tgz", + "integrity": "sha512-j/lym8nf5E21LwBT4Df1VD6hRO2L2iwUeUmP7litikRsVp1H6NWx20NEp0Y7su+7XGc476GnXXc4kFeZNGmaSQ==", + "dev": true, + "dependencies": { + "@rollup/pluginutils": "^5.0.1", + "@types/resolve": "1.20.2", + "deepmerge": "^4.2.2", + "is-builtin-module": "^3.2.1", + "is-module": "^1.0.0", + "resolve": "^1.22.1" + }, + "engines": { + "node": ">=14.0.0" + }, + "peerDependencies": { + "rollup": "^2.78.0||^3.0.0||^4.0.0" + }, + "peerDependenciesMeta": { + "rollup": { + "optional": true + } + } + }, + "node_modules/@rollup/pluginutils": { + "version": "5.0.5", + "resolved": "https://registry.npmjs.org/@rollup/pluginutils/-/pluginutils-5.0.5.tgz", + "integrity": "sha512-6aEYR910NyP73oHiJglti74iRyOwgFU4x3meH/H8OJx6Ry0j6cOVZ5X/wTvub7G7Ao6qaHBEaNsV3GLJkSsF+Q==", + "dev": true, + "dependencies": { + "@types/estree": "^1.0.0", + "estree-walker": "^2.0.2", + "picomatch": "^2.3.1" + }, + "engines": { + "node": ">=14.0.0" + }, + "peerDependencies": { + "rollup": "^1.20.0||^2.0.0||^3.0.0||^4.0.0" + }, + "peerDependenciesMeta": { + "rollup": { + "optional": true + } + } + }, + "node_modules/@rollup/pluginutils/node_modules/estree-walker": { + "version": "2.0.2", + "resolved": "https://registry.npmjs.org/estree-walker/-/estree-walker-2.0.2.tgz", + "integrity": "sha512-Rfkk/Mp/DL7JVje3u18FxFujQlTNR2q6QfMSMB7AvCBx91NGj/ba3kCfza0f6dVDbw7YlRf/nDrn7pQrCCyQ/w==", + "dev": true + }, "node_modules/@skeletonlabs/skeleton": { "version": "2.0.0", "resolved": "https://registry.npmjs.org/@skeletonlabs/skeleton/-/skeleton-2.0.0.tgz", @@ -676,6 +842,21 @@ "@sveltejs/kit": "^1.0.0" } }, + "node_modules/@sveltejs/adapter-node": { + "version": "1.3.1", + "resolved": "https://registry.npmjs.org/@sveltejs/adapter-node/-/adapter-node-1.3.1.tgz", + "integrity": "sha512-A0VgRQDCDPzdLNoiAbcOxGw4zT1Mc+n1LwT1OmO350R7WxrEqdMUChPPOd1iMfIDWlP4ie6E2d/WQf5es2d4Zw==", + "dev": true, + "dependencies": { + "@rollup/plugin-commonjs": "^25.0.0", + "@rollup/plugin-json": "^6.0.0", + "@rollup/plugin-node-resolve": "^15.0.1", + "rollup": "^3.7.0" + }, + "peerDependencies": { + "@sveltejs/kit": "^1.0.0" + } + }, "node_modules/@sveltejs/kit": { "version": "1.24.1", "resolved": "https://registry.npmjs.org/@sveltejs/kit/-/kit-1.24.1.tgz", @@ -804,6 +985,12 @@ "integrity": "sha512-SnHmG9wN1UVmagJOnyo/qkk0Z7gejYxOYYmaAwr5u2yFYfsupN3sg10kyzN8Hep/2zbHxCnsumxOoRIRMBwKCg==", "dev": true }, + "node_modules/@types/resolve": { + "version": "1.20.2", + "resolved": "https://registry.npmjs.org/@types/resolve/-/resolve-1.20.2.tgz", + "integrity": "sha512-60BCwRFOZCQhDncwQdxxeOEEkbc5dIMccYLwbxsS4TUNeVECQ/pBJ0j09mrHOl/JJvpRPGwO9SvE4nR2Nb/a4Q==", + "dev": true + }, "node_modules/@types/semver": { "version": "7.5.1", "resolved": "https://registry.npmjs.org/@types/semver/-/semver-7.5.1.tgz", @@ -1232,6 +1419,18 @@ "node": "*" } }, + "node_modules/builtin-modules": { + "version": "3.3.0", + "resolved": "https://registry.npmjs.org/builtin-modules/-/builtin-modules-3.3.0.tgz", + "integrity": "sha512-zhaCDicdLuWN5UbN5IMnFqNMhNfo919sH85y2/ea+5Yg9TsTkeZxpL+JLbp6cgYFS4sRLp3YV4S6yDuqVWHYOw==", + "dev": true, + "engines": { + "node": ">=6" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, "node_modules/busboy": { "version": "1.6.0", "resolved": "https://registry.npmjs.org/busboy/-/busboy-1.6.0.tgz", @@ -1377,6 +1576,12 @@ "node": ">= 6" } }, + "node_modules/commondir": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/commondir/-/commondir-1.0.1.tgz", + "integrity": "sha512-W9pAhw0ja1Edb5GVdIF1mjZw/ASI0AlShXM83UUGe2DVr5TdAPEA1OA8m/g8zWp9x6On7gqufY+FatDbC3MDQg==", + "dev": true + }, "node_modules/concat-map": { "version": "0.0.1", "resolved": "https://registry.npmjs.org/concat-map/-/concat-map-0.0.1.tgz", @@ -2194,6 +2399,21 @@ "node": ">=8" } }, + "node_modules/is-builtin-module": { + "version": "3.2.1", + "resolved": "https://registry.npmjs.org/is-builtin-module/-/is-builtin-module-3.2.1.tgz", + "integrity": "sha512-BSLE3HnV2syZ0FK0iMA/yUGplUeMmNz4AW5fnTunbCIqZi4vG3WjJT9FHMy5D69xmAYBHXQhJdALdpwVxV501A==", + "dev": true, + "dependencies": { + "builtin-modules": "^3.3.0" + }, + "engines": { + "node": ">=6" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, "node_modules/is-core-module": { "version": "2.13.0", "resolved": "https://registry.npmjs.org/is-core-module/-/is-core-module-2.13.0.tgz", @@ -2227,6 +2447,12 @@ "node": ">=0.10.0" } }, + "node_modules/is-module": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/is-module/-/is-module-1.0.0.tgz", + "integrity": "sha512-51ypPSPCoTEIN9dy5Oy+h4pShgJmPCygKfyRCISBI+JoWT/2oJvK8QPxmwv7b/p239jXrm9M1mlQbyKJ5A152g==", + "dev": true + }, "node_modules/is-number": { "version": "7.0.0", "resolved": "https://registry.npmjs.org/is-number/-/is-number-7.0.0.tgz", diff --git a/package.json b/package.json index 4132743..0e6b928 100644 --- a/package.json +++ b/package.json @@ -17,6 +17,7 @@ "@skeletonlabs/skeleton": "2.0.0", "@skeletonlabs/tw-plugin": "0.1.0", "@sveltejs/adapter-auto": "^2.0.0", + "@sveltejs/adapter-node": "^1.3.1", "@sveltejs/kit": "^1.20.4", "@tailwindcss/forms": "0.5.6", "@tailwindcss/typography": "0.5.10", From 194e78ce04e0c8019a2be48fec7461391b3525cb Mon Sep 17 00:00:00 2001 From: Gautham Krishna Date: Wed, 18 Oct 2023 11:50:36 +0530 Subject: [PATCH 26/57] temp removal of footer --- src/routes/+layout.svelte | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/routes/+layout.svelte b/src/routes/+layout.svelte index 958fff8..b66f1f1 100644 --- a/src/routes/+layout.svelte +++ b/src/routes/+layout.svelte @@ -30,5 +30,5 @@ - Footer + From 5a29d2bc6cc19bf306b73435ee1b883eee8f3219 Mon Sep 17 00:00:00 2001 From: Gautham Krishna Date: Wed, 18 Oct 2023 11:51:12 +0530 Subject: [PATCH 27/57] placeholder on main page for testing --- src/routes/+page.server.ts | 4 +++- src/routes/+page.svelte | 4 +++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/src/routes/+page.server.ts b/src/routes/+page.server.ts index 15731d3..944ce8f 100644 --- a/src/routes/+page.server.ts +++ b/src/routes/+page.server.ts @@ -1,8 +1,10 @@ import type { App } from '../app'; + export async function load({ locals }: { locals: App.Locals }) { if (locals && locals.user) { + const user = locals.user.data.user; return { - user: locals.user.data.user + user: user }; } } diff --git a/src/routes/+page.svelte b/src/routes/+page.svelte index a82e4ce..7cce96e 100644 --- a/src/routes/+page.svelte +++ b/src/routes/+page.svelte @@ -1,14 +1,16 @@
-
+
+
From eb23f1f11cad4ccd2770be02bb187fcc8385cdb3 Mon Sep 17 00:00:00 2001 From: Gautham Krishna Date: Wed, 18 Oct 2023 11:51:36 +0530 Subject: [PATCH 28/57] deleting cookie without session in db also --- src/routes/logout/+page.server.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/routes/logout/+page.server.ts b/src/routes/logout/+page.server.ts index ac76457..a72337d 100644 --- a/src/routes/logout/+page.server.ts +++ b/src/routes/logout/+page.server.ts @@ -6,12 +6,12 @@ export async function load({ cookies, locals }) { const user = locals.user ? JSON.parse(atob(cookies.get('user'))) : null; const sessionid = user.data ? user.data['session-id'] : null; const response = await api.logout(sessionid); + cookies.delete('user'); + locals.user = null; if (response.error) { console.log(response.error); throw redirect(307, '/'); } - cookies.delete('user'); - locals.user = null; console.log(response.data); throw redirect(307, '/'); } From 6c145fb3ae28ada0e06737f860d8d062f8df7495 Mon Sep 17 00:00:00 2001 From: Gautham Krishna Date: Wed, 18 Oct 2023 11:51:58 +0530 Subject: [PATCH 29/57] importing node just incase --- svelte.config.js | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/svelte.config.js b/svelte.config.js index 1eac3be..a300235 100644 --- a/svelte.config.js +++ b/svelte.config.js @@ -1,14 +1,14 @@ import adapter from '@sveltejs/adapter-auto'; +import node from '@sveltejs/adapter-node'; import { vitePreprocess } from '@sveltejs/kit/vite'; - /** @type {import('@sveltejs/kit').Config} */ const config = { extensions: ['.svelte'], // Consult https://kit.svelte.dev/docs/integrations#preprocessors // for more information about preprocessors - preprocess: [ vitePreprocess()], - + preprocess: [vitePreprocess()], + kit: { // adapter-auto only supports some environments, see https://kit.svelte.dev/docs/adapter-auto for a list. // If your environment is not supported or you settled on a specific environment, switch out the adapter. @@ -16,4 +16,4 @@ const config = { adapter: adapter() } }; -export default config; \ No newline at end of file +export default config; From d1e4b25c24cfd7e70a3214bafb687a4921cf97d3 Mon Sep 17 00:00:00 2001 From: Gautham Krishna Date: Wed, 18 Oct 2023 11:53:51 +0530 Subject: [PATCH 30/57] changed z index for popup --- src/lib/components/Navbar.svelte | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/lib/components/Navbar.svelte b/src/lib/components/Navbar.svelte index af42f9e..60db3fa 100644 --- a/src/lib/components/Navbar.svelte +++ b/src/lib/components/Navbar.svelte @@ -95,7 +95,7 @@ {#if signedin}
From d206137bcdc1c4940bcba60f054c811b1de9aa5e Mon Sep 17 00:00:00 2001 From: Gautham Krishna Date: Wed, 18 Oct 2023 12:09:43 +0530 Subject: [PATCH 31/57] testing for posts removed --- src/routes/feed/+page.svelte | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/src/routes/feed/+page.svelte b/src/routes/feed/+page.svelte index 1713658..a12059d 100644 --- a/src/routes/feed/+page.svelte +++ b/src/routes/feed/+page.svelte @@ -18,19 +18,14 @@ loaded = res.data.count !== 10; cursor = res.data.cursor_id; newBatch = res.data.data; - console.log(newBatch); - console.log(loaded); } } - return newBatch; } $: { data = [...data, ...newBatch]; - console.log(data); } onMount(async () => { - const data = await fetchMore(); - console.log(data); + fetchMore(); }); From 1d09de0305c689e8e28d4c6b2b868297b20624cc Mon Sep 17 00:00:00 2001 From: Gautham Krishna Date: Wed, 18 Oct 2023 12:14:31 +0530 Subject: [PATCH 32/57] small changes --- src/routes/feed/+page.svelte | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/routes/feed/+page.svelte b/src/routes/feed/+page.svelte index a12059d..062898c 100644 --- a/src/routes/feed/+page.svelte +++ b/src/routes/feed/+page.svelte @@ -32,7 +32,7 @@
-{#await fetchMore()} +{#await newBatch}
From a42b464841e063674615a911205b49cdf49b6c9b Mon Sep 17 00:00:00 2001 From: Gautham Krishna Date: Wed, 18 Oct 2023 13:29:13 +0530 Subject: [PATCH 33/57] adding link to author page on component --- src/lib/components/post.svelte | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/lib/components/post.svelte b/src/lib/components/post.svelte index f24481d..9bc3aeb 100644 --- a/src/lib/components/post.svelte +++ b/src/lib/components/post.svelte @@ -3,6 +3,7 @@ export let rating: number; export let description: string; export let author: string; + export let author_id: string; let initials = author.slice(0, 2); import { Avatar } from '@skeletonlabs/skeleton'; @@ -11,7 +12,7 @@
- +
{author}
From b5dee69a8eb0a30da3e4e91f060fc735330d0e03 Mon Sep 17 00:00:00 2001 From: Gautham Krishna Date: Wed, 18 Oct 2023 13:29:27 +0530 Subject: [PATCH 34/57] feed fixing --- src/routes/+page.svelte | 2 +- src/routes/feed/+page.svelte | 5 +++-- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/src/routes/+page.svelte b/src/routes/+page.svelte index 7cce96e..3d8c306 100644 --- a/src/routes/+page.svelte +++ b/src/routes/+page.svelte @@ -9,7 +9,7 @@
- +
diff --git a/src/routes/feed/+page.svelte b/src/routes/feed/+page.svelte index 062898c..5fc32fc 100644 --- a/src/routes/feed/+page.svelte +++ b/src/routes/feed/+page.svelte @@ -19,6 +19,7 @@ cursor = res.data.cursor_id; newBatch = res.data.data; } + console.log(newBatch[0]); } } $: { @@ -32,13 +33,13 @@
-{#await newBatch} +{#await data}
{:then data} {#each data as post} - {post.id} + {post.title} {/each} {/await} From 3ffcb2118fa301240cfc52b644dc1d461dea4f35 Mon Sep 17 00:00:00 2001 From: Gautham Krishna Date: Wed, 18 Oct 2023 13:34:25 +0530 Subject: [PATCH 35/57] post layout added --- src/routes/feed/+page.svelte | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/src/routes/feed/+page.svelte b/src/routes/feed/+page.svelte index 5fc32fc..eae1f97 100644 --- a/src/routes/feed/+page.svelte +++ b/src/routes/feed/+page.svelte @@ -39,9 +39,14 @@
{:then data} {#each data as post} - {post.title} + {/each} - {/await} {#each data as item}
From e0ba4e3e023fa77da8ac1ccdb0bae79c632adfb3 Mon Sep 17 00:00:00 2001 From: Gautham Krishna Date: Wed, 18 Oct 2023 13:36:33 +0530 Subject: [PATCH 36/57] minor changes --- src/routes/feed/+page.svelte | 15 ++++----------- 1 file changed, 4 insertions(+), 11 deletions(-) diff --git a/src/routes/feed/+page.svelte b/src/routes/feed/+page.svelte index eae1f97..0682bbb 100644 --- a/src/routes/feed/+page.svelte +++ b/src/routes/feed/+page.svelte @@ -48,15 +48,8 @@ /> {/each} {/await} -{#each data as item} -
- {item.id} +{#if !loaded} +
+
- -{/each} -
- - -
+{/if} From 525828d78a07da538b1fc1bc39abbe6062c6d1fb Mon Sep 17 00:00:00 2001 From: Gautham Krishna Date: Wed, 18 Oct 2023 13:42:16 +0530 Subject: [PATCH 37/57] catching error on loading posts --- src/routes/feed/+page.svelte | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/routes/feed/+page.svelte b/src/routes/feed/+page.svelte index 0682bbb..db3f917 100644 --- a/src/routes/feed/+page.svelte +++ b/src/routes/feed/+page.svelte @@ -21,6 +21,7 @@ } console.log(newBatch[0]); } + return newBatch; } $: { data = [...data, ...newBatch]; @@ -35,7 +36,9 @@
{#await data}
- + + +
{:then data} {#each data as post} @@ -47,6 +50,8 @@ author_id={post.author.id} /> {/each} +{:catch error} +
An Error occurred while loading posts
{/await} {#if !loaded}
From d1444d447ddd690ba10bc2d318a25aec9467275a Mon Sep 17 00:00:00 2001 From: Gautham Krishna Date: Wed, 18 Oct 2023 13:47:39 +0530 Subject: [PATCH 38/57] fixing post component --- src/lib/components/post.svelte | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/lib/components/post.svelte b/src/lib/components/post.svelte index 9bc3aeb..d4eaea8 100644 --- a/src/lib/components/post.svelte +++ b/src/lib/components/post.svelte @@ -12,7 +12,7 @@
- +
{author}
From 47db9475f2c2ea09f1111132dcfe9e14b2b81803 Mon Sep 17 00:00:00 2001 From: Gautham Krishna Date: Wed, 18 Oct 2023 13:48:36 +0530 Subject: [PATCH 39/57] fixing placeholders --- src/routes/feed/+page.svelte | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/src/routes/feed/+page.svelte b/src/routes/feed/+page.svelte index db3f917..874885f 100644 --- a/src/routes/feed/+page.svelte +++ b/src/routes/feed/+page.svelte @@ -9,6 +9,7 @@ let data: any[] = []; let newBatch: any[] = []; + let loading: any[]; let loaded: boolean = false; let cursor: string | undefined = undefined; async function fetchMore() { @@ -23,18 +24,19 @@ } return newBatch; } + + onMount(async () => { + loading = fetchMore(); + }); $: { data = [...data, ...newBatch]; } - onMount(async () => { - fetchMore(); - });
-{#await data} +{#await loading}
@@ -55,6 +57,11 @@ {/await} {#if !loaded}
- +
{/if} From 92a632154f4a39dfa8d82de49ed0451c81b89ec1 Mon Sep 17 00:00:00 2001 From: Gautham Krishna Date: Wed, 18 Oct 2023 13:52:33 +0530 Subject: [PATCH 40/57] error handling --- src/routes/feed/+page.svelte | 25 ++++++++++++------------- 1 file changed, 12 insertions(+), 13 deletions(-) diff --git a/src/routes/feed/+page.svelte b/src/routes/feed/+page.svelte index 874885f..c78d73e 100644 --- a/src/routes/feed/+page.svelte +++ b/src/routes/feed/+page.svelte @@ -26,7 +26,7 @@ } onMount(async () => { - loading = fetchMore(); + loading = await fetchMore(); }); $: { data = [...data, ...newBatch]; @@ -36,30 +36,29 @@
+{#each data as post} + +{/each} {#await loading}
-{:then data} - {#each data as post} - - {/each} {:catch error}
An Error occurred while loading posts
{/await} {#if !loaded}
From b4427fedee9004c82b1125e1fa83b9b6f1de6508 Mon Sep 17 00:00:00 2001 From: Gautham Krishna Date: Wed, 18 Oct 2023 13:57:37 +0530 Subject: [PATCH 41/57] placeholders fixing --- src/routes/feed/+page.svelte | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/routes/feed/+page.svelte b/src/routes/feed/+page.svelte index c78d73e..8fced34 100644 --- a/src/routes/feed/+page.svelte +++ b/src/routes/feed/+page.svelte @@ -22,7 +22,7 @@ } console.log(newBatch[0]); } - return newBatch; + return Promise.resolve(newBatch); } onMount(async () => { From 1850d127bcfb633c41bdbd03ce1d8cb3bec224b9 Mon Sep 17 00:00:00 2001 From: Gautham Krishna Date: Wed, 18 Oct 2023 20:29:01 +0530 Subject: [PATCH 42/57] type changing for loading --- src/routes/feed/+page.svelte | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/routes/feed/+page.svelte b/src/routes/feed/+page.svelte index 8fced34..6e9b0ca 100644 --- a/src/routes/feed/+page.svelte +++ b/src/routes/feed/+page.svelte @@ -9,7 +9,7 @@ let data: any[] = []; let newBatch: any[] = []; - let loading: any[]; + let loading: any[] | Promise; let loaded: boolean = false; let cursor: string | undefined = undefined; async function fetchMore() { @@ -26,7 +26,7 @@ } onMount(async () => { - loading = await fetchMore(); + loading = fetchMore(); }); $: { data = [...data, ...newBatch]; From 5a29034be86a59d982b948c4a3128565e153587e Mon Sep 17 00:00:00 2001 From: Gautham Krishna Date: Wed, 18 Oct 2023 22:33:59 +0530 Subject: [PATCH 43/57] generalizing posts container --- src/lib/components/Posts.svelte | 17 +++++++++++++---- src/routes/feed/+page.svelte | 14 ++------------ 2 files changed, 15 insertions(+), 16 deletions(-) diff --git a/src/lib/components/Posts.svelte b/src/lib/components/Posts.svelte index b5b27cc..fcb6d36 100644 --- a/src/lib/components/Posts.svelte +++ b/src/lib/components/Posts.svelte @@ -1,9 +1,18 @@ -
- {#each items as item} - {item} +
+ {#each data as post} +
+ +
{/each}
diff --git a/src/routes/feed/+page.svelte b/src/routes/feed/+page.svelte index 6e9b0ca..ae44434 100644 --- a/src/routes/feed/+page.svelte +++ b/src/routes/feed/+page.svelte @@ -1,8 +1,6 @@ -
+
{#each data as post} -
+
Date: Wed, 18 Oct 2023 22:45:42 +0530 Subject: [PATCH 45/57] improving feed page and post components --- src/lib/components/Posts.svelte | 28 ++++++++++++++------------- src/lib/components/loadingpost.svelte | 2 +- src/lib/components/post.svelte | 2 +- src/routes/feed/+page.svelte | 8 ++++---- 4 files changed, 21 insertions(+), 19 deletions(-) diff --git a/src/lib/components/Posts.svelte b/src/lib/components/Posts.svelte index 2798301..f7702ad 100644 --- a/src/lib/components/Posts.svelte +++ b/src/lib/components/Posts.svelte @@ -3,16 +3,18 @@ import Post from '$lib/components/post.svelte'; -
- {#each data as post} -
- -
- {/each} -
+{#if data.length !== 0} +
+ {#each data as post} +
+ +
+ {/each} +
+{/if} diff --git a/src/lib/components/loadingpost.svelte b/src/lib/components/loadingpost.svelte index 26b9805..b58c6d9 100644 --- a/src/lib/components/loadingpost.svelte +++ b/src/lib/components/loadingpost.svelte @@ -1,4 +1,4 @@ -
+
diff --git a/src/lib/components/post.svelte b/src/lib/components/post.svelte index d4eaea8..9ba5379 100644 --- a/src/lib/components/post.svelte +++ b/src/lib/components/post.svelte @@ -9,7 +9,7 @@ import { Avatar } from '@skeletonlabs/skeleton'; -
+
diff --git a/src/routes/feed/+page.svelte b/src/routes/feed/+page.svelte index ae44434..169cb8c 100644 --- a/src/routes/feed/+page.svelte +++ b/src/routes/feed/+page.svelte @@ -12,9 +12,9 @@ let cursor: string | undefined = undefined; async function fetchMore() { if (!loaded) { - const res = await api.get_posts(10, cursor); + const res = await api.get_posts(1, cursor); if (res.data) { - loaded = res.data.count !== 10; + loaded = res.data.count !== 1; cursor = res.data.cursor_id; newBatch = res.data.data; } @@ -31,12 +31,12 @@ } -
+
{#await loading} -
+
From e2bf47c940c919489a7763f41c0d72670b000aed Mon Sep 17 00:00:00 2001 From: Gautham Krishna Date: Wed, 18 Oct 2023 22:48:00 +0530 Subject: [PATCH 46/57] increasing posts per request --- src/routes/feed/+page.svelte | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/routes/feed/+page.svelte b/src/routes/feed/+page.svelte index 169cb8c..ba82d1e 100644 --- a/src/routes/feed/+page.svelte +++ b/src/routes/feed/+page.svelte @@ -12,9 +12,9 @@ let cursor: string | undefined = undefined; async function fetchMore() { if (!loaded) { - const res = await api.get_posts(1, cursor); + const res = await api.get_posts(10, cursor); if (res.data) { - loaded = res.data.count !== 1; + loaded = res.data.count !== 10; cursor = res.data.cursor_id; newBatch = res.data.data; } From 8648e4b95ebd74beee2a1087c2ec162a7538d778 Mon Sep 17 00:00:00 2001 From: Gautham Krishna Date: Thu, 19 Oct 2023 00:15:17 +0530 Subject: [PATCH 47/57] showing posts of a user on the user page --- src/lib/api.ts | 15 +++++++++ src/routes/user/[slug]/+page.svelte | 52 ++++++++++++++++++++++++++++- 2 files changed, 66 insertions(+), 1 deletion(-) diff --git a/src/lib/api.ts b/src/lib/api.ts index 1c9167f..8947ecf 100644 --- a/src/lib/api.ts +++ b/src/lib/api.ts @@ -65,3 +65,18 @@ export async function get_posts(take: number, cursor?: string) { }); return { data, error }; } + +export async function get_user_posts(user_id: string, take: number, cursor?: string) { + const { data, error } = await GET('/post/', { + params: { + header: { + take: take, + cursor: cursor + }, + query: { + uid: user_id + } + } + }); + return { data, error }; +} diff --git a/src/routes/user/[slug]/+page.svelte b/src/routes/user/[slug]/+page.svelte index 649e89c..c34ee92 100644 --- a/src/routes/user/[slug]/+page.svelte +++ b/src/routes/user/[slug]/+page.svelte @@ -1,7 +1,36 @@ -
@@ -23,5 +52,26 @@
This User has no Posts
+ {:else} + + {#await loading} +
+ + + +
+ {:catch error} +
An Error occurred while loading posts
+ {/await} + {#if !loaded} +
+ +
+ {/if} {/if}
From 832d300df56eaa566860dbc49385939dff185bd2 Mon Sep 17 00:00:00 2001 From: Gautham Krishna Date: Thu, 19 Oct 2023 00:20:48 +0530 Subject: [PATCH 48/57] small changes --- src/routes/user/[slug]/+page.svelte | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/routes/user/[slug]/+page.svelte b/src/routes/user/[slug]/+page.svelte index c34ee92..07f4311 100644 --- a/src/routes/user/[slug]/+page.svelte +++ b/src/routes/user/[slug]/+page.svelte @@ -53,7 +53,7 @@ This User has no Posts
{:else} - + {#await loading}
From 7935dcffaf51d2a93d787df2995505f9234a7b02 Mon Sep 17 00:00:00 2001 From: Gautham Krishna Date: Thu, 19 Oct 2023 21:53:19 +0530 Subject: [PATCH 49/57] api method to get post by id --- src/lib/api.ts | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/src/lib/api.ts b/src/lib/api.ts index 8947ecf..6cc2ec8 100644 --- a/src/lib/api.ts +++ b/src/lib/api.ts @@ -80,3 +80,14 @@ export async function get_user_posts(user_id: string, take: number, cursor?: str }); return { data, error }; } + +export async function get_post(post_id: string) { + const { data, error } = await GET('/post/{id}', { + params: { + path: { + id: post_id + } + } + }); + return { data, error }; +} From 63a7b0a9b12a61be4f66ef0f3173c1fbecafd68e Mon Sep 17 00:00:00 2001 From: Gautham Krishna Date: Thu, 19 Oct 2023 21:53:57 +0530 Subject: [PATCH 50/57] creating template for post page --- src/lib/components/ExpandedPost.svelte | 27 ++++++++++++++++++++++++++ src/lib/components/comment.svelte | 1 + src/lib/components/comments.svelte | 3 +++ 3 files changed, 31 insertions(+) create mode 100644 src/lib/components/ExpandedPost.svelte create mode 100644 src/lib/components/comment.svelte create mode 100644 src/lib/components/comments.svelte diff --git a/src/lib/components/ExpandedPost.svelte b/src/lib/components/ExpandedPost.svelte new file mode 100644 index 0000000..7d00449 --- /dev/null +++ b/src/lib/components/ExpandedPost.svelte @@ -0,0 +1,27 @@ + + +
+
+
+
+ +
+ {username} +
+
+ {title} +
+
+
{title}
+
{description}
+
{rating}
+
+
+
diff --git a/src/lib/components/comment.svelte b/src/lib/components/comment.svelte new file mode 100644 index 0000000..a8beed5 --- /dev/null +++ b/src/lib/components/comment.svelte @@ -0,0 +1 @@ +
diff --git a/src/lib/components/comments.svelte b/src/lib/components/comments.svelte new file mode 100644 index 0000000..d532a0f --- /dev/null +++ b/src/lib/components/comments.svelte @@ -0,0 +1,3 @@ +
+
+
From d76ab763a5f316eaf8340a4e2d7ed7d3d9e502df Mon Sep 17 00:00:00 2001 From: Gautham Krishna Date: Thu, 19 Oct 2023 21:54:48 +0530 Subject: [PATCH 51/57] make_post route basics done --- src/lib/components/loadingcomment.svelte | 0 src/routes/make_post/+page.server.ts | 0 src/routes/make_post/+page.svelte | 7 +++++++ 3 files changed, 7 insertions(+) create mode 100644 src/lib/components/loadingcomment.svelte create mode 100644 src/routes/make_post/+page.server.ts create mode 100644 src/routes/make_post/+page.svelte diff --git a/src/lib/components/loadingcomment.svelte b/src/lib/components/loadingcomment.svelte new file mode 100644 index 0000000..e69de29 diff --git a/src/routes/make_post/+page.server.ts b/src/routes/make_post/+page.server.ts new file mode 100644 index 0000000..e69de29 diff --git a/src/routes/make_post/+page.svelte b/src/routes/make_post/+page.svelte new file mode 100644 index 0000000..ee01b87 --- /dev/null +++ b/src/routes/make_post/+page.svelte @@ -0,0 +1,7 @@ + + + + From d0358d9ae634744ef82dfbcfacecb27699cf1160 Mon Sep 17 00:00:00 2001 From: Gautham Krishna Date: Thu, 19 Oct 2023 21:55:01 +0530 Subject: [PATCH 52/57] updating make post route --- src/lib/components/makepost.svelte | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/lib/components/makepost.svelte b/src/lib/components/makepost.svelte index 3b48855..ddf18c0 100644 --- a/src/lib/components/makepost.svelte +++ b/src/lib/components/makepost.svelte @@ -2,8 +2,8 @@ import { FileDropzone } from '@skeletonlabs/skeleton'; -
-
+
+
@@ -32,9 +32,9 @@
File - + -
-
{title}
+
{title}
{rating} diff --git a/src/routes/post/[slug]/+page.server.ts b/src/routes/post/[slug]/+page.server.ts index e69de29..fdcb03b 100644 --- a/src/routes/post/[slug]/+page.server.ts +++ b/src/routes/post/[slug]/+page.server.ts @@ -0,0 +1,22 @@ +import { error } from '@sveltejs/kit'; +import * as api from '$lib/api'; + +export async function load({ params, locals }) { + if ( + /^[0-9a-f]{8}-[0-9a-f]{4}-[0-5][0-9a-f]{3}-[089ab][0-9a-f]{3}-[0-9a-f]{12}$/i.test(params.slug) + ) { + if (locals && locals.user) { + const res = await api.get_post(params.slug); + if (res.error) { + // throwing error for user not found + throw error(400, 'Post Not Found'); + } else { + if (res.data) { + return res.data; + } + } + } + } + //throwing error for invalid user id + throw error(400, 'Invalid User ID'); +} From a8b94ffeb83a033ecdc76d892f7edc0cc65ba662 Mon Sep 17 00:00:00 2001 From: Gautham Krishna Date: Thu, 19 Oct 2023 22:18:02 +0530 Subject: [PATCH 56/57] making postpage work --- src/routes/post/[slug]/+page.server.ts | 1 + src/routes/post/[slug]/+page.svelte | 4 ++++ 2 files changed, 5 insertions(+) diff --git a/src/routes/post/[slug]/+page.server.ts b/src/routes/post/[slug]/+page.server.ts index fdcb03b..04e5b2d 100644 --- a/src/routes/post/[slug]/+page.server.ts +++ b/src/routes/post/[slug]/+page.server.ts @@ -7,6 +7,7 @@ export async function load({ params, locals }) { ) { if (locals && locals.user) { const res = await api.get_post(params.slug); + console.log(res); if (res.error) { // throwing error for user not found throw error(400, 'Post Not Found'); diff --git a/src/routes/post/[slug]/+page.svelte b/src/routes/post/[slug]/+page.svelte index a9e86cd..f2d94f4 100644 --- a/src/routes/post/[slug]/+page.svelte +++ b/src/routes/post/[slug]/+page.svelte @@ -1,4 +1,8 @@ + + + From 16e14235c92848820230e4008ab63c4e5541cd2d Mon Sep 17 00:00:00 2001 From: Gautham Krishna Date: Thu, 26 Oct 2023 17:13:14 +0530 Subject: [PATCH 57/57] checking error when post is fetched --- src/routes/post/[slug]/+page.server.ts | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/routes/post/[slug]/+page.server.ts b/src/routes/post/[slug]/+page.server.ts index 04e5b2d..61da253 100644 --- a/src/routes/post/[slug]/+page.server.ts +++ b/src/routes/post/[slug]/+page.server.ts @@ -10,14 +10,16 @@ export async function load({ params, locals }) { console.log(res); if (res.error) { // throwing error for user not found + console.log(res.error); throw error(400, 'Post Not Found'); } else { if (res.data) { + console.log(res.data); return res.data; } } } } //throwing error for invalid user id - throw error(400, 'Invalid User ID'); + throw error(400, 'Not Logged in '); }