feat: add some stats to post actions
This commit is contained in:
1 parent
47cd2a0fea
commit
dbb6f16fde
8 files changed
+81
-30
No files matched your search
+1
-1
@@ -20,7 +20,7 @@
|
|||||||
"linkify-it": "^5.0.0",
|
"linkify-it": "^5.0.0",
|
||||||
"marked": "^5.1.2",
|
"marked": "^5.1.2",
|
||||||
"marked-linkify-it": "^3.1.10",
|
"marked-linkify-it": "^3.1.10",
|
||||||
"mono-svelte": "^1.6.26",
|
"mono-svelte": "latest",
|
||||||
"nprogress": "^0.2.0",
|
"nprogress": "^0.2.0",
|
||||||
"postcss": "^8.4.30",
|
"postcss": "^8.4.30",
|
||||||
"rollup-plugin-visualizer": "^5.9.2",
|
"rollup-plugin-visualizer": "^5.9.2",
|
||||||
|
|||||||
@@ -128,7 +128,7 @@
|
|||||||
title={hideTitle ? undefined : tags?.title ? tags.title : post.post.name}
|
title={hideTitle ? undefined : tags?.title ? tags.title : post.post.name}
|
||||||
read={post.read}
|
read={post.read}
|
||||||
style="grid-area: meta;"
|
style="grid-area: meta;"
|
||||||
edited={post.post.updated != undefined}
|
edited={post.post.updated}
|
||||||
tags={tags?.tags}
|
tags={tags?.tags}
|
||||||
{view}
|
{view}
|
||||||
>
|
>
|
||||||
|
|||||||
@@ -3,6 +3,7 @@
|
|||||||
import PostVote from './PostVote.svelte'
|
import PostVote from './PostVote.svelte'
|
||||||
import { getInstance, site } from '$lib/lemmy.js'
|
import { getInstance, site } from '$lib/lemmy.js'
|
||||||
import {
|
import {
|
||||||
|
ArrowsUpDown,
|
||||||
ArrowTopRightOnSquare,
|
ArrowTopRightOnSquare,
|
||||||
Bookmark,
|
Bookmark,
|
||||||
BookmarkSlash,
|
BookmarkSlash,
|
||||||
@@ -11,6 +12,7 @@
|
|||||||
ChatBubbleOvalLeft,
|
ChatBubbleOvalLeft,
|
||||||
ChatBubbleOvalLeftEllipsis,
|
ChatBubbleOvalLeftEllipsis,
|
||||||
CheckBadge,
|
CheckBadge,
|
||||||
|
Clock,
|
||||||
EllipsisHorizontal,
|
EllipsisHorizontal,
|
||||||
Eye,
|
Eye,
|
||||||
EyeSlash,
|
EyeSlash,
|
||||||
@@ -20,6 +22,7 @@
|
|||||||
Language,
|
Language,
|
||||||
MapPin,
|
MapPin,
|
||||||
Newspaper,
|
Newspaper,
|
||||||
|
Pencil,
|
||||||
PencilSquare,
|
PencilSquare,
|
||||||
ServerStack,
|
ServerStack,
|
||||||
Share,
|
Share,
|
||||||
@@ -60,6 +63,9 @@
|
|||||||
import { publishedToDate } from '$lib/components/util/date'
|
import { publishedToDate } from '$lib/components/util/date'
|
||||||
import TextProps from '$lib/components/ui/text/TextProps.svelte'
|
import TextProps from '$lib/components/ui/text/TextProps.svelte'
|
||||||
import { communityLink, userLink } from '$lib/lemmy/generic'
|
import { communityLink, userLink } from '$lib/lemmy/generic'
|
||||||
|
import RelativeDate, {
|
||||||
|
formatRelativeDate,
|
||||||
|
} from '$lib/components/util/RelativeDate.svelte'
|
||||||
|
|
||||||
export let post: PostView
|
export let post: PostView
|
||||||
export let view: View = 'cozy'
|
export let view: View = 'cozy'
|
||||||
@@ -214,6 +220,53 @@
|
|||||||
>
|
>
|
||||||
<Icon slot="prefix" src={EllipsisHorizontal} width={16} micro />
|
<Icon slot="prefix" src={EllipsisHorizontal} width={16} micro />
|
||||||
</Button>
|
</Button>
|
||||||
|
<MenuDivider>{$t('cards.site.stats')}</MenuDivider>
|
||||||
|
<div class="flex flex-row gap-1 items-center">
|
||||||
|
<MenuButton class="flex-1">
|
||||||
|
<Icon src={Clock} size="16" micro slot="prefix" />
|
||||||
|
<span>
|
||||||
|
{publishedToDate(post.post.published).toLocaleDateString(undefined, {
|
||||||
|
dateStyle: 'short',
|
||||||
|
})}
|
||||||
|
</span>
|
||||||
|
</MenuButton>
|
||||||
|
{#if post.post.updated}
|
||||||
|
{@const editedTime = formatRelativeDate(
|
||||||
|
publishedToDate(post.post.updated),
|
||||||
|
{
|
||||||
|
style: 'long',
|
||||||
|
}
|
||||||
|
)}
|
||||||
|
<MenuButton class="flex-1" aria-label={editedTime}>
|
||||||
|
<Icon src={Pencil} size="16" micro slot="prefix" />
|
||||||
|
<RelativeDate date={publishedToDate(post.post.updated)} />
|
||||||
|
</MenuButton>
|
||||||
|
{/if}
|
||||||
|
</div>
|
||||||
|
{#if post.counts.score}
|
||||||
|
{@const ratio =
|
||||||
|
post.counts.upvotes / (post.counts.upvotes + post.counts.downvotes)}
|
||||||
|
<MenuButton
|
||||||
|
aria-label={$t('aria.vote.score', { default: post.counts.score })}
|
||||||
|
>
|
||||||
|
<Icon src={ArrowsUpDown} size="16" micro slot="prefix" />
|
||||||
|
{$t('post.actions.vote.score')}
|
||||||
|
•
|
||||||
|
<FormattedNumber
|
||||||
|
number={post.counts.score}
|
||||||
|
options={{ notation: 'standard' }}
|
||||||
|
class="font-medium"
|
||||||
|
/>
|
||||||
|
•
|
||||||
|
<FormattedNumber
|
||||||
|
number={ratio}
|
||||||
|
options={{ style: 'percent' }}
|
||||||
|
class="font-medium {ratio > 0.7
|
||||||
|
? 'text-blue-700 dark:text-blue-300'
|
||||||
|
: 'text-red-500'}"
|
||||||
|
/>
|
||||||
|
</MenuButton>
|
||||||
|
{/if}
|
||||||
<MenuDivider>{$t('post.actions.more.creator')}</MenuDivider>
|
<MenuDivider>{$t('post.actions.more.creator')}</MenuDivider>
|
||||||
<MenuButton link href={userLink(post.creator)}>
|
<MenuButton link href={userLink(post.creator)}>
|
||||||
<Icon
|
<Icon
|
||||||
@@ -239,16 +292,9 @@
|
|||||||
{post.community.title}
|
{post.community.title}
|
||||||
</TextProps>
|
</TextProps>
|
||||||
</MenuButton>
|
</MenuButton>
|
||||||
<!-- <MenuButton href="/instances/{instanceId(post.community.actor_id)}">
|
<MenuDivider>
|
||||||
<svelte:fragment slot="prefix">
|
{$t('post.actions.more.actions')}
|
||||||
<Icon src={ServerStack} size="16" micro class="flex-shrink-0" />
|
</MenuDivider>
|
||||||
</svelte:fragment>
|
|
||||||
<TextProps wrap="no-wrap">
|
|
||||||
{instanceId(post.community.actor_id)}
|
|
||||||
</TextProps>
|
|
||||||
</MenuButton> -->
|
|
||||||
<hr class="border-slate-200 dark:border-zinc-800 mx-2 my-2" />
|
|
||||||
<MenuDivider>{$t('post.actions.more.actions')}</MenuDivider>
|
|
||||||
{#if $profile?.user && $profile?.jwt && $profile.user.local_user_view.person.id == post.creator.id}
|
{#if $profile?.user && $profile?.jwt && $profile.user.local_user_view.person.id == post.creator.id}
|
||||||
<MenuButton on:click={() => (editing = true)}>
|
<MenuButton on:click={() => (editing = true)}>
|
||||||
<Icon src={PencilSquare} size="16" micro slot="prefix" />
|
<Icon src={PencilSquare} size="16" micro slot="prefix" />
|
||||||
|
|||||||
@@ -43,7 +43,9 @@
|
|||||||
import Avatar from '$lib/components/ui/Avatar.svelte'
|
import Avatar from '$lib/components/ui/Avatar.svelte'
|
||||||
import { Badge, Material, Popover } from 'mono-svelte'
|
import { Badge, Material, Popover } from 'mono-svelte'
|
||||||
import UserLink from '$lib/components/lemmy/user/UserLink.svelte'
|
import UserLink from '$lib/components/lemmy/user/UserLink.svelte'
|
||||||
import RelativeDate from '$lib/components/util/RelativeDate.svelte'
|
import RelativeDate, {
|
||||||
|
formatRelativeDate,
|
||||||
|
} from '$lib/components/util/RelativeDate.svelte'
|
||||||
import type { Community, Person, SubscribedType } from 'lemmy-js-client'
|
import type { Community, Person, SubscribedType } from 'lemmy-js-client'
|
||||||
import {
|
import {
|
||||||
Bookmark,
|
Bookmark,
|
||||||
@@ -65,6 +67,7 @@
|
|||||||
import { t } from '$lib/translations'
|
import { t } from '$lib/translations'
|
||||||
import { Pencil, type IconSource } from 'svelte-hero-icons'
|
import { Pencil, type IconSource } from 'svelte-hero-icons'
|
||||||
import CommunityHeader from '../community/CommunityHeader.svelte'
|
import CommunityHeader from '../community/CommunityHeader.svelte'
|
||||||
|
import { publishedToDate } from '$lib/components/util/date'
|
||||||
|
|
||||||
export let community: Community | undefined = undefined
|
export let community: Community | undefined = undefined
|
||||||
export let showCommunity: boolean = true
|
export let showCommunity: boolean = true
|
||||||
@@ -75,7 +78,7 @@
|
|||||||
export let title: string | undefined = undefined
|
export let title: string | undefined = undefined
|
||||||
export let id: number | undefined = undefined
|
export let id: number | undefined = undefined
|
||||||
export let read: boolean = false
|
export let read: boolean = false
|
||||||
export let edited: boolean = false
|
export let edited: string | undefined = undefined
|
||||||
|
|
||||||
export let view: View = 'cozy'
|
export let view: View = 'cozy'
|
||||||
|
|
||||||
@@ -167,7 +170,15 @@
|
|||||||
<RelativeDate date={published} class="flex-shrink-0" />
|
<RelativeDate date={published} class="flex-shrink-0" />
|
||||||
{/if}
|
{/if}
|
||||||
{#if edited}
|
{#if edited}
|
||||||
<Icon src={Pencil} micro size="14" />
|
<div
|
||||||
|
title={$t('post.meta.lastEdited', {
|
||||||
|
default: formatRelativeDate(publishedToDate(edited), {
|
||||||
|
style: 'long',
|
||||||
|
}),
|
||||||
|
})}
|
||||||
|
>
|
||||||
|
<Icon src={Pencil} micro size="14" />
|
||||||
|
</div>
|
||||||
{/if}
|
{/if}
|
||||||
</span>
|
</span>
|
||||||
<div
|
<div
|
||||||
|
|||||||
@@ -44,19 +44,8 @@
|
|||||||
|
|
||||||
export let url: string
|
export let url: string
|
||||||
export let type: MediaType = 'embed'
|
export let type: MediaType = 'embed'
|
||||||
|
|
||||||
export let openMediaBias = false
|
|
||||||
|
|
||||||
const stripSubdomain = (url: string) =>
|
|
||||||
new URL(url).hostname.split('.').slice(-2).join('.')
|
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
{#if openMediaBias}
|
|
||||||
{#await import('$lib/components/mbfc/MBFCModal.svelte') then { default: MbfcModal }}
|
|
||||||
<MbfcModal domain={stripSubdomain(url)} bind:open={openMediaBias} />
|
|
||||||
{/await}
|
|
||||||
{/if}
|
|
||||||
|
|
||||||
<Menu {...$$restProps}>
|
<Menu {...$$restProps}>
|
||||||
<slot name="target" slot="target" />
|
<slot name="target" slot="target" />
|
||||||
|
|
||||||
|
|||||||
@@ -120,7 +120,6 @@
|
|||||||
<Icon src={UserGroup} micro width={16} slot="prefix" />
|
<Icon src={UserGroup} micro width={16} slot="prefix" />
|
||||||
{$t('account.accounts')}
|
{$t('account.accounts')}
|
||||||
</MenuButton>
|
</MenuButton>
|
||||||
<hr class="dark:opacity-10 w-[90%] my-2 mx-auto" />
|
|
||||||
<MenuDivider>{$t('nav.menu.app')}</MenuDivider>
|
<MenuDivider>{$t('nav.menu.app')}</MenuDivider>
|
||||||
<MenuButton link href="/settings">
|
<MenuButton link href="/settings">
|
||||||
<Icon src={Cog6Tooth} micro width={16} slot="prefix" />
|
<Icon src={Cog6Tooth} micro width={16} slot="prefix" />
|
||||||
|
|||||||
@@ -481,7 +481,8 @@
|
|||||||
},
|
},
|
||||||
"vote": {
|
"vote": {
|
||||||
"upvote": "Upvote",
|
"upvote": "Upvote",
|
||||||
"downvote": "Downvote"
|
"downvote": "Downvote",
|
||||||
|
"score": "Score"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"badges": {
|
"badges": {
|
||||||
@@ -496,6 +497,10 @@
|
|||||||
"zoomIn": "Zoom in",
|
"zoomIn": "Zoom in",
|
||||||
"zoomOut": "Zoom out",
|
"zoomOut": "Zoom out",
|
||||||
"close": "Close"
|
"close": "Close"
|
||||||
|
},
|
||||||
|
"meta": {
|
||||||
|
"lastEdited": "Last edited {{default}}",
|
||||||
|
"created": "Created {{default}}"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"comment": {
|
"comment": {
|
||||||
@@ -859,7 +864,8 @@
|
|||||||
"vote": {
|
"vote": {
|
||||||
"group": "Post voting controls",
|
"group": "Post voting controls",
|
||||||
"upvotes": "{{default}} upvotes",
|
"upvotes": "{{default}} upvotes",
|
||||||
"downvotes": "{{default}} downvotes"
|
"downvotes": "{{default}} downvotes",
|
||||||
|
"score": "Score: {{default}}"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"stats": {
|
"stats": {
|
||||||
|
|||||||
@@ -204,7 +204,7 @@
|
|||||||
moderator: post.post_view.creator_is_moderator,
|
moderator: post.post_view.creator_is_moderator,
|
||||||
}}
|
}}
|
||||||
published={publishedToDate(post.post_view.post.published)}
|
published={publishedToDate(post.post_view.post.published)}
|
||||||
edited={post.post_view.post.updated != undefined}
|
edited={post.post_view.post.updated}
|
||||||
bind:title={post.post_view.post.name}
|
bind:title={post.post_view.post.name}
|
||||||
style="width: max-content;"
|
style="width: max-content;"
|
||||||
/>
|
/>
|
||||||
|
|||||||
Reference in new issue
Block a user