Merge branch 'main' into listview-selfpost-thumbnail

This commit is contained in:
Xylight authored and GitHub committed 2024-07-11 15:29:36 -07:00
commit 82a06974ef
53 files changed
+2061 -441

No files matched your search

+86 -130
View File
@@ -4,7 +4,8 @@ import {
} from '$lib/components/lemmy/moderation/moderation.js'
import { toast } from 'mono-svelte'
import { DEFAULT_INSTANCE_URL, instance } from '$lib/instance.js'
import { client, getClient, site } from '$lib/lemmy.js'
import { client, getClient } from '$lib/lemmy.js'
import { site } from './lemmy'
import { userSettings } from '$lib/settings.js'
import { instanceToURL, moveItem } from '$lib/util.js'
import {
@@ -13,7 +14,7 @@ import {
type MyUserInfo,
type Community,
} from 'lemmy-js-client'
import { get, writable } from 'svelte/store'
import { derived, get, writable, type Writable } from 'svelte/store'
import { MINIMUM_VERSION, versionIsSupported } from '$lib/version.js'
import { browser } from '$app/environment'
import { env } from '$env/dynamic/public'
@@ -57,12 +58,12 @@ interface ProfileData {
defaultInstance?: string
}
interface PersonData extends MyUserInfo {
notifications: {
inbox: number
reports: number
applications: number
}
interface PersonData extends MyUserInfo {}
interface Notifications {
inbox: number
reports: number
applications: number
}
const getCookie = (key: string): string | undefined => {
@@ -91,19 +92,77 @@ export let profileData = writable<ProfileData>(
}
)
// stupid hack to get dev server working
// why does this always happen to me
let fetchingUser = false
let initialInstance = get(profileData).defaultInstance
export let profile = derived<Writable<ProfileData>, Profile>(
profileData,
(pd) => {
const profile =
pd.profiles.find((p) => p.id == pd.profile) ?? getDefaultProfile()
if (profile?.jwt) {
if (!profile.user && !fetchingUser) {
site.set(undefined)
fetchingUser = true
notifications.set({ applications: 0, inbox: 0, reports: 0 })
userFromJwt(profile.jwt, profile.instance)
.then((res) => {
if (!res?.user)
toast({
content: 'Your login has expired. Re-login to fix this issue.',
type: 'warning',
})
site.set(res?.site)
profile.user = res?.user
profile.avatar = res?.user.local_user_view.person.avatar
checkInbox()
fetchingUser = false
})
.catch((e) => {
fetchingUser = false
toast({ content: e, type: 'error' })
})
}
} else {
if (browser) {
site.set(undefined)
client({ instanceURL: profile.instance })
.getSite()
.then((res) => site.set(res))
}
}
instance.set(profile.instance)
return profile
}
)
export let notifications = writable<Notifications>({
applications: 0,
inbox: 0,
reports: 0,
})
profileData.subscribe(async (pd) => {
setFromStorage('profileData', pd)
const serialized: ProfileData = {
...pd,
profiles: pd.profiles.map((p) => serializeUser(p)),
}
if (pd.profile == -1 && initialInstance != pd.defaultInstance) {
initialInstance = get(profileData).defaultInstance ?? DEFAULT_INSTANCE_URL
setFromStorage('profileData', serialized)
if (serialized.profile == -1) {
instance?.set(get(profileData).defaultInstance ?? DEFAULT_INSTANCE_URL)
}
if (pd.profiles.length == 0) {
if (serialized.profiles.length == 0) {
profileData.update((pd) => ({
...pd,
profiles: [
@@ -145,43 +204,6 @@ if (
}
}
export let profile = writable<Profile | undefined>(getProfile())
profile.subscribe(async (p) => {
if (p?.id == -1) {
instance?.set(get(profileData).defaultInstance ?? DEFAULT_INSTANCE_URL)
}
if (!p) return
instance.set(p.instance)
// fetch the user because p.user is undefined
if (p?.jwt && !p?.user) {
const user = await userFromJwt(p.jwt, p.instance)
.then((user) => {
if (!user?.user)
toast({
content: 'Your login has expired. Re-login to fix this issue.',
type: 'warning',
})
site.set(user?.site)
return user
})
.catch((err) => {
toast({ content: err as any, type: 'error' })
})
if (!user?.user) return
profile.update(() => ({
...p,
user: user!.user,
username: user?.user.local_user_view.person.name,
avatar: user?.user.local_user_view.person.avatar,
}))
}
})
export async function setUser(jwt: string, inst: string, username: string) {
try {
new URL(instanceToURL(inst))
@@ -217,11 +239,6 @@ export async function setUser(jwt: string, inst: string, username: string) {
avatar: user.user.local_user_view.person.avatar,
}
profile.set({
...newProfile,
user: user!.user,
})
return {
profile: id,
profiles: [newProfile, ...pd.profiles],
@@ -261,32 +278,12 @@ async function userFromJwt(
if (!myUser) return undefined
return {
user: {
notifications: {
applications: 0,
inbox: 0,
reports: 0,
},
...myUser,
},
user: myUser,
site: site,
}
}
function getProfile() {
const id = get(profileData).profile
if (id == -1) {
return getDefaultProfile()
}
const pd = get(profileData)
return pd.profiles.find((p) => p.id == id)
}
export function resetProfile() {
profile.set(getDefaultProfile())
profileData.update((p) => ({ ...p, profile: -1 }))
}
@@ -308,10 +305,12 @@ export function deleteProfile(id: number) {
}
}
const serializeUser = (user: Profile): Profile => ({
...user,
user: undefined,
})
function serializeUser(user: Profile): Profile {
return {
...user,
user: undefined,
}
}
instance.subscribe(async (i) => {
try {
@@ -324,35 +323,8 @@ instance.subscribe(async (i) => {
})
export async function setUserID(id: number) {
const pd = get(profileData)
if (id == -1) {
resetProfile()
instance.set(DEFAULT_INSTANCE_URL)
return
}
let prof = pd.profiles.find((p) => p.id == id)
if (!prof) return profile.update(() => getDefaultProfile())
prof = serializeUser(prof)
profileData.update((p) => ({ ...p, profile: id }))
if (prof?.jwt) {
const user = await userFromJwt(prof.jwt, prof.instance)
.then((u) => u)
.catch((err) => {
toast({ content: err as any, type: 'error' })
})
instance.set(prof.instance)
prof.user = user?.user
prof.avatar = user?.user.local_user_view.person.avatar
site.set(user?.site)
}
profile.update(() => prof ?? getDefaultProfile())
return prof
return get(profile)
}
export function moveProfile(id: number, up: boolean) {
@@ -369,11 +341,7 @@ export function moveProfile(id: number, up: boolean) {
}
}
const getNotificationCount = async (
jwt: string,
mod: boolean,
admin: boolean
) => {
async function getNotificationCount(jwt: string, mod: boolean, admin: boolean) {
const unreads = await getClient().getUnreadCount()
let reports: number = 0
@@ -419,26 +387,14 @@ async function checkInbox() {
const notifs = await getNotificationCount(
jwt,
amModOfAny(user) ?? false,
isAdmin(user)
user ? isAdmin(user) : false
)
user.notifications = {
notifications.set({
inbox: notifs.unreads,
applications: notifs.applications,
reports: notifs.reports,
}
profile.update((p) => ({
...p!,
user: user,
}))
})
}
setInterval(checkInbox, 4 * 60 * 1000)
let prevId: number | undefined = -2
profile.subscribe((p) => {
if (p?.id == prevId || !p?.user) return
prevId = p?.id
if (p.id != -1) checkInbox()
})
@@ -16,6 +16,7 @@
class="items-center flex flex-row gap-2 hover:underline max-w-full min-w-0 {$$props.class ||
''}"
href="/c/{community.name}@{new URL(community.actor_id).hostname}"
data-sveltekit-preload-data="tap"
>
{#if avatar}
<Avatar
@@ -28,7 +29,7 @@
{#if name}
<span class="flex gap-0 items-center max-w-full min-w-0 flex-shrink">
<span class="font-medium">{community.title}</span>
<span class="font-medium username-text">{community.title}</span>
{#if showInstance}
<span
class="text-slate-500 dark:text-zinc-500 font-normal
@@ -47,5 +48,12 @@
overflow: hidden;
text-overflow: ellipsis;
max-width: 100%;
flex: 1;
}
.username-text {
white-space: nowrap;
overflow: hidden;
text-overflow: ellipsis;
}
</style>
+42 -7
View File
@@ -5,7 +5,10 @@
import PostActions from '$lib/components/lemmy/post/PostActions.svelte'
import { userSettings } from '$lib/settings.js'
import PostLink from '$lib/components/lemmy/post/PostLink.svelte'
import PostMeta from '$lib/components/lemmy/post/PostMeta.svelte'
import PostMeta, {
parseTags,
type Tag,
} from '$lib/components/lemmy/post/PostMeta.svelte'
import { Badge, Material, toast } from 'mono-svelte'
import Markdown from '$lib/components/markdown/Markdown.svelte'
import ExpandableImage from '$lib/components/ui/ExpandableImage.svelte'
@@ -34,6 +37,10 @@
export let view = $userSettings.view
$: type = mediaType(post.post.url, view)
$: tags = parseTags(post.post.name)
$: rule = getTagRule(tags.tags)
$: hideTitle =
$userSettings.posts.deduplicateEmbed &&
post.post.embed_title == post.post.name &&
@@ -45,6 +52,19 @@
post.post.embed_description == post.post.body &&
view != 'compact'
function getTagRule(tags: Tag[]): 'blur' | 'hide' | undefined {
const tagContent = tags.map((t) => t.content.toLowerCase())
let rule: 'blur' | 'hide' | undefined
tagContent.forEach((tag) => {
if ($userSettings.tagRules?.[tag])
rule = $userSettings.tagRules?.[tag] ?? rule
if (rule == 'hide') return rule
})
return rule
}
function onClick(e: any) {
const event = e as MouseEvent
const parent = document.getElementById(post.post.id.toString())
@@ -55,11 +75,16 @@
}
</script>
<!--
@component
This is the sole component for displaying posts.
It adapts to all kinds of form factors for different contexts, such as feeds, full post view, and crosspost list.
-->
<!-- svelte-ignore a11y-no-static-element-interactions -->
<!-- svelte-ignore a11y-click-events-have-key-events -->
<Material
color={view != 'card' ? 'none' : 'distinct'}
class="relative max-w-full min-w-0 w-full group cursor-pointer
class="post relative max-w-full min-w-0 w-full group cursor-pointer
{view != 'card' ? 'bg-transparent !border-0' : 'p-5'} {view == 'compact'
? 'py-4 list-type'
: view == 'list'
@@ -70,9 +95,11 @@
on:click={(e) => {
onClick(e)
}}
style={$$props.style ?? ''}
>
<PostMeta
community={hideCommunity ? undefined : post.community}
community={post.community}
showCommunity={!hideCommunity}
user={post.creator}
published={publishedToDate(post.post.published)}
badges={{
@@ -91,9 +118,10 @@
? 'Subscribed'
: 'NotSubscribed'}
id={post.post.id}
title={hideTitle ? undefined : post.post.name}
title={hideTitle ? undefined : tags?.title ? tags.title : post.post.name}
read={post.read}
style="grid-area: meta;"
tags={tags?.tags}
>
<slot name="badges" slot="badges" />
</PostMeta>
@@ -102,12 +130,19 @@
style="grid-area:embed;"
class={view == 'list' || view == 'compact' ? '' : 'contents'}
>
<PostMedia bind:post={post.post} {view} {type} />
{#if rule != 'hide'}
<PostMedia
bind:post={post.post}
blur={rule == 'blur' ? true : undefined}
{view}
{type}
/>
{/if}
</div>
{#if view == 'list' || view == 'compact'}
<PostMediaCompact
bind:post={post.post}
bind:type={type}
bind:type
class="{$userSettings.leftAlign
? 'mr-2'
: 'ml-2'} flex-shrink no-list-margin"
@@ -115,7 +150,7 @@
/>
{/if}
{/key}
{#if post.post.body && !post.post.nsfw && view != 'compact' && !hideBody}
{#if post.post.body && !post.post.nsfw && view != 'compact' && !hideBody && rule != 'hide'}
<PostBody body={post.post.body} {view} style="grid-area: body" />
{/if}
{#if actions}
@@ -23,6 +23,7 @@
import { t } from '$lib/translations'
import { slide } from 'svelte/transition'
import { feature } from '$lib/version'
import Header from '$lib/components/ui/layout/pages/Header.svelte'
export let edit = false
@@ -140,7 +141,7 @@
community_id: data.community!.id,
name: data.title,
body: data.body,
url: data.url,
url: data.url || undefined,
nsfw: data.nsfw,
custom_thumbnail: data.thumbnail,
alt_text: data.alt_text,
@@ -228,9 +229,9 @@
<form on:submit|preventDefault={submit} class="flex flex-col gap-4 h-full">
<slot name="formtitle">
<h1 class="font-bold text-xl">
<Header class="font-bold text-xl">
{edit ? $t('form.post.edit') : $t('form.post.create')}
</h1>
</Header>
</slot>
{#if !edit && data}
{#if !data.community}
+12 -5
View File
@@ -1,6 +1,6 @@
<script lang="ts">
import Link, { parseURL } from '$lib/components/input/Link.svelte'
import { Material } from 'mono-svelte'
import { Button, Material } from 'mono-svelte'
import { Icon, Link as LinkIcon } from 'svelte-hero-icons'
import { optimizeImageURL } from './helpers'
@@ -14,6 +14,10 @@
$: richURL = parseURL(url)
</script>
<!--
@component
For embed-type posts. Displays embed card or a compact link.
-->
{#if embed_title && !compact}
<Material color="distinct" class="flex flex-row gap-4">
<div class="flex flex-col gap-2">
@@ -60,12 +64,15 @@
{/if}
</Material>
{:else}
<Link
<Button
href={url}
target="_blank"
class="text-slate-700 dark:text-zinc-300 inline-flex items-center gap-1 text-sm"
class="text-slate-700 dark:text-zinc-300 inline-flex items-center gap-1 text-xs overflow-hidden w-max max-w-full"
size="sm"
color="ghost"
rounding="pill"
>
<Icon src={LinkIcon} size="14" mini slot="icon" class="flex-shrink-0" />
<Icon src={LinkIcon} size="14" mini slot="prefix" class="flex-shrink-0" />
{#if richURL}
<div class="flex max-w-full overflow-hidden">
{richURL.hostname}
@@ -76,7 +83,7 @@
{:else}
{url}
{/if}
</Link>
</Button>
{#if thumbnail_url && !compact}
<a href={url} target="_blank">
<img
+89 -9
View File
@@ -1,3 +1,39 @@
<script lang="ts" context="module">
export interface Tag {
content: string
color?: string
icon?: IconSource
}
export const textToTag: Map<string, Tag> = new Map<string, Tag>([
['OC', { content: 'OC', color: '#03A8F240' }],
['NSFL', { content: 'NSFL', color: '#ff000040' }],
['CW', { content: 'CW', color: '#ff000040' }],
])
export const parseTags = (
title?: string
): { tags: Tag[]; title?: string } => {
if (!title) return { tags: [] }
let extracted: Tag[] = []
title = title.replace(/\[(.*?)\]/g, (match, content) => {
extracted.push(
textToTag.get(content) ?? {
content: content,
}
)
return ''
})
return {
tags: extracted,
title: title,
}
}
</script>
<script lang="ts">
import CommunityLink from '$lib/components/lemmy/community/CommunityLink.svelte'
import Avatar from '$lib/components/ui/Avatar.svelte'
@@ -13,6 +49,7 @@
LockClosed,
Megaphone,
Plus,
Tag,
Trash,
} from 'svelte-hero-icons'
import { getInstance } from '$lib/lemmy.js'
@@ -22,8 +59,10 @@
import { userSettings } from '$lib/settings'
import Markdown from '$lib/components/markdown/Markdown.svelte'
import { t } from '$lib/translations'
import type { IconSource } from 'svelte-hero-icons'
export let community: Community | undefined = undefined
export let showCommunity: boolean = true
export let subscribed: SubscribedType | undefined = undefined
export let user: Person | undefined = undefined
@@ -43,15 +82,29 @@
moderator: false,
admin: false,
}
export let tags: Tag[] = []
$: {
if (title && tags.length == 0) {
const result = parseTags(title)
tags = result.tags
title = result.title
}
}
</script>
<!--
@component
This component will build two different things: a post's meta block and the title.
-->
<div
class="grid w-full meta {community
? 'grid-rows-2'
: 'grid-rows-1'} text-xs min-w-0 max-w-full"
style={$$props.style ?? ''}
>
{#if community}
{#if showCommunity && community}
<Subscribe let:subscribe let:subscribing>
<button
on:click={async () => {
@@ -74,8 +127,8 @@
class="absolute w-3.5 h-3.5 {subscribed == 'NotSubscribed'
? 'bg-primary-900 dark:bg-primary-100 text-white dark:text-black'
: 'bg-primary-100 dark:bg-primary-900 text-black dark:text-white'} rounded-full ring-2 box-border
ring-slate-50 dark:ring-zinc-950
-bottom-1 right-1 grid place-items-center transition-all"
ring-slate-50 dark:ring-zinc-950 grid place-items-center transition-all
right-0 -translate-x-1 -translate-y-2"
>
<Icon
src={subscribed == 'NotSubscribed' ? Plus : Check}
@@ -87,19 +140,19 @@
</button>
</Subscribe>
{/if}
{#if community}
{#if showCommunity && community}
<CommunityLink
{community}
style="grid-area: community;"
class="flex-shrink"
class="flex-shrink self-end"
/>
{/if}
<span
class="text-slate-600 dark:text-zinc-400 flex flex-row gap-2 items-center"
class="text-slate-600 dark:text-zinc-400 flex flex-row gap-2 items-center self-start"
style="grid-area: stats;"
>
{#if user}
<UserLink avatarSize={20} {user} avatar={!community}>
<UserLink avatarSize={20} {user} avatar={!showCommunity}>
<svelte:fragment slot="badges">
{#if badges.moderator}
<ShieldIcon filled width={14} class="text-green-500" />
@@ -115,9 +168,29 @@
{/if}
</span>
<div
class="flex flex-row items-center self-center flex-wrap gap-2 [&>*]:flex-shrink-0 badges"
class="flex flex-row justify-end items-center self-center flex-wrap gap-2 [&>*]:flex-shrink-0 badges ml-2"
style="grid-area: badges;"
>
{#if tags}
{#each tags as tag}
<a
class="hover:brightness-110"
href="/search?community={community?.id}&q=[{tag.content}]&type=Posts"
style={tag.color ? `--tag-color: ${tag.color};` : ''}
>
<Badge class={tag.color ? 'badge-tag-color' : ''}>
<svelte:fragment slot="icon">
{#if tag.icon}
<Icon src={tag.icon} micro size="14" />
{:else}
<Icon src={Tag} micro size="14" />
{/if}
</svelte:fragment>
{tag.content}
</Badge>
</a>
{/each}
{/if}
{#if badges.nsfw}
<Badge label={$t('post.badges.nsfw')} color="red-subtle" allowIconOnly>
<Icon src={ExclamationTriangle} size="14" micro slot="icon" />
@@ -180,9 +253,12 @@
class:text-slate-600={$userSettings.markReadPosts && read}
class:dark:text-zinc-400={$userSettings.markReadPosts && read}
style="grid-area: title;"
data-sveltekit-preload-data="tap"
>
<Markdown source={title} inline noStyle class="leading-[1.3]"></Markdown>
</a>
{:else}
<div style="grid-area: title; margin: 0;"></div>
{/if}
<style>
@@ -193,6 +269,10 @@
'avatar stats badges';
gap: 0;
grid-template-rows: auto auto;
grid-template-columns: auto 1fr auto;
grid-template-columns: max-content minmax(0, auto) auto;
}
:global(.badge-tag-color) {
background-color: var(--tag-color) !important;
}
</style>
@@ -7,6 +7,11 @@
import { ArchiveBox, Icon, Minus, Plus } from 'svelte-hero-icons'
import { expoOut } from 'svelte/easing'
import { fly, slide } from 'svelte/transition'
import { browser } from '$app/environment'
import { afterUpdate, onMount, tick, type SvelteComponent } from 'svelte'
import { createWindowVirtualizer } from '@tanstack/svelte-virtual'
import { afterNavigate, beforeNavigate } from '$app/navigation'
import { _posts } from '../../../../../routes/+page.svelte'
type PostViewWithCrossposts = PostView & {
withCrossposts: true
@@ -98,16 +103,16 @@
</Placeholder>
</div>
{:else}
{#each combinedPosts as post, index (post.post.id)}
{#each combinedPosts as post, index}
{#if !($userSettings.hidePosts.deleted && post.post.deleted) && !($userSettings.hidePosts.removed && post.post.removed)}
<li
in:fly|global={{
y: -8,
duration: index < 4 ? 500 : 0,
duration: 500,
opacity: 0,
delay: index < 4 ? index * 100 : 0,
delay: 100 + index * 20,
}}
class="relative"
class="relative post-container"
>
<Post
hideCommunity={community}
@@ -116,12 +121,9 @@
? 'compact'
: $userSettings.view}
{post}
class="transition-all duration-250 {post.withCrossposts &&
viewPost != post.post.id
? ''
: ''}"
class="transition-all duration-250"
on:hide={() => {
combinedPosts = combinedPosts.toSpliced(index, 1)
posts = posts.toSpliced(index, 1)
}}
>
<svelte:fragment slot="badges">
@@ -175,4 +177,5 @@
{/if}
{/each}
{/if}
<slot />
</ul>
@@ -0,0 +1,222 @@
<script lang="ts">
import Post from '$lib/components/lemmy/post/Post.svelte'
import Placeholder from '$lib/components/ui/Placeholder.svelte'
import { userSettings } from '$lib/settings.js'
import type { PostView } from 'lemmy-js-client'
import { Badge, Button } from 'mono-svelte'
import { ArchiveBox, Icon, Minus, Plus } from 'svelte-hero-icons'
import { expoOut } from 'svelte/easing'
import { fly, slide } from 'svelte/transition'
import { browser } from '$app/environment'
import { afterUpdate, onMount, tick, type SvelteComponent } from 'svelte'
import { createWindowVirtualizer } from '@tanstack/svelte-virtual'
import { afterNavigate, beforeNavigate } from '$app/navigation'
import { _posts } from '../../../../../routes/+page.svelte'
type PostViewWithCrossposts = PostView & {
withCrossposts: true
crossposts: PostView[]
}
type PostViewWithoutCrossposts = PostView & { withCrossposts?: false }
export let posts: PostView[]
export let community: boolean = false
const addCrosspostProperty = (
post: PostView,
crossposts: PostView[]
): PostViewWithCrossposts => ({
...post,
crossposts: crossposts,
withCrossposts: true,
})
const combineCrossposts = (
posts: PostView[]
): (PostViewWithCrossposts | PostViewWithoutCrossposts)[] => {
const urlMap = new Map<
string,
PostViewWithCrossposts | PostViewWithoutCrossposts
>()
const results: (PostViewWithCrossposts | PostViewWithoutCrossposts)[] = []
const seenUrls = new Set<string>()
posts?.forEach((post) => {
if (
!post ||
($userSettings.hidePosts.deleted && post.post.deleted) ||
($userSettings.hidePosts.removed && post.post.removed)
)
return
if (!post?.post?.url) {
results.push(post)
return
}
let existing = urlMap.get(post.post.url)
if (existing) {
existing.withCrossposts = true
if (existing.withCrossposts) {
existing.crossposts = [...(existing.crossposts || []), post]
}
urlMap.set(post.post.url, existing)
} else {
urlMap.set(post.post.url, post)
results.push(post)
}
seenUrls.add(post.post.url)
})
return results
}
// $: combinedPosts = combineCrossposts(posts)
let viewPost: number = -1
const virtualizer = createWindowVirtualizer({
count: posts.length,
estimateSize: () => 150,
})
$: if (posts.length)
$virtualizer.setOptions({
count: posts.length,
})
let virtualItemEls: HTMLElement[] = []
$: items = $virtualizer.getVirtualItems()
$: {
if (virtualItemEls.length)
virtualItemEls.forEach((el) => $virtualizer.measureElement(el))
}
afterNavigate(() => {
$virtualizer.scrollToIndex($_posts?.lastSeen)
})
</script>
<ul
class="flex flex-col list-none {$userSettings.view == 'card'
? 'gap-3 md:gap-4'
: 'divide-y'} divide-slate-200 dark:divide-zinc-800"
style={$userSettings.leftAlign
? `--template-areas:
'media meta'
'media title'
'media body'
'embed embed'
'actions actions'; --template-columns: auto 1fr;`
: ``}
>
{#if posts?.length == 0}
<div class="h-full grid place-items-center">
<Placeholder
icon={ArchiveBox}
title="No posts"
description="There are no posts that match this filter."
>
<Button href="/communities">
<Icon src={Plus} size="16" mini slot="prefix" />
<span>Follow some communities</span>
</Button>
</Placeholder>
</div>
{:else}
<!-- {#each combinedPosts as post, index} -->
<!-- {#if !($userSettings.hidePosts.deleted && post.post.deleted) && !($userSettings.hidePosts.removed && post.post.removed)} -->
<div
style="position:relative; height: {browser
? `${$virtualizer.getTotalSize()}px`
: '100%'}; width: 100%;"
>
<div
style="position: absolute; top: 0; left: 0; width: 100%; transform: translateY({items[0]
? items[0].start
: 0}px);"
class="divide-y divide-slate-200 dark:divide-zinc-800"
id="feed"
>
{#each items as row, index (row.index)}
<li
in:fly|global={{
y: -8,
duration: 300,
opacity: 0,
delay: 50 + index * 20,
}}
bind:this={virtualItemEls[index]}
data-index={row.index}
class="relative post-container"
>
<Post
hideCommunity={community}
view={(posts[row.index].post.featured_community ||
posts[row.index].post.featured_local) &&
$userSettings.posts.compactFeatured
? 'compact'
: $userSettings.view}
post={posts[row.index]}
class="transition-all duration-250"
on:hide={() => {
posts = posts.toSpliced(row.index, 1)
}}
>
<svelte:fragment slot="badges">
<!-- {#if posts[index].withCrossposts}
<button
on:click={() => {
if (viewPost == posts[index].post.id) viewPost = -1
else viewPost = posts[index].post.id
}}
>
<Badge
class="z-10 backdrop-blur-xl hover:brightness-110 cursor-pointer transition-all"
color="gray-subtle"
>
{#if viewPost == posts[index].post.id}
<Icon mini src={Minus} size="14" />
{:else}
<Icon mini src={Plus} size="14" />
{/if}
{posts[index].crossposts.length} crosspost{posts[index]
.crossposts.length == 1
? ''
: 's'}
</Badge>
</button>{/if} -->
</svelte:fragment>
</Post>
<!-- {#if posts[index].withCrossposts && viewPost == posts[index].post.id}
<div
transition:slide|global={{
axis: 'y',
duration: 500,
easing: expoOut,
}}
>
<span
class="text-sm flex flex-row gap-2 items-center"
class:my-4={$userSettings.view == 'card'}
>
Crossposts <hr class="w-full dark:border-zinc-800" />
{posts[index].crossposts.length}
</span>
{#each posts[index].crossposts as crosspost, index}
<div class="w-full transition-all mb-4">
<Post post={crosspost} view={$userSettings.view} />
</div>
{/each}
</div>
{/if} -->
</li>
{/each}
</div>
</div>
<!-- {/if} -->
<!-- {/each} -->
{/if}
<slot />
</ul>
+21 -15
View File
@@ -12,18 +12,19 @@ export const bestImageURL = (
compact: boolean = true,
width: number = 1024
) => {
if (width > 1024) {
if (post.url) return `${post.url}?format=webp`
else if (post.thumbnail_url) return `${post.thumbnail_url}?format=webp`
}
let fetchWidth =
width > 1024
? // -1 disables a small thumbnail
-1
: // set width to 512 if compact
compact
? 512
: // otherwise, just use the original width
width
if (compact && post.thumbnail_url)
return `${post.thumbnail_url}?thumbnail=256&format=webp`
else if (compact && post.url) return `${post.url}?thumbnail=256&format=webp`
if (post.url) return `${post.url}?thumbnail=${width}&format=webp`
else if (post.thumbnail_url)
return `${post.thumbnail_url}?thumbnail=${width}&format=webp`
if (post.thumbnail_url)
return optimizeImageURL(post.thumbnail_url, fetchWidth)
else if (post.url) return optimizeImageURL(post.url, fetchWidth)
return post.url ?? ''
}
@@ -34,11 +35,16 @@ export const optimizeImageURL = (
): string => {
try {
const url = new URL(urlStr)
url.searchParams.append('format', 'webp')
url.searchParams.append(
'thumbnail',
findClosestNumber([128, 256, 512, 1024], width).toString()
)
if (width > 0) {
url.searchParams.append(
'thumbnail',
findClosestNumber([128, 256, 512, 728, 1024, 1536], width).toString()
)
}
return url.toString()
} catch (e) {
console.log(e)
@@ -92,6 +92,10 @@
$: embedUrl = urlToEmbed(url)
</script>
<!--
@component
Displays a video file or embedded video iframe.
-->
{#if opened}
{#if type == 'video'}
<!-- svelte-ignore a11y-media-has-caption -->
@@ -19,10 +19,17 @@
export let post: Post
export let type: MediaType = 'none'
export let opened: boolean | undefined = undefined
export let blur: boolean = post.nsfw && $userSettings.nsfwBlur
let showAltText = false
</script>
<!--
@component
This component will show either
- A media item (pictures, videos) (large form factor posts only)
- Embed link/card.
-->
{#if type == 'image'}
{#if view == 'card' || view == 'cozy'}
<!--disabled preloads here since most people will hover over every image while scrolling-->
@@ -39,9 +46,9 @@
>
<!-- svelte-ignore a11y-missing-attribute -->
<img
src={bestImageURL(post, false, 256)}
src={bestImageURL(post, false, 64)}
loading="lazy"
class="-z-10 absolute top-0 left-0 w-full h-full object-cover blur-xl opacity-50"
class="-z-10 absolute top-0 left-0 w-full h-full object-cover blur-xl opacity-40"
/>
<picture class="max-h-[inherit]">
<source
@@ -68,7 +75,7 @@
transition-opacity duration-300 object-contain mx-auto"
width={512}
height={300}
class:blur-3xl={post.nsfw && $userSettings.nsfwBlur}
class:blur-3xl={blur}
alt={post.alt_text ?? ''}
/>
</picture>
@@ -16,14 +16,43 @@
export let type: MediaType = 'none'
</script>
<div
class="w-24 sm:w-32 h-24 relative group/media {$$props.class ?? ''}"
style={$$props.style ?? ''}
>
{#if post.alt_text}
<Popover
openOnHover
placement={$userSettings.leftAlign ? 'bottom-start' : 'bottom-end'}
<!--
@component
Thumbnails for compact and list view posts.
-->
<div
class="w-24 sm:w-32 h-24 relative group/media {$$props.class ?? ''}"
style={$$props.style ?? ''}
>
{#if post.alt_text}
<Popover
openOnHover
placement={$userSettings.leftAlign ? 'bottom-start' : 'bottom-end'}
>
<Material
slot="target"
padding="none"
rounding="full"
elevation="high"
class="w-max absolute bottom-0 left-0 py-0.5 px-1.5 m-1 font-bold"
>
ALT
</Material>
<div class="max-w-sm">
{post.alt_text}
</div>
</Popover>
{/if}
<svelte:element
this={!$userSettings.expandImages || type != 'image' ? 'a' : 'button'}
href={postLink(post)}
on:click={() => {
if (type == 'image') {
showImage(bestImageURL(post, false, 2048))
}
}}
role="button"
tabindex="0"
>
<Material
slot="target"
+10 -1
View File
@@ -19,6 +19,7 @@
class="items-center flex flex-row gap-1 hover:underline max-w-full min-w-0 {$$props.class ??
''}"
href="/u/{user.name}@{new URL(user.actor_id).hostname}"
data-sveltekit-preload-data="tap"
>
{#if avatar}
<Avatar
@@ -32,7 +33,7 @@
class="flex gap-0 items-center flex-shrink max-w-full min-w-0"
class:ml-0.5={avatar}
>
<span class:font-medium={showInstance}>
<span class:font-medium={showInstance} class="username-text">
{$userSettings.displayNames ? user.display_name || user.name : user.name}
</span>
{#if showInstance}
@@ -62,6 +63,14 @@
white-space: nowrap;
overflow: hidden;
text-overflow: ellipsis;
min-width: 0;
max-width: 100%;
flex: 1;
}
.username-text {
white-space: nowrap;
overflow: hidden;
text-overflow: ellipsis;
}
</style>
+1 -1
View File
@@ -3,7 +3,7 @@
import { createAvatar } from '@dicebear/core'
import * as initials from '@dicebear/initials'
const sizes = [48, 64, 128, 256, 512]
const sizes = [16, 32, 48, 64, 128, 256, 512]
export let url: string | undefined
export let alt: string = ''
+5 -1
View File
@@ -68,7 +68,11 @@
<svelte:window bind:innerWidth={screenWidth} />
<div class="shell {$$props.class}" style={colorsToVars($colors)}>
<div
{...$$restProps}
class="shell {$$props.class}"
style={colorsToVars($colors)}
>
<slot />
<div
class="
@@ -1,3 +1,12 @@
<h1 class="text-3xl font-bold flex items-center gap-2 {$$props.class ?? ''}">
<script lang="ts">
import { userSettings } from '$lib/settings'
</script>
<h1
class="text-3xl font-bold flex items-center gap-2 {$userSettings.font ==
'satoshi/nunito'
? 'font-display'
: ''} {$$props.class ?? ''}"
>
<slot />
</h1>
+3 -3
View File
@@ -1,5 +1,5 @@
<script lang="ts">
import { profile, profileData } from '$lib/auth.js'
import { notifications, profile, profileData } from '$lib/auth.js'
import Link from '$lib/components/input/Link.svelte'
import ShieldIcon from '$lib/components/lemmy/moderation/ShieldIcon.svelte'
import {
@@ -112,7 +112,7 @@
class="relative"
isSelectedFilter={(path) => path.startsWith('/admin')}
>
{#if ($profile?.user?.notifications.applications ?? 0) > 0}
{#if ($notifications.applications ?? 0) > 0}
<div
class="rounded-full w-2 h-2 bg-red-500 absolute -top-1 -left-1"
/>
@@ -125,7 +125,7 @@
label={$t('nav.moderation')}
class="relative"
>
{#if ($profile?.user?.notifications.reports ?? 0) > 0}
{#if ($notifications.reports ?? 0) > 0}
<div
class="rounded-full w-2 h-2 bg-red-500 absolute -top-1 -left-1"
/>
+4 -4
View File
@@ -1,5 +1,5 @@
<script lang="ts">
import { profile } from '$lib/auth'
import { notifications, profile } from '$lib/auth'
import {
Badge,
@@ -73,7 +73,7 @@
alt={$profile.user.local_user_view.person.name}
/>
</div>
{#if $profile.user.notifications.inbox > 0}
{#if $notifications.inbox > 0}
<div
class="rounded-full w-2 h-2 bg-red-500 absolute top-0 left-0 z-10"
/>
@@ -104,9 +104,9 @@
<MenuButton link href="/inbox">
<Icon src={Inbox} mini width={16} slot="prefix" />
{$t('profile.inbox')}
{#if $profile.user.notifications.inbox > 0}
{#if $notifications.inbox > 0}
<Badge color="red-subtle" class="text-xs ml-auto font-bold !py-0.5">
{$profile.user.notifications.inbox}
{$notifications.inbox}
</Badge>
{/if}
</MenuButton>
+27
View File
@@ -13,6 +13,9 @@ import {
ServerStack,
PencilSquare,
MapPin,
Fire,
ArrowTrendingUp,
Star,
} from 'svelte-hero-icons'
import { get } from 'svelte/store'
@@ -38,6 +41,22 @@ export const defaultLinks: Link[] = [
url: '/?type=Subscribed',
label: t.get('filter.location.subscribed'),
},
{
url: '/?type=All&sort=Hot',
label: t.get('filter.sort.hot'),
},
{
url: '/?type=All&sort=Active',
label: t.get('filter.sort.active'),
},
{
url: '/?type=All&sort=TopDay',
label: t.get('filter.sort.top.time.day'),
},
{
url: '/?type=All&sort=New',
label: t.get('filter.sort.new'),
},
{
url: '/communities',
label: t.get('nav.communities'),
@@ -74,6 +93,14 @@ export const iconOfLink = (url: string): IconSource => {
return Newspaper
case '/?type=Local':
return MapPin
case '/?type=All&sort=Hot':
return Fire
case '/?type=All&sort=Active':
return ArrowTrendingUp
case '/?type=All&sort=TopDay':
return ChartBar
case '/?type=All&sort=New':
return Star
case '/communities':
return GlobeAlt
case '/search':
+3 -3
View File
@@ -14,7 +14,7 @@
UserCircle,
UserGroup,
} from 'svelte-hero-icons'
import { profile, profileData } from '$lib/auth.js'
import { notifications, profile, profileData } from '$lib/auth.js'
import { userSettings } from '$lib/settings.js'
import SidebarButton from '$lib/components/ui/sidebar/SidebarButton.svelte'
import CommunityList from '$lib/components/ui/sidebar/CommunityList.svelte'
@@ -70,12 +70,12 @@
<SidebarButton icon={Inbox} href="/inbox">
<span slot="label" class="flex items-center gap-2">
{$t('profile.inbox')}
{#if $profile?.user?.notifications.inbox}
{#if $notifications.inbox}
<Badge
class="w-5 h-5 !p-0 grid place-items-center ml-auto"
color="red-subtle"
>
{$profile?.user?.notifications.inbox}
{$notifications.inbox}
</Badge>
{/if}
</span>
+30 -3
View File
@@ -473,7 +473,8 @@
},
"message": {
"success": "Success",
"error": "Error"
"error": "Error",
"retry": "Retry"
},
"toast": {
"noComments": "The API returned no comments.",
@@ -528,7 +529,9 @@
"waitApplication": "Wait for your registration application to be accepted before logging in.",
"blockUser": "Blocked that user.",
"unblockUser": "Unblocked that user.",
"purgeUser": "Purged that user."
"purgeUser": "Purged that user.",
"settingsImport": "Successfully imported settings",
"settingsImportWarning": "The imported settings don't seem valid. Are you sure you want to import this?"
},
"settings": {
"title": "Settings",
@@ -536,6 +539,9 @@
"desktop": "Desktop",
"tablet": "Tablet",
"mobile": "Mobile",
"export": "Export",
"import": "Import",
"reset": "Reset",
"navigation": {
"title": "Navigation",
"dockPos": {
@@ -580,8 +586,15 @@
"de": "German",
"fi": "Finnish",
"pt": "Portuguese",
"zh": "Chinese",
"zh-Hans": "Chinese (Simplified)",
"zh-Hant": "Chinese (Traditional)",
"auto": "Auto",
"credits": "Credits"
"credits": "Credits",
"useRtl": {
"title": "Use RTL layout",
"description": "Use an RTL layout for RTL languages."
}
},
"view": {
"title": "Post style",
@@ -594,6 +607,10 @@
"title": "Default sort",
"description": "The default sorting to use in feeds."
},
"infiniteScroll": {
"title": "Infinite scroll",
"description": "New posts are added as you scroll down, without having to click 'next'."
},
"postsInNewTab": {
"title": "Open posts in new tab",
"description": "Open posts in a separate tab instead of the current."
@@ -632,6 +649,16 @@
"title": "Translation",
"description": "The LibreTranslate instance to use for translation.",
"instance": "Domain"
},
"titleTags": {
"title": "Parse tags in title",
"description": "Take text in [brackets] and turn it into tags that you can click to search for.",
"rules": {
"title": "Rules",
"blur": "Blur",
"hide": "Hide",
"show": "Show"
}
}
},
"embeds": {
+15 -3
View File
@@ -115,7 +115,7 @@
"slurFilter": "Kielletyt sanat (regex)",
"federation": "Federointi päällä",
"captcha": {
"enabled": "Päällä"
"enabled": "CAPTCHA Päällä"
},
"emailAdminsOnApplication": "Lähetä ylläpitäjille sähköposti-ilmoitus hakemuksista",
"federationDebug": "Federoinnin vianetsintätila"
@@ -357,7 +357,8 @@
"generateTitle": "Hae otsikko",
"create": "Luo julkaisu",
"edit": "Muokkaa julkaisua",
"url": "URL"
"url": "URL",
"altText": "Vaihtoehtoinen teksti"
},
"profile": {
"2fa": {
@@ -601,6 +602,10 @@
"placeholders": {
"title": "Satunnaiset paikkamerkit",
"description": "Näytä satunnaisia paikkamerkkejä tyhjillä tekstikentillä."
},
"colorscheme": {
"title": "Väritila",
"description": "Valitse väritila."
}
},
"title": "Asetukset",
@@ -620,6 +625,10 @@
"on": "Päällä",
"off": "Pois päältä",
"adaptive": "Mukautuva"
},
"pins": {
"title": "Kiinnitykset",
"description": "Lisää kiinnityksiä sivupalkkiin napsauttamalla kuvaketta. Napsauta oikealla poistaaksesi sen."
}
},
"lemmy": {
@@ -688,6 +697,9 @@
"description": "Näytä vianetsintätiedot"
},
"title": "Muut"
}
},
"desktop": "Työpöytä",
"tablet": "Tabletti",
"mobile": "Mobiili"
}
}
+72 -6
View File
@@ -117,7 +117,8 @@
"generateTitle": "Generate le Titre",
"uploadImage": "Ajouter une Image",
"url": "URL",
"nsfw": "NSFW"
"nsfw": "NSFW",
"altText": "Équivalent textuel"
},
"profile": {
"displayName": "Nom affiché",
@@ -171,7 +172,8 @@
"footer": "{{users:number}} En ligne {{users; 1:user; default:users;}}"
},
"legal": {
"noLegal": "Cet instance n'a aucune information legale."
"noLegal": "Cet instance n'a aucune information legale.",
"title": "Légal"
},
"profile": {
"user": "Utilisateur",
@@ -258,7 +260,7 @@
"federation": "Federation activée",
"federationDebug": "mode de débogage de federation",
"captcha": {
"enabled": "Activé"
"enabled": "CAPTCHA Activé"
},
"title": "Configuration"
},
@@ -290,7 +292,7 @@
"title": "Administrateurs",
"empty": {
"title": "Aucun administrateurs",
"description": "Il n'y a aucun administrateur de serveur, je sais pas comment vous avez fait cela."
"description": "Il n'y a aucun administrateur de serveur, je ne sais pas comment vous avez reussi a faire cela."
}
},
"federation": {
@@ -303,7 +305,12 @@
"allow": "Whitelister",
"allowplaceholder": "Whitelister une instance",
"emptyBlock": {
"title": "Aucune instances blocqués"
"title": "Aucune instances bloqués",
"description": "Le bloc d'une instance cachera toutes nouvelles soumissions de cette instance."
},
"emptyAllow": {
"title": "Aucunes instances sur la liste blanche",
"description": "Mettre une instance sur la liste blanche bloquera toutes les autres instances."
}
}
},
@@ -334,7 +341,32 @@
},
"instances": "Instances",
"translators": "Traducteurs",
"createCommunity": "Créer une communauté"
"createCommunity": "Créer une communauté",
"modlog": "Journal de modération",
"verifyEmail": {
"message": "Votre email a été verifié, vous pouvez maintenant fermer cette fenêtre.",
"error": "La vérification de l'email a échouée."
},
"passwordChange": {
"title": "Changer le mot de passe",
"description": "Choisissez votre nouveaux mot de passe.",
"instance": "Sur quelle instance est hostée votre compte?"
},
"resetLogin": {
"title": "Réinitialiser le mot de passe",
"description": "Mettez l'email de vôtre compte, et un lien de réinitialision de mot de passe sera envoyé. Si vôtre compte n'a pas de email, vous devez contacter les administrateurs de votre instance."
},
"theme": {
"import": "Importer",
"export": "Exporter",
"reset": "Réinitialiser",
"accent": "Couleur d'accentuation",
"resetWarning": {
"title": "Réinitialiser les paramètres d'apparence",
"description": "Ceci remettera a zéro toute la configuration de l'apparence, il est conseillé de l'exporter d'abord."
},
"title": "Apparence"
}
},
"verifyEmail": {
"message": "Votre e-mail est maintenant vérifié. Vous pouvez maintenant fermer cette fenetre.",
@@ -353,7 +385,41 @@
"app": {
"lang": {
"": "Dont translate the below!"
},
"theming": {
"link": "Configuration d'apparence"
}
}
},
"comment": {
"reply": "Répondre",
"actions": {
"link": "Copier le lien"
}
},
"moderation": {
"report": "Créer un signalement",
"ban": {
"banning": "Bannir l'utilisateur",
"deleteData": "Suprimmer les données",
"warning": "Cette option supprimera TOUTES les publications de cet utilisateur.",
"expires": "Expire (UTC)",
"banFromCommunity": "Ban d'une communauté"
}
},
"cards": {
"site": {
"stats": "Statistiques",
"admins": "Administrateurs"
},
"community": {
"members": "Membres",
"moderators": "Modérateurs",
"subscribe": "S'abonner",
"subscribed": "Abonné",
"modlog": "Journal de modération",
"block": "Bloquer",
"unblock": "Débloquer"
}
}
}
+310 -1
View File
@@ -1 +1,310 @@
{}
{
"filter": {
"unread": "לא נקרא",
"location": {
"label": "מיקום",
"all": "הכל",
"local": "מקומי",
"subscribed": "רשום",
"moderator": "מנהל",
"global": "גלובלי"
},
"sort": {
"label": "מיון",
"active": "פעיל",
"hot": "חם",
"top": {
"time": {
"label": "זמן",
"all": "הכל",
"9months": "9 חודשים",
"6months": "6 חודשים",
"3months": "3 חודשים",
"month": "חודש",
"week": "שבוע",
"day": "יום",
"12hours": "12 שעות",
"6hours": "6 שעות",
"hour": "שעה"
},
"label": "הטובים ביותר"
},
"new": "חדש",
"old": "ישן",
"controversial": "שנוי במחלוקת",
"mostcomments": "תגובות",
"newcomments": "תגובות חדשות",
"scaled": "מטפסים"
},
"view": {
"label": "פריסה",
"cozy": "נוח",
"list": "רשימה",
"compact": "דחוס",
"legacy": "ישן"
},
"type": "סוג",
"filter": "סינון",
"inbox": {
"messages": "הודעות",
"replies": "תגובות",
"mentions": "אזכורים"
}
},
"form": {
"profile": {
"showBots": "הצגת בוטים",
"2fa": {
"paste": "נא להדביק את זה באפליקציית ה-authenticator שלך.",
"totp": "TOTP",
"2fa": "2FA"
},
"displayName": "כינוי",
"bio": "אודות",
"avatar": "תמונת פרופיל",
"banner": "באנר",
"email": "אימייל",
"matrix": "משתמש Matrix",
"showNSFW": "הצגת תוכן למבוגרים",
"bot": "חשבון בוט",
"currentPassword": "סיסמה נוכחית",
"newPassword": "סיסמה חדשה",
"verifyNewPassword": "אימות סיסמה חדשה",
"deleteAccount": {
"label": "מחיקת חשבון",
"deleteContent": "מחיקת תוכן",
"warning": "פעולה זו תמחק את כל התוכן שלך."
},
"scores": "הצגת הצבעות",
"showRead": "תצוגת פוסטים שנקראו"
},
"confirmPassword": "אישור סיסמה",
"post": {
"title": "כותרת",
"altText": "טקסט חלופי",
"create": "יצירת פוסט",
"edit": "עריכת פוסט",
"community": "קהילה",
"url": "קישור",
"body": "גוף",
"nsfw": "תוכן למבוגרים",
"generateTitle": "יצירת כותרת",
"uploadImage": "העלאת תמונה"
},
"signup": {
"application": {
"info": "כדי להצטרף לשרת זה, חובה למלא את בקשת ההצטרפות ולחכות לקבלה. ישלח אימייל כאשר בקשתך התקבלה.",
"label": "בקשה להצטרפות"
},
"title": "הרשמה",
"description": "נא לבחור שרת שמעניין אותך, או לכתוב קישור באופן ידני.",
"chooseInstance": "בחירת שרת",
"closed": {
"title": "רישומים סגורים",
"description": "בשרת זה הרישומים סגורים. נא למצוא שרת אחר.",
"anotherInstance": "מציאת שרת אחר"
},
"info": "השרת הוא היכן שחשבונך שמור, אך עדיין ניתן לגשת לתוכן משרתים נוספים."
},
"email": "אימייל",
"description": "תיאור",
"username": "שם משתמש",
"name": "שם",
"password": "סיסמה",
"2fa": "קוד 2FA",
"forgotpassword": "שכחתי את הסיסמה",
"submit": "שליחה",
"edit": "עריכה",
"preview": "תצוגה מקדימה",
"instance": "קישור לשרת",
"setup": "הגדרה"
},
"profile": {
"profile": "פרופיל",
"inbox": "דואר נכנס",
"saved": "שמורים",
"subscribed": "רשומים"
},
"routes": {
"frontpage": {
"footer": "{{users:number}} {{users; 1:משתמש; default:משתמשים;}} {{users; 1:פעיל; default:פעילים;}}",
"title": "דף הבית"
},
"modlog": "יומן הנהלה",
"instances": "שרתים",
"legal": {
"title": "משפטי",
"noLegal": "לשרת זה אין מידע משפטי."
},
"profile": {
"user": "משתמש",
"settings": "הגדרות",
"credentials": "אימות",
"moderates": "מנהל/ת",
"favorites": "אהובים"
},
"translators": "מתרגמים",
"accounts": "חשבונות",
"communities": "קהילות",
"search": {
"title": "חיפוש",
"noResults": {
"title": "אין תוצאות",
"description": "אין תוצאות שתואמות את מילות המפתח שלך. מומלץ לעדכן את חיפושך.",
"alt": "חיפוש ברחבי הפדיורס"
},
"query": "חיפוש"
},
"admin": {
"config": {
"captcha": {
"enabled": "CAPTCHA מופעלת"
},
"federation": "פדרציה מופעלת",
"title": "הגדרות",
"sidebar": "סרגל צידי",
"icon": "סמל",
"banner": "באנר",
"downvotesEnabled": "הפעלת הצבעות נגד",
"nsfwEnabled": "הפעלת תוכן למבוגרים",
"registration": {
"label": "מצב רישום",
"open": "פתוח",
"application": "חייב בקשה",
"closed": "סגור"
},
"applicationQuestion": "שאלת בקשה",
"adminCommunityOnly": "רק מנהלים גבוהים יכולים ליצור קהילות",
"requireVerifyEmail": "חייב אימות על ידי אימייל",
"emailAdminsOnApplication": "שליחות אימייל למנהלים גבוהים בעת קבלת בקשות חדשות",
"emailAdminsOnReport": "שליחת אימייל למנהלים גבוהים בעת קבלת דיווחים חדשים",
"listingType": {
"label": "סוג רישום",
"all": "הכל",
"local": "מקומי"
},
"private": "שרת פרטי",
"slurFilter": "סינון קללות regex",
"federationDebug": "מצב דיבוג פדרציה",
"hideModlogModNames": "הסתרת שמות מנהלים ביומן ההנהלה"
},
"title": "מנהל גבוה",
"applications": {
"title": "בקשות",
"empty": {
"title": "אין בקשות חדשות",
"description": "בקשות להצטרפות השרת יופיעו פה."
},
"application": "בקשה",
"approved": "מאושרת",
"denied": "נדחתה",
"user": "משתמש",
"deny": "לדחות",
"approve": "לאשר",
"reason": "סיבה",
"modalTitle": "דחיית בקשה"
},
"taglines": {
"title": "שורות תיוג",
"add": "הוספת שורת תיוג",
"empty": {
"title": "אין שורות תיוג",
"description": "שורת תיוג אקראית תופיע על כרטיס האתר כאשר משתמשים יבקרו בשרתך."
}
},
"team": {
"title": "מנהלים גבוהים",
"empty": {
"title": "אין מנהלים גבוהים",
"description": "איכשהו אין מנהלים גבוהים לאתר זה. איך??"
}
},
"federation": {
"title": "פדרציה",
"csv": "העלאת CSV",
"block": "חסימה",
"blockplaceholder": "חסימת שרת...",
"blocked": "שרתים חסומים",
"allowed": "שרתים מורשים"
}
},
"saved": "שמורים",
"createPost": "יצירת פוסט",
"createCommunity": "יצירת קהילה",
"post": {
"commentCount": "תגובות",
"addComment": "הוספת תגובה",
"scrollToTop": "גלילה לתחילת העמוד",
"instanceWarning": "הפוסט הזה מבוקש משרת השונה משל חשבונך. פעולות רבות יכשלו.",
"remoteView": "תצוגה מרחוק",
"localView": "תצוגה מקומית",
"thread": {
"single": "מוצג שרשור בודד.",
"allComments": "כל התגובות",
"part": "מוצג חלק משרשור",
"context": "תצוגת הקשר"
},
"crosspostCount": "פוסטים משותפים"
},
"inbox": {
"title": "דואר נכנס",
"markAsRead": "סימון הכל כנקרא",
"empty": {
"title": "אין הודעות חדשות",
"description": "הודעות, תגובות, ואזכורים יופיעו פה."
}
},
"moderation": {
"title": "מנהל",
"empty": {
"title": "אין דיווחים חדשים",
"description": "כאשר תוכן מדווח, ניתן לפעול בנידון כאן."
},
"reason": "סיבה",
"resolve": "פתירה",
"unresolve": "הסרת פתירה"
}
},
"nav": {
"home": "בית",
"admin": "מנהל גבוה",
"moderation": "מנהל",
"communities": "קהילות",
"search": "חיפוש",
"create": {
"label": "יצירה",
"community": "קהילה",
"logingate": "חובה עליך להתחבר כדי ליצור תוכן.",
"post": "פוסט"
},
"menu": {
"label": "פרופיל",
"app": "אפליקציה",
"settings": "הגדרות",
"colorscheme": {
"label": "צבעים",
"system": "מערכת",
"dark": "כהה",
"light": "בהיר"
},
"theme": "סגנון",
"about": "אודות",
"source": "מקור",
"donate": "תרומה",
"instance": "שרת"
}
},
"account": {
"login": "התחברות",
"logout": "התנתקות",
"signup": "הרשמה",
"accounts": "חשבונות",
"changeinstance": "שינוי שרת",
"resetColor": "איפוס צבעים",
"addGuest": "הוספת אורח",
"moveUp": "הזזה למעלה",
"moveDown": "הזזה למטה",
"guest": "אורח",
"versionGate": "הגרסה הזו של Photon תומכת בשרתים המריצים {{version}} או גרסה עדכנית יותר."
}
}
-1
View File
@@ -1 +0,0 @@
{}
+228
View File
@@ -0,0 +1,228 @@
{
"form": {
"profile": {
"email": "Email",
"displayName": "顯示名稱",
"bio": "個人簡介",
"avatar": "大頭貼",
"banner": "背景橫幅",
"showNSFW": "顯示限制級(NSFW)內容",
"scores": "顯示讚數",
"bot": "機器人帳號",
"showBots": "顯示機器人貼文",
"showRead": "顯示已讀貼文",
"currentPassword": "當前密碼",
"newPassword": "新密碼",
"verifyNewPassword": "確認密碼"
},
"username": "使用者名稱",
"name": "名稱",
"instance": "站點網址",
"password": "密碼",
"confirmPassword": "確認密碼",
"2fa": "2FA兩步驗證碼",
"forgotpassword": "忘記密碼",
"submit": "送出",
"edit": "編輯",
"preview": "預覽",
"post": {
"create": "發文",
"edit": "編輯貼文",
"community": "社群",
"title": "標題",
"url": "網址",
"body": "內文",
"nsfw": "限制級(NSFW)",
"generateTitle": "代入標題",
"uploadImage": "上傳影像",
"altText": "替代文字"
},
"signup": {
"title": "註冊"
}
},
"routes": {
"createPost": "發文",
"saved": "保存",
"createCommunity": "創建社群",
"post": {
"crosspostCount": "轉貼",
"commentCount": "留言",
"addComment": "新增留言"
},
"verifyEmail": {
"message": "您的電子郵件已通過驗證。您現在可以關閉此視窗。",
"error": "無法驗證您的電子郵件。"
},
"passwordChange": {
"title": "更改密碼",
"description": "選擇您的新密碼。",
"instance": "您的帳戶託管在哪個實例上?"
},
"resetLogin": {
"title": "重置密碼",
"description": "輸入您帳戶的電子郵件,將發送密碼重設連結。如果您的帳戶沒有電子郵件,請聯繫您的實例管理員。"
},
"theme": {
"title": "主題",
"import": "匯入",
"export": "匯出",
"reset": "重設"
}
},
"common": {
"back": "往前",
"next": "往後",
"refresh": "重整"
},
"profile": {
"profile": "個人資料",
"inbox": "信箱",
"saved": "保存",
"subscribed": "訂閱"
},
"nav": {
"home": "首頁",
"admin": "設定",
"moderation": "管理",
"communities": "探索",
"search": "搜尋",
"create": {
"label": "新增",
"post": "貼文",
"community": "社群",
"logingate": "你需要登入,才能發文."
},
"menu": {
"label": "個人資料",
"app": "App",
"settings": "設定",
"colorscheme": {
"label": "主題",
"system": "系統",
"dark": "暗黑",
"light": "光亮"
},
"theme": "主題",
"about": "關於",
"source": "來源",
"instance": "站點"
}
},
"account": {
"login": "登入",
"logout": "登出",
"signup": "註冊",
"accounts": "帳號",
"changeinstance": "變更站點",
"resetColor": "重設顏色",
"addGuest": "新增遊客",
"moveUp": "往上",
"moveDown": "往下",
"guest": "遊客"
},
"filter": {
"location": {
"label": "範圍",
"all": "所有",
"local": "本站",
"subscribed": "已訂閱",
"moderator": "管理的",
"global": "全部"
},
"sort": {
"label": "排序",
"active": "活躍",
"hot": "熱門",
"top": {
"label": "最佳",
"time": {
"label": "時間",
"all": "所有",
"9months": "9月以來",
"6months": "6月以來",
"3months": "3月以來",
"month": "這月以來",
"week": "這周",
"day": "日",
"12hours": "12小時",
"6hours": "6小時",
"hour": "這小時"
}
},
"new": "最新",
"old": "最舊",
"controversial": "最有爭議",
"scaled": "各版熱門",
"mostcomments": "最多留言",
"newcomments": "最新留言"
},
"view": {
"label": "顯示模式",
"cozy": "可莉",
"list": "列表",
"compact": "緊湊",
"legacy": "經典"
},
"type": "類型",
"filter": "過濾",
"unread": "未讀",
"inbox": {
"messages": "私信",
"replies": "回覆",
"mentions": "標記"
}
},
"cards": {
"site": {
"about": "關於",
"stats": "統計",
"admins": "管理員"
},
"community": {
"members": "訪客",
"moderators": "管理員",
"subscribe": "訂閱",
"subscribed": "已訂閱",
"block": "封鎖",
"unblock": "取消封鎖",
"blockInstance": "封鎖站點",
"favorite": "最愛",
"unfavorite": "取消最愛"
}
},
"content": {
"all": "所有",
"users": "使用者"
},
"post": {
"actions": {
"save": "保存",
"more": {
"crosspost": "轉貼"
}
},
"badges": {
"nsfw": "限制級(NSFW)",
"featured": "置頂"
}
},
"moderation": {
"report": "檢舉"
},
"settings": {
"title": "設定",
"app": {
"lang": {
"title": "語言",
"auto": "自動"
}
},
"lemmy": {
"nsfwBlur": {
"title": "限制級(NSFW) 遮擋",
"description": "模糊圖片並隱藏限制級(NSFW)帖文預覽。"
}
}
}
}
+228
View File
@@ -0,0 +1,228 @@
{
"profile": {
"inbox": "信箱",
"profile": "個人資料",
"saved": "保存",
"subscribed": "訂閱"
},
"nav": {
"home": "首頁",
"moderation": "管理",
"admin": "設定",
"communities": "探索",
"search": "搜尋",
"create": {
"label": "新增",
"post": "貼文",
"community": "社群",
"logingate": "你需要登入,才能發文."
},
"menu": {
"app": "App",
"settings": "設定",
"colorscheme": {
"label": "主題",
"system": "系統",
"dark": "暗黑",
"light": "光亮"
},
"theme": "主題",
"about": "關於",
"source": "來源",
"instance": "站點",
"label": "個人資料"
}
},
"account": {
"login": "登入",
"logout": "登出",
"accounts": "帳號",
"changeinstance": "變更站點",
"resetColor": "重設顏色",
"addGuest": "新增遊客",
"moveUp": "往上",
"moveDown": "往下",
"guest": "遊客",
"signup": "註冊"
},
"filter": {
"location": {
"label": "範圍",
"all": "所有",
"subscribed": "已訂閱",
"moderator": "管理的",
"global": "全部",
"local": "本站"
},
"sort": {
"label": "排序",
"hot": "熱門",
"top": {
"label": "最佳",
"time": {
"label": "時間",
"all": "所有",
"9months": "9月以來",
"6months": "6月以來",
"3months": "3月以來",
"month": "這月以來",
"week": "這周",
"day": "日",
"6hours": "6小時",
"hour": "這小時",
"12hours": "12小時"
}
},
"new": "最新",
"old": "最舊",
"controversial": "最有爭議",
"scaled": "各版熱門",
"newcomments": "最新留言",
"mostcomments": "最多留言",
"active": "活躍"
},
"view": {
"cozy": "可莉",
"list": "列表",
"compact": "緊湊",
"label": "顯示模式",
"legacy": "經典"
},
"type": "類型",
"filter": "過濾",
"unread": "未讀",
"inbox": {
"messages": "私信",
"replies": "回覆",
"mentions": "標記"
}
},
"form": {
"name": "名稱",
"instance": "站點網址",
"username": "使用者名稱",
"password": "密碼",
"confirmPassword": "確認密碼",
"forgotpassword": "忘記密碼",
"submit": "送出",
"edit": "編輯",
"preview": "預覽",
"post": {
"create": "發文",
"edit": "編輯貼文",
"community": "社群",
"title": "標題",
"url": "網址",
"body": "內文",
"nsfw": "限制級(NSFW)",
"altText": "替代文字",
"generateTitle": "代入標題",
"uploadImage": "上傳影像"
},
"profile": {
"displayName": "顯示名稱",
"bio": "個人簡介",
"avatar": "大頭貼",
"banner": "背景橫幅",
"email": "Email",
"showNSFW": "顯示限制級(NSFW)內容",
"scores": "顯示讚數",
"bot": "機器人帳號",
"showRead": "顯示已讀貼文",
"currentPassword": "當前密碼",
"newPassword": "新密碼",
"verifyNewPassword": "確認密碼",
"showBots": "顯示機器人貼文"
},
"signup": {
"title": "註冊"
},
"2fa": "2FA兩步驗證碼"
},
"routes": {
"saved": "保存",
"createPost": "發文",
"createCommunity": "創建社群",
"post": {
"crosspostCount": "轉貼",
"commentCount": "留言",
"addComment": "新增留言"
},
"verifyEmail": {
"error": "無法驗證您的電子郵件。",
"message": "您的電子郵件已通過驗證。您現在可以關閉此視窗。"
},
"passwordChange": {
"title": "更改密碼",
"description": "選擇您的新密碼。",
"instance": "您的帳戶託管在哪個實例上?"
},
"resetLogin": {
"title": "重置密碼",
"description": "輸入您帳戶的電子郵件,將發送密碼重設連結。如果您的帳戶沒有電子郵件,請聯繫您的實例管理員。"
},
"theme": {
"title": "主題",
"import": "匯入",
"export": "匯出",
"reset": "重設"
}
},
"cards": {
"site": {
"about": "關於",
"stats": "統計",
"admins": "管理員"
},
"community": {
"moderators": "管理員",
"subscribe": "訂閱",
"subscribed": "已訂閱",
"block": "封鎖",
"unblock": "取消封鎖",
"blockInstance": "封鎖站點",
"favorite": "最愛",
"unfavorite": "取消最愛",
"members": "訪客"
}
},
"content": {
"all": "所有",
"users": "使用者"
},
"post": {
"actions": {
"save": "保存",
"more": {
"crosspost": "轉貼"
}
},
"badges": {
"nsfw": "限制級(NSFW)",
"featured": "置頂"
}
},
"moderation": {
"report": "檢舉"
},
"settings": {
"title": "設定",
"app": {
"lang": {
"auto": "自動",
"title": "語言"
}
},
"lemmy": {
"nsfwBlur": {
"description": "模糊圖片並隱藏限制級(NSFW)帖文預覽。",
"title": "限制級(NSFW) 遮擋"
}
}
},
"common": {
"next": "往後",
"back": "往前",
"refresh": "重整"
}
}
+22 -19
View File
@@ -44,11 +44,8 @@ async function customFetch(
}
}
const url = toURL(input)
if (auth && url) url.searchParams.set('auth', auth)
const res = await f(url ?? input, init)
if (!res.ok) error(res.status, await res.text());
const res = await f(input, init)
if (!res.ok) error(res.status, await res.text())
return res
}
@@ -101,27 +98,33 @@ export async function validateInstance(instance: string): Promise<boolean> {
}
}
export function mayBeIncompatible(minVersion: string, availableVersion: string) {
if (minVersion.valueOf() === availableVersion.valueOf()) return false;
export function mayBeIncompatible(
minVersion: string,
availableVersion: string
) {
if (minVersion.valueOf() === availableVersion.valueOf()) return false
const versionFormatter = /[\d.]/;
if (!minVersion.match(versionFormatter) || !availableVersion.match(availableVersion)) {
return true;
const versionFormatter = /[\d.]/
if (
!minVersion.match(versionFormatter) ||
!availableVersion.match(availableVersion)
) {
return true
}
const splitMinVersion = minVersion.split('.');
const splitAvailableVersion = availableVersion.split('.');
const splitMinVersion = minVersion.split('.')
const splitAvailableVersion = availableVersion.split('.')
if (splitMinVersion.length !== splitAvailableVersion.length) return true;
if (splitMinVersion.length !== splitAvailableVersion.length) return true
for (let i = 0; i < splitMinVersion.length; ++i) {
const minVersionDigit = parseInt(splitMinVersion[i]);
const availableVersionDigit = parseInt(splitAvailableVersion[i]);
const minVersionDigit = parseInt(splitMinVersion[i])
const availableVersionDigit = parseInt(splitAvailableVersion[i])
if (availableVersionDigit === undefined) return true;
if (minVersionDigit < availableVersionDigit) return false;
if (availableVersionDigit < minVersionDigit) return true;
if (availableVersionDigit === undefined) return true
if (minVersionDigit < availableVersionDigit) return false
if (availableVersionDigit < minVersionDigit) return true
}
return false;
return false
}
-6
View File
@@ -96,10 +96,4 @@ export function addFavorite(item: Community, add: boolean = true) {
}
p.favorites = favs
profileData.update(() => pd)
profile.update((p) => ({
...p,
favorites: favs,
id: p!.id,
instance: p!.instance,
}))
}
+5 -16
View File
@@ -1,4 +1,4 @@
import { profile, type Profile } from '$lib/auth.js'
import { profile, profileData, type Profile } from '$lib/auth.js'
import { getClient } from '$lib/lemmy.js'
import { trycatch } from '$lib/util.js'
import type { Community, MyUserInfo, PersonView } from 'lemmy-js-client'
@@ -22,30 +22,19 @@ export const addSubscription = (
community: Community,
subscribe: boolean = true
) => {
const p = get(profile)
const pd = get(profileData)
const p = pd.profiles.find((p) => p.id == pd.profile)
if (!p?.user) return
if (subscribe) {
profile.set({
...p,
user: {
...p.user,
follows: [
...p.user.follows,
{
community: community,
follower: p.user.local_user_view.person,
},
],
},
})
profileData.set(pd)
} else {
p.user.follows.splice(
p.user.follows.findIndex((i) => i.community.id == community.id),
1
)
profile.set(p)
profileData.set(pd)
}
}
+15 -1
View File
@@ -88,8 +88,14 @@ interface Settings {
compactFeatured: boolean
showHidden: boolean
}
infiniteScroll: boolean
language: string | null
useRtl: boolean
translator: string | undefined
parseTags: boolean
tagRules: {
[key: string]: 'hide' | 'blur'
}
}
export const defaultSettings: Settings = {
@@ -155,14 +161,22 @@ export const defaultSettings: Settings = {
compactFeatured: toBool(env.PUBLIC_COMPACT_FEATURED) ?? true,
showHidden: false,
},
infiniteScroll: true,
language: env.PUBLIC_LANGUAGE ?? null,
useRtl: false,
translator: env.PUBLIC_TRANSLATOR ?? undefined,
parseTags: true,
tagRules: {
cw: 'blur',
nsfl: 'blur',
nsfw: 'blur',
},
}
export const userSettings = writable(defaultSettings)
const migrate = (settings: any): Settings => {
if (typeof settings.moderation.removalReasonPreset == 'string') {
if (typeof settings?.moderation?.removalReasonPreset == 'string') {
settings.moderation.presets = [
{
title: 'Preset 1',
+15
View File
@@ -27,11 +27,26 @@ const config: Config = {
key: '',
loader: async () => (await import('./i18n/de.json')).default,
},
{
locale: 'he',
key: '',
loader: async () => (await import('./i18n/he.json')).default,
},
{
locale: 'pt',
key: '',
loader: async () => (await import('./i18n/pt.json')).default,
},
{
locale: 'zh-Hans',
key: '',
loader: async () => (await import('./i18n/zh-Hans.json')).default,
},
{
locale: 'zh-Hant',
key: '',
loader: async () => (await import('./i18n/zh-Hant.json')).default,
},
],
fallbackLocale: 'en',
}
+2 -1
View File
@@ -5,7 +5,8 @@ import { get } from 'svelte/store'
import type { SubscribedType } from 'lemmy-js-client'
import { page } from '$app/stores'
import { feature } from '$lib/version.js'
import { client, site } from '$lib/lemmy.js'
import { client } from '$lib/lemmy.js'
import { site } from './lemmy'
export const findClosestNumber = (numbers: number[], target: number): number =>
numbers.reduce((prev, curr) =>