Merge branch 'main' into main

This commit is contained in:
Xylight authored and GitHub committed 2024-07-11 15:46:43 -07:00
commit e0c9c07e84
138 files changed
+17608 -2197

No files matched your search

+14 -12
View File
@@ -1,22 +1,24 @@
<script lang="ts">
import { goto } from '$app/navigation'
import { page } from '$app/stores'
import { t } from '$lib/translations'
import { Button } from 'mono-svelte'
import { Icon, XMark } from 'svelte-hero-icons'
</script>
<div
class="flex flex-col gap-2 mx-auto my-auto items-center h-full justify-center"
>
<div
class="rounded-full bg-red-200 dark:bg-red-900 text-red-600 dark:text-red-300 p-3 w-max"
>
<Icon src={XMark} size="32" mini />
</div>
<h1 class="text-red-800 dark:text-red-300 text-4xl font-black">
<div class="flex flex-col gap-4 mx-auto my-auto h-full justify-center">
<h1 class="text-red-500 text-4xl font-black flex items-center flex-row gap-2">
<div
class="rounded-full bg-red-500 text-red-100 dark:text-red-900 p-1 w-max"
>
<Icon src={XMark} mini size="24" />
</div>
{$page.status}
</h1>
<p class="text-red-800 dark:text-red-300">Failed to fetch that page.</p>
<code>{$page.error?.message}</code>
<Button on:click={() => goto($page.url)}>Retry</Button>
<code class="rounded-md dark:!bg-zinc-950 px-2 py-1 min-w-48">
{$page.error?.message}
</code>
<Button size="sm" class="w-max" on:click={() => goto($page.url)}>
{$t('message.retry')}
</Button>
</div>
+22
View File
@@ -0,0 +1,22 @@
import { loadTranslations, locales } from '$lib/translations.js'
import { get } from 'svelte/store'
export const load = async ({ url, request }) => {
const languages = request.headers.get('Accept-Language')?.split(',')
const availableLangs = get(locales)
let preferredLanguage = 'en'
if (!languages) {
await loadTranslations(preferredLanguage)
return
}
for (const lang of languages.reverse()) {
const splitLang = lang.split(';')[0]
if (availableLangs.includes(splitLang)) {
preferredLanguage = splitLang
}
}
await loadTranslations(preferredLanguage)
return
}
+20 -8
View File
@@ -14,6 +14,7 @@
defaultColors,
inDarkLegacyTheme,
legacyTheme,
type Colors,
} from '$lib/ui/colors.js'
import { userSettings } from '$lib/settings.js'
import { Button, ModalContainer, Spinner, ToastContainer } from 'mono-svelte'
@@ -26,21 +27,24 @@
import { site } from '$lib/lemmy.js'
import ExpandableImage from '$lib/components/ui/ExpandableImage.svelte'
import { LINKED_INSTANCE_URL } from '$lib/instance'
import { locale } from '$lib/translations'
nProgress.configure({
minimum: 0.4,
trickleSpeed: 200,
showSpinner: false,
easing: 'ease-out',
speed: 300,
})
let barTimeout: any = 0
$: {
if (browser) {
if ($navigating) {
nProgress.start()
barTimeout = setTimeout(() => nProgress.start(), 100)
}
if (!$navigating) {
clearTimeout(barTimeout)
nProgress.done()
}
}
@@ -62,21 +66,28 @@
.matchMedia('(prefers-color-scheme: dark)')
.addEventListener('change', (event) => {
darklegacyTheme = inDarkLegacyTheme()
themeColor = getMetaColor($colors)
})
document.body.querySelector('.loader')?.classList.add('hidden')
}
})
$: title = routes[($page.route.id as keyof typeof routes) ?? '']
$: browser ? document.body.setAttribute('style', colorsToVars($colors)) : ''
// svelte reactivity goof
const getMetaColor = (colors: Colors): string | undefined => {
const regex = /var\([^,]+,\s*(#[0-9A-Fa-f]{6})\)/m
return darklegacyTheme
? colors.zinc?.[925] ?? defaultColors.zinc[925].match(regex)?.[1]
: colors.slate?.[25] ?? defaultColors.slate[25].match(regex)?.[1]
}
$: themeColor = getMetaColor($colors)
</script>
<svelte:head>
<meta
name="theme-color"
content={darklegacyTheme
? $colors?.zinc?.[925] ?? defaultColors.zinc[925]
: $colors?.slate?.[25] ?? defaultColors.slate[25]}
/>
<meta name="theme-color" content={themeColor} />
{#if $site}
<title>{$site.site_view.site.name}</title>
{#if LINKED_INSTANCE_URL}
@@ -97,6 +108,7 @@
Skip Navigation
</Button>
<Shell
dir={$locale == 'he' && $userSettings.useRtl ? 'rtl' : 'ltr'}
class="min-h-screen {$userSettings.font == 'inter'
? 'font-inter'
: $userSettings.font == 'system'
+18 -1
View File
@@ -1,3 +1,20 @@
import { browser } from '$app/environment'
import { env } from '$env/dynamic/public'
import { userSettings } from '$lib/settings.js'
import { loadTranslations } from '$lib/translations.js'
import { get } from 'svelte/store'
export let ssr = (env.PUBLIC_SSR_ENABLED?.toLowerCase() ?? 'false') == 'true'
export let ssr = (env.PUBLIC_SSR_ENABLED?.toLowerCase() ?? 'false') == 'true'
export const load = async ({}) => {
if (browser) {
const initLocale =
get(userSettings)?.language ?? navigator?.language ?? 'en'
console.log(`Loading locale ${initLocale}`)
await loadTranslations(initLocale)
}
return
}
+181 -54
View File
@@ -1,49 +1,148 @@
<script lang="ts" context="module">
export interface CachedPosts {
data: {
sort: SortType
listingType: ListingType
page: number
posts: GetPostsResponse
cursor: {
next: string | undefined
}
}
params: URLSearchParams
lastSeen: number
instance: string
}
export const _posts = writable<CachedPosts>(undefined)
export const shouldReload = (
cache: CachedPosts | undefined,
params: string,
instance: string
): boolean =>
cache?.instance != instance || cache?.params.toString() != params
</script>
<script lang="ts">
import { page } from '$app/stores'
import StickyCard from '$lib/components/ui/StickyCard.svelte'
import SiteCard from '$lib/components/lemmy/SiteCard.svelte'
import Pageination from '$lib/components/ui/Pageination.svelte'
import Sort from '$lib/components/lemmy/dropdowns/Sort.svelte'
import ViewSelect from '$lib/components/lemmy/dropdowns/ViewSelect.svelte'
import { searchParam } from '$lib/util.js'
import PostFeed from '$lib/components/lemmy/post/PostFeed.svelte'
import { Button, Modal, Select, Spinner } from 'mono-svelte'
import { ChartBar, GlobeAmericas, Icon, ServerStack } from 'svelte-hero-icons'
import { profile } from '$lib/auth.js'
import { site } from '$lib/lemmy.js'
import { amModOfAny } from '$lib/components/lemmy/moderation/moderation.js'
import { feature } from '$lib/version.js'
import { userSettings } from '$lib/settings.js'
import FormattedNumber from '$lib/components/util/FormattedNumber.svelte'
import { ChartBar, ExclamationTriangle, Icon } from 'svelte-hero-icons'
import { getClient, site } from '$lib/lemmy.js'
import Location from '$lib/components/lemmy/dropdowns/Location.svelte'
import Header from '$lib/components/ui/layout/pages/Header.svelte'
import { t } from '$lib/translations.js'
import InfiniteScroll from 'svelte-infinite-scroll'
import { Button } from 'mono-svelte'
import { writable } from 'svelte/store'
import type { GetPostsResponse, ListingType, SortType } from 'lemmy-js-client'
import { userSettings } from '$lib/settings.js'
import { browser } from '$app/environment'
import { onMount } from 'svelte'
import VirtualFeed from '$lib/components/lemmy/post/feed/VirtualFeed.svelte'
import PostFeed from '$lib/components/lemmy/post/feed/PostFeed.svelte'
export let data
let sidebar = false
const limit = 20
let hasMore = data.posts.posts.length != 0
let error: any = undefined
let loading = false
async function loadMore() {
if (!hasMore || loading) return
try {
loading = true
console.log(`loading more with cursor ${data.cursor.next}`)
const newPosts = await getClient()
.getPosts({
limit: limit,
page: data.page,
sort: data.sort,
type_: data.listingType,
page_cursor: data.cursor.next,
})
.catch((e) => {
throw new Error(e)
})
error = null
hasMore = newPosts.posts.length != 0
data.cursor.next = newPosts.next_page
data.posts.posts = [...data.posts.posts, ...newPosts.posts]
_posts.update((ps) => ({
data: data,
params: ps.params,
lastSeen: ps.lastSeen,
instance: ps.instance,
}))
loading = false
} catch (e) {
error = e
loading = false
}
}
const callback: IntersectionObserverCallback = (entries, observer) => {
entries.forEach((entry) => {
if (!entry.isIntersecting) return
const element = entry.target as HTMLElement
const id = element.getAttribute('data-index')
if (!id) return
$_posts.lastSeen = Number(id)
observer.unobserve(element)
})
}
onMount(() => {
const observer = new IntersectionObserver(callback, {
root: null,
rootMargin: '0px',
threshold: 0.5,
})
const elements = document.querySelectorAll('.post-container')
elements.forEach((el) => observer.observe(el))
const postContainer = document.querySelector('#feed')
if (postContainer) {
const mutationObserver = new MutationObserver((mutations) => {
mutations.forEach((mutation) => {
if (mutation.type === 'childList') {
mutation.addedNodes.forEach((node) => {
if (
node instanceof HTMLElement &&
node.classList.contains('post-container')
) {
observer.observe(node)
}
})
}
})
})
mutationObserver.observe(postContainer, {
childList: true,
subtree: true,
})
}
})
</script>
<Modal bind:open={sidebar}>
<span slot="title">About</span>
<div class="mx-auto">
{#if $site}
<SiteCard
site={$site.site_view}
taglines={$site.taglines}
admins={$site.admins}
version={$site.version}
/>
{/if}
</div>
</Modal>
<div
class="background-gradient w-full h-48 absolute top-0 left-0 -z-10 object-cover"
></div>
<div class="flex flex-col gap-4 max-w-full w-full min-w-0">
<header>
<Header>Frontpage</Header>
<Header>{$t('routes.frontpage.title')}</Header>
</header>
<div class="flex items-center gap-2">
<Location changeDefault selected={data.listingType} />
@@ -52,11 +151,51 @@
<ViewSelect />
</div>
</div>
<PostFeed posts={data.posts.posts} />
<div class="mt-auto">
<svelte:component
this={browser ? VirtualFeed : PostFeed}
posts={data.posts.posts}
>
{#if $userSettings.infiniteScroll && browser}
{#if error}
<div
class="flex flex-col justify-center items-center
rounded-xl gap-2 py-8 mt-6
border !border-b !border-red-500 bg-red-500/5 px-4"
>
<div class="bg-red-500/30 rounded-full p-3 text-red-500">
<Icon src={ExclamationTriangle} size="24" solid></Icon>
</div>
<pre class="py-0.5">{error}</pre>
<Button
color="primary"
{loading}
disabled={loading}
on:click={loadMore}
>
{$t('message.retry')}
</Button>
</div>
{:else if hasMore}
<div class="w-full flex flex-col skeleton gap-2 animate-pulse pt-6">
<div class="w-96 h-8"></div>
<div class="w-full h-48"></div>
<div class="!bg-transparent h-8 flex justify-between">
<div class="w-48 h-8"></div>
<div class="w-24 h-8"></div>
</div>
</div>
{/if}
<InfiniteScroll window threshold={1000} on:loadMore={loadMore} />
{/if}
</svelte:component>
<svelte:element
this={$userSettings.infiniteScroll ? 'noscript' : 'div'}
class="mt-auto"
>
<Pageination
page={data.page}
cursor={{ next: data.cursor.next, back: data.cursor.back }}
cursor={{ next: data.cursor.next }}
on:change={(p) => searchParam($page.url, 'page', p.detail.toString())}
on:cursor={(c) => {
searchParam($page.url, 'cursor', c.detail)
@@ -64,29 +203,17 @@
>
<span class="flex flex-row items-center gap-1">
<Icon src={ChartBar} size="16" mini />
<FormattedNumber
number={$site?.site_view.counts.users_active_day ?? 0}
class="text-black dark:text-white font-medium"
/>
<span class="font-normal">active users</span>
{$t('routes.frontpage.footer', {
// @ts-ignore
users: $site?.site_view.counts.users_active_day ?? '??',
})}
</span>
</Pageination>
</div>
</svelte:element>
</div>
<style>
.background-gradient {
background-image: radial-gradient(
circle at left,
rgba(162, 1, 114, 0.05) 0%,
rgba(255, 0, 43, 0) 100%
),
radial-gradient(
circle at 60% 80%,
rgba(162, 33, 1, 0.1) 0%,
rgba(255, 0, 174, 0) 100%
);
background-repeat: no-repeat;
mask-image: linear-gradient(to bottom, rgba(0 0 0 / 100%), transparent);
<style lang="postcss">
.skeleton * {
@apply bg-slate-100 dark:bg-zinc-800 rounded-md;
}
</style>
+57 -30
View File
@@ -1,46 +1,73 @@
import { getClient } from '$lib/lemmy.js'
import { userSettings } from '$lib/settings.js'
import type { ListingType, SortType } from 'lemmy-js-client'
import { get } from 'svelte/store'
import type { GetPostsResponse, ListingType, SortType } from 'lemmy-js-client'
import { get, writable } from 'svelte/store'
import { error } from '@sveltejs/kit'
import { profile } from '$lib/auth.js'
import { feature } from '$lib/version.js'
import { _posts, shouldReload, type CachedPosts } from './+page.svelte'
import { browser } from '$app/environment'
import { instance } from '$lib/instance'
export async function load({ url, fetch }) {
const cursor = url.searchParams.get('cursor') as string | undefined
const prevCursor = url.searchParams.get('prevCursor') as string | undefined
const page = Number(url.searchParams.get('page')) || undefined
const sort: SortType =
(url.searchParams.get('sort') as SortType) ||
get(userSettings).defaultSort.sort
const listingType: ListingType =
(url.searchParams.get('type') as ListingType) ||
get(userSettings).defaultSort.feed
const settings = get(userSettings)
const posts = await getClient(undefined, fetch).getPosts({
limit: 20,
page: page,
sort: sort,
type_: listingType,
page_cursor: cursor,
})
const sort: SortType =
(url.searchParams.get('sort') as SortType) || settings.defaultSort.sort
const listingType: ListingType =
(url.searchParams.get('type') as ListingType) || settings.defaultSort.feed
const cached: CachedPosts | undefined = get(_posts)
const posts = shouldReload(cached, url.searchParams.toString(), get(instance))
? await getClient(undefined, fetch).getPosts({
limit: 20,
page: page,
sort: sort,
type_: listingType,
page_cursor: cursor,
show_hidden: settings.posts.showHidden,
})
: cached.data.posts
if (
shouldReload(cached, url.searchParams.toString(), get(instance)) &&
browser
)
_posts.set({
data: {
sort: sort,
listingType: listingType,
page: page || 1,
posts: posts,
cursor: {
next: posts.next_page,
},
},
params: url.searchParams,
lastSeen: 0,
instance: get(instance),
})
try {
return {
sort: sort,
listingType: listingType,
page: page || 1,
posts: posts,
cursor: {
next: posts.next_page,
back: prevCursor,
current: cursor,
},
}
return shouldReload(cached, url.searchParams.toString(), get(instance))
? {
sort: sort,
listingType: listingType,
page: page || 1,
posts: posts,
cursor: {
next: posts.next_page,
back: prevCursor,
current: cursor,
},
}
: cached.data
} catch (err) {
error(500, {
message: 'Failed to fetch homepage.',
});
message: 'Failed to fetch homepage.',
})
}
}
+29 -100
View File
@@ -23,6 +23,7 @@
import {
ArrowLeftOnRectangle,
ArrowRightOnRectangle,
ArrowsRightLeft,
ArrowUturnLeft,
BugAnt,
Check,
@@ -38,41 +39,12 @@
} from 'svelte-hero-icons'
import { flip } from 'svelte/animate'
import { expoInOut, expoOut } from 'svelte/easing'
import { t } from '$lib/translations'
import Header from '$lib/components/ui/layout/pages/Header.svelte'
let newInstance: string = $profileData.defaultInstance ?? DEFAULT_INSTANCE_URL
let loading = false
async function changeGuestInstance() {
loading = true
try {
const valid = await validateInstance(newInstance.trim())
if (!valid) {
throw new Error('invalid instance')
}
toast({
content: 'Changed guest instance.',
type: 'success',
})
} catch (err) {
toast({
content: 'Failed to contact that instance URL. Is it down?',
type: 'error',
})
loading = false
return
}
$profileData.defaultInstance = newInstance
if ($currentProfile && $currentProfile.id == -1) {
$instance = newInstance
}
loading = false
}
let debugging = false
let debugProfile: Profile | undefined = undefined
@@ -85,7 +57,7 @@
</script>
<svelte:head>
<title>Accounts</title>
<title>{$t('routes.accounts')}</title>
</svelte:head>
{#if debugging}
@@ -159,31 +131,12 @@
Sign up
</Button>
</div>
{#if LINKED_INSTANCE_URL === undefined}
<div class="flex flex-row font-normal gap-2">
<TextInput
label="Guest instance"
on:change={changeGuestInstance}
placeholder="Instance URL"
bind:value={newInstance}
/>
<Button
color="primary"
class="h-max self-end"
size="lg"
{loading}
disabled={loading}
>
Change
</Button>
</div>
{/if}
</div>
</div>
{:else}
<div class="flex flex-col h-full gap-4">
<div class="flex flex-row justify-between">
<h1 class="text-2xl font-bold">Accounts</h1>
<Header>{$t('routes.accounts')}</Header>
</div>
<EditableList
on:action={(acc) => {
@@ -232,21 +185,24 @@
? 'Switch'
: 'Current'}
on:click={async () => {
if (profile.id == $currentProfile?.id) setUserID(-1)
else {
if (profile.id != $currentProfile?.id) {
switching = profile.id
await setUserID(profile.id)
switching = -69
}
}}
size="square-md"
color={profile.id == $currentProfile?.id ? 'primary' : 'secondary'}
color={profile.id == $currentProfile?.id ? 'primary' : 'ghost'}
loading={switching == profile.id}
disabled={switching == profile.id}
>
{#if profile.id == $currentProfile?.id}
<Icon src={Check} mini size="16" />
{/if}
<svelte:fragment slot="prefix">
{#if profile.id == $currentProfile?.id}
<Icon src={Check} mini size="16" />
{:else}
<Icon src={ArrowsRightLeft} size="16" mini />
{/if}
</svelte:fragment>
</Button>
<Menu placement="bottom-end">
<Button size="square-md" slot="target">
@@ -256,6 +212,7 @@
<Button
size="square-md"
color="secondary"
title={$t('account.moveUp')}
on:click={() => moveProfile(profile.id, true)}
>
<Icon src={ChevronUp} size="16" mini slot="prefix" />
@@ -263,6 +220,7 @@
<Button
size="square-md"
color="secondary"
title={$t('account.moveDown')}
on:click={() => moveProfile(profile.id, false)}
>
<Icon src={ChevronDown} size="16" mini slot="prefix" />
@@ -273,7 +231,7 @@
on:click={() => (profile.color = undefined)}
>
<Icon src={ArrowUturnLeft} size="16" mini slot="prefix" />
Reset Color
{$t('account.resetColor')}
</MenuButton>
{#if $userSettings.debugInfo}
<MenuButton
@@ -283,58 +241,29 @@
}}
>
<Icon src={BugAnt} size="16" mini slot="prefix" />
Debug Info
{$t('common.debug')}
</MenuButton>
{/if}
<MenuButton on:click={() => action(profile)} color="danger-subtle">
<Icon slot="prefix" src={ArrowRightOnRectangle} size="16" mini />
Log Out
{$t('account.logout')}
</MenuButton>
</Menu>
</div>
{/each}
<div class="flex flex-row gap-4 items-center py-4">
<span class="font-bold flex flex-col">Guest</span>
<div class="ml-auto" />
<Button
aria-label={$currentProfile?.id != -1 ? 'Switch' : 'Current'}
on:click={async () => {
if ($currentProfile?.id != -1) setUserID(-1)
}}
size="square-md"
color={$currentProfile?.id == -1 ? 'primary' : 'secondary'}
>
{#if $currentProfile?.id == -1}
<Icon src={Check} mini size="16" />
{/if}
</Button>
</div>
</EditableList>
<div class="mt-auto" />
<div class="flex flex-row font-normal gap-2">
<TextInput
on:change={changeGuestInstance}
placeholder="Instance URL"
label="Guest instance"
bind:value={newInstance}
disabled={LINKED_INSTANCE_URL != undefined}
size="sm"
>
<span slot="prefix">https://</span>
</TextInput>
<Button
color="primary"
{loading}
disabled={loading || LINKED_INSTANCE_URL != undefined}
class="self-end"
>
Change
<div class="flex items-center gap-2">
<Button href="/login" size="lg" class="flex-1" color="primary">
<Icon slot="prefix" src={ArrowLeftOnRectangle} size="16" mini />
{$t('account.login')}
</Button>
{#if !LINKED_INSTANCE_URL}
<Button href="/login/guest" size="lg">
<Icon slot="prefix" src={Plus} size="16" mini />
{$t('account.addGuest')}
</Button>
{/if}
</div>
<Button href="/login" size="lg">
<Icon slot="prefix" src={ArrowLeftOnRectangle} size="16" mini />
Log In
</Button>
</div>
{/if}
+9 -8
View File
@@ -1,15 +1,16 @@
<script>
import { goto } from '$app/navigation'
import { page } from '$app/stores'
import { profile } from '$lib/auth'
import { notifications, profile } from '$lib/auth'
import MultiSelect from '$lib/components/input/Switch.svelte'
import { t } from '$lib/translations'
import { Badge } from 'mono-svelte'
</script>
{#if ($profile?.user?.notifications.applications ?? 0) > 0}
{#if $notifications.applications > 0}
<span class="flex flex-row text-red-500 gap-2">
<Badge color="red-subtle" class="w-max">
{$profile?.user?.notifications.applications}
{$notifications.applications}
</Badge> unread applications
</span>
{/if}
@@ -24,11 +25,11 @@
'/admin/federation',
]}
optionNames={[
'Configuration',
'Applications',
'Taglines',
'Team',
'Federation',
$t('routes.admin.config.title'),
$t('routes.admin.applications.title'),
$t('routes.admin.taglines.title'),
$t('routes.admin.team.title'),
$t('routes.admin.federation.title'),
]}
selected={$page.url.pathname}
on:select={(e) => {
+2 -1
View File
@@ -1,6 +1,7 @@
import { profile } from '$lib/auth.js'
import { get } from 'svelte/store'
import { getClient, site as siteStore } from '$lib/lemmy.js'
import { getClient } from '$lib/lemmy.js'
import { site as siteStore } from '$lib/lemmy'
export async function load({ fetch }) {
if (!get(profile)) return
+6 -4
View File
@@ -6,15 +6,17 @@
import { ClipboardDocumentCheck, Icon } from 'svelte-hero-icons'
import Application from './Application.svelte'
import MultiSelect from '$lib/components/input/Switch.svelte'
import { t } from '$lib/translations'
import Header from '$lib/components/ui/layout/pages/Header.svelte'
export let data
</script>
<h1 class="font-bold text-2xl">Applications</h1>
<Header>{$t('routes.admin.applications.title')}</Header>
<MultiSelect
options={[false, true]}
selected={data.unreadOnly ?? true}
optionNames={['All', 'Unread']}
optionNames={[$t('filter.location.all'), $t('filter.unread')]}
on:select={(e) =>
searchParam($page.url, 'unreadOnly', e.detail.toString(), 'page')}
/>
@@ -35,7 +37,7 @@
{:else}
<Placeholder
icon={ClipboardDocumentCheck}
title="No new applications"
description="Applications to join your instance will appear here."
title={$t('routes.admin.applications.empty.title')}
description={$t('routes.admin.applications.empty.description')}
/>
{/if}
@@ -1,15 +1,19 @@
<script lang="ts">
import { profile } from '$lib/auth.js'
import { notifications, profile } from '$lib/auth.js'
import UserLink from '$lib/components/lemmy/user/UserLink.svelte'
import SectionTitle from '$lib/components/ui/SectionTitle.svelte'
import { Material, toast } from 'mono-svelte'
import { getClient } from '$lib/lemmy.js'
import type {ApproveRegistrationApplication, RegistrationApplicationView} from 'lemmy-js-client'
import type {
ApproveRegistrationApplication,
RegistrationApplicationView,
} from 'lemmy-js-client'
import { Button } from 'mono-svelte'
import { Check, Icon, XMark } from 'svelte-hero-icons'
import RelativeDate from '$lib/components/util/RelativeDate.svelte'
import { publishedToDate } from '$lib/components/util/date'
import ApplicationDenyModal from "$lib/components/lemmy/modal/ApplicationDenyModal.svelte";
import ApplicationDenyModal from '$lib/components/lemmy/modal/ApplicationDenyModal.svelte'
import { t } from '$lib/translations'
export let application: RegistrationApplicationView
@@ -31,32 +35,32 @@
} else {
reviewing = true
while (reviewing) {
await new Promise(res => setTimeout(res, 1000))
await new Promise((res) => setTimeout(res, 1000))
}
if (!denying) {
denyReason = ""
denyReason = ''
return
}
if (denyReason != "") {
if (denyReason != '') {
registrationApplicationAnswer.deny_reason = denyReason
}
}
try {
await getClient().approveRegistrationApplication(registrationApplicationAnswer)
await getClient().approveRegistrationApplication(
registrationApplicationAnswer
)
toast({
content: `Successfully ${
approve ? 'approved' : 'denied'
} that application.`,
content: approve
? $t('toast.approvedApplication')
: $t('toast.deniedApplication'),
type: 'success',
})
application.creator_local_user.accepted_application = approve
application.admin = $profile.user!.local_user_view.person
application.registration_application.deny_reason = denyReason
$profile.user!.notifications.applications -= 1
$notifications.applications -= 1
} catch (err) {
toast({
content: err as any,
@@ -71,7 +75,12 @@
</script>
{#if reviewing}
<ApplicationDenyModal bind:open={reviewing} bind:denying bind:denyReason user={application.creator}/>
<ApplicationDenyModal
bind:open={reviewing}
bind:denying
bind:denyReason
user={application.creator}
/>
{/if}
<Material class="flex flex-col gap-2">
<div class="flex flex-col gap-1">
@@ -81,7 +90,7 @@
/>
</span>
<SectionTitle>User</SectionTitle>
<SectionTitle>{$t('routes.admin.applications.user')}</SectionTitle>
<span class="text-sm">
<UserLink user={application.creator} avatar avatarSize={20} />
</span>
@@ -95,12 +104,12 @@
{#if typeof application.registration_application.deny_reason !== 'undefined' && application.registration_application.deny_reason !== ''}
<div>
<div class="flex items-center gap-1 text-sm">
<UserLink avatar user={application.admin} />
<SectionTitle>
{application.creator_local_user.accepted_application
? 'Approved'
: 'Denied'} by
? $t('routes.admin.applications.approved')
: $t('routes.admin.applications.denied')}
</SectionTitle>
<UserLink avatar user={application.admin} />
<SectionTitle>:</SectionTitle>
</div>
<p>{application.registration_application.deny_reason}</p>
@@ -108,12 +117,12 @@
<div class="md:ml-auto" />
{:else}
<div class="flex items-center gap-1 text-sm">
<SectionTitle>
{application.creator_local_user.accepted_application
? 'Approved'
: 'Denied'} by
</SectionTitle>
<UserLink avatar user={application.admin} />
<SectionTitle>
{application.creator_local_user.accepted_application
? $t('routes.admin.applications.approved')
: $t('routes.admin.applications.denied')}
</SectionTitle>
</div>
<div class="md:ml-auto" />
{/if}
@@ -125,7 +134,7 @@
.accepted_application === false && application.admin
? '!text-red-500'
: ''}"
aria-label="Deny"
aria-label={$t('routes.admin.applications.deny')}
on:click={() => review(false)}
loading={denying || reviewing}
disabled={approving || denying || reviewing}
@@ -138,7 +147,7 @@
.accepted_application
? '!text-green-500'
: ''}"
aria-label="Approve"
title={$t('routes.admin.applications.approve')}
on:click={() => review(true)}
loading={approving}
disabled={approving || denying || reviewing}
+91 -62
View File
@@ -1,13 +1,15 @@
<script lang="ts">
import { profile } from '$lib/auth.js'
import MarkdownEditor from '$lib/components/markdown/MarkdownEditor.svelte'
import { Label, toast } from 'mono-svelte'
import { Label, Switch, toast } from 'mono-svelte'
import { getClient } from '$lib/lemmy.js'
import type { EditSite } from 'lemmy-js-client'
import type { PageData } from './$types.js'
import { Button, Checkbox, Select, TextInput } from 'mono-svelte'
import ImageUploadModal from '$lib/components/lemmy/modal/ImageUploadModal.svelte';
import { DocumentPlus, Icon } from 'svelte-hero-icons';
import ImageUploadModal from '$lib/components/lemmy/modal/ImageUploadModal.svelte'
import { DocumentPlus, Icon } from 'svelte-hero-icons'
import { t } from '$lib/translations.js'
import Header from '$lib/components/ui/layout/pages/Header.svelte'
export let data: PageData
@@ -29,7 +31,7 @@
...formData,
})
toast({
content: 'Updated your site.',
content: $t('toast.updatedSite'),
type: 'success',
})
} catch (err) {
@@ -46,136 +48,163 @@
let uploading = {
icon: false,
banner: false
banner: false,
}
</script>
<svelte:head>
<title>Administration</title>
<title>{$t('routes.admin.title')}</title>
</svelte:head>
<form class="flex flex-col gap-4" on:submit|preventDefault={save}>
<h1 class="font-bold text-2xl">Site configuration</h1>
<Header>{$t('routes.admin.config.title')}</Header>
{#if formData}
<TextInput bind:value={formData.name} label="Name" />
<TextInput bind:value={formData.description} label="Description" />
<TextInput bind:value={formData.name} label={$t('form.name')} />
<TextInput
bind:value={formData.description}
label={$t('form.description')}
/>
<MarkdownEditor
previewButton
bind:value={formData.sidebar}
label="Sidebar"
label={$t('routes.admin.config.sidebar')}
/>
<MarkdownEditor
previewButton
bind:value={formData.legal_information}
label="Legal"
label={$t('routes.legal.title')}
/>
<div class="flex flex-col gap-1">
<Label>Icon</Label>
<button type="button" on:click={() => uploading.icon = !uploading.icon} class="flex flex-col gap-4 bg-white dark:bg-black border border-slate-300 dark:border-zinc-800 p-4 w-full h-32 rounded-xl">
<Label>{$t('routes.admin.config.icon')}</Label>
<button
type="button"
on:click={() => (uploading.icon = !uploading.icon)}
class="flex flex-col gap-4 bg-white dark:bg-black border border-slate-300 dark:border-zinc-800 p-4 w-full h-32 rounded-xl"
>
{#if formData.icon}
<img src={formData.icon} class="rounded-md mx-auto h-full" />
{:else}
<Icon src={DocumentPlus} size="48" class="text-slate-500 dark:text-zinc-500 mx-auto my-auto" />
<Icon
src={DocumentPlus}
size="48"
class="text-slate-500 dark:text-zinc-500 mx-auto my-auto"
/>
{/if}
</button>
{#if uploading.icon}
<ImageUploadModal
bind:open={uploading.icon}
bind:output={formData.icon}
on:upload={() => uploading.icon = false}
on:upload={() => (uploading.icon = false)}
/>
{/if}
</div>
<div class="flex flex-col gap-1">
<Label>Banner</Label>
<button type="button" on:click={() => uploading.banner = !uploading.banner} class="flex flex-col gap-4 bg-white dark:bg-black border border-slate-300 dark:border-zinc-800 p-4 w-full h-32 rounded-xl">
<Label>{$t('routes.admin.config.banner')}</Label>
<button
type="button"
on:click={() => (uploading.banner = !uploading.banner)}
class="flex flex-col gap-4 bg-white dark:bg-black border border-slate-300 dark:border-zinc-800 p-4 w-full h-32 rounded-xl"
>
{#if formData.banner}
<img src={formData.banner} class="rounded-md mx-auto h-full" />
{:else}
<Icon src={DocumentPlus} size="48" class="text-slate-500 dark:text-zinc-500 mx-auto my-auto" />
<Icon
src={DocumentPlus}
size="48"
class="text-slate-500 dark:text-zinc-500 mx-auto my-auto"
/>
{/if}
</button>
{#if uploading.banner}
<ImageUploadModal
bind:open={uploading.banner}
bind:output={formData.banner}
on:upload={() => uploading.banner = false}
on:upload={() => (uploading.banner = false)}
/>
{/if}
</div>
<Checkbox bind:checked={formData.enable_downvotes} defaultValue={true}>
Enable downvotes
</Checkbox>
<Checkbox checked={formData.enable_nsfw} defaultValue={true}>
Enable NSFW
</Checkbox>
<Switch bind:checked={formData.enable_downvotes} defaultValue={true}>
{$t('routes.admin.config.downvotesEnabled')}
</Switch>
<Switch checked={formData.enable_nsfw} defaultValue={true}>
{$t('routes.admin.config.nsfwEnabled')}
</Switch>
<Select
label="Registration Mode"
label={$t('routes.admin.config.registration.label')}
bind:value={formData.registration_mode}
class="w-max"
>
<option value="Open">Open</option>
<option value="RequireApplication">Require Application</option>
<option value="Closed">Closed</option>
<option value="Open">
{$t('routes.admin.config.registration.open')}
</option>
<option value="RequireApplication">
{$t('routes.admin.config.registration.application')}
</option>
<option value="Closed">
{$t('routes.admin.config.registration.closed')}
</option>
</Select>
{#if formData.registration_mode == 'RequireApplication'}
<MarkdownEditor
previewButton
label="Application question"
label={$t('routes.admin.config.applicationQuestion')}
bind:value={formData.application_question}
/>
{/if}
<Checkbox
<Switch
bind:checked={formData.community_creation_admin_only}
defaultValue={true}
>
Only admins can create communities
</Checkbox>
<Checkbox
{$t('routes.admin.config.adminCommunityOnly')}
</Switch>
<Switch
bind:checked={formData.require_email_verification}
defaultValue={true}
>
Require email verification
</Checkbox>
<Checkbox
{$t('routes.admin.config.requireVerifyEmail')}
</Switch>
<Switch
bind:checked={formData.application_email_admins}
defaultValue={true}
>
Email admins on receiving new applications
</Checkbox>
<Checkbox bind:checked={formData.reports_email_admins} defaultValue={true}>
Email admins on receiving new reports
</Checkbox>
{$t('routes.admin.config.emailAdminsOnApplication')}
</Switch>
<Switch bind:checked={formData.reports_email_admins} defaultValue={true}>
{$t('routes.admin.config.emailAdminsOnReport')}
</Switch>
<Select
label="Listing Type"
label={$t('routes.admin.config.listingType.label')}
bind:value={formData.default_post_listing_type}
class="w-max"
>
<option value="All">All</option>
<option value="Local">Local</option>
<option value="All">{$t('routes.admin.config.listingType.all')}</option>
<option value="Local">
{$t('routes.admin.config.listingType.local')}
</option>
</Select>
<Checkbox bind:checked={formData.private_instance} defaultValue={true}>
Private instance
</Checkbox>
<Checkbox bind:checked={formData.hide_modlog_mod_names} defaultValue={true}>
Hide modlog mod names
</Checkbox>
<Switch bind:checked={formData.private_instance} defaultValue={true}>
{$t('routes.admin.config.private')}
</Switch>
<Switch bind:checked={formData.hide_modlog_mod_names} defaultValue={true}>
{$t('routes.admin.config.hideModlogModNames')}
</Switch>
<TextInput
bind:value={formData.slur_filter_regex}
label="Slur filter regex"
label={$t('routes.admin.config.slurFilter')}
placeholder="(word1|word2)"
/>
<Checkbox bind:checked={formData.federation_enabled} defaultValue={true}>
Federation enabled
</Checkbox>
<Checkbox bind:checked={formData.federation_debug} defaultValue={false}>
Federation debug mode
</Checkbox>
<Checkbox bind:checked={formData.captcha_enabled} defaultValue={false}>
Captcha enabled
</Checkbox>
<Switch bind:checked={formData.federation_enabled} defaultValue={true}>
{$t('routes.admin.config.federation')}
</Switch>
<Switch bind:checked={formData.federation_debug} defaultValue={false}>
{$t('routes.admin.config.federationDebug')}
</Switch>
<Switch bind:checked={formData.captcha_enabled} defaultValue={false}>
{$t('routes.admin.config.captcha.enabled')}
</Switch>
{/if}
<Button color="primary" size="lg" loading={saving} disabled={saving} submit>
Save
{$t('common.save')}
</Button>
</form>
+23 -27
View File
@@ -5,6 +5,7 @@
import RelativeDate from '$lib/components/util/RelativeDate.svelte'
import { publishedToDate } from '$lib/components/util/date.js'
import { getClient } from '$lib/lemmy.js'
import { t } from '$lib/translations.js'
import { trycatch } from '$lib/util.js'
import type { Instance } from 'lemmy-js-client'
import {
@@ -108,7 +109,7 @@
if (res) {
toast({
content: 'Edited your site.',
content: $t('toast.updatedSite'),
type: 'success',
})
}
@@ -126,8 +127,7 @@
if (!data.federated_instances?.federated_instances?.blocked)
throw new Error('Missing instance')
const content = e.target?.result
if (!content)
toast({ content: 'No content in that file', type: 'warning' })
if (!content) toast({ content: $t('toast.failCSV'), type: 'warning' })
try {
const instances: Instance[] = []
@@ -151,12 +151,12 @@
data.federated_instances.federated_instances.blocked = instances
} catch (err) {
toast({ content: err as 'Failed to parse CSV', type: 'error' })
toast({ content: $t('toast.failCSV'), type: 'error' })
}
}
reader.onerror = (e) =>
toast({ content: 'Failed to read file.', type: 'error' })
toast({ content: $t('toast.failCSV'), type: 'error' })
reader.readAsText(files[0])
}
@@ -167,24 +167,20 @@
</script>
<svelte:head>
<title>Federation</title>
<title>{$t('routes.admin.federation.title')}</title>
</svelte:head>
<h1 class="font-bold text-2xl flex items-center justify-between">
Federation <Button
color="primary"
on:click={save}
loading={saving}
disabled={saving}
>
Save
{$t('routes.admin.federation.title')}
<Button color="primary" on:click={save} loading={saving} disabled={saving}>
{$t('common.save')}
</Button>
</h1>
{#if data.site && data.federated_instances?.federated_instances?.blocked}
<FileInput preview={false} bind:files={csv}>
<Button class="w-max" slot="button">
<Icon src={Plus} mini size="18" slot="prefix" />
Upload a CSV
{$t('routes.admin.federation.csv')}
</Button>
<svelte:fragment slot="choose">
{''}
@@ -192,14 +188,14 @@
</FileInput>
<div class="flex flex-col md:flex-row gap-4">
<div class="flex-1 w-full max-h-[42rem] h-full flex flex-col gap-2">
<h2 class="font-bold text-lg">Blocked Instances</h2>
<h2 class="font-bold text-lg">{$t('routes.admin.federation.blocked')}</h2>
<form
on:submit|preventDefault={() =>
moderateInstance(blockInstance.instance, true)}
class="flex flex-row gap-2"
>
<TextInput
placeholder="Block an instance..."
placeholder={$t('routes.admin.federation.blockplaceholder')}
class="flex-1"
bind:value={blockInstance.instance}
/>
@@ -208,7 +204,7 @@
loading={blockInstance.loading}
disabled={blockInstance.loading}
>
Block
{$t('routes.admin.federation.block')}
</Button>
</form>
<Material class="h-full overflow-auto" color="distinct">
@@ -252,8 +248,8 @@
{:else}
<Placeholder
icon={Check}
title="No blocked instances"
description="Blocking an instance will hide submissions from that instance."
title={$t('routes.admin.federation.emptyBlock.title')}
description={$t('routes.admin.federation.emptyBlock.description')}
/>
{/if}
</EditableList>
@@ -261,7 +257,7 @@
</div>
<div class="md:flex-1 w-full max-h-[42rem] flex flex-col gap-2">
<h2 class="font-bold text-lg flex items-center space-x-1">
<span>Allowed Instances</span>
<span>{$t('routes.admin.federation.allowed')}</span>
{#if allowInstance.instance || !(data.federated_instances.federated_instances.allowed?.length == 0)}
<Popover openOnHover placement="bottom-end">
<Icon
@@ -272,9 +268,7 @@
size="20"
/>
<p class="font-normal">
Adding items to "Allowed Instances" will <strong>
block every other instance.
</strong>
{$t('routes.admin.federation.emptyAllow.description')}
</p>
</Popover>
{/if}
@@ -285,7 +279,7 @@
class="flex flex-row gap-2"
>
<TextInput
placeholder="Allow an instance..."
placeholder={$t('routes.admin.federation.allowplaceholder')}
class="flex-1"
bind:value={allowInstance.instance}
/>
@@ -294,7 +288,7 @@
loading={allowInstance.loading}
disabled={allowInstance.loading}
>
Allow
{$t('routes.admin.federation.allow')}
</Button>
</form>
<Material class="h-full overflow-auto" color="distinct">
@@ -335,8 +329,10 @@
<div class="my-auto h-max">
<Placeholder
icon={Check}
title="No allowed instances"
description="Adding an item to this will block every other instance."
title={$t('routes.admin.federation.emptyAllow.title')}
description={$t(
'routes.admin.federation.emptyAllow.description'
)}
/>
</div>
{/if}
+12 -14
View File
@@ -9,6 +9,8 @@
import type { Tagline } from 'lemmy-js-client'
import { Button } from 'mono-svelte'
import { Icon, Plus, QuestionMarkCircle, Trash } from 'svelte-hero-icons'
import Header from '$lib/components/ui/layout/pages/Header.svelte'
import { t } from '$lib/translations.js'
export let data
@@ -27,7 +29,7 @@
taglines: taglines,
})
toast({
content: 'Successfully saved taglines.',
content: $t('toast.updatedSite'),
type: 'success',
})
} catch (err) {
@@ -43,7 +45,7 @@
{#if taglines.length > 0}
<div class="flex flex-row justify-between items-center">
<h1 class="font-bold text-2xl">Taglines</h1>
<Header>{$t('routes.admin.taglines.title')}</Header>
<Button
color="primary"
on:click={save}
@@ -52,7 +54,7 @@
size="lg"
class="h-max"
>
Save
{$t('common.save')}
</Button>
</div>
<EditableList
@@ -89,23 +91,19 @@
newTagline = ''
}}
>
<MarkdownEditor
bind:value={newTagline}
placeholder="Add a tagline"
images={false}
/>
<MarkdownEditor bind:value={newTagline} images={false} />
<Button size="lg" submit>
<Icon src={Plus} size="16" mini slot="prefix" />
Add
{$t('common.add')}
</Button>
</form>
{:else}
<div class="my-auto">
<Placeholder
icon={Plus}
title="No taglines"
description="A random tagline will appear when users visit your instance."
title={$t('routes.admin.taglines.empty.title')}
description={$t('routes.admin.taglines.empty.description')}
>
<div class="mt-4 max-w-xl w-full flex flex-col gap-2">
<form
@@ -120,18 +118,18 @@
>
<MarkdownEditor
bind:value={newTagline}
placeholder="Add a tagline"
placeholder={$t('routes.admin.taglines.add')}
images={false}
/>
<Button size="lg" submit>
<Icon src={Plus} size="16" mini slot="prefix" />
Add
{$t('common.add')}
</Button>
</form>
<Button on:click={save} color="primary" size="lg" class="w-full">
Save
{$t('common.save')}
</Button>
</div>
</Placeholder>
+8 -10
View File
@@ -10,6 +10,8 @@
import { removeItem, trycatch } from '$lib/util.js'
import { Button, TextInput } from 'mono-svelte'
import { Icon, Plus, QuestionMarkCircle, Trash } from 'svelte-hero-icons'
import Header from '$lib/components/ui/layout/pages/Header.svelte'
import { t } from '$lib/translations.js'
export let data
@@ -19,7 +21,7 @@
async function removeAdmin(id: number, confirm: boolean): Promise<any> {
if (!confirm)
return toast({
content: 'Are you sure you want to remove that admin?',
content: $t('toast.removeAdminWarning'),
action: () => removeAdmin(id, true),
})
@@ -35,25 +37,21 @@
if (result) {
data.site!.admins = result.admins
toast({
content: 'Removed that admin.',
content: $t('toast.removeAdmin'),
type: 'success',
})
}
}
</script>
<svelte:head>
<title>Admin Team</title>
</svelte:head>
<h1 class="font-bold text-2xl">Admins</h1>
<Header>{$t('routes.admin.team.title')}</Header>
{#if data.site}
<EditableList let:action on:action={(e) => removeAdmin(e.detail, false)}>
{#if data.site.admins.length <= 0}
<Placeholder
icon={QuestionMarkCircle}
title="No admins"
description="Somehow there's no admins of this site. How?!"
title={$t('routes.admin.team.empty.title')}
description={$t('routes.admin.team.empty.description')}
/>
{:else}
{#each data.site?.admins ?? [] as admin}
@@ -96,7 +94,7 @@
/>
<Button loading={adding} disabled={adding} size="md" class="h-full" submit>
<Icon src={Plus} mini size="16" slot="prefix" />
Add Admin
{$t('common.add')}
</Button>
</form>
{/if}
+14 -24
View File
@@ -7,7 +7,7 @@
import { fullCommunityName, searchParam } from '$lib/util.js'
import { onDestroy, onMount } from 'svelte'
import { setSessionStorage } from '$lib/session.js'
import PostFeed from '$lib/components/lemmy/post/PostFeed.svelte'
import PostFeed from '$lib/components/lemmy/post/feed/PostFeed.svelte'
import { Button, Modal, toast } from 'mono-svelte'
import { afterNavigate } from '$app/navigation'
import { browser } from '$app/environment'
@@ -21,7 +21,7 @@
} from 'svelte-hero-icons'
import Placeholder from '$lib/components/ui/Placeholder.svelte'
import { profile } from '$lib/auth'
import { addResumable } from '$lib/lemmy/item.js'
import { t } from '$lib/translations.js'
export let data
@@ -35,18 +35,6 @@
)
})
afterNavigate(() => {
if ($profile) {
addResumable({
avatar: data.community.community_view.community.icon,
id: data.community.community_view.community.id,
url: $page.url,
name: data.community.community_view.community.title,
type: 'community',
})
}
})
onDestroy(() => {
if (browser) {
if ($navigating?.to?.route?.id == '/create/post') return
@@ -56,15 +44,17 @@
})
</script>
<Modal bind:open={sidebar}>
<span slot="title">About</span>
<div class="mx-auto">
<CommunityCard
community_view={data.community.community_view}
moderators={data.community.moderators}
/>
</div>
</Modal>
{#if sidebar}
<Modal bind:open={sidebar}>
<span slot="title">About</span>
<div class="mx-auto">
<CommunityCard
community_view={data.community.community_view}
moderators={data.community.moderators}
/>
</div>
</Modal>
{/if}
{#if data.community.community_view.community.banner}
<img
@@ -94,7 +84,7 @@
}`
)
toast({ content: 'Copied to clipboard.' })
toast({ content: $t('toast.copied') })
}}
class="dark:text-zinc-400 text-slate-600 text-sm text-left"
>
+1
View File
@@ -22,6 +22,7 @@ export async function load({ params, fetch, url }) {
page: page,
sort: sort,
page_cursor: cursor,
show_hidden: get(userSettings).posts.showHidden,
}),
}
}
@@ -9,6 +9,8 @@
import { getClient } from '$lib/lemmy.js'
import { flip } from 'svelte/animate'
import { Button, TextInput } from 'mono-svelte'
import { t } from '$lib/translations.js'
import Header from '$lib/components/ui/layout/pages/Header.svelte'
export let data: PageData
@@ -37,14 +39,14 @@
data.community.moderators = addModRes.moderators
toast({
content: 'Added that user as a moderator.',
content: $t('toast.addMod'),
type: 'success',
})
formData.newModerator = ''
} else {
toast({
content: 'Could not find that user.',
content: $t('toast.failFindUser'),
type: 'warning',
})
}
@@ -71,7 +73,7 @@
data.community.moderators = res.moderators
toast({
content: 'Successfully updated community moderators.',
content: $t('toast.updateMods'),
type: 'success',
})
} catch (err) {
@@ -83,11 +85,7 @@
}
</script>
<svelte:head>
<title>Moderator Team</title>
</svelte:head>
<h1 class="text-2xl font-bold">Moderators</h1>
<Header>Moderators</Header>
<EditableList
let:action
on:action={(e) => {
+10 -20
View File
@@ -13,6 +13,9 @@
import Sort from '$lib/components/lemmy/dropdowns/Sort.svelte'
import Placeholder from '$lib/components/ui/Placeholder.svelte'
import CommunityItem from '$lib/components/lemmy/community/CommunityItem.svelte'
import Location from '$lib/components/lemmy/dropdowns/Location.svelte'
import { t } from '$lib/translations.js'
import Header from '$lib/components/ui/layout/pages/Header.svelte'
export let data
@@ -24,8 +27,8 @@
<title>Communities</title>
</svelte:head>
<h1 class="text-3xl font-bold">
<span>Communities</span>
<Header>
<span>{$t('routes.communities')}</span>
<Popover
openOnHover
class="!inline-flex"
@@ -52,20 +55,9 @@
</p>
</Material>
</Popover>
</h1>
</Header>
<div class="flex flex-row flex-wrap gap-4 mt-4 items-center">
<Select
bind:value={data.type}
on:change={() => searchParam($page.url, 'type', data.type ?? 'All', 'page')}
>
<span slot="label" class="flex items-center gap-1">
<Icon src={GlobeAmericas} mini size="15" />
Location
</span>
<option value="All">All</option>
<option value="Local">Local</option>
<option value="Subscribed">Subscribed</option>
</Select>
<Location selected={data.type} />
<Sort selected={data.sort} />
<form
on:submit|preventDefault={() => searchParam($page.url, 'q', search, 'page')}
@@ -73,8 +65,7 @@
>
<TextInput
bind:value={search}
placeholder="Search for a community..."
label="Query"
label={$t('routes.search.query')}
size="md"
/>
<Button
@@ -93,9 +84,8 @@
{#if data.communities.length == 0}
<Placeholder
icon={QuestionMarkCircle}
title="No communities"
description="There are no communities that match this filter. Try refining your
search."
title={$t('routes.search.noResults.title')}
description={$t('routes.search.noResults.description')}
/>
{/if}
{#each data.communities as community}
+1 -1
View File
@@ -26,7 +26,7 @@
subscribing = false
return res
} catch (error) {
toast({ content: 'Failed to subscribe to community', type: 'error' })
toast({ content: error as any, type: 'error' })
}
subscribing = false
+4 -2
View File
@@ -4,6 +4,8 @@
import { profile } from '$lib/auth.js'
import { onDestroy, onMount } from 'svelte'
import { getSessionStorage, setSessionStorage } from '$lib/session.js'
import { t } from '$lib/translations.js'
import Header from '$lib/components/ui/layout/pages/Header.svelte'
export let data = {
crosspost: false,
@@ -27,7 +29,7 @@
</script>
<svelte:head>
<title>Create post</title>
<title>{$t('form.post.create')}</title>
</svelte:head>
<div class="w-full max-w-5xl mx-auto h-full">
@@ -46,6 +48,6 @@
passedCommunity={community}
on:submit={(e) => goto(`/post/${e.detail.post.id}`)}
>
<h1 class="text-3xl font-bold" slot="formtitle">Create Post</h1>
<Header class="text-3xl font-bold" slot="formtitle">Create Post</Header>
</PostForm>
</div>
+26 -15
View File
@@ -2,6 +2,7 @@
import InboxItem from './InboxItem.svelte'
import {
AdjustmentsHorizontal,
ArrowPath,
Bars3BottomRight,
Check,
Funnel,
@@ -12,12 +13,14 @@
import { goto } from '$app/navigation'
import { page } from '$app/stores'
import Pageination from '$lib/components/ui/Pageination.svelte'
import { profile } from '$lib/auth.js'
import { notifications, profile } from '$lib/auth.js'
import Placeholder from '$lib/components/ui/Placeholder.svelte'
import { fly } from 'svelte/transition'
import { searchParam } from '$lib/util.js'
import { Button, Select } from 'mono-svelte'
import EndPlaceholder from '$lib/components/ui/EndPlaceholder.svelte'
import Header from '$lib/components/ui/layout/pages/Header.svelte'
import { t } from '$lib/translations'
export let data
@@ -33,7 +36,7 @@
const response = await getClient().markAllAsRead()
$profile.user.notifications.inbox = 0
$notifications.inbox = 0
goto($page.url, {
invalidateAll: true,
@@ -49,16 +52,24 @@
<title>Inbox</title>
</svelte:head>
<div class="flex flex-row justify-between">
<h1 class="font-bold text-3xl">Inbox</h1>
<div class="flex flex-row gap-2">
<Header class="mr-auto">{$t('routes.inbox.title')}</Header>
<Button
on:click={() => goto($page.url, { invalidateAll: true })}
size="square-md"
title={$t('common.refresh')}
>
<Icon src={ArrowPath} size="16" mini slot="prefix" />
</Button>
<Button
on:click={markAllAsRead}
loading={markingAsRead}
disabled={markingAsRead}
size="md"
class="!h-8"
>
<Icon src={Check} width={16} mini slot="prefix" />
Mark All Read
{$t('routes.inbox.markAsRead')}
</Button>
</div>
<div class="mt-4" />
@@ -75,10 +86,10 @@
>
<span slot="label" class="flex items-center gap-1">
<Icon src={Funnel} size="15" mini />
Filter
{$t('filter.filter')}
</span>
<option value="false">All</option>
<option value="true">Unread</option>
<option value="false">{$t('filter.location.all')}</option>
<option value="true">{$t('filter.unread')}</option>
</Select>
<Select
bind:value={data.type}
@@ -86,20 +97,20 @@
>
<span slot="label" class="flex items-center gap-1">
<Icon src={AdjustmentsHorizontal} size="15" mini />
Type
{$t('filter.type')}
</span>
<option value="all">All</option>
<option value="mentions">Mentions</option>
<option value="replies">Replies</option>
<option value="messages">Messages</option>
<option value="all">{$t('filter.location.all')}</option>
<option value="mentions">{$t('filter.inbox.mentions')}</option>
<option value="replies">{$t('filter.inbox.replies')}</option>
<option value="messages">{$t('filter.inbox.messages')}</option>
</Select>
</div>
<div class="flex flex-col gap-4 list-none my-4 flex-1 h-full">
{#if !data.data || (data.data?.length ?? 0) == 0}
<Placeholder
icon={Inbox}
title="No new notifications"
description="Messages, replies, and mentions will appear here."
title={$t('routes.inbox.empty.title')}
description={$t('routes.inbox.empty.description')}
/>
{:else}
{#each data.data as item}
+5 -3
View File
@@ -2,7 +2,7 @@
import Comment from '$lib/components/lemmy/comment/Comment.svelte'
import UserLink from '$lib/components/lemmy/user/UserLink.svelte'
import { getClient } from '$lib/lemmy.js'
import { profile } from '$lib/auth.js'
import { notifications, profile } from '$lib/auth.js'
import {
ArrowUturnLeft,
ArrowUturnUp,
@@ -21,6 +21,7 @@
import type { InboxItem } from '$lib/lemmy/inbox.js'
import PrivateMessage from '$lib/components/lemmy/inbox/PrivateMessage.svelte'
import PrivateMessageModal from '$lib/components/lemmy/modal/PrivateMessageModal.svelte'
import { t } from '$lib/translations'
export let item: InboxItem
@@ -57,7 +58,7 @@
}
item.read = isRead
if ($profile.user) $profile.user.notifications.inbox += isRead ? -1 : 1
if ($profile.user) $notifications.inbox += isRead ? -1 : 1
loading = false
}
@@ -104,6 +105,7 @@
{loading}
disabled={loading}
on:click={() => markAsRead(!item.read)}
title={$t('post.actions.more.markRead')}
>
<Icon slot="prefix" src={Check} mini size="16" />
</Button>
@@ -117,7 +119,7 @@
{/if}
{:else}
<Button
title="Jump"
title={$t('common.jump')}
href="/comment/{item.item.comment.id}"
size="square-md"
>
+4 -14
View File
@@ -1,7 +1,9 @@
<script lang="ts">
import SiteCard from '$lib/components/lemmy/SiteCard.svelte'
import Markdown from '$lib/components/markdown/Markdown.svelte'
import Header from '$lib/components/ui/layout/pages/Header.svelte'
import { site } from '$lib/lemmy'
import { t } from '$lib/translations'
import { Button, Modal, Spinner } from 'mono-svelte'
let siteOpen: boolean = false
@@ -9,23 +11,11 @@
<div class="flex flex-row w-full">
{#if $site}
<Modal bind:open={siteOpen}>
<SiteCard
site={$site.site_view}
admins={$site.admins}
taglines={$site.taglines}
/>
</Modal>
<div class="flex flex-col flex-1 gap-4">
<h1 class="font-bold text-2xl w-full flex items-center justify-between">
Legal <span class="lg:hidden">
<Button on:click={() => (siteOpen = !siteOpen)}>Site</Button>
</span>
</h1>
<Header>{$t('routes.legal.title')}</Header>
<Markdown
source={$site.site_view.local_site.legal_information ??
'This instance does not have any legal information.'}
$t('routes.legal.noLegal')}
/>
</div>
{:else}
+26 -15
View File
@@ -10,9 +10,16 @@
validateInstance,
} from '$lib/lemmy.js'
import { Button, TextInput } from 'mono-svelte'
import { Icon, Identification, QuestionMarkCircle } from 'svelte-hero-icons'
import {
Icon,
Identification,
QuestionMarkCircle,
UserCircle,
} from 'svelte-hero-icons'
import { DOMAIN_REGEX_FORMS } from '$lib/util.js'
import { MINIMUM_VERSION } from '$lib/version.js'
import { t } from '$lib/translations'
import Header from '$lib/components/ui/layout/pages/Header.svelte'
let data = {
instance: DEFAULT_INSTANCE_URL,
@@ -41,7 +48,7 @@
const result = await setUser(response.jwt, data.instance, data.username)
if (result) {
toast({ content: 'Successfully logged in.', type: 'success' })
toast({ content: $t('toast.logIn'), type: 'success' })
goto('/')
}
} else {
@@ -64,14 +71,13 @@
<div class="max-w-xl w-full mx-auto h-max my-auto">
<form on:submit|preventDefault={logIn} class="flex flex-col gap-5">
<div class="flex flex-col gap-2">
<h1 class="font-bold text-3xl">Log In</h1>
<Header>{$t('account.login')}</Header>
{#if $site && mayBeIncompatible(MINIMUM_VERSION, $site.version.replace('v', ''))}
<Note>
This version of Photon supports instances running
<span style="font-family: monospace;">
v{MINIMUM_VERSION}
</span>
or higher.
{$t('account.versionGate', {
//@ts-ignore
version: `v${MINIMUM_VERSION}`,
})}
</Note>
{/if}
</div>
@@ -79,14 +85,14 @@
<TextInput
id="username"
bind:value={data.username}
label="Username"
label={$t('form.username')}
class="flex-1"
required
/>
{#if !LINKED_INSTANCE_URL}
<TextInput
id="instance_url"
label="Instance URL"
label={$t('form.instance')}
placeholder={DEFAULT_INSTANCE_URL}
disabled={LINKED_INSTANCE_URL != undefined}
bind:value={data.instance}
@@ -100,16 +106,17 @@
<TextInput
id="password"
bind:value={data.password}
label="Password"
label={$t('form.password')}
type="password"
minlength={10}
maxlength={60}
required
class="w-full"
/>
<TextInput
id="totp"
bind:value={data.totp}
label="2FA Code"
label={$t('form.2fa')}
placeholder="123456"
pattern={'\\d{6}'}
minlength={6}
@@ -124,17 +131,21 @@
size="lg"
submit
>
Log In
{$t('account.login')}
</Button>
<hr class="dark:border-zinc-700" />
<div class="flex flex-row items-center gap-2">
<Button color="tertiary" href="/signup">
<Icon src={Identification} mini size="16" />
Sign Up
{$t('account.signup')}
</Button>
<Button color="tertiary" href="/login_reset">
<Icon src={QuestionMarkCircle} mini size="16" />
Forgot Password
{$t('form.forgotpassword')}
</Button>
<Button color="tertiary" href="/login/guest">
<Icon src={UserCircle} mini size="16" />
{$t('account.guest')}
</Button>
</div>
</form>
+95
View File
@@ -0,0 +1,95 @@
<script lang="ts">
import { site, validateInstance } from '$lib/lemmy.js'
import { Button, Note, TextInput, toast } from 'mono-svelte'
import { MINIMUM_VERSION } from '$lib/version'
import { mayBeIncompatible } from '$lib/lemmy'
import { DOMAIN_REGEX_FORMS } from '$lib/util'
import { profile, profileData, type Profile } from '$lib/auth'
import { LINKED_INSTANCE_URL } from '$lib/instance'
import { goto } from '$app/navigation'
import { t } from '$lib/translations'
import Header from '$lib/components/ui/layout/pages/Header.svelte'
let form = {
instance: '',
username: `${$t('account.guest')} ${$profileData.profiles.filter((p) => p.jwt == undefined).length + 1}`,
loading: false,
}
async function addGuest() {
form.loading = true
if (!(await validateInstance(form.instance))) {
toast({ content: $t('toast.failInstanceURL'), type: 'error' })
form.loading = false
return
}
profileData.update((pd) => {
// too lazy to make a decent system
const id = Math.floor(Math.random() * 100000)
const newProfile: Profile = {
id: id,
instance: form.instance,
username: form.username,
}
return {
profile: id,
profiles: [...pd.profiles, newProfile],
}
})
toast({ content: $t('toast.addAccount'), type: 'success' })
goto('/')
form.loading = false
}
</script>
<div class="max-w-xl w-full mx-auto h-max my-auto">
<form on:submit|preventDefault={addGuest} class="flex flex-col gap-5">
<div class="flex flex-col gap-2">
<Header>{$t('account.addGuest')}</Header>
{#if $site && mayBeIncompatible(MINIMUM_VERSION, $site.version.replace('v', ''))}
<Note>
{$t('account.versionGate', {
//@ts-ignore
version: `v${MINIMUM_VERSION}`,
})}
</Note>
{/if}
</div>
<div class="inline-flex items-center gap-2">
<TextInput
required
label={$t('form.name')}
bind:value={form.username}
placeholder="Guest 2"
minlength={1}
class="flex-1"
></TextInput>
{#if !LINKED_INSTANCE_URL}
<TextInput
required
label={$t('form.instance')}
bind:value={form.instance}
pattern={DOMAIN_REGEX_FORMS}
placeholder="example.com"
class="flex-1"
/>
{/if}
</div>
<Button
submit
class="w-full"
color="primary"
size="lg"
loading={form.loading}
disabled={form.loading}
>
{$t('form.submit')}
</Button>
</form>
</div>
+8 -8
View File
@@ -5,6 +5,7 @@
instance as currentInstance,
} from '$lib/instance.js'
import { getClient, validateInstance } from '$lib/lemmy.js'
import { t } from '$lib/translations'
import { Button, TextInput, toast } from 'mono-svelte'
let instance = LINKED_INSTANCE_URL || $currentInstance || ''
@@ -15,14 +16,14 @@
loading = true
try {
if (!(await validateInstance(instance)))
throw new Error('Failed to contact instance url')
throw new Error($t('toast.failInstanceURL'))
await getClient(instance).passwordReset({
email: email,
})
toast({
content: 'A password reset link was sent to your email.',
content: $t('toast.resetLink'),
type: 'success',
})
} catch (err) {
@@ -36,29 +37,28 @@
</script>
<div class="my-auto max-w-xl mx-auto flex flex-col gap-2">
<h1 class="font-bold text-3xl">Reset Password</h1>
<h1 class="font-bold text-3xl">{$t('routes.resetLogin.title')}</h1>
<p>
Enter the email of your account, and a password reset link will be sent. If
you did not have an email set up, contact your instance admins.
{$t('routes.resetLogin.description')}
</p>
<form class="mt-2 flex flex-col gap-4" on:submit|preventDefault={submit}>
{#if !LINKED_INSTANCE_URL}
<TextInput
bind:value={instance}
label="Instance URL"
label={$t('form.instance')}
placeholder={DEFAULT_INSTANCE_URL}
required
/>
{/if}
<TextInput
bind:value={email}
label="Email"
label={$t('form.email')}
type="email"
required
placeholder="example@example.com"
/>
<Button color="primary" size="lg" {loading} disabled={loading} submit>
Submit
{$t('form.submit')}
</Button>
</form>
</div>
+9 -7
View File
@@ -14,12 +14,14 @@
import Placeholder from '$lib/components/ui/Placeholder.svelte'
import { searchParam } from '$lib/util.js'
import { Button, Material, Select } from 'mono-svelte'
import { t } from '$lib/translations'
import Header from '$lib/components/ui/layout/pages/Header.svelte'
export let data
</script>
<div class="mb-4 flex flex-col gap-4">
<h1 class="font-bold text-3xl">Moderation</h1>
<Header>{$t('routes.moderation.title')}</Header>
<div class="flex flex-row gap-2 flex-wrap items-center">
<Select
bind:value={data.type}
@@ -27,14 +29,14 @@
>
<span slot="label" class="flex items-center gap-1">
<Icon src={Funnel} size="15" mini />
Filter
{$t('filter.filter')}
</span>
<option value="all">All</option>
<option value="unread">Unread</option>
<option value="all">{$t('filter.location.all')}</option>
<option value="unread">{$t('filter.unread')}</option>
</Select>
<Button href="/modlog" class="h-max ml-auto">
<Icon src={Newspaper} size="16" mini />
Modlog
{$t('routes.modlog')}
</Button>
</div>
</div>
@@ -60,7 +62,7 @@
{:else}
<Placeholder
icon={Inbox}
title="No new reports"
description="When submissions are reported, you can act on them here."
title={$t('routes.moderation.empty.title')}
description={$t('routes.moderation.empty.description')}
/>
{/if}
+14 -14
View File
@@ -10,10 +10,11 @@
PrivateMessageReportView,
} from 'lemmy-js-client'
import { Check, Icon } from 'svelte-hero-icons'
import { profile } from '$lib/auth.js'
import { notifications, profile } from '$lib/auth.js'
import { Button } from 'mono-svelte'
import type { ReportView } from '$lib/lemmy/report.js'
import PrivateMessage from '$lib/components/lemmy/inbox/PrivateMessage.svelte'
import { t } from '$lib/translations'
export let item: ReportView
@@ -33,9 +34,9 @@
item.resolved = res.comment_report_view.comment_report.resolved
toast({
content: `${
item.resolved ? 'Resolved' : 'Unresolved'
} that report.`,
content: item.resolved
? $t('toast.resolveReport')
: $t('toast.unresolveReport'),
type: 'success',
})
@@ -49,9 +50,9 @@
item.resolved = res.post_report_view.post_report.resolved
toast({
content: `${
item.resolved ? 'Resolved' : 'Unresolved'
} that report.`,
content: item.resolved
? $t('toast.resolveReport')
: $t('toast.unresolveReport'),
type: 'success',
})
@@ -66,9 +67,9 @@
item.resolved =
res.private_message_report_view.private_message_report.resolved
toast({
content: `${
item.resolved ? 'Resolved' : 'Unresolved'
} that report.`,
content: item.resolved
? $t('toast.resolveReport')
: $t('toast.unresolveReport'),
type: 'success',
})
@@ -76,7 +77,7 @@
}
}
$profile.user.notifications.reports += item.resolved ? 1 : -1
$notifications.reports += item.resolved ? 1 : -1
} catch (err) {
toast({
content: err as any,
@@ -105,7 +106,7 @@
<div class="flex flex-row gap-4 items-center">
<div>
<span class="text-xs font-bold dark:text-zinc-400 text-slate-600">
Reason
{$t('routes.moderation.reason')}
</span>
<p>
{item.reason}
@@ -116,8 +117,7 @@
class="w-8 h-8 !p-1 ml-auto {item.resolved
? '!text-green-600 dark:!text-green-400'
: ''}"
aria-label="Resolve"
title="Resolve"
title={$t('routes.moderation.resolve')}
loading={resolving}
disabled={resolving}
>
@@ -1,5 +1,6 @@
<script>
import { page } from '$app/stores'
import { t } from '$lib/translations'
import { XMark, Icon } from 'svelte-hero-icons'
</script>
@@ -9,9 +10,8 @@
>
<Icon src={XMark} size="32" mini />
</div>
<h1 class="text-red-800 dark:text-red-300 text-2xl font-semibold">Error</h1>
<p class="text-red-800 dark:text-red-300">
That password reset token doesn't exist.
</p>
<h1 class="text-red-800 dark:text-red-300 text-2xl font-semibold">
{$t('message.error')}
</h1>
<code>{$page.error?.message}</code>
</div>
+10 -10
View File
@@ -6,6 +6,7 @@
instance as currentInstance,
} from '$lib/instance.js'
import { getClient, validateInstance } from '$lib/lemmy.js'
import { t } from '$lib/translations'
import { Button, TextInput, toast } from 'mono-svelte'
export let data: {
@@ -21,7 +22,7 @@
loading = true
try {
if (!(await validateInstance(instance)))
throw new Error('Failed to contact instance url')
throw new Error($t('toast.failInstanceURL'))
await getClient(instance).passwordChangeAfterReset({
password: password,
@@ -30,7 +31,7 @@
})
toast({
content: 'Your password was reset.',
content: $t('toast.passwordReset'),
type: 'success',
})
@@ -46,38 +47,37 @@
</script>
<div class="my-auto max-w-xl mx-auto flex flex-col gap-2">
<h1 class="font-bold text-3xl">Reset Password</h1>
<h1 class="font-bold text-3xl">{$t('routes.passwordChange.title')}</h1>
<p>
You've clicked an email with the password reset link in it. Now, choose your
new password.
{$t('routes.passwordChange.description')}
</p>
<form class="mt-2 flex flex-col gap-4" on:submit|preventDefault={submit}>
{#if !LINKED_INSTANCE_URL}
<TextInput
bind:value={instance}
label="Instance URL"
label={$t('form.password')}
placeholder={DEFAULT_INSTANCE_URL}
required
>
<span class="font-normal text-xs">
What instance did you reset your password for?
{$t('routes.passwordChange.instance')}
</span>
</TextInput>
{/if}
<TextInput
bind:value={password}
label="New Password"
label={$t('form.profile.newPassword')}
type="password"
required
/>
<TextInput
bind:value={password_verify}
label="New Password (Verify)"
label={$t('form.profile.verifyNewPassword')}
type="password"
required
/>
<Button color="primary" size="lg" {loading} disabled={loading} submit>
Submit
{$t('form.submit')}
</Button>
</form>
</div>
@@ -21,7 +21,7 @@
} from 'svelte-hero-icons'
import PostLink from '$lib/components/lemmy/post/PostLink.svelte'
import PostMeta from '$lib/components/lemmy/post/PostMeta.svelte'
import { Material, Select, removeToast, toast } from 'mono-svelte'
import { Material, Select, Spinner, removeToast, toast } from 'mono-svelte'
import type { CommentSortType } from 'lemmy-js-client'
import { profile } from '$lib/auth.js'
import { instance } from '$lib/instance.js'
@@ -40,8 +40,9 @@
} from '$lib/components/lemmy/post/helpers.js'
import Post from '$lib/components/lemmy/post/Post.svelte'
import Expandable from '$lib/components/ui/Expandable.svelte'
import { addResumable } from '$lib/lemmy/item.js'
import { Popover } from 'mono-svelte'
import { t } from '$lib/translations.js'
import { createWindowVirtualizer } from '@tanstack/svelte-virtual'
export let data
@@ -54,6 +55,8 @@
) {
getClient().markPostAsRead({
read: $userSettings.markPostsAsRead,
post_ids: [post.post_view.post.id],
// @ts-ignore
post_id: post.post_view.post.id,
})
}
@@ -62,26 +65,11 @@
afterNavigate(async () => {
// reactivity hack
post = data.post
if ($profile) {
addResumable({
avatar: post.post_view.post.thumbnail_url
? optimizeImageURL(post.post_view.post.thumbnail_url, 64)
: undefined,
id: post.post_view.post.id,
url: $page.url,
name: post.post_view.post.name,
type: 'post',
subdivision: {
name: post.post_view.community.name,
avatar: post.post_view.community.icon,
},
})
}
})
const fetchOnHome = async (jwt: string) => {
const id = toast({
content: 'Attempting to fetch this post on your home instance...',
content: $t('toast.fetchPostOnHome'),
loading: true,
})
@@ -124,6 +112,25 @@
$: remoteView =
$page.params.instance?.toLowerCase() != $instance.toLowerCase()
const virtualizer = createWindowVirtualizer({
count: 0,
estimateSize: () => 50,
})
onMount(async () => {
const comments = await data.comments
$virtualizer.setOptions({ count: comments.comments.length })
})
let virtualItemEls: HTMLElement[] = []
$: items = $virtualizer.getVirtualItems()
$: {
if (virtualItemEls.length)
virtualItemEls.forEach((el) => $virtualizer.measureElement(el))
}
</script>
<svelte:head>
@@ -144,11 +151,11 @@
{/if}
</svelte:head>
<div class="flex flex-col gap-2 {remoteView ? '' : ''}">
<div class="flex flex-col gap-2">
{#if remoteView}
<div
class="sticky top-0 bg-slate-50 dark:bg-zinc-950 z-20
border-b border-zinc-800
border-b dark:border-zinc-800 border-slate-300
-mx-4 -mt-4 md:-mt-6 md:-mx-6 sticky-header px-4 py-2
flex items-center gap-2 mb-4 h-12
"
@@ -161,11 +168,10 @@
slot="target"
class="bg-slate-200 dark:bg-zinc-700 p-0.5 rounded-full text-primary-900 dark:text-primary-100"
/>
This post was fetched from a different server than your account's. Many actions
won't work.
{$t('routes.post.instanceWarning')}
</Popover>
<span class="text-primary-900 dark:text-primary-100 font-bold">
Remote View
{$t('routes.post.remoteView')}
</span>
{#if $profile?.jwt}
<Button
@@ -177,7 +183,7 @@
}}
>
<Icon src={Home} mini size="16" />
Local View
{$t('routes.post.localView')}
</Button>
{/if}
</div>
@@ -202,6 +208,7 @@
moderator: post.post_view.creator_is_moderator,
}}
published={publishedToDate(post.post_view.post.published)}
bind:title={post.post_view.post.name}
/>
</div>
<Button on:click={() => history.back()} size="square-md">
@@ -243,7 +250,7 @@
class="inline-block w-full text-left text-base font-normal"
>
<span class="font-bold">{post.cross_posts.length}</span>
crossposts
{$t('routes.post.crosspostCount')}
</div>
<div
class="!divide-y divide-slate-200 dark:divide-zinc-800 flex flex-col"
@@ -265,14 +272,14 @@ flex-wrap gap-4 sticky top-20 w-full box-border z-20 mt-4"
>
<p class="font-medium text-sm flex items-center gap-2">
<Icon src={InformationCircle} mini size="20" />
You're viewing part of a thread.
{$t('routes.post.thread.part')}
</p>
<Button
{loading}
disabled={loading}
href="/comment/{$page.params.instance}/{data.thread.showContext}"
>
Show Context
{$t('routes.post.thread.context')}
</Button>
</Material>
{:else if data.thread.singleThread}
@@ -285,10 +292,10 @@ flex-wrap gap-4 sticky top-20 w-full box-border z-20 mt-4"
>
<p class="font-medium text-sm flex items-center gap-2">
<Icon src={InformationCircle} mini size="20" />
You're viewing a single thread.
{$t('routes.post.thread.single')}
</p>
<Button {loading} disabled={loading} on:click={reloadComments}>
All comments
{$t('routes.post.thread.allComments')}
</Button>
</Material>
{/if}
@@ -298,7 +305,7 @@ flex-wrap gap-4 sticky top-20 w-full box-border z-20 mt-4"
<span class="font-bold">
<FormattedNumber number={post.post_view.counts.comments} />
</span>
comments
{$t('routes.post.commentCount')}
</div>
<div class="gap-2 flex items-center h-8">
<Select
@@ -307,55 +314,71 @@ flex-wrap gap-4 sticky top-20 w-full box-border z-20 mt-4"
bind:value={commentSort}
on:change={reloadComments}
>
<option value="Hot">Hot</option>
<option value="Top">Top</option>
<option value="New">New</option>
<option value="Old">Old</option>
{#if feature('controversialSort', $page.params.instance == $instance ? $site?.version : '0.0.0')}
<option value="Controversial">Controversial</option>
{/if}
<option value="Hot">{$t('filter.sort.hot')}</option>
<option value="Top">{$t('filter.sort.top.label')}</option>
<option value="New">{$t('filter.sort.new')}</option>
<option value="Old">{$t('filter.sort.old')}</option>
<option value="Controversial">{$t('filter.sort.controversial')}</option>
</Select>
<Button size="square-md" on:click={reloadComments}>
<Icon src={ArrowPath} size="16" mini slot="prefix" />
</Button>
</div>
</div>
{#if $profile?.user}
<CommentForm
postId={post.post_view.post.id}
on:comment={(comment) =>
(data.comments.comments = [
comment.detail.comment_view,
...data.comments.comments,
])}
locked={post.post_view.post.locked ||
$page.params.instance.toLowerCase() != $instance.toLowerCase()}
on:focus={() => (commenting = true)}
tools={commenting}
preview={commenting}
placeholder={commenting ? undefined : 'Add a comment'}
rows={commenting ? 7 : 1}
{#await data.comments}
<div class="flex flex-col gap-4">
{#each new Array(10) as empty}
<div class="animate-pulse flex flex-col gap-2 skeleton w-full">
<div class="w-96 h-4" />
<div class="w-full h-12" />
<div class="w-48 h-4" />
</div>
{/each}
</div>
{:then comments}
{#if $profile?.jwt}
<CommentForm
postId={post.post_view.post.id}
on:comment={(comment) =>
(comments.comments = [
comment.detail.comment_view,
...comments.comments,
])}
locked={(post.post_view.post.locked &&
!(
$profile?.user?.local_user_view.local_user.admin ||
$profile?.user?.moderates
.map((c) => c.community.id)
.includes(data.post.community_view.community.id)
)) ||
$page.params.instance.toLowerCase() != $instance.toLowerCase()}
on:focus={() => (commenting = true)}
tools={commenting}
preview={commenting}
placeholder={commenting ? undefined : $t('routes.post.addComment')}
rows={commenting ? 7 : 1}
/>
{/if}
<Comments
post={post.post_view.post}
nodes={buildCommentsTree(
comments.comments,
undefined,
(c) =>
!(
($userSettings.hidePosts.deleted && c.comment.deleted) ||
($userSettings.hidePosts.removed && c.comment.removed)
)
)}
isParent={true}
/>
{/if}
<Comments
post={post.post_view.post}
nodes={buildCommentsTree(
data.comments.comments,
undefined,
(c) =>
!(
($userSettings.hidePosts.deleted && c.comment.deleted) ||
($userSettings.hidePosts.removed && c.comment.removed)
)
)}
isParent={true}
/>
{/await}
{#if post.post_view.counts.comments > 5}
<EndPlaceholder>
<span class="text-black dark:text-white font-bold">
{post.post_view.counts.comments}
</span>
comments
{$t('routes.post.commentCount')}
<Button
color="tertiary"
@@ -363,8 +386,14 @@ flex-wrap gap-4 sticky top-20 w-full box-border z-20 mt-4"
slot="action"
>
<Icon src={ChevronDoubleUp} mini size="16" slot="prefix" />
Scroll to top
{$t('routes.post.scrollToTop')}
</Button>
</EndPlaceholder>
{/if}
</div>
<style lang="postcss">
.skeleton * {
@apply bg-slate-100 dark:bg-zinc-800 rounded-md;
}
</style>
@@ -1,62 +1,66 @@
import { env } from '$env/dynamic/public'
import { profile } from '$lib/auth.js'
import CommunityCard from '$lib/components/lemmy/community/CommunityCard.svelte'
import { getClient } from '$lib/lemmy.js'
import { SSR_ENABLED, userSettings } from '$lib/settings.js'
import { error } from '@sveltejs/kit'
import { get } from 'svelte/store'
import { browser } from "$app/environment";
import { env } from "$env/dynamic/public";
import { profile } from "$lib/auth.js";
import CommunityCard from "$lib/components/lemmy/community/CommunityCard.svelte";
import { getClient } from "$lib/lemmy.js";
import { awaitIfServer } from "$lib/promise.js";
import { SSR_ENABLED, userSettings } from "$lib/settings.js";
import { error } from "@sveltejs/kit";
import type { GetComments } from "lemmy-js-client";
import { get } from "svelte/store";
export async function load({ params, url, fetch }) {
const post = await getClient(params.instance.toLowerCase(), fetch).getPost({
id: Number(params.id),
})
const thread = url.searchParams.get("thread");
let parentId: number | undefined;
let showContext: string | undefined = undefined;
let max_depth = post.post_view.counts.comments > 100 ? 1 : 3
const thread = url.searchParams.get('thread')
let parentId: number | undefined
let showContext: string | undefined = undefined
let max_depth = 3;
if (thread) {
const split = thread.split('.')
const split = thread.split(".");
if (split.length >= 9) {
const sliced = split.slice(0, split.length - 4)
showContext = sliced[sliced.length - 1]
parentId = Number(split[split.length - 5])
const sliced = split.slice(0, split.length - 4);
showContext = sliced[sliced.length - 1];
parentId = Number(split[split.length - 5]);
} else {
parentId = Number(split[1])
parentId = Number(split[1]);
}
if (!Number.isInteger(parentId)) {
parentId = undefined
parentId = undefined;
}
}
if (parentId) {
max_depth = 10
max_depth = 10;
}
const sort = get(userSettings)?.defaultSort?.comments ?? 'Hot'
const sort = get(userSettings)?.defaultSort?.comments ?? "Hot";
const commentParams: any = {
const commentParams: GetComments = {
post_id: Number(params.id),
type_: 'All',
type_: "All",
limit: 50,
page: 1,
max_depth: max_depth,
saved_only: false,
sort: sort,
parent_id: parentId,
}
};
const comments = getClient(params.instance, fetch).getComments(commentParams);
const post = await getClient(params.instance.toLowerCase(), fetch).getPost({
id: Number(params.id),
});
return {
thread: {
showContext: showContext,
singleThread: parentId != undefined
singleThread: parentId != undefined,
},
post: post,
commentSort: sort,
comments: await getClient(params.instance, fetch).getComments(commentParams),
comments: (await awaitIfServer(comments)).data,
slots: {
sidebar: {
component: CommunityCard,
@@ -65,5 +69,5 @@ export async function load({ params, url, fetch }) {
},
},
},
}
};
}
@@ -1,5 +1,5 @@
<div
class="flex flex-col divide-y divide-zinc-800 [&>*]:py-3 first:p-0 last:py-0"
class="flex flex-col divide-y divide-slate-200 dark:divide-zinc-800 [&>*]:py-3 first:p-0 last:py-0"
>
<slot />
</div>
@@ -17,6 +17,7 @@
import Placeholder from '$lib/components/ui/Placeholder.svelte'
import { Button } from 'mono-svelte'
import Entity from '$lib/components/ui/Entity.svelte'
import { t } from '$lib/translations.js'
// sveltekit doesn't feel like making types work right now
export let data: PageData & {
@@ -81,7 +82,7 @@
{#if data.community_blocks?.length > 0 || data.person_blocks?.length > 0 || (data.my_user?.instance_blocks?.length ?? 0) > 0}
{#if data.my_user?.instance_blocks && (data.my_user?.instance_blocks?.length ?? 0) > 0}
<div>
<SectionTitle>Instances</SectionTitle>
<SectionTitle>{$t('content.instances')}</SectionTitle>
<EditableList let:action on:action={(i) => unblockInstances(i.detail)}>
{#each data.my_user?.instance_blocks as block (block.instance.id)}
<div
@@ -105,17 +106,10 @@
{/each}
</EditableList>
</div>
{:else}
<Placeholder
description="Go to a community's page and click 'block instance' to stop seeing posts and
comments from its instance."
title="No blocked instances"
center={false}
/>
{/if}
{#if data.community_blocks?.length > 0}
<div>
<SectionTitle>Communities</SectionTitle>
<SectionTitle>{$t('content.communities')}</SectionTitle>
<EditableList let:action on:action={(i) => unblockCommunity(i.detail)}>
{#each data.community_blocks as block (block.community.id)}
<div
@@ -135,17 +129,10 @@
{/each}
</EditableList>
</div>
{:else}
<Placeholder
description="Go to a community's page and click 'block' to stop seeing posts and
comments from it."
title="No blocked communities"
center={false}
/>
{/if}
{#if data.person_blocks?.length > 0}
<div>
<SectionTitle>Users</SectionTitle>
<SectionTitle>{$t('content.users')}</SectionTitle>
<EditableList let:action on:action={(i) => unblockUser(i.detail)}>
{#each data.person_blocks as block (block.target.id)}
<div
@@ -165,20 +152,5 @@
{/each}
</EditableList>
</div>
{:else}
<Placeholder
description="Go to a user's profile and click 'block' to stop seeing posts and
comments from them."
title="No blocked users"
center={false}
/>
{/if}
{:else}
<div class="my-auto">
<Placeholder
description="Go to a community or user's page and click 'block' to stop seeing submissions from it."
title="No blocks"
center={false}
/>
</div>
{/if}
@@ -10,6 +10,8 @@
import Switch from '$lib/components/input/Switch.svelte'
import { feature } from '$lib/version.js'
import QrCode from "svelte-qrcode"
import { t } from '$lib/translations.js'
import Header from '$lib/components/ui/layout/pages/Header.svelte'
export let data
@@ -40,12 +42,12 @@
await setUser(res.jwt, instance, username!)
$currentInstance = instance
toast({ content: 'Your login was refreshed.', type: 'success' })
toast({ content: $t('toast.loginRefresh'), type: 'success' })
} else {
throw new Error('Invalid credentials')
throw new Error($t('toast.invalidLogin'))
}
toast({ content: 'Successfully changed your password. ' })
toast({ content: $t('toast.passwordReset') })
} catch (e) {
toast({
content: e as any,
@@ -84,84 +86,91 @@
</script>
<h1 class="font-bold text-3xl">Credentials</h1>
<h1 class="font-bold text-3xl">{$t('routes.profile.credentials')}</h1>
<div class="flex flex-row flex-wrap gap-8">
<div class="flex flex-col gap-2 max-w-sm w-full">
<h1 class="font-bold text-2xl">Password</h1>
<h1 class="font-bold text-2xl">{$t('form.password')}</h1>
<form
on:submit|preventDefault={changePassword}
class="max-w-sm flex flex-col gap-4"
>
<TextInput
bind:value={oldPassword}
label="Current Password"
label={$t('form.profile.currentPassword')}
type="password"
minlength={10}
required
/>
<TextInput
bind:value={newPassword}
label="New Password"
label={$t('form.profile.newPassword')}
type="password"
minlength={10}
required
/>
<TextInput
bind:value={newPasswordVerify}
label="New Password (Verify)"
label={$t('form.profile.verifyNewPassword')}
type="password"
minlength={10}
required
/>
<Button size="lg" color="primary" submit {loading} disabled={loading}>
Submit
{$t('form.submit')}
</Button>
</form>
</div>
<div class="flex flex-col gap-4 max-w-sm w-full">
<h1 class="font-bold text-2xl">2FA</h1>
<Header>{$t('form.profile.2fa.2fa')}</Header>
<p>
2FA is <span class="font-bold">
{totpEnabled ? 'enabled' : 'disabled'}
<span class="font-bold">
{totpEnabled ? $t('common.enabled') : $t('common.disabled')}
</span>
</p>
{#if totpEnabled || totpLink}
{#if totpLink && !totpEnabled}
<span class="font-normal text-xs">Scan this code using your authenticator app or add it manually</span>
<QrCode value={totpLink} size=1024/>
<TextInput disabled type="password" value={totpLink} label="TOTP Link">
<QrCode value={totpLink} size=768/>
<TextInput
disabled
type="password"
value={totpLink}
label={$t('form.profile.2fa.totp')}
>
<button
slot="suffix"
class="contents"
on:click={() => {
if (!totpLink) return
navigator.clipboard?.writeText(totpLink)
toast({ content: 'Copied to clipboard.' })
toast({ content: $t('toast.copied') })
}}
>
<Icon src={ClipboardDocument} size="20" mini />
</button>
<Icon src={ClipboardDocument} size="20" mini />
</button>
<span class="font-normal text-xs">
{$t('form.profile.2fa.paste')}
</span>
</TextInput>
{/if}
<form class="flex flex-col gap-2" on:submit|preventDefault={() => {}}>
<TextInput
bind:value={verify_totp}
placeholder="012345"
label="2FA Code"
label={$t('form.2fa')}
/>
{#if totpEnabled}
<Button on:click={() => twofa(false, true)} size="lg" color="primary">
Disable
{$t('common.disabled')}
</Button>
{:else}
<Button on:click={() => twofa(true, true)} size="lg" color="primary">
Enable
{$t('common.enabled')}
</Button>
{/if}
</form>
{:else}
<Button on:click={() => twofa(true)} size="lg" color="primary">
Setup
{$t('form.setup')}
</Button>
{/if}
</div>
@@ -7,6 +7,8 @@
import type { SaveUserSettings } from 'lemmy-js-client'
import { Button, Checkbox, Modal, TextInput } from 'mono-svelte'
import { uploadImage } from '$lib/util.js'
import { t } from '$lib/translations.js'
import Header from '$lib/components/ui/layout/pages/Header.svelte'
export let data
@@ -39,8 +41,7 @@
})
toast({
content:
'Saved your user settings. If you changed your email, a verification email will have been sent.',
content: $t('toast.saveSettings'),
type: 'success',
})
} catch (err) {
@@ -63,21 +64,21 @@
switch (level) {
case 0: {
toast({
content: 'Are you sure you want to delete your account?',
content: $t('toast.confirmDelete1'),
action: () => deleteAccount(1),
})
return
}
case 1: {
toast({
content: 'Are you really sure?',
content: $t('toast.confirmDelete2'),
action: () => deleteAccount(2),
})
return
}
case 2: {
toast({
content: 'Final warning. Are you reeeeeeally sure?',
content: $t('toast.confirmDelete3'),
action: () => deleteAccount(3),
})
return
@@ -91,13 +92,13 @@
if (!(deletion.password || null)) {
toast({
content: 'You must provide your password.',
content: $t('toast.needPassword'),
type: 'warning',
})
}
const id = toast({
content: 'You did this. Deleting account...',
content: $t('toast.deleting'),
loading: true,
})
@@ -119,7 +120,7 @@
setUserID(-1)
toast({
content: 'Your account was deleted.',
content: $t('toast.deleted'),
})
goto('/')
} catch (err) {
@@ -141,50 +142,58 @@
action="Submit"
on:action={() => deleteAccount(4)}
>
<span slot="title">Delete account</span>
<span slot="title">{$t('form.profile.deleteAccount.label')}</span>
<TextInput
label="Password"
label={$t('form.password')}
type="password"
bind:value={deletion.password}
/>
<Checkbox bind:checked={deletion.deleteContent}>
Delete content
{$t('form.profile.deleteAccount.deleteContent')}
<span slot="description">
This will delete ALL of your account's posts and comments.
{$t('form.profile.deleteAccount.warning')}
</span>
</Checkbox>
</Modal>
{/if}
<form class="flex flex-col gap-4 h-full" on:submit|preventDefault={save}>
<h1 class="font-bold text-2xl">User settings</h1>
<Header>{$t('routes.profile.settings')}</Header>
{#if data.my_user?.local_user_view?.local_user && formData}
<TextInput
label="Display name"
label={$t('form.profile.displayName')}
bind:value={formData.display_name}
placeholder="Optional"
/>
<MarkdownEditor
images={false}
bind:value={formData.bio}
label="Bio"
label={$t('form.profile.bio')}
previewButton
/>
<ImageInput label="Profile Image" bind:files={profileImage} />
<ImageInput label="Banner Image" bind:files={bannerImage} />
<TextInput label="Email" bind:value={formData.email} />
<ImageInput label={$t('form.profile.avatar')} bind:files={profileImage} />
<ImageInput label={$t('form.profile.banner')} bind:files={bannerImage} />
<TextInput label={$t('form.profile.email')} bind:value={formData.email} />
<TextInput
label="Matrix User"
label={$t('form.profile.matrix')}
bind:value={formData.matrix_user_id}
placeholder="@user:example.com"
/>
<Checkbox bind:checked={formData.show_nsfw}>Show NSFW content</Checkbox>
<Checkbox bind:checked={formData.show_scores}>Show Scores</Checkbox>
<Checkbox bind:checked={formData.bot_account}>Bot Account</Checkbox>
<Checkbox bind:checked={formData.show_nsfw}>
{$t('form.profile.showNSFW')}
</Checkbox>
<Checkbox bind:checked={formData.show_scores}>
{$t('form.profile.scores')}
</Checkbox>
<Checkbox bind:checked={formData.bot_account}>
{$t('form.profile.bot')}
</Checkbox>
<Checkbox bind:checked={formData.show_bot_accounts}>
Show Bot Accounts
{$t('form.profile.showBots')}
</Checkbox>
<Checkbox bind:checked={formData.show_read_posts}>
{$t('form.profile.showRead')}
</Checkbox>
<Checkbox bind:checked={formData.show_read_posts}>Show Read Posts</Checkbox>
<Button
submit
@@ -194,10 +203,8 @@
{loading}
disabled={loading}
>
Save
{$t('common.save')}
</Button>
{:else}
<Material padding="lg">The API didn't return your user settings.</Material>
{/if}
<Button
on:click={() => deleteAccount(0)}
@@ -205,6 +212,6 @@
size="lg"
class="ml-auto"
>
Delete account
{$t('form.profile.deleteAccount.label')}
</Button>
</form>
+8 -2
View File
@@ -3,10 +3,11 @@
import { page } from '$app/stores'
import MultiSelect from '$lib/components/input/Switch.svelte'
import { t } from '$lib/translations'
</script>
<svelte:head>
<title>Profile</title>
<title>{$t('profile.profile')}</title>
</svelte:head>
<div class="flex flex-col gap-4 h-full z-0">
@@ -17,7 +18,12 @@
'/profile/blocks',
'/profile/password',
]}
optionNames={['User', 'Settings', 'Blocks', 'Credentials']}
optionNames={[
$t('routes.profile.user'),
$t('routes.profile.settings'),
$t('routes.profile.blocks'),
$t('routes.profile.credentials'),
]}
selected={$page.url.pathname}
on:select={(e) => {
goto(e.detail)
+4 -2
View File
@@ -9,6 +9,8 @@
import { page } from '$app/stores'
import Placeholder from '$lib/components/ui/Placeholder.svelte'
import { Bookmark } from 'svelte-hero-icons'
import { t } from '$lib/translations.js'
import Header from '$lib/components/ui/layout/pages/Header.svelte'
export let data
@@ -17,10 +19,10 @@
</script>
<svelte:head>
<title>Saved</title>
<title>{$t('routes.saved')}</title>
</svelte:head>
<h1 class="text-3xl font-bold">Saved</h1>
<Header>{$t('routes.saved')}</Header>
<div
class="flex flex-col list-none my-4 divide-slate-200 dark:divide-zinc-800"
class:gap-4={$userSettings.view == 'card'}
+17 -18
View File
@@ -33,6 +33,8 @@
} from 'svelte-hero-icons'
import { expoOut } from 'svelte/easing'
import { slide } from 'svelte/transition'
import { t } from '$lib/translations.js'
import Header from '$lib/components/ui/layout/pages/Header.svelte'
type Result = PostView | CommentView | PersonView | CommunityView
@@ -46,10 +48,10 @@
</script>
<svelte:head>
<title>Search</title>
<title>{$t('routes.search.title')}</title>
</svelte:head>
<h1 class="font-bold text-3xl">Search</h1>
<Header>{$t('routes.search.title')}</Header>
<div class="flex flex-row flex-wrap items-center gap-4 mt-4">
<Select
bind:value={data.type}
@@ -57,25 +59,20 @@
>
<span slot="label" class="flex items-center gap-1">
<Icon src={AdjustmentsHorizontal} mini size="15" />
Filter
{$t('filter.type')}
</span>
<option value="All">All</option>
<option value="Posts">Posts</option>
<option value="Comments">Comments</option>
<option value="Communities">Communities</option>
<option value="Users">Users</option>
<option value="All">{$t('content.all')}</option>
<option value="Posts">{$t('content.posts')}</option>
<option value="Comments">{$t('content.comments')}</option>
<option value="Communities">{$t('content.communities')}</option>
<option value="Users">{$t('content.users')}</option>
</Select>
<Sort navigate bind:selected={data.sort} />
<form
on:submit|preventDefault={() => searchParam($page.url, 'q', query, 'page')}
class="flex flex-col sm:flex-row gap-2 sm:ml-auto items-center"
>
<TextInput
bind:value={query}
placeholder="Search for a keyword..."
label="Query"
size="md"
/>
<TextInput bind:value={query} label={$t('routes.search.query')} size="md" />
<Button
submit
color="secondary"
@@ -100,7 +97,7 @@
{#if moreOptions}
<div transition:slide={{ axis: 'y', easing: expoOut }} class="max-w-sm">
<ObjectAutocomplete
label="Community"
label={$t('nav.create.community')}
jwt={$profile?.jwt}
listing_type={'All'}
showWhenEmpty={true}
@@ -112,8 +109,10 @@
{#if !data.results}
<Placeholder
icon={MagnifyingGlass}
title="No results"
description="Search across the fediverse"
title={$t('routes.search.noResults.title')}
description={query == ''
? $t('routes.search.noResults.alt')
: $t('routes.search.noResults.description')}
class="pt-4"
/>
{:else}
@@ -123,7 +122,7 @@
out:slide={{ axis: 'y', easing: expoOut }}
>
<Spinner width={24} />
<span>Federating...</span>
<span>{$t('routes.search.federating')}</span>
</div>
{:then object}
{#if object}
+360 -128
View File
@@ -3,13 +3,28 @@
import Setting from './Setting.svelte'
import MultiSelect from '$lib/components/input/Switch.svelte'
import Sort from '$lib/components/lemmy/dropdowns/Sort.svelte'
import { Disclosure, Material, Switch, TextInput, toast } from 'mono-svelte'
import {
Badge,
Disclosure,
Material,
Note,
Switch,
TextInput,
toast,
Popover,
Modal,
TextArea,
} from 'mono-svelte'
import SectionTitle from '$lib/components/ui/SectionTitle.svelte'
import Link from '$lib/components/input/Link.svelte'
import {
ArrowDownTray,
ArrowPath,
ArrowRight,
ArrowUpOnSquare,
ArrowUpTray,
ChatBubbleOvalLeftEllipsis,
CheckCircle,
ChevronDown,
ChevronRight,
GlobeAmericas,
@@ -22,96 +37,233 @@
import { Button, Checkbox, Select } from 'mono-svelte'
import ViewSelect from '$lib/components/lemmy/dropdowns/ViewSelect.svelte'
import { LINKED_INSTANCE_URL } from '$lib/instance.js'
import { removeItem } from '$lib/util.js'
import { DOMAIN_REGEX_FORMS, removeItem } from '$lib/util.js'
import Section from './Section.svelte'
import ToggleSetting from './ToggleSetting.svelte'
import { locale, locales, t } from '$lib/translations'
import { defaultLinks, iconOfLink } from '$lib/components/ui/navbar/link'
import Header from '$lib/components/ui/layout/pages/Header.svelte'
let pin: string = ''
let importing = false
let importText = ''
</script>
<svelte:head>
<title>Settings</title>
<title>{$t('settings.title')}</title>
</svelte:head>
<h1 class="text-3xl font-bold flex justify-between">
Settings <Button
on:click={() => {
toast({
content: 'Are you sure you want to reset your settings to the default?',
action: () => ($userSettings = defaultSettings),
})
{#if importing}
<Modal
bind:open={importing}
on:action={() => {
try {
if (importText == '') {
throw new Error('Import is empty')
}
const parsed = JSON.parse(importText)
const merged = { ...defaultSettings, ...parsed }
$userSettings = merged
toast({ content: $t('toast.settingsImport'), type: 'success' })
importing = false
} catch (err) {
// @ts-ignore
toast({ content: err, type: 'error' })
}
}}
class="font-normal"
title={$t('routes.theme.import')}
action={$t('routes.theme.import')}
>
<Icon src={ArrowPath} mini size="16" slot="prefix" />
Reset
</Button>
</h1>
<TextArea bind:value={importText} style="font-family: monospace;" />
</Modal>
{/if}
<Header class="text-3xl font-bold flex justify-between">
{$t('settings.title')}
<div class="flex items-center">
<Button
size="square-lg"
on:click={() => {
importText = ''
importing = true
}}
class="font-normal"
title={$t('settings.import')}
roundingSide="left"
>
<Icon src={ArrowDownTray} mini size="18" slot="prefix" />
</Button>
<Button
size="square-lg"
on:click={() => {
const json = JSON.stringify($userSettings)
navigator?.clipboard?.writeText?.(json)
toast({ content: $t('toast.copied') })
}}
class="font-normal"
title={$t('settings.export')}
rounding="none"
>
<Icon src={ArrowUpTray} mini size="18" slot="prefix" />
</Button>
<Button
size="square-lg"
on:click={() => {
toast({
content: $t('toast.resetSettings'),
action: () => ($userSettings = defaultSettings),
})
}}
class="font-normal"
title={$t('settings.reset')}
roundingSide="right"
>
<Icon src={ArrowPath} mini size="18" slot="prefix" />
</Button>
</div>
</Header>
<div class="flex flex-col gap-4" style="scroll-behavior: smooth;">
<Section title="Navigation">
<div>
<Button
color="ghost"
on:click={() => {
$userSettings.dock.noGap = true
$userSettings.dock.top = true
}}
disabled={$userSettings.dock.noGap && $userSettings.dock.top}
>
Legacy Navigation Style
</Button>
</div>
<Section title={$t('settings.navigation.title')}>
<Setting>
<span slot="title">Dock alignment</span>
<span slot="description">Where the dock should be put</span>
<span slot="title">{$t('settings.navigation.dockPos.title')}</span>
<span slot="description">
{$t('settings.navigation.dockPos.description')}
</span>
<MultiSelect
options={[true, false]}
optionNames={['Top', 'Bottom']}
options={[true, false, null]}
optionNames={[
$t('settings.navigation.dockPos.top'),
$t('settings.navigation.dockPos.bottom'),
$t('settings.navigation.dockPos.adaptive'),
]}
bind:selected={$userSettings.dock.top}
/>
</Setting>
<ToggleSetting
bind:checked={$userSettings.dock.noGap}
title="Panel mode"
description="Extend the dock to screen edges, similar to a panel."
/>
<Setting>
<span slot="title">{$t('settings.navigation.panel.title')}</span>
<span slot="description">
{$t('settings.navigation.panel.description')}
</span>
<MultiSelect
options={[true, false, null]}
optionNames={[
$t('settings.navigation.panel.on'),
$t('settings.navigation.panel.off'),
$t('settings.navigation.panel.adaptive'),
]}
bind:selected={$userSettings.dock.noGap}
/>
</Setting>
<Setting
supportedPlatforms={{ desktop: true, tablet: true, mobile: false }}
>
<span slot="title">{$t('settings.navigation.pins.title')}</span>
<span slot="description">
{$t('settings.navigation.pins.description')}
</span>
<div class="flex items-center gap-1 flex-wrap">
{#each defaultLinks as pin}
<Popover openOnHover placement="bottom">
<Button
size="square-md"
slot="target"
disabled={$userSettings.dock.pins
?.map((p) => p.url)
?.includes(pin.url)}
on:click={() => {
$userSettings.dock.pins = [
...($userSettings.dock.pins ?? []),
pin,
]
}}
>
<Icon src={iconOfLink(pin.url)} mini size="16" />
</Button>
<Material
slot="popover"
padding="none"
class="px-4 py-2 flex flex-col"
>
<span class="font-medium text-lg">{pin.label}</span>
<code class="bg-slate-50 dark:!bg-zinc-950 !rounded-md">
{pin.url}
</code>
</Material>
</Popover>
{/each}
</div>
</Setting>
</Section>
<Section title="Photon">
<Section title={$t('settings.app.title')}>
<div class="flex flex-col gap-2">
<Setting>
<span slot="title" class="inline-flex items-center gap-2">
{$t('settings.app.lang.title')}
<Badge>{$t('settings.beta')}</Badge>
</span>
<p slot="description">
{$t('settings.app.lang.description')}
<Note>
{$t('settings.app.lang.note')}
</Note>
<Link href="/translators" highlight class="text-base font-semibold">
{$t('settings.app.lang.credits')}
</Link>
</p>
<Select bind:value={$userSettings.language}>
<option value={null}>{$t('settings.app.lang.auto')}</option>
{#each $locales as locale}
<option value={locale}>
{$t(`settings.app.lang.${locale}`, { default: locale })}
</option>
{/each}
{#if $userSettings.debugInfo}
<option value="dev">Raw Strings</option>
{/if}
</Select>
</Setting>
{#if $locale == 'he'}
<ToggleSetting
bind:checked={$userSettings.useRtl}
title={$t('settings.app.lang.useRtl.title')}
></ToggleSetting>
{/if}
</div>
<Setting>
<span slot="title">Theming</span>
<span slot="description">Customize Photon's colors.</span>
<Button href="/theme">
Go to themes <Icon src={ArrowRight} size="16" mini slot="suffix" />
</Button>
</Setting>
<Setting>
<span slot="title">Post style</span>
<span slot="title">{$t('settings.app.view.title')}</span>
<ViewSelect showLabel={false} />
<p slot="description">
{#if $userSettings.view == 'list'}
Show posts in a list, with post bodies and compact images.
{$t('settings.app.view.list')}
{:else if $userSettings.view == 'cozy'}
Show posts with large images, rich embeds and longer post bodies.
{$t('settings.app.view.cozy')}
{:else if $userSettings.view == 'compact'}
Show posts in a list, without post bodies and with tighter spacing.
{$t('settings.app.view.compact')}
{:else if $userSettings.view == 'card'}
Photon's old post style.
{$t('settings.app.view.legacy')}
{/if}
</p>
</Setting>
<Setting optionClass="flex-[2] max-w-full flex-wrap min-w-0">
<span slot="title">Default sort</span>
<span slot="description">The default sort to use for feeds.</span>
<span slot="title">{$t('settings.app.sort.title')}</span>
<span slot="description">{$t('settings.app.sort.description')}</span>
<div class="flex max-[500px]:flex-col flex-wrap gap-2 w-max max-w-full">
<div class="max-w-full">
<Select bind:value={$userSettings.defaultSort.feed}>
<span slot="label" class="flex items-center gap-1">
<Icon src={GlobeAmericas} size="16" mini />
Location
{$t('filter.location.label')}
</span>
<option value="All">All</option>
<option value="Local">Local</option>
<option value="Subscribed">Subscribed</option>
<option value="All">{$t('filter.location.all')}</option>
<option value="Local">{$t('filter.location.local')}</option>
<option value="Subscribed">
{$t('filter.location.subscribed')}
</option>
<option value="Moderator">{$t('filter.location.moderator')}</option>
</Select>
</div>
<div class="max-w-full">
@@ -124,70 +276,136 @@
<Select bind:value={$userSettings.defaultSort.comments}>
<span slot="label" class="flex items-center gap-1">
<Icon src={ChatBubbleOvalLeftEllipsis} size="14" mini />
Comments
{$t('content.comments')}
</span>
<option value="Hot">Hot</option>
<option value="Top">Top</option>
<option value="New">New</option>
<option value="Hot">{$t('filter.sort.hot')}</option>
<option value="Top">{$t('filter.sort.top.label')}</option>
<option value="New">{$t('filter.sort.new')}</option>
</Select>
</div>
</div>
</Setting>
<ToggleSetting
beta
bind:checked={$userSettings.infiniteScroll}
title={$t('settings.app.infiniteScroll.title')}
description={$t('settings.app.infiniteScroll.description')}
/>
<ToggleSetting
bind:checked={$userSettings.openLinksInNewTab}
title="Open posts in new tab"
description="Rather than opening posts in the same tab, open a separate one."
title={$t('settings.app.postsInNewTab.title')}
description={$t('settings.app.postsInNewTab.description')}
/>
<ToggleSetting
bind:checked={$userSettings.displayNames}
title="Use display name"
description="Show a user's display name instead of their account username."
title={$t('settings.app.displayName.title')}
description={$t('settings.app.displayName.description')}
/>
<ToggleSetting
supportedPlatforms={{ desktop: true, tablet: false, mobile: false }}
bind:checked={$userSettings.newWidth}
title="Limit layout width"
description="Improve readability by limiting main content width."
title={$t('settings.app.limitLayoutWidth.title')}
description={$t('settings.app.limitLayoutWidth.description')}
/>
<ToggleSetting
bind:checked={$userSettings.randomPlaceholders}
title="Random placeholders"
description="Show a random placeholder for forms for comments, posts, etc."
title={$t('settings.app.placeholders.title')}
description={$t('settings.app.placeholders.description')}
/>
<ToggleSetting
bind:checked={$userSettings.expandImages}
title="Expand images"
description="Clicking on a post's image brings you to an expanded view rather than
sending you to the post page."
title={$t('settings.app.expandImages.title')}
description={$t('settings.app.expandImages.description')}
/>
<ToggleSetting
bind:checked={$userSettings.posts.deduplicateEmbed}
title="Hide duplicate titles/bodies"
description="Hides the post title and body if they're the same as the embed."
title={$t('settings.app.duplicateTitles.title')}
description={$t('settings.app.duplicateTitles.description')}
/>
<Setting>
<span slot="title">Thumbnail alignment</span>
<span slot="title">{$t('settings.app.thumbnailSide.title')}</span>
<span slot="description">
Where thumbnails should be on the post in list/compact view.
{$t('settings.app.thumbnailSide.title')}
</span>
<MultiSelect
options={[true, false]}
optionNames={['Left', 'Right']}
optionNames={[
$t('settings.app.thumbnailSide.left'),
$t('settings.app.thumbnailSide.right'),
]}
bind:selected={$userSettings.leftAlign}
/>
</Setting>
<Setting itemsClass="flex-col !items-start">
<span slot="title">{$t('settings.app.font.title')}</span>
<span slot="description">{$t('settings.app.font.description')}</span>
<MultiSelect
options={['inter', 'satoshi/nunito', 'system', 'browser']}
optionNames={['Inter', 'Satoshi/Nunito', 'System UI', 'Browser Font']}
bind:selected={$userSettings.font}
/>
</Setting>
<Setting>
<span slot="title">{$t('settings.app.theming.title')}</span>
<span slot="description">{$t('settings.app.theming.description')}</span>
<Button href="/theme">
{$t('settings.app.theming.link')}
<Icon src={ArrowRight} size="16" mini slot="suffix" />
</Button>
</Setting>
<Setting>
<span slot="title">{$t('settings.app.translation.title')}</span>
<span slot="description">
{$t('settings.app.translation.description')}
</span>
<TextInput
bind:value={$userSettings.translator}
label={$t('settings.app.translation.instance')}
pattern={DOMAIN_REGEX_FORMS}
/>
</Setting>
<div>
<ToggleSetting
title={$t('settings.app.titleTags.title')}
description={$t('settings.app.titleTags.description')}
bind:checked={$userSettings.parseTags}
/>
<Setting>
<svelte:fragment slot="title">
{$t('settings.app.titleTags.rules.title')}
</svelte:fragment>
<div
class="flex flex-col divide-y [&>*]:py-2 items-end divide-slate-200 dark:divide-zinc-800"
>
{#each Object.keys($userSettings.tagRules) as rule}
<div class="flex flex-row flex-wrap items-center gap-2">
<span class="text-lg font-medium">{rule}</span>
<MultiSelect
bind:selected={$userSettings.tagRules[rule]}
options={['blur', 'hide']}
optionNames={[
$t('settings.app.titleTags.rules.blur'),
$t('settings.app.titleTags.rules.hide'),
]}
/>
</div>
{/each}
</div>
</Setting>
</div>
</Section>
<Section title="Embeds">
<Section title={$t('settings.embeds.title')}>
<ToggleSetting
title="Click to view"
description="Don't load an embed until you click it. (It is recommended to leave this on, to not load a video you don't want to load.)"
title={$t('settings.embeds.clickToView.title')}
description={$t('settings.embeds.clickToView.description')}
bind:checked={$userSettings.embeds.clickToView}
/>
<Setting>
<span slot="title">YouTube</span>
<span slot="description">
The website to use to embed YouTube content.
{$t('settings.embeds.youtube.description')}
</span>
<Select bind:value={$userSettings.embeds.youtube}>
<option value="youtube">YouTube</option>
@@ -195,102 +413,116 @@
<option value="piped">Piped</option>
</Select>
</Setting>
<Setting vertical>
<span slot="title">Font</span>
<span slot="description">What font Photon should use.</span>
<MultiSelect
options={['inter', 'satoshi/nunito', 'system', 'browser']}
optionNames={['Inter', 'Satoshi/Nunito', 'System UI', 'Browser Font']}
bind:selected={$userSettings.font}
/>
</Setting>
{#if $userSettings.embeds.youtube == 'invidious'}
<Setting>
<span slot="title">{$t('settings.embeds.instance.invidious')}</span>
<span slot="description">
{$t('settings.embeds.instance.description')}
</span>
<TextInput
label={$t('settings.embeds.instance.invidious')}
pattern={DOMAIN_REGEX_FORMS}
bind:value={$userSettings.embeds.invidious}
/>
</Setting>
{/if}
{#if $userSettings.embeds.youtube == 'piped'}
<Setting>
<span slot="title">{$t('settings.embeds.instance.piped')}</span>
<span slot="description">
{$t('settings.embeds.instance.description')}
</span>
<TextInput
label={$t('settings.embeds.instance.piped')}
pattern={DOMAIN_REGEX_FORMS}
bind:value={$userSettings.embeds.piped}
/>
</Setting>
{/if}
</Section>
<Section title="Lemmy">
<Section title={$t('settings.lemmy.title')}>
<ToggleSetting
bind:checked={$userSettings.posts.showHidden}
title={$t('settings.lemmy.showHiddenPosts.title')}
description={$t('settings.lemmy.showHiddenPosts.description')}
/>
<ToggleSetting
bind:checked={$userSettings.posts.compactFeatured}
title="Compact featured posts"
description="Make featured posts more compact."
title={$t('settings.lemmy.compactFeatured.title')}
description={$t('settings.lemmy.compactFeatured.description')}
/>
<ToggleSetting
bind:checked={$userSettings.markPostsAsRead}
title="Mark read posts"
description="Mark a post as read when you click on it."
title={$t('settings.lemmy.markReadPosts.title')}
description={$t('settings.lemmy.markReadPosts.description')}
/>
<ToggleSetting
bind:checked={$userSettings.markReadPosts}
title="Fade read posts"
description="Fade the title of posts you've already read."
title={$t('settings.lemmy.fadeReadPosts.title')}
description={$t('settings.lemmy.fadeReadPosts.title')}
/>
<ToggleSetting
bind:checked={$userSettings.crosspostOriginalLink}
title="'Crossposted from' when crossposting"
description="If enabled, crossposts will include a link to the original post."
title={$t('settings.lemmy.crosspostMarker.title')}
description={$t('settings.lemmy.crosspostMarker.description')}
/>
<Setting>
<span slot="title">Hide Submissions</span>
<span slot="title">{$t('settings.lemmy.hideSubmissions.title')}</span>
<span slot="description">
<p>Hide certain types of submissions.</p>
<p>
Looking to hide read posts? That was moved to your <Link
href="/profile/settings"
highlight
>
profile settings.
</Link>
</p>
<p>{$t('settings.lemmy.hideSubmissions.description')}</p>
</span>
<div class="flex flex-col items-start gap-4 flex-wrap">
<Switch bind:checked={$userSettings.hidePosts.deleted}>Deleted</Switch>
<Switch bind:checked={$userSettings.hidePosts.deleted}>
{$t('settings.lemmy.hideSubmissions.deleted')}
</Switch>
<Switch bind:checked={$userSettings.hidePosts.removed}>
Removed by Moderator
{$t('settings.lemmy.hideSubmissions.removed')}
</Switch>
</div>
</Setting>
<ToggleSetting
bind:checked={$userSettings.nsfwBlur}
title="NSFW blur"
description="Blur images and remove post bodies of content tagged NSFW."
title={$t('settings.lemmy.nsfwBlur.title')}
description={$t('settings.lemmy.nsfwBlur.description')}
/>
<Setting>
<span slot="title">Show instances</span>
<span slot="description">Show items' instances.</span>
<span slot="title">{$t('settings.lemmy.instances.title')}</span>
<span slot="description">
{$t('settings.lemmy.instances.description')}
</span>
<div class="flex flex-row flex-wrap items-center gap-4">
<Checkbox bind:checked={$userSettings.showInstances.user}>
Users
{$t('content.users')}
</Checkbox>
<Checkbox bind:checked={$userSettings.showInstances.comments}>
Comments
{$t('content.comments')}
</Checkbox>
<Checkbox bind:checked={$userSettings.showInstances.community}>
Communities
{$t('content.communities')}
</Checkbox>
</div>
</Setting>
</Section>
<Section title="Moderation">
<Section title={$t('settings.moderation.title')}>
<Setting mainClass="md:flex-row flex-col !items-start">
<span slot="title">Removal reply presets</span>
<span slot="title">{$t('settings.moderation.replyPresets.title')}</span>
<span slot="description">
<p>Presets to use for "Reply reason" in a submission removal.</p>
<p>{$t('settings.moderation.replyPresets.description')}</p>
<ul class="leading-6">
<li>Syntax:</li>
<li>{$t('settings.moderation.replyPresets.syntax')}</li>
<li>
<code>{'{{reason}}'}</code>
: The provided reason
</li>
<li>
<code>{'{{post}}'}</code>
: The title of the post
</li>
<li>
<code>{'{{community}}'}</code>
: The community the submission was removed in.
</li>
<li>
<code>{'{{username}}'}</code>
: The username of the creator of the submission.
</li>
</ul>
</span>
@@ -365,11 +597,11 @@
</Setting>
</Section>
<Section title="Other">
<Section title={$t('settings.other.title')}>
<ToggleSetting
bind:checked={$userSettings.debugInfo}
title="Debug info"
description="Display debug information"
title={$t('settings.other.debug.title')}
description={$t('settings.other.debug.description')}
/>
</Section>
</div>
+53 -16
View File
@@ -1,25 +1,62 @@
<script lang="ts">
import { t } from '$lib/translations'
import { Badge } from 'mono-svelte'
import {
ComputerDesktop,
DevicePhoneMobile,
DeviceTablet,
Icon,
} from 'svelte-hero-icons'
export let vertical: boolean = false
export let supportedPlatforms = {
desktop: true,
tablet: true,
mobile: true,
}
</script>
<div
class="flex {vertical
? 'flex-col'
: 'flex-row items-center'} w-full justify-between gap-4 max-w-full {$$props.mainClass}"
class="flex flex-col w-full justify-between gap-2 max-w-full {$$props.mainClass}"
>
<div class="flex flex-col gap-0.5 flex-1 {$$props.class}">
<h1 class="font-medium text-base"><slot name="title" /></h1>
{#if $$slots.description}
<p class="text-slate-800 dark:text-zinc-200 text-sm">
<slot name="description" />
</p>
{/if}
</div>
{#if $$slots.default}
<div
class="w-full flex flex-col gap-2 flex-1 items-end max-w-full {$$props.optionClass}"
>
<slot />
{#if Object.values(supportedPlatforms).some((v) => v == false)}
<div class="flex items-center gap-2 flex-wrap">
{#if supportedPlatforms.desktop}
<Badge>
<Icon src={ComputerDesktop} micro size="14" slot="icon" />
{$t('settings.desktop')}
</Badge>
{/if}
{#if supportedPlatforms.tablet}
<Badge>
<Icon src={DeviceTablet} micro size="14" slot="icon" />
{$t('settings.tablet')}
</Badge>
{/if}
{#if supportedPlatforms.mobile}
<Badge>
<Icon src={DevicePhoneMobile} micro size="14" slot="icon" />
{$t('settings.mobile')}
</Badge>
{/if}
</div>
{/if}
<div class="flex flex-row items-center gap-6 {$$props.itemsClass}">
<div class="flex flex-col gap-0.5 flex-1 {$$props.class}">
<h1 class="font-medium text-base"><slot name="title" /></h1>
{#if $$slots.description}
<p class="text-slate-800 dark:text-zinc-200 text-sm">
<slot name="description" />
</p>
{/if}
</div>
{#if $$slots.default}
<div
class="w-full flex flex-col gap-2 flex-1 items-end max-w-full {$$props.optionClass}"
>
<slot />
</div>
{/if}
</div>
</div>
+43 -2
View File
@@ -1,12 +1,53 @@
<script lang="ts">
import { Switch } from 'mono-svelte'
import { t } from '$lib/translations'
import { Badge, Switch } from 'mono-svelte'
import {
ComputerDesktop,
DevicePhoneMobile,
DeviceTablet,
Icon,
} from 'svelte-hero-icons'
export let title: string
export let description: string | undefined = undefined
export let checked: boolean = false
export let beta = false
export let supportedPlatforms = {
desktop: true,
tablet: true,
mobile: true,
}
</script>
<div class="flex flex-row items-center w-full justify-between gap-4 max-w-full">
<div class="flex flex-col w-full justify-between gap-2 max-w-full">
{#if Object.values(supportedPlatforms).some((v) => v == false) || beta}
<div class="flex items-center gap-2 flex-wrap">
{#if beta}
<Badge>Beta</Badge>
{/if}
{#if Object.values(supportedPlatforms).some((v) => v == false)}
{#if supportedPlatforms.desktop}
<Badge>
<Icon src={ComputerDesktop} micro size="14" slot="icon" />
{$t('settings.desktop')}
</Badge>
{/if}
{#if supportedPlatforms.tablet}
<Badge>
<Icon src={DeviceTablet} micro size="14" slot="icon" />
{$t('settings.tablet')}
</Badge>
{/if}
{#if supportedPlatforms.mobile}
<Badge>
<Icon src={DevicePhoneMobile} micro size="14" slot="icon" />
{$t('settings.mobile')}
</Badge>
{/if}
{/if}
</div>
{/if}
<Switch
bind:checked
class="flex-row-reverse items-center w-full"
+9 -9
View File
@@ -21,6 +21,7 @@
import { Button, TextInput } from 'mono-svelte'
import { onMount } from 'svelte'
import Avatar from '$lib/components/ui/Avatar.svelte'
import { t } from '$lib/translations'
let selectedInstance: string = ''
let validating: boolean = false
@@ -64,7 +65,7 @@
// ]
} catch (e) {
toast({
content: 'Failed to fetch available instances.',
content: $t('toast.failFetchInstances'),
type: 'error',
})
}
@@ -78,15 +79,14 @@
</script>
<svelte:head>
<title>Sign up | Choose Instance</title>
<title>{$t('form.signup.title')}</title>
</svelte:head>
<div class="mx-auto max-w-xl flex flex-col gap-4 my-auto h-max w-full">
<h1 class="font-bold text-4xl">Sign Up</h1>
<p>Choose an instance that interests you, or type the URL manually.</p>
<h1 class="font-bold text-4xl">{$t('form.signup.title')}</h1>
<p>{$t('form.signup.description')}</p>
<p>
An instance is the server that your account will be hosted on, but you can
still access and interact with content from other instances.
{$t('form.signup.info')}
</p>
<Material color="distinct" class="h-64 overflow-auto">
<div
@@ -129,7 +129,7 @@
goto(`/signup/${selectedInstance}`)
} else {
toast({
content: 'Could not contact that instance URL',
content: $t('toast.failInstanceURL'),
type: 'error',
})
}
@@ -140,7 +140,7 @@
>
<TextInput
bind:value={selectedInstance}
label="Choose an instance"
label={$t('form.signup.chooseInstance')}
required
{placeholder}
on:input={() => {
@@ -154,7 +154,7 @@
loading={validating}
disabled={validating}
>
Go
{$t('form.submit')}
</Button>
</form>
</div>
+20 -22
View File
@@ -20,6 +20,8 @@
XCircle,
} from 'svelte-hero-icons'
import { instance as currentInstance } from '$lib/instance.js'
import Header from '$lib/components/ui/layout/pages/Header.svelte'
import { t } from '$lib/translations.js'
export let data
@@ -67,7 +69,7 @@
if (res?.jwt) {
await setUser(res.jwt, $page.params.instance, username)
toast({ content: 'Successfully logged in.', type: 'success' })
toast({ content: $t('toast.logIn'), type: 'success' })
goto('/')
} else if (
res.verify_email_sent ||
@@ -76,8 +78,7 @@
currentInstance.set(instance)
if (res.verify_email_sent) {
toast({
content:
'A verification link was sent to your email. Verify your email, and then you can log in.',
content: $t('toast.verifyEmail'),
type: 'info',
})
}
@@ -85,18 +86,17 @@
data.site_view.local_site.registration_mode == 'RequireApplication'
) {
toast({
content:
'Please wait for your registration application to be approved before you can log in.',
content: $t('toast.waitApplication'),
type: 'info',
})
}
goto('/')
} else {
throw new Error('Failed to sign up.')
throw new Error($t('toast.failSignup'))
}
toast({
content: 'Signed up.',
content: $t('toast.successSignup'),
type: 'success',
})
} catch (err) {
@@ -125,39 +125,37 @@
</span>
{#if data.site_view.local_site.registration_mode != 'Closed'}
<h1 class="font-bold text-3xl">Create account</h1>
<Header>{$t('form.signup.title')}</Header>
<TextInput
bind:value={email}
label="Email"
label={$t('form.email')}
required={data.site_view.local_site.require_email_verification}
type="email"
/>
<TextInput bind:value={username} label="Username" required />
<TextInput bind:value={username} label={$t('form.username')} required />
<TextInput
bind:value={password}
label="Password"
label={$t('form.password')}
required
type="password"
/>
<TextInput
bind:value={passwordVerify}
label="Confirm Password"
label={$t('form.confirmPassword')}
required
type="password"
/>
{#if data.site_view.local_site.registration_mode == 'RequireApplication'}
<Material class="dark:text-yellow-200 text-yellow-800 bg-yellow-500/20">
<Icon src={ExclamationTriangle} mini size="20" />
To join this instance, you must fill out this application, and wait to be
accepted. You will receive an email if your application is accepted.
{$t('form.signup.application.info')}
</Material>
{#if data.site_view.local_site.application_question}
<Markdown source={data.site_view.local_site.application_question} />
{/if}
<MarkdownEditor
label="Application"
label={$t('form.signup.application.label')}
required
placeholder="An explanation of why you think this instance is awesome"
bind:value={application}
/>
{/if}
@@ -199,7 +197,7 @@
</div>
</div>
{/if}
<Checkbox bind:checked={nsfw}>Show NSFW content</Checkbox>
<Checkbox bind:checked={nsfw}>{$t('form.profile.showNSFW')}</Checkbox>
<input type="dn" name="honeypot" bind:value={honeypot} class="hidden" />
<Button
submit
@@ -209,17 +207,17 @@
disabled={submitting}
class="mt-auto"
>
Submit
{$t('form.submit')}
</Button>
{:else}
<div class="my-auto">
<Placeholder
icon={XCircle}
title="Registrations closed"
description="New account creation has been disabled on this instance."
title={$t('form.signup.closed.title')}
description={$t('form.signup.closed.description')}
>
<Button icon={Plus} href="https://join-lemmy.org">
Find another instance
<Button icon={Plus} href="/signup">
{$t('form.signup.closed.anotherInstance')}
</Button>
</Placeholder>
</div>
+20 -14
View File
@@ -17,6 +17,8 @@
Icon,
} from 'svelte-hero-icons'
import ColorSwatch from './ColorSwatch.svelte'
import { t } from '$lib/translations'
import Header from '$lib/components/ui/layout/pages/Header.svelte'
const c = defaultColors
@@ -36,22 +38,22 @@
throw new Error('Import is empty')
}
$colors = JSON.parse(importText)
toast({ content: 'Import successful', type: 'success' })
toast({ content: $t('message.success'), type: 'success' })
importing = false
} catch (err) {
// @ts-ignore
toast({ content: err, type: 'error' })
}
}}
title="Import"
action="Import"
title={$t('routes.theme.import')}
action={$t('routes.theme.import')}
>
<TextArea bind:value={importText} style="font-family: monospace;" />
</Modal>
{/if}
<div class="flex flex-col gap-4 h-full">
<h1 class="font-bold text-3xl">Theme</h1>
<Header>Theme</Header>
<div class="flex items-center gap-4">
<Button
on:click={() => {
@@ -60,7 +62,7 @@
size="lg"
>
<Icon src={ArrowUpTray} size="16" mini />
Import
{$t('routes.theme.import')}
</Button>
<Button
on:click={() => {
@@ -70,37 +72,37 @@
size="lg"
>
<Icon src={ArrowDownTray} size="16" mini />
Export
{$t('routes.theme.export')}
</Button>
<Button
on:click={() => {
modal({
actions: [
action({
content: 'Close',
content: $t('common.cancel'),
close: true,
}),
action({
action: () => {
$colors = { other: {}, primary: {}, zinc: {}, slate: {} }
},
content: 'Reset',
content: $t('routes.theme.reset'),
close: true,
type: 'danger',
}),
],
title: 'Reset Theme',
body: 'This will reset all your colors to the default. We recommend exporting your theme first.',
title: $t('routes.theme.resetWarning.title'),
body: $t('routes.theme.resetWarning.description'),
})
}}
size="lg"
>
<Icon src={ArrowPath} size="16" mini />
Reset
{$t('routes.theme.reset')}
</Button>
</div>
<Material color="transparent" class="items-center gap-x-4 color-grid gap-y-2">
<h1 class="text-2xl font-bold col-span-2">Accent</h1>
<h1 class="text-2xl font-bold col-span-2">{$t('routes.theme.accent')}</h1>
<ColorSwatch
backgroundColor={defaultColors.primary[900]}
bind:value={$colors.primary[900]}
@@ -111,8 +113,12 @@
bind:value={$colors.primary[100]}
class="!w-12 !h-12 col-span-1"
/>
<span class="font-semibold text-base">Light</span>
<span class="font-semibold text-base">Dark</span>
<span class="font-semibold text-base">
{$t('nav.menu.colorscheme.light')}
</span>
<span class="font-semibold text-base">
{$t('nav.menu.colorscheme.dark')}
</span>
</Material>
<div class="grid grid-cols-1 sm:grid-cols-2 md:grid-cols-3 gap-2">
{#each svelteIntellisenseSucks() as category}
+40
View File
@@ -0,0 +1,40 @@
<script lang="ts">
import Header from '$lib/components/ui/layout/pages/Header.svelte'
import { t } from '$lib/translations'
import { Heart, Icon } from 'svelte-hero-icons'
</script>
<Header class="mb-4">
{$t('routes.translators')}
</Header>
<ul class="divide-y divide-slate-200 dark:divide-zinc-900 list">
<li class="flex flex-col">
<span class="font-bold text-lg">Estonian</span>
<span>pewgar_seemsimandroid@lemmy.blahaj.zone</span>
</li>
<li class="flex flex-col">
<span class="font-bold text-lg">Finnish</span>
<span>sevonj</span>
</li>
<li class="flex flex-col">
<span class="font-bold text-lg">French</span>
<span>Blisterexe@lemmy.zip</span>
</li>
<li class="flex flex-col">
<span class="font-bold text-lg">German</span>
<span>Tmpod</span>
</li>
<li class="flex flex-col">
<span class="font-bold text-lg">Portuguese</span>
<span>poVoq</span>
</li>
</ul>
<style>
.list > *:not(:first-child) {
padding-top: 0.5rem;
}
.list > *:not(:last-child) {
padding-bottom: 0.5rem;
}
</style>
+80 -84
View File
@@ -41,6 +41,10 @@
import PrivateMessageModal from '$lib/components/lemmy/modal/PrivateMessageModal.svelte'
import LabelStat from '$lib/components/ui/LabelStat.svelte'
import PostBody from '$lib/components/lemmy/post/PostBody.svelte'
import Expandable from '$lib/components/ui/Expandable.svelte'
import { communityLink } from '$lib/lemmy/generic.js'
import ItemList from '$lib/components/lemmy/generic/ItemList.svelte'
import { t } from '$lib/translations.js'
export let data
@@ -66,7 +70,7 @@
}
toast({
content: `Successfully ${blocked ? 'unblocked' : 'blocked'} that user.`,
content: blocked ? $t('toast.unblockUser') : $t('toast.blockUser'),
type: 'success',
})
@@ -95,14 +99,14 @@
async function purgeUser() {
purgingUser = false
const purgeToast = toast({ content: 'Purging user...', loading: true })
const purgeToast = toast({ content: '', loading: true })
try {
await client().purgePerson({
person_id: data.person_view.person.id,
})
removeToast(purgeToast)
toast({ content: 'Purged that user.', type: 'success' })
toast({ content: $t('toast.purgeUser'), type: 'success' })
} catch (e) {
toast({ content: e as any, type: 'error' })
}
@@ -155,59 +159,7 @@
alt="User banner"
/>
{/if}
<div class="flex flex-col-reverse gap-4 max-w-full w-full">
<div class="flex flex-col gap-4 max-w-full w-full min-w-0">
<div class="flex flex-row gap-4 flex-wrap justify-between">
<Select
bind:value={data.sort}
on:change={() => searchParam($page.url, 'sort', data.sort, 'page')}
>
<span slot="label" class="flex items-center gap-1">
<Icon src={ChartBar} size="14" mini />
Sort
</span>
<option value="New">New</option>
<option value="TopAll">Top</option>
<option value="Old">Old</option>
</Select>
<Select
bind:value={data.type}
on:change={() => searchParam($page.url, 'type', data.type, 'page')}
>
<span slot="label" class="flex items-center gap-1">
<Icon src={AdjustmentsHorizontal} size="15" mini />
Type
</span>
<option value="all">All</option>
<option value="posts">Posts</option>
<option value="comments">Comments</option>
</Select>
</div>
{#if data.items.length == 0}
<Placeholder
icon={PencilSquare}
title="No submissions"
description="This user has no submissions that match this filter."
/>
{:else}
<div
class="!divide-y divide-slate-200 dark:divide-zinc-800 flex flex-col"
>
{#each data.items as item}
{#if isCommentView(item) && (data.type == 'all' || data.type == 'comments')}
<CommentItem comment={item} />
{:else if !isCommentView(item) && (data.type == 'all' || data.type == 'posts')}
<Post post={item} />
{/if}
{/each}
</div>
{/if}
<Pageination
page={data.page}
on:change={(p) => searchParam($page.url, 'page', p.detail.toString())}
/>
</div>
<div class="flex flex-col gap-4 max-w-full w-full">
<div class="flex flex-col gap-4">
<Avatar
width={64}
@@ -234,41 +186,33 @@
<LabelStat
content={data.person_view.counts.post_count.toString()}
formatted
label="Posts"
label={$t('content.posts')}
/>
<LabelStat
content={data.person_view.counts.comment_count.toString()}
formatted
label="Comments"
label={$t('content.comments')}
/>
</div>
{#if (data.moderates ?? []).length > 0}
<div class="flex flex-col gap-2 max-w-full">
<span class="font-bold">Moderates</span>
<div
class="flex items-center -space-x-1 flex-wrap hover:space-x-1 transition-all
cursor-pointer"
>
{#each data.moderates as moderator}
<Popover openOnHover placement="top" class="transition-all">
<a
class="block ring rounded-full ring-slate-50 dark:ring-zinc-950 transition-all"
href="/c/{moderator.community.name}@{new URL(
moderator.community.actor_id
).hostname}"
slot="target"
>
<Avatar
width={28}
url={moderator.community.icon}
alt={moderator.community.title}
/>
</a>
<span class="font-bold">{moderator.community.title}</span>
</Popover>
{/each}
</div>
</div>
<Expandable
class="border-y w-full py-3
dark:border-zinc-800 text-slate-700 dark:text-zinc-300 transition-colors"
>
<span slot="title" class="flex items-center gap-1">
<ShieldIcon width={14} filled />
{$t('routes.profile.moderates')}
</span>
<ItemList
items={data.moderates.map((m) => ({
id: m.community.id,
name: m.community.title,
url: communityLink(m.community),
avatar: m.community.icon,
instance: new URL(m.community.actor_id).hostname,
}))}
/>
</Expandable>
{/if}
{#if $profile?.user && $profile.jwt && data.person_view.person.id != $profile.user.local_user_view.person.id}
<div class="flex items-center gap-2 w-full">
@@ -329,4 +273,56 @@
</div>
{/if}
</div>
<div class="flex flex-col gap-4 max-w-full w-full min-w-0">
<div class="flex flex-row gap-4 flex-wrap justify-between">
<Select
bind:value={data.sort}
on:change={() => searchParam($page.url, 'sort', data.sort, 'page')}
>
<span slot="label" class="flex items-center gap-1">
<Icon src={ChartBar} size="14" mini />
{$t('filter.sort.label')}
</span>
<option value="New">{$t('filter.sort.new')}</option>
<option value="TopAll">{$t('filter.sort.top.label')}</option>
<option value="Old">{$t('filter.sort.old')}</option>
</Select>
<Select
bind:value={data.type}
on:change={() => searchParam($page.url, 'type', data.type, 'page')}
>
<span slot="label" class="flex items-center gap-1">
<Icon src={AdjustmentsHorizontal} size="15" mini />
{$t('filter.type')}
</span>
<option value="all">{$t('content.all')}</option>
<option value="posts">{$t('content.posts')}</option>
<option value="comments">{$t('content.comments')}</option>
</Select>
</div>
{#if data.items.length == 0}
<Placeholder
icon={PencilSquare}
title="No submissions"
description="This user has no submissions that match this filter."
/>
{:else}
<div
class="!divide-y divide-slate-200 dark:divide-zinc-800 flex flex-col"
>
{#each data.items as item}
{#if isCommentView(item) && (data.type == 'all' || data.type == 'comments')}
<CommentItem comment={item} />
{:else if !isCommentView(item) && (data.type == 'all' || data.type == 'posts')}
<Post post={item} />
{/if}
{/each}
</div>
{/if}
<Pageination
page={data.page}
on:change={(p) => searchParam($page.url, 'page', p.detail.toString())}
/>
</div>
</div>
@@ -1,5 +1,6 @@
<script>
import { page } from '$app/stores'
import { t } from '$lib/translations'
import { XMark, Icon } from 'svelte-hero-icons'
</script>
@@ -9,7 +10,9 @@
>
<Icon src={XMark} size="32" mini />
</div>
<h1 class="text-red-800 dark:text-red-300 text-2xl font-semibold">Error</h1>
<p class="text-red-800 dark:text-red-300">Failed to verify your email.</p>
<h1 class="text-red-800 dark:text-red-300 text-2xl font-semibold">
{$t('message.error')}
</h1>
<p class="text-red-800 dark:text-red-300">{$t('routes.verifyEmail.error')}</p>
<code>{$page.error?.message}</code>
</div>
+3 -2
View File
@@ -1,5 +1,6 @@
<script>
import { LINKED_INSTANCE_URL } from '$lib/instance'
import { t } from '$lib/translations'
import { Check, Icon } from 'svelte-hero-icons'
</script>
@@ -10,10 +11,10 @@
<Icon src={Check} size="32" mini />
</div>
<h1 class="text-green-800 dark:text-green-200 text-2xl font-semibold">
Success
{$t('message.success')}
</h1>
<p class="text-green-800 dark:text-green-200">
Your email was verified. You can safely close this window.
{$t('routes.verifyEmail.message')}
</p>
{#if !LINKED_INSTANCE_URL}
<p>