Compare commits
4 commits
0ccfdbb78e
...
3cf9e024c0
| Author | SHA1 | Date | |
|---|---|---|---|
| 3cf9e024c0 | |||
| 9fd5be2815 | |||
| 76b946d55c | |||
| bffae34b3e |
24 changed files with 220 additions and 29 deletions
|
|
@ -1,7 +1,7 @@
|
||||||
{
|
{
|
||||||
"name": "@yusurko/vigil",
|
"name": "@yusurko/vigil",
|
||||||
"private": true,
|
"private": true,
|
||||||
"version": "0.1.0-dev43",
|
"version": "0.1.0-dev47",
|
||||||
"type": "module",
|
"type": "module",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"dev": "vite dev",
|
"dev": "vite dev",
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
|
|
||||||
let { query = $bindable<string>() }: {query?: string} = $props();
|
let { query }: {query?: string} = $props();
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<input value={query} type="search" name="query" class="bigsearch" />
|
<input value={query} type="search" name="query" class="bigsearch" />
|
||||||
|
|
|
||||||
|
|
@ -1,14 +1,15 @@
|
||||||
|
|
||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
let { narrow = false, children } : { narrow?: boolean, children: any } = $props();
|
let { narrow = false, small = false, children } : { narrow?: boolean, small ?: boolean, children: any } = $props();
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<div class="centered" class:narrow={narrow}>
|
<div class="centered" class:narrow={narrow} class:small={small}>
|
||||||
{@render children () }
|
{@render children () }
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<style>
|
<style>
|
||||||
.centered {text-align: center;}
|
.centered {text-align: center;}
|
||||||
.centered.narrow { max-width: 400px; margin: auto; }
|
.centered.narrow { max-width: 400px; margin: auto; }
|
||||||
|
.centered.small { font-size: smaller; }
|
||||||
</style>
|
</style>
|
||||||
|
|
||||||
|
|
|
||||||
29
src/lib/DesktopFooter.svelte
Normal file
29
src/lib/DesktopFooter.svelte
Normal file
|
|
@ -0,0 +1,29 @@
|
||||||
|
<script lang="ts">
|
||||||
|
import Centered from "./Centered.svelte";
|
||||||
|
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<Centered small={true}>
|
||||||
|
<p>© 2021-2025 Sakuragasaki46.</p>
|
||||||
|
<ul>
|
||||||
|
<li><a href="/about">About</a></li>
|
||||||
|
<li><a href="/terms">Terms</a></li>
|
||||||
|
<li><a href="/privacy">Privacy</a></li>
|
||||||
|
<li><a href="https://nekode.yusur.moe/yusur/freak" target="_blank">GitHub</a></li>
|
||||||
|
</ul>
|
||||||
|
</Centered>
|
||||||
|
|
||||||
|
<style>
|
||||||
|
ul {
|
||||||
|
list-style: none;
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
justify-content: stretch;
|
||||||
|
max-width: 640px;
|
||||||
|
margin: auto;
|
||||||
|
}
|
||||||
|
|
||||||
|
ul > li {
|
||||||
|
flex: 1;
|
||||||
|
}
|
||||||
|
</style>
|
||||||
|
|
@ -19,12 +19,11 @@
|
||||||
<style>
|
<style>
|
||||||
ul {
|
ul {
|
||||||
list-style: none;
|
list-style: none;
|
||||||
padding: 0 1em;
|
padding: 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
ul > li {
|
ul > li {
|
||||||
margin-top: 3px;
|
margin: 3px 0;
|
||||||
margin-bottom: 3px;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
p.big {
|
p.big {
|
||||||
|
|
|
||||||
|
|
@ -30,10 +30,11 @@ let { id, title, content = "", votes, my_vote, comment_count } = post;
|
||||||
.post-frame {
|
.post-frame {
|
||||||
padding-inline-start: 2em;
|
padding-inline-start: 2em;
|
||||||
position: relative;
|
position: relative;
|
||||||
|
min-height: 7em;
|
||||||
}
|
}
|
||||||
.message-stats {
|
.message-stats {
|
||||||
position: absolute;
|
position: absolute;
|
||||||
inset-inline-start: 0;
|
inset-inline-start: -6px;
|
||||||
top: 0;
|
top: 0;
|
||||||
width: 2em;
|
width: 2em;
|
||||||
display: flex;
|
display: flex;
|
||||||
|
|
|
||||||
|
|
@ -81,12 +81,13 @@ let { title, id, content = '', to, votes, my_vote, comment_count } = post;
|
||||||
}
|
}
|
||||||
.message-stats {
|
.message-stats {
|
||||||
position: absolute;
|
position: absolute;
|
||||||
inset-inline-start: 0;
|
inset-inline-start: -6px;
|
||||||
top: 0;
|
top: 0;
|
||||||
width: 2em;
|
width: 2em;
|
||||||
display: flex;
|
display: flex;
|
||||||
flex-direction: column;
|
flex-direction: column;
|
||||||
justify-content: flex-start;
|
justify-content: flex-start;
|
||||||
align-items: center;
|
align-items: center;
|
||||||
|
margin-inline-end: 6px;
|
||||||
}
|
}
|
||||||
</style>
|
</style>
|
||||||
|
|
@ -27,7 +27,7 @@ let me = $derived(getMe());
|
||||||
<style>
|
<style>
|
||||||
|
|
||||||
footer {
|
footer {
|
||||||
position: sticky;
|
position: fixed;
|
||||||
bottom: 0;
|
bottom: 0;
|
||||||
left: 0;
|
left: 0;
|
||||||
width: 100%;
|
width: 100%;
|
||||||
|
|
|
||||||
|
|
@ -17,4 +17,10 @@ let { post } : {post: PostEntry }= $props();
|
||||||
|
|
||||||
<style>
|
<style>
|
||||||
ul.post-meta > li { margin-inline-end: 9px; }
|
ul.post-meta > li { margin-inline-end: 9px; }
|
||||||
|
|
||||||
|
@media (max-width:799px) {
|
||||||
|
ul.post-meta {
|
||||||
|
font-size: .8em;
|
||||||
|
}
|
||||||
|
}
|
||||||
</style>
|
</style>
|
||||||
|
|
@ -28,12 +28,12 @@ let mobiRightActive = $state(false);
|
||||||
grid-template-areas:
|
grid-template-areas:
|
||||||
". title ."
|
". title ."
|
||||||
"left center right";
|
"left center right";
|
||||||
margin: 1em 2em;
|
padding: 1em 2em;
|
||||||
position: relative;
|
position: relative;
|
||||||
}
|
}
|
||||||
|
|
||||||
.layout-left { grid-area: left; padding-right: 1em; }
|
.layout-left { grid-area: left; padding-inline-end: 1em; }
|
||||||
.layout-right { grid-area: right; padding-left: 1em; }
|
.layout-right { grid-area: right; padding-inline-start: 1em; }
|
||||||
.layout-content { grid-area: center; }
|
.layout-content { grid-area: center; }
|
||||||
.layout-title { grid-area: title; text-align: center; font-size: 1.4em; }
|
.layout-title { grid-area: title; text-align: center; font-size: 1.4em; }
|
||||||
|
|
||||||
|
|
@ -86,6 +86,8 @@ let mobiRightActive = $state(false);
|
||||||
"center center center";
|
"center center center";
|
||||||
|
|
||||||
grid-template-columns: 2em auto 2em;
|
grid-template-columns: 2em auto 2em;
|
||||||
|
|
||||||
|
padding: 1em .5em;
|
||||||
}
|
}
|
||||||
|
|
||||||
.layout-left, .layout-right { display: none; }
|
.layout-left, .layout-right { display: none; }
|
||||||
|
|
@ -107,6 +109,10 @@ let mobiRightActive = $state(false);
|
||||||
right: 0;
|
right: 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.layout-content {
|
||||||
|
font-size: .9em;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -9,6 +9,7 @@ import type { ServerHealth, UserEntry } from '$lib/backend';
|
||||||
import { getFlash } from 'sveltekit-flash-message';
|
import { getFlash } from 'sveltekit-flash-message';
|
||||||
import { page } from "$app/state";
|
import { page } from "$app/state";
|
||||||
import FlashMessage from '$lib/FlashMessage.svelte';
|
import FlashMessage from '$lib/FlashMessage.svelte';
|
||||||
|
import DesktopFooter from '$lib/DesktopFooter.svelte';
|
||||||
|
|
||||||
let { data, children } : {
|
let { data, children } : {
|
||||||
data: {me: UserEntry},
|
data: {me: UserEntry},
|
||||||
|
|
@ -53,6 +54,8 @@ let colorThemeCls = $derived(`color-scheme-${colorScheme} color-theme-${colorThe
|
||||||
{@render children()}
|
{@render children()}
|
||||||
</main>
|
</main>
|
||||||
|
|
||||||
|
<DesktopFooter />
|
||||||
|
|
||||||
<MobileFooter />
|
<MobileFooter />
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|
|
||||||
43
src/routes/create/+page.server.ts
Normal file
43
src/routes/create/+page.server.ts
Normal file
|
|
@ -0,0 +1,43 @@
|
||||||
|
import { backend } from '$lib/backend.js';
|
||||||
|
import { redirect } from 'sveltekit-flash-message/server';
|
||||||
|
|
||||||
|
export const actions = {
|
||||||
|
|
||||||
|
async default (event) {
|
||||||
|
const { request }= event;
|
||||||
|
|
||||||
|
const data = await request.formData();
|
||||||
|
const guildName = ''+data.get('to');
|
||||||
|
const title = data.get('title');
|
||||||
|
const content = data.get('content');
|
||||||
|
const privacy = +(data.get('privacy') || 0);
|
||||||
|
|
||||||
|
const backend2 = await backend.withEvent(event).oath();
|
||||||
|
const resp = await backend2.submitJson(`guild/@${encodeURIComponent(guildName)}`, {
|
||||||
|
title, content, privacy
|
||||||
|
})
|
||||||
|
|
||||||
|
const { status } = resp;
|
||||||
|
const respData = await resp.json();
|
||||||
|
|
||||||
|
if ([200, 204].indexOf(status) < 0) {
|
||||||
|
// error
|
||||||
|
console.log(`/create: status ${status}`);
|
||||||
|
switch(status) {
|
||||||
|
case 403:
|
||||||
|
case 404:
|
||||||
|
redirect({
|
||||||
|
message: respData.error
|
||||||
|
}, event);
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
redirect({message: `Unknown error (HTTP ${status})`}, event);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
const { id: myId } = respData;
|
||||||
|
|
||||||
|
redirect(303, "/=" + myId);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
@ -1,4 +1,5 @@
|
||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
|
import { enhance } from "$app/forms";
|
||||||
import Centered from "$lib/Centered.svelte";
|
import Centered from "$lib/Centered.svelte";
|
||||||
import EditPost from "$lib/EditPost.svelte";
|
import EditPost from "$lib/EditPost.svelte";
|
||||||
import { getMe } from "$lib/globals.svelte";
|
import { getMe } from "$lib/globals.svelte";
|
||||||
|
|
@ -12,14 +13,15 @@
|
||||||
let content = $state("");
|
let content = $state("");
|
||||||
let privacy = $state(0);
|
let privacy = $state(0);
|
||||||
let guildName = $state("");
|
let guildName = $state("");
|
||||||
|
//let guildInfo = $state(null);
|
||||||
|
|
||||||
let enablePost = $derived(!!content && !!guildName && false);
|
let enablePost = $derived(!!content && !!guildName);
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
|
|
||||||
{#if me}
|
{#if me}
|
||||||
<SLayout title="New post">
|
<SLayout title="New post">
|
||||||
<form method="POST" class="card">
|
<form method="POST" class="card" use:enhance>
|
||||||
<p>Posting as <strong>@{me.username}</strong></p>
|
<p>Posting as <strong>@{me.username}</strong></p>
|
||||||
|
|
||||||
<label>
|
<label>
|
||||||
|
|
|
||||||
|
|
@ -45,7 +45,7 @@ export const actions = {
|
||||||
// login success
|
// login success
|
||||||
const { id: myId } = respData;
|
const { id: myId } = respData;
|
||||||
|
|
||||||
redirect(303, "/user/" + myId);
|
redirect(303, "/@" + myId);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} satisfies Actions;
|
} satisfies Actions;
|
||||||
|
|
|
||||||
13
src/routes/privacy/+page.svelte
Normal file
13
src/routes/privacy/+page.svelte
Normal file
|
|
@ -0,0 +1,13 @@
|
||||||
|
<script lang="ts">
|
||||||
|
import { SvelteShowdown } from "svelte-showdown";
|
||||||
|
|
||||||
|
let { data }: { data: {content: string} } = $props();
|
||||||
|
|
||||||
|
let { content } = data;
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<article class="card">
|
||||||
|
<p class="faint">Privacy Policy</p>
|
||||||
|
|
||||||
|
<SvelteShowdown {content} />
|
||||||
|
</article>
|
||||||
19
src/routes/privacy/+page.ts
Normal file
19
src/routes/privacy/+page.ts
Normal file
|
|
@ -0,0 +1,19 @@
|
||||||
|
import { backend } from '$lib/backend.js';
|
||||||
|
import { error } from '@sveltejs/kit';
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
export async function load(event) {
|
||||||
|
|
||||||
|
const resp = await backend.withEvent(event).fetch('about/privacy');
|
||||||
|
|
||||||
|
if(resp.status === 404) {
|
||||||
|
error(404);
|
||||||
|
}
|
||||||
|
|
||||||
|
const respJ = await resp.json();
|
||||||
|
|
||||||
|
const { content } = respJ;
|
||||||
|
|
||||||
|
return { content };
|
||||||
|
}
|
||||||
13
src/routes/rules/+page.svelte
Normal file
13
src/routes/rules/+page.svelte
Normal file
|
|
@ -0,0 +1,13 @@
|
||||||
|
<script lang="ts">
|
||||||
|
import { SvelteShowdown } from "svelte-showdown";
|
||||||
|
|
||||||
|
let { data }: { data: {content: string} } = $props();
|
||||||
|
|
||||||
|
let { content } = data;
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<article class="card">
|
||||||
|
<p class="faint">Community Guidelines</p>
|
||||||
|
|
||||||
|
<SvelteShowdown {content} />
|
||||||
|
</article>
|
||||||
19
src/routes/rules/+page.ts
Normal file
19
src/routes/rules/+page.ts
Normal file
|
|
@ -0,0 +1,19 @@
|
||||||
|
import { backend } from '$lib/backend.js';
|
||||||
|
import { error } from '@sveltejs/kit';
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
export async function load(event) {
|
||||||
|
|
||||||
|
const resp = await backend.withEvent(event).fetch('about/rules');
|
||||||
|
|
||||||
|
if(resp.status === 404) {
|
||||||
|
error(404);
|
||||||
|
}
|
||||||
|
|
||||||
|
const respJ = await resp.json();
|
||||||
|
|
||||||
|
const { content } = respJ;
|
||||||
|
|
||||||
|
return { content };
|
||||||
|
}
|
||||||
|
|
@ -32,12 +32,9 @@ export const actions = {
|
||||||
event.locals.results = results;
|
event.locals.results = results;
|
||||||
event.locals.query = query;
|
event.locals.query = query;
|
||||||
console.log(event.locals);
|
console.log(event.locals);
|
||||||
|
|
||||||
|
return { results, query };
|
||||||
}
|
}
|
||||||
} satisfies Actions;
|
} satisfies Actions;
|
||||||
|
|
||||||
export function load (event) {
|
|
||||||
const { results, query } = event.locals;
|
|
||||||
|
|
||||||
return { results, query };
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,23 +1,30 @@
|
||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
import { enhance } from "$app/forms";
|
import { enhance } from "$app/forms";
|
||||||
|
import type { PostEntry } from "$lib/backend";
|
||||||
import BigSearchInput from "$lib/BigSearchInput.svelte";
|
import BigSearchInput from "$lib/BigSearchInput.svelte";
|
||||||
import Feed from "$lib/Feed.svelte";
|
import Feed from "$lib/Feed.svelte";
|
||||||
import { RiSearchLine } from "svelte-remixicon";
|
import { RiSearchLine } from "svelte-remixicon";
|
||||||
import type { PageProps } from "./$types";
|
|
||||||
|
|
||||||
let { data }: PageProps = $props();
|
let { data }: {
|
||||||
console.log(data);
|
data: {
|
||||||
|
query: string,
|
||||||
|
results: PostEntry[]
|
||||||
|
}
|
||||||
|
} = $props();
|
||||||
let { query, results } = $derived(data);
|
let { query, results } = $derived(data);
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<form method="POST" use:enhance>
|
<form method="POST" use:enhance>
|
||||||
<ul class="row">
|
<ul class="row">
|
||||||
<BigSearchInput bind:query />
|
<BigSearchInput {query} />
|
||||||
<button class="inline"><RiSearchLine /></button>
|
<button type="submit" class="inline"><RiSearchLine /></button>
|
||||||
</ul>
|
</ul>
|
||||||
</form>
|
</form>
|
||||||
|
|
||||||
{#if query}
|
{#if query}
|
||||||
<Feed posts={results} />
|
<Feed posts={results} />
|
||||||
|
{:else}
|
||||||
|
<p>Search function is broken!</p>
|
||||||
{/if}
|
{/if}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
13
src/routes/terms/+page.svelte
Normal file
13
src/routes/terms/+page.svelte
Normal file
|
|
@ -0,0 +1,13 @@
|
||||||
|
<script lang="ts">
|
||||||
|
import { SvelteShowdown } from "svelte-showdown";
|
||||||
|
|
||||||
|
let { data }: { data: {content: string} } = $props();
|
||||||
|
|
||||||
|
let { content } = data;
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<article class="card">
|
||||||
|
<p class="faint">Terms of Service</p>
|
||||||
|
|
||||||
|
<SvelteShowdown {content} />
|
||||||
|
</article>
|
||||||
19
src/routes/terms/+page.ts
Normal file
19
src/routes/terms/+page.ts
Normal file
|
|
@ -0,0 +1,19 @@
|
||||||
|
import { backend } from '$lib/backend.js';
|
||||||
|
import { error } from '@sveltejs/kit';
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
export async function load(event) {
|
||||||
|
|
||||||
|
const resp = await backend.withEvent(event).fetch('about/terms');
|
||||||
|
|
||||||
|
if(resp.status === 404) {
|
||||||
|
error(404);
|
||||||
|
}
|
||||||
|
|
||||||
|
const respJ = await resp.json();
|
||||||
|
|
||||||
|
const { content } = respJ;
|
||||||
|
|
||||||
|
return { content };
|
||||||
|
}
|
||||||
|
|
@ -11,8 +11,6 @@ export async function load(event) {
|
||||||
error(404);
|
error(404);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
const respJ = await resp.json();
|
const respJ = await resp.json();
|
||||||
|
|
||||||
let { users } = respJ;
|
let { users } = respJ;
|
||||||
|
|
|
||||||
|
|
@ -4,6 +4,8 @@ import { configDotenv } from 'dotenv';
|
||||||
|
|
||||||
configDotenv();
|
configDotenv();
|
||||||
|
|
||||||
|
console.info(`server name is ${process.env.SERVER_NAME}`);
|
||||||
|
|
||||||
export default defineConfig({
|
export default defineConfig({
|
||||||
plugins: [sveltekit()],
|
plugins: [sveltekit()],
|
||||||
server: {
|
server: {
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue