diff --git a/package.json b/package.json index 44b2bc0..d40de8a 100644 --- a/package.json +++ b/package.json @@ -24,6 +24,7 @@ "dotenv": "^16.4.5", "node-cache": "^5.1.2", "postgres": "^3.4.4", - "ssh2": "^1.15.0" + "ssh2": "^1.15.0", + "vite-plugin-entry-shaking": "^0.4.3" } } diff --git a/src/comp/avatar.svelte b/src/comp/avatar.svelte new file mode 100644 index 0000000..0f499e1 --- /dev/null +++ b/src/comp/avatar.svelte @@ -0,0 +1,21 @@ + + + + + + + diff --git a/src/comp/comment.svelte b/src/comp/comment.svelte index e3731cb..78d767b 100644 --- a/src/comp/comment.svelte +++ b/src/comp/comment.svelte @@ -1,5 +1,6 @@ + +
-
{comment.author?.name}
+

{comment.content}

-
+
{#each commentNode.children as reply} {/each} diff --git a/src/comp/fx/glowfx.svelte b/src/comp/fx/glowfx.svelte new file mode 100644 index 0000000..c4ffd1d --- /dev/null +++ b/src/comp/fx/glowfx.svelte @@ -0,0 +1,100 @@ + + + + + +
+ +
+
+ diff --git a/src/comp/fx/perspectivefx.svelte b/src/comp/fx/perspectivefx.svelte new file mode 100644 index 0000000..449d05c --- /dev/null +++ b/src/comp/fx/perspectivefx.svelte @@ -0,0 +1,79 @@ + + + + + +
+
+ +
+
+ diff --git a/src/comp/mention.svelte b/src/comp/mention.svelte new file mode 100644 index 0000000..d6d75bf --- /dev/null +++ b/src/comp/mention.svelte @@ -0,0 +1,61 @@ + + + + +{#if user} + + +
+ @ + {user.name} +
+
+{:else} + + +
+ @ + Deleted User +
+
+{/if} \ No newline at end of file diff --git a/src/comp/post.svelte b/src/comp/post.svelte deleted file mode 100644 index 992846b..0000000 --- a/src/comp/post.svelte +++ /dev/null @@ -1,17 +0,0 @@ - - -
- {post.name} -

{post.author?.name}

-

{post.category.name}

- -

{post.content}

-
diff --git a/src/comp/postcard.svelte b/src/comp/postcard.svelte new file mode 100644 index 0000000..fd8119d --- /dev/null +++ b/src/comp/postcard.svelte @@ -0,0 +1,100 @@ + + + + + diff --git a/src/comp/postlist.svelte b/src/comp/postlist.svelte index 0528ad9..c95b057 100644 --- a/src/comp/postlist.svelte +++ b/src/comp/postlist.svelte @@ -1,5 +1,5 @@ -
+ + +
{#each posts as post} - + {/each}
diff --git a/src/comp/rating.svelte b/src/comp/rating.svelte index 0e77421..8c1efd1 100644 --- a/src/comp/rating.svelte +++ b/src/comp/rating.svelte @@ -5,7 +5,33 @@ export let rating; -
-

up: {rating.likes}

-

down: {rating.dislikes}

+ + +
+ + + + {rating.likes} + + + + {rating.dislikes}
diff --git a/src/comp/ratingvertical.svelte b/src/comp/ratingvertical.svelte new file mode 100644 index 0000000..ee81e6f --- /dev/null +++ b/src/comp/ratingvertical.svelte @@ -0,0 +1,36 @@ + + + + +
+ + + + {rating.likes - rating.dislikes} + + + +
diff --git a/src/comp/sidebar.svelte b/src/comp/sidebar.svelte new file mode 100644 index 0000000..f7acbc7 --- /dev/null +++ b/src/comp/sidebar.svelte @@ -0,0 +1,42 @@ + + + + + diff --git a/src/comp/useritem.svelte b/src/comp/useritem.svelte new file mode 100644 index 0000000..4c15fa5 --- /dev/null +++ b/src/comp/useritem.svelte @@ -0,0 +1,22 @@ + + + + + + + + + diff --git a/src/lib/server/db/category.js b/src/lib/server/db/category.js index d2bf150..0ab419a 100644 --- a/src/lib/server/db/category.js +++ b/src/lib/server/db/category.js @@ -31,7 +31,7 @@ const updateCategoryCache = cacheUpdater(cache); /** * @param {import('postgres').Sql} sql - * @param {number[]} user_ids + * @param {number[] | undefined} user_ids * @returns {Promise>} */ export const getCategoriesCached = cachedMethod(cache, getCategories); @@ -40,16 +40,18 @@ export const getCategoriesCachedByRef = refExtendCachedMethod(getCategoriesCache /** * @param {import('postgres').Sql} sql - * @param {number[]} category_ids + * @param {number[] | undefined} category_ids * @returns {Promise>} */ -export async function getCategories(sql, category_ids) { - if (category_ids.length == 0) return new Map(); +export async function getCategories(sql, category_ids = undefined) { + if (category_ids !== undefined && category_ids.length == 0) return new Map(); + + const filter = category_ids ? sql`WHERE id IN ${ sql(category_ids) }` : sql``; const query = sql` SELECT id, name FROM doki8902.post_category - WHERE id IN ${ sql(category_ids) };`; + ${ filter };`; let categories = await query; diff --git a/src/routes/(app)/+layout.server.js b/src/routes/(app)/+layout.server.js new file mode 100644 index 0000000..846dc96 --- /dev/null +++ b/src/routes/(app)/+layout.server.js @@ -0,0 +1,10 @@ +import { getCategories } from "$lib/server/db/category"; + +/** @type {import("@sveltejs/kit").ServerLoad} */ +export async function load({ locals }) { + const categories = await getCategories(locals.sql); + + return { + categories: categories + }; +} diff --git a/src/routes/(app)/+layout.svelte b/src/routes/(app)/+layout.svelte index dbaeac4..2af15cc 100644 --- a/src/routes/(app)/+layout.svelte +++ b/src/routes/(app)/+layout.svelte @@ -1,11 +1,34 @@ + +
- + +
+ +
diff --git a/src/routes/(app)/posts/[name]/+page.svelte b/src/routes/(app)/posts/[name]/+page.svelte index f20ced7..83e4c38 100644 --- a/src/routes/(app)/posts/[name]/+page.svelte +++ b/src/routes/(app)/posts/[name]/+page.svelte @@ -1,5 +1,7 @@