diff --git a/src/lib/components/Post.svelte b/src/lib/components/Post.svelte index a5e657f..516d4e0 100644 --- a/src/lib/components/Post.svelte +++ b/src/lib/components/Post.svelte @@ -1,11 +1,13 @@ + + + + +
+ Upload File +
+ ++ {#if form?.success} + {#if form?.href} + {form?.success} + {:else} + {form?.success} + {/if} + {/if} + Create an image for the world to see. +
+ \ No newline at end of file diff --git a/src/routes/new_post/+page.server.js b/src/routes/new_post/+page.server.js deleted file mode 100644 index 5116ab6..0000000 --- a/src/routes/new_post/+page.server.js +++ /dev/null @@ -1,19 +0,0 @@ -import { backend } from '../../lib/db/db.js'; -import { checkLength, checkRegex } from '../../lib/util.js'; - -/** @type {import('./$types').Actions} */ -export const actions = { - create: async ({ request, cookies }) => { - const data = await request.formData(); - const content = data.get('content') + ''; - - var lengthCheck = checkLength(content,'Post content',1,10240); - - if (lengthCheck) - return lengthCheck; - - await backend.postCreate({user, content}); - - return {'success': 'Successfully posted.'}; - } -}; \ No newline at end of file diff --git a/src/routes/new_post/+page.svelte b/src/routes/new_post/+page.svelte index 397594f..57f99e4 100644 --- a/src/routes/new_post/+page.svelte +++ b/src/routes/new_post/+page.svelte @@ -26,10 +26,20 @@ -- {#if form?.success} -
{form?.success}
- {/if} - Create a post for the world to see. - + ++ {#if form?.success} + {#if form?.href} + {form?.success} + {:else} + {form?.success} + {/if} + {/if} +
+Create a post for the world to see.
++ img||filename.blah embeds a user-uploaded file in this site +
+ \ No newline at end of file diff --git a/src/routes/post/[post]/+page.js b/src/routes/post/[post]/+page.js index a5b74a9..2b44140 100644 --- a/src/routes/post/[post]/+page.js +++ b/src/routes/post/[post]/+page.js @@ -7,13 +7,7 @@ export async function load({ fetch, params, url }) { await new Promise(resolve => setTimeout(resolve, 100)); - var f = (new FormData()); - - f.append('id',id); - const res = await fetch(`/api/postGet`, { - method: 'POST', - body: f - }); + const res = await fetch(`/api/postGet?id=${id}`); const postJson = (await res.json()).data; console.log(postJson);