diff --git a/package.json b/package.json index 1850e2d..b081e66 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "@yusurko/vigil", "private": true, - "version": "0.1.0-dev43", + "version": "0.1.0-dev42", "type": "module", "scripts": { "dev": "vite dev", diff --git a/src/app.d.ts b/src/app.d.ts index dd01331..d49d347 100644 --- a/src/app.d.ts +++ b/src/app.d.ts @@ -14,7 +14,7 @@ declare global { site: ServerHealth | null, me: UserEntry | null, results?: object[], - query?: string, + query?: string } // interface PageState {} // interface Platform {} diff --git a/src/lib/CommentCount.svelte b/src/lib/CommentCount.svelte deleted file mode 100644 index a4f5ea1..0000000 --- a/src/lib/CommentCount.svelte +++ /dev/null @@ -1,24 +0,0 @@ - - - -
- - {count??'-'} -
- - \ No newline at end of file diff --git a/src/lib/CommentSection.svelte b/src/lib/CommentSection.svelte deleted file mode 100644 index 9f6955a..0000000 --- a/src/lib/CommentSection.svelte +++ /dev/null @@ -1,16 +0,0 @@ - - -{#if comments === null} - - - -{/if} \ No newline at end of file diff --git a/src/lib/EditPost.svelte b/src/lib/EditPost.svelte deleted file mode 100644 index ba0c397..0000000 --- a/src/lib/EditPost.svelte +++ /dev/null @@ -1,35 +0,0 @@ - - - - - - - - - - \ No newline at end of file diff --git a/src/lib/FeedPost.svelte b/src/lib/FeedPost.svelte index 8b0f0aa..728b811 100644 --- a/src/lib/FeedPost.svelte +++ b/src/lib/FeedPost.svelte @@ -1,68 +1,25 @@ -
-
-

- {title} -

- -
- -
- + +

+ {title} +

+ + +
+
-
+ diff --git a/src/lib/FullPost.svelte b/src/lib/FullPost.svelte index f3a6e63..82a2dba 100644 --- a/src/lib/FullPost.svelte +++ b/src/lib/FullPost.svelte @@ -1,5 +1,7 @@ @@ -34,24 +34,21 @@ let { title, id, content = '', to, votes, my_vote, comment_count } = post; - + +
    {#if me && me.id !== post.author?.id}
  • Report
  • {/if} {#if me && me.id === post.author?.id } -
  • Edit
  • +
  • Edit
  • {/if}
- - {#snippet left()} {#if to.type === 'guild'} @@ -77,13 +74,13 @@ let { title, id, content = '', to, votes, my_vote, comment_count } = post; overflow-x: auto; } .post-body { - margin-inline-start: 2em; + margin-inline-start: 3em; } .message-stats { position: absolute; inset-inline-start: 0; top: 0; - width: 2em; + width: 3em; display: flex; flex-direction: column; justify-content: flex-start; diff --git a/src/lib/GuildAbout.svelte b/src/lib/GuildAbout.svelte index 8be9b0f..8d5c569 100644 --- a/src/lib/GuildAbout.svelte +++ b/src/lib/GuildAbout.svelte @@ -9,6 +9,7 @@ let { guild }: { guild: GuildEntry } = $props(); + {#if guild}
    @@ -20,4 +21,4 @@ let { guild }: { guild: GuildEntry } = $props(); {/if}
-{/if} +{/if} \ No newline at end of file diff --git a/src/lib/GuildSelect.svelte b/src/lib/GuildSelect.svelte index 529ad08..ddf41ae 100644 --- a/src/lib/GuildSelect.svelte +++ b/src/lib/GuildSelect.svelte @@ -2,7 +2,7 @@ import { backend, type GuildEntry } from "./backend"; -let { value = $bindable("") } = $props(); +let value = $state(""); let suggestions: Promise = $derived(getSuggestions(value)); diff --git a/src/lib/MetaNav.svelte b/src/lib/MetaNav.svelte index 94a1d01..9b9d224 100644 --- a/src/lib/MetaNav.svelte +++ b/src/lib/MetaNav.svelte @@ -1,6 +1,6 @@ -{#if me}
  • -
  • -
  • +
  • +
-{/if} diff --git a/src/lib/Wip.svelte b/src/lib/Wip.svelte deleted file mode 100644 index 0913a74..0000000 --- a/src/lib/Wip.svelte +++ /dev/null @@ -1,8 +0,0 @@ - - - - \ No newline at end of file diff --git a/src/lib/backend.ts b/src/lib/backend.ts index 4953448..92cbfdb 100644 --- a/src/lib/backend.ts +++ b/src/lib/backend.ts @@ -29,21 +29,8 @@ export type PostEntry = { title: string, created_at: string, author?: UserEntry | null, - content?: string, - to: UserEntry | GuildEntry , - privacy?: number, - votes?: number | null, - my_vote?: 1 | -1 | 0, - comment_count?: number | null -}; - -export type CommentEntry = { - id: string, - parent?: {id: string}, - locked?: boolean, - removed?: number | true, - content?: string, - created_at: string + content?: string | null, + to: UserEntry | GuildEntry }; export type ServerHealth = { diff --git a/src/lib/globals.svelte.ts b/src/lib/globals.svelte.ts index 622dbf3..984b82f 100644 --- a/src/lib/globals.svelte.ts +++ b/src/lib/globals.svelte.ts @@ -22,6 +22,8 @@ export function setHealth ({ name, version, post_count, user_count, color_theme health.color_theme = color_theme; } + + export function setMe (me: UserEntry | null) { health.me = me; } diff --git a/src/routes/+layout.svelte b/src/routes/+layout.svelte index 7579dd9..ff7f53f 100644 --- a/src/routes/+layout.svelte +++ b/src/routes/+layout.svelte @@ -36,7 +36,7 @@ let colorThemeCls = $derived(`color-scheme-${colorScheme} color-theme-${colorThe -
+

{appName()} @@ -54,7 +54,7 @@ let colorThemeCls = $derived(`color-scheme-${colorScheme} color-theme-${colorThe -

+ diff --git a/src/routes/create/+page.svelte b/src/routes/create/+page.svelte index af0029c..16cb54d 100644 --- a/src/routes/create/+page.svelte +++ b/src/routes/create/+page.svelte @@ -1,19 +1,18 @@ @@ -23,26 +22,34 @@

Posting as @{me.username}

- + + + + {#if privacy === 0} Your post will be PUBLIC! {/if} - + {#snippet left()} - + ... {/snippet} {#snippet right()} - + ... {/snippet}
{:else} @@ -53,10 +60,22 @@ \ No newline at end of file diff --git a/src/routes/edit/[x+3d][id]/+page.svelte b/src/routes/edit/[x+3d][id]/+page.svelte deleted file mode 100644 index 22d9955..0000000 --- a/src/routes/edit/[x+3d][id]/+page.svelte +++ /dev/null @@ -1,65 +0,0 @@ - - - -{#if me?.id === post.author?.id} - -
-

Posting as @{me?.username}

- - - - - - {#if privacy === 0} - Your post will be PUBLIC! - {/if} - - - - - - {#snippet left()} - - {/snippet} - - {#snippet right()} - - {/snippet} -
-{:else if me} - You can't edit posts that are not your own. -{:else} - - You must be logged in in order to edit your own posts. - -{/if} - - \ No newline at end of file diff --git a/src/routes/edit/[x+3d][id]/+page.ts b/src/routes/edit/[x+3d][id]/+page.ts deleted file mode 100644 index 2ab8998..0000000 --- a/src/routes/edit/[x+3d][id]/+page.ts +++ /dev/null @@ -1,51 +0,0 @@ -import { backend, type GuildEntry } from '$lib/backend.js'; -import { getMe } from '$lib/globals.svelte'; -import { error, isHttpError, redirect } from '@sveltejs/kit'; - -export async function load(event) { - - const { params } = event; - const { id } = params; - - const resp = await backend.withEvent(event).fetch('post/' + encodeURIComponent(id)); - - if(resp.status === 404) { - error(404); - } - - let post; - - try{ - const respJ = await resp.json(); - - let { posts } = respJ; - post = posts[id]; - - let me = getMe(); - - if (!me) { - redirect(303, "/login?next=" + encodeURIComponent(event.url.pathname)); - } - if ( post.author.id !== me?.id) { - error(403); - } - - if (post?.to && post.to.type === 'guild') { - const guild: GuildEntry = post.to; - const guildResp = await backend.withEvent(event).fetch('guild/' + encodeURIComponent(guild.id)); - const guildJson = await guildResp.json(); - const guildInfo = guildJson?.guilds?.[guild.id]; - guildInfo.type = 'guild'; - post.to = guildInfo || guild; - console.log(post.to); - } - - } catch (e) { - if (isHttpError(e)) throw e; - - console.error(e); - error(502); - } - - return post; -} \ No newline at end of file diff --git a/src/routes/login/+page.server.ts b/src/routes/login/+page.server.ts index 8f9053c..25752ae 100644 --- a/src/routes/login/+page.server.ts +++ b/src/routes/login/+page.server.ts @@ -5,6 +5,7 @@ import { redirect } from 'sveltekit-flash-message/server'; export const actions = { default: async (event) => { + // TODO login const { request } = event; diff --git a/src/routes/register/+page.svelte b/src/routes/register/+page.svelte index b1e61cc..4195c82 100644 --- a/src/routes/register/+page.svelte +++ b/src/routes/register/+page.svelte @@ -1,7 +1,6 @@