@meith/web 0.16.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE.md +165 -0
- package/app/(auth)/layout.tsx +6 -0
- package/app/(auth)/login/page.tsx +106 -0
- package/app/(auth)/login/verify/page.tsx +55 -0
- package/app/(auth)/register/page.tsx +83 -0
- package/app/(auth)/reset/confirm/page.tsx +45 -0
- package/app/(auth)/reset/page.tsx +22 -0
- package/app/(auth)/verify/page.tsx +44 -0
- package/app/(auth)/verify/resend/page.tsx +51 -0
- package/app/(board)/[slug]/feed.xml/route.ts +48 -0
- package/app/(board)/[slug]/new/page.tsx +112 -0
- package/app/(board)/[slug]/page.tsx +403 -0
- package/app/(board)/discover/[view]/page.tsx +115 -0
- package/app/(board)/discover/page.tsx +5 -0
- package/app/(board)/layout.tsx +22 -0
- package/app/(board)/member/[id]/page.tsx +187 -0
- package/app/(board)/member/[id]/reputation/page.tsx +195 -0
- package/app/(board)/member/by-name/[name]/page.tsx +32 -0
- package/app/(board)/messages/[id]/page.tsx +103 -0
- package/app/(board)/messages/compose/page.tsx +60 -0
- package/app/(board)/messages/layout.tsx +5 -0
- package/app/(board)/messages/page.tsx +179 -0
- package/app/(board)/modcp/forums/page.tsx +59 -0
- package/app/(board)/modcp/ip/page.tsx +158 -0
- package/app/(board)/modcp/layout.tsx +5 -0
- package/app/(board)/modcp/log/page.tsx +98 -0
- package/app/(board)/modcp/page.tsx +112 -0
- package/app/(board)/moderation/layout.tsx +5 -0
- package/app/(board)/moderation/page.tsx +111 -0
- package/app/(board)/moderation/reports/page.tsx +193 -0
- package/app/(board)/moderation/warn/page.tsx +158 -0
- package/app/(board)/notifications/layout.tsx +5 -0
- package/app/(board)/notifications/page.tsx +144 -0
- package/app/(board)/notifications/preferences/page.tsx +65 -0
- package/app/(board)/online/page.tsx +119 -0
- package/app/(board)/page.tsx +195 -0
- package/app/(board)/plugins/[key]/[[...path]]/page.tsx +72 -0
- package/app/(board)/privacy/page.tsx +12 -0
- package/app/(board)/report/page.tsx +71 -0
- package/app/(board)/rules/page.tsx +12 -0
- package/app/(board)/search/[token]/page.tsx +130 -0
- package/app/(board)/search/page.tsx +289 -0
- package/app/(board)/stats/page.tsx +202 -0
- package/app/(board)/subscriptions/layout.tsx +5 -0
- package/app/(board)/subscriptions/page.tsx +142 -0
- package/app/(board)/terms/page.tsx +12 -0
- package/app/(board)/thread/[slug]/edit/page.tsx +107 -0
- package/app/(board)/thread/[slug]/feed.xml/route.ts +42 -0
- package/app/(board)/thread/[slug]/page.tsx +707 -0
- package/app/(board)/thread/[slug]/poll/page.tsx +41 -0
- package/app/(board)/thread/[slug]/post/[postId]/history/page.tsx +160 -0
- package/app/(board)/thread/[slug]/reply/page.tsx +136 -0
- package/app/(board)/unsubscribe/page.tsx +73 -0
- package/app/(board)/usercp/avatar/page.tsx +56 -0
- package/app/(board)/usercp/contacts/page.tsx +141 -0
- package/app/(board)/usercp/email/confirm/page.tsx +52 -0
- package/app/(board)/usercp/layout.tsx +23 -0
- package/app/(board)/usercp/options/page.tsx +56 -0
- package/app/(board)/usercp/page.tsx +71 -0
- package/app/(board)/usercp/profile/page.tsx +81 -0
- package/app/(board)/usercp/security/page.tsx +238 -0
- package/app/(board)/usercp/security/verify/page.tsx +92 -0
- package/app/(board)/usercp/signature/page.tsx +67 -0
- package/app/admin/antispam/page.tsx +155 -0
- package/app/admin/api/marketplace/screenshot/route.ts +68 -0
- package/app/admin/api/plugins/[key]/[...path]/route.ts +27 -0
- package/app/admin/api-tokens/page.tsx +129 -0
- package/app/admin/content/announcements/page.tsx +110 -0
- package/app/admin/content/attachments/page.tsx +199 -0
- package/app/admin/content/navigation/page.tsx +123 -0
- package/app/admin/content/page.tsx +170 -0
- package/app/admin/forums/[id]/page.tsx +96 -0
- package/app/admin/forums/[id]/permissions/page.tsx +108 -0
- package/app/admin/forums/page.tsx +45 -0
- package/app/admin/groups/[id]/page.tsx +133 -0
- package/app/admin/groups/memberships/page.tsx +56 -0
- package/app/admin/groups/page.tsx +104 -0
- package/app/admin/groups/promotions/page.tsx +143 -0
- package/app/admin/layout.tsx +86 -0
- package/app/admin/log/page.tsx +116 -0
- package/app/admin/page.tsx +206 -0
- package/app/admin/plugins/[key]/[[...path]]/page.tsx +276 -0
- package/app/admin/plugins/browse/page.tsx +70 -0
- package/app/admin/plugins/page.tsx +165 -0
- package/app/admin/security/page.tsx +124 -0
- package/app/admin/settings/page.tsx +190 -0
- package/app/admin/system/page.tsx +303 -0
- package/app/admin/themes/[key]/page.tsx +110 -0
- package/app/admin/themes/browse/page.tsx +70 -0
- package/app/admin/themes/page.tsx +163 -0
- package/app/admin/users/[id]/merge/page.tsx +136 -0
- package/app/admin/users/[id]/page.tsx +208 -0
- package/app/admin/users/mail/page.tsx +68 -0
- package/app/admin/users/page.tsx +260 -0
- package/app/admin/users/prune/page.tsx +186 -0
- package/app/api/health/route.ts +11 -0
- package/app/api/metrics/route.ts +66 -0
- package/app/api/plugins/[key]/[...path]/route.ts +27 -0
- package/app/api/read/all/route.ts +15 -0
- package/app/api/read/forum/[id]/route.ts +29 -0
- package/app/api/read/thread/[id]/route.ts +40 -0
- package/app/api/ready/route.ts +63 -0
- package/app/api/system/tick/route.ts +77 -0
- package/app/api/v1/[...path]/route.ts +208 -0
- package/app/api/v1/openapi.json/route.ts +12 -0
- package/app/apple-icon.ts +11 -0
- package/app/atom.xml/route.ts +7 -0
- package/app/attachment/[id]/route.ts +10 -0
- package/app/attachment/[id]/thumb/route.ts +10 -0
- package/app/auth/passkey/options/route.ts +145 -0
- package/app/auth/passkey/verify/route.ts +241 -0
- package/app/auth/resume/route.ts +55 -0
- package/app/auth/sso/[provider]/callback/route.ts +173 -0
- package/app/auth/sso/[provider]/go/route.ts +57 -0
- package/app/auth/sso/[provider]/route.ts +105 -0
- package/app/avatar/[id]/route.ts +31 -0
- package/app/brand/icon-192.png/route.ts +7 -0
- package/app/brand/icon-512.png/route.ts +7 -0
- package/app/brand/icon-maskable.png/route.ts +7 -0
- package/app/demo/stripe/[[...path]]/route.ts +27 -0
- package/app/error.tsx +15 -0
- package/app/feed.xml/route.ts +7 -0
- package/app/forumdisplay.php/page.tsx +11 -0
- package/app/group/[id]/badge/[scheme]/route.ts +26 -0
- package/app/icon.ts +13 -0
- package/app/install/page.tsx +221 -0
- package/app/jump/page.tsx +28 -0
- package/app/layout.tsx +124 -0
- package/app/logo/[scheme]/route.ts +24 -0
- package/app/manifest.ts +43 -0
- package/app/member.php/page.tsx +11 -0
- package/app/memberlist.php/page.tsx +11 -0
- package/app/not-found.tsx +14 -0
- package/app/opengraph-image.ts +11 -0
- package/app/redirect/page.tsx +44 -0
- package/app/robots.txt/route.ts +35 -0
- package/app/showthread.php/page.tsx +11 -0
- package/app/sitemap/[page]/route.ts +64 -0
- package/app/sitemap.xml/route.ts +31 -0
- package/app/twitter-image.ts +11 -0
- package/app/viewforum.php/page.tsx +11 -0
- package/app/viewtopic.php/page.tsx +11 -0
- package/bin/forum-web.mjs +241 -0
- package/components.json +21 -0
- package/instrumentation.ts +18 -0
- package/next.config.mjs +182 -0
- package/package.json +99 -0
- package/postcss.config.mjs +7 -0
- package/proxy.ts +160 -0
- package/src/components/account/active-sessions.tsx +87 -0
- package/src/components/account/avatar-form.tsx +119 -0
- package/src/components/account/credential-proof-form.tsx +76 -0
- package/src/components/account/logout-form.tsx +14 -0
- package/src/components/account/notification-forms.tsx +157 -0
- package/src/components/account/passkey-enrol.tsx +81 -0
- package/src/components/account/passkey-proof-button.tsx +47 -0
- package/src/components/account/push-device-form.tsx +193 -0
- package/src/components/account/relation-forms.tsx +69 -0
- package/src/components/account/reputation-forms.tsx +124 -0
- package/src/components/account/security-activity.tsx +46 -0
- package/src/components/account/sign-in-methods.tsx +166 -0
- package/src/components/account/subscription-forms.tsx +151 -0
- package/src/components/account/two-factor-forms.tsx +226 -0
- package/src/components/account/usercp-forms.tsx +387 -0
- package/src/components/account/usercp-nav.tsx +14 -0
- package/src/components/account/usercp-shell.tsx +34 -0
- package/src/components/admin/admin-forms.tsx +92 -0
- package/src/components/admin/admin-nav.tsx +52 -0
- package/src/components/admin/admin-undo.tsx +32 -0
- package/src/components/admin/api-token-forms.tsx +89 -0
- package/src/components/admin/badge-forms.tsx +97 -0
- package/src/components/admin/branding-forms.tsx +102 -0
- package/src/components/admin/content-forms.tsx +712 -0
- package/src/components/admin/form-bits.tsx +11 -0
- package/src/components/admin/forum-forms.tsx +524 -0
- package/src/components/admin/forum-tree.tsx +454 -0
- package/src/components/admin/group-forms.tsx +646 -0
- package/src/components/admin/mail-test-card.tsx +90 -0
- package/src/components/admin/marketplace-forms.tsx +30 -0
- package/src/components/admin/marketplace-listing.tsx +123 -0
- package/src/components/admin/navigation-forms.tsx +229 -0
- package/src/components/admin/navigation-tree.tsx +442 -0
- package/src/components/admin/oklch-picker.tsx +180 -0
- package/src/components/admin/plugin-forms.tsx +225 -0
- package/src/components/admin/settings-form.tsx +148 -0
- package/src/components/admin/system-forms.tsx +169 -0
- package/src/components/admin/theme-changes.tsx +354 -0
- package/src/components/admin/theme-forms.tsx +636 -0
- package/src/components/admin/theme-palette.tsx +119 -0
- package/src/components/admin/theme-preview.tsx +461 -0
- package/src/components/admin/user-bulk-toolbar.tsx +99 -0
- package/src/components/admin/user-forms.tsx +488 -0
- package/src/components/auth/auth-page.tsx +45 -0
- package/src/components/auth/form-controls.tsx +117 -0
- package/src/components/auth/login-form.tsx +47 -0
- package/src/components/auth/passkey-client.ts +171 -0
- package/src/components/auth/passkey-second-factor.tsx +69 -0
- package/src/components/auth/passkey-sign-in.tsx +61 -0
- package/src/components/auth/register-form.tsx +136 -0
- package/src/components/auth/resend-verification-form.tsx +34 -0
- package/src/components/auth/reset-confirm-form.tsx +43 -0
- package/src/components/auth/reset-request-form.tsx +35 -0
- package/src/components/auth/second-factor-form.tsx +51 -0
- package/src/components/auth/sso-buttons.tsx +47 -0
- package/src/components/board/live-region.tsx +74 -0
- package/src/components/board/search-off-notice.tsx +18 -0
- package/src/components/board/section-page.tsx +114 -0
- package/src/components/content/attachment-field.tsx +51 -0
- package/src/components/content/composer-field.ts +31 -0
- package/src/components/content/composer-ids.ts +6 -0
- package/src/components/content/composer-intents.tsx +27 -0
- package/src/components/content/composer-recovery.tsx +215 -0
- package/src/components/content/edit-post-form.tsx +121 -0
- package/src/components/content/markdown-editor.tsx +590 -0
- package/src/components/content/markdown-syntax.ts +53 -0
- package/src/components/content/mention-token.ts +23 -0
- package/src/components/content/multiquote-button.tsx +32 -0
- package/src/components/content/multiquote-selection.tsx +105 -0
- package/src/components/content/multiquote.ts +125 -0
- package/src/components/content/new-thread-form.tsx +169 -0
- package/src/components/content/poll-edit-form.tsx +96 -0
- package/src/components/content/poll.tsx +89 -0
- package/src/components/content/quote-in-place.tsx +51 -0
- package/src/components/content/reply-form.tsx +113 -0
- package/src/components/content/thanks-button.tsx +65 -0
- package/src/components/content/thread-rating.tsx +143 -0
- package/src/components/install/install-form.tsx +497 -0
- package/src/components/legal/legal-document.tsx +22 -0
- package/src/components/messages/message-forms.tsx +152 -0
- package/src/components/moderation/inline-moderation-form.tsx +158 -0
- package/src/components/moderation/modcp-nav.tsx +15 -0
- package/src/components/moderation/modcp-shell.tsx +41 -0
- package/src/components/moderation/queue-form.tsx +96 -0
- package/src/components/moderation/report-forms.tsx +120 -0
- package/src/components/moderation/signature-lock-form.tsx +83 -0
- package/src/components/moderation/thread-surgery-form.tsx +96 -0
- package/src/components/moderation/thread-tools-form.tsx +137 -0
- package/src/components/moderation/warning-forms.tsx +125 -0
- package/src/components/profile/custom-field.tsx +79 -0
- package/src/components/shell/appearance-icons.tsx +35 -0
- package/src/components/shell/board-notice.tsx +21 -0
- package/src/components/shell/copy-record.ts +20 -0
- package/src/components/shell/copy.tsx +17 -0
- package/src/components/shell/crash-notice.tsx +86 -0
- package/src/components/shell/demo-banner.tsx +49 -0
- package/src/components/shell/group-name-style.tsx +6 -0
- package/src/components/shell/measure.ts +1 -0
- package/src/components/shell/notification-menu.tsx +361 -0
- package/src/components/shell/offline-notice.tsx +29 -0
- package/src/components/shell/onboarding-banner.tsx +39 -0
- package/src/components/shell/page-shell.tsx +167 -0
- package/src/components/shell/panel-list.tsx +95 -0
- package/src/components/shell/panel-nav.tsx +40 -0
- package/src/components/shell/panel-overview.tsx +81 -0
- package/src/components/shell/panel-page.tsx +96 -0
- package/src/components/shell/panel-pagination.tsx +28 -0
- package/src/components/shell/panel-shell.tsx +31 -0
- package/src/components/shell/theme-runtime-style.tsx +6 -0
- package/src/components/shell/theme-switcher.tsx +97 -0
- package/src/components/shell/timezone-probe.tsx +45 -0
- package/src/components/shell/view-tabs.tsx +60 -0
- package/src/config.ts +13 -0
- package/src/server/absent-services.ts +29 -0
- package/src/server/admin-actions.ts +171 -0
- package/src/server/admin-settings-actions.ts +83 -0
- package/src/server/admin-undo-actions.ts +70 -0
- package/src/server/admin-undo.ts +75 -0
- package/src/server/admin.ts +112 -0
- package/src/server/announcements.ts +82 -0
- package/src/server/antispam.ts +310 -0
- package/src/server/api/content.ts +486 -0
- package/src/server/api/http.ts +119 -0
- package/src/server/api/members.ts +109 -0
- package/src/server/api/messages.ts +113 -0
- package/src/server/api/registry.ts +30 -0
- package/src/server/api/search.ts +98 -0
- package/src/server/api/subscriptions.ts +106 -0
- package/src/server/api-auth.ts +66 -0
- package/src/server/api-token-actions.ts +85 -0
- package/src/server/api-tokens-admin.ts +95 -0
- package/src/server/appearance-actions.ts +39 -0
- package/src/server/attachment-download.ts +43 -0
- package/src/server/attachment-embed.ts +63 -0
- package/src/server/attachment-upload-actions.ts +92 -0
- package/src/server/attachments.ts +257 -0
- package/src/server/auth-actions.ts +479 -0
- package/src/server/auth-config.ts +61 -0
- package/src/server/auth-events.ts +92 -0
- package/src/server/auth-form-state.ts +14 -0
- package/src/server/auth-mail.ts +104 -0
- package/src/server/avatars.ts +83 -0
- package/src/server/board-latest-actions.ts +7 -0
- package/src/server/board-latest.tsx +103 -0
- package/src/server/board-offline.ts +23 -0
- package/src/server/board-url.ts +14 -0
- package/src/server/brand-assets.ts +151 -0
- package/src/server/brand-mark.tsx +110 -0
- package/src/server/branding-actions.ts +53 -0
- package/src/server/branding.ts +101 -0
- package/src/server/cache-targets.ts +13 -0
- package/src/server/code-highlighting.ts +33 -0
- package/src/server/container.ts +402 -0
- package/src/server/content-actions.ts +459 -0
- package/src/server/content-admin-actions.ts +492 -0
- package/src/server/content-admin.ts +95 -0
- package/src/server/content-security-policy.ts +35 -0
- package/src/server/context.ts +32 -0
- package/src/server/cookies.ts +139 -0
- package/src/server/credential-proof-actions.ts +42 -0
- package/src/server/credential-proof.ts +35 -0
- package/src/server/current-location.ts +19 -0
- package/src/server/demo-stripe.ts +104 -0
- package/src/server/demo-uploads.ts +28 -0
- package/src/server/demo.ts +80 -0
- package/src/server/discovery.ts +104 -0
- package/src/server/embeds.ts +113 -0
- package/src/server/error-notice.tsx +41 -0
- package/src/server/federation-actions.ts +113 -0
- package/src/server/federation.ts +138 -0
- package/src/server/feed-builder.ts +72 -0
- package/src/server/feed-routes.ts +122 -0
- package/src/server/fixture-actor-source.ts +62 -0
- package/src/server/fixture-forum-repo.ts +59 -0
- package/src/server/fixture-member-profile-repo.ts +30 -0
- package/src/server/fixture-post-repo.ts +108 -0
- package/src/server/fixture-thread-repo.ts +98 -0
- package/src/server/form-state-reporter.ts +34 -0
- package/src/server/form-values.ts +23 -0
- package/src/server/forum-admin-actions.ts +353 -0
- package/src/server/forum-admin.ts +98 -0
- package/src/server/group-admin-actions.ts +341 -0
- package/src/server/group-admin.ts +98 -0
- package/src/server/group-badge-actions.ts +61 -0
- package/src/server/group-badge.ts +62 -0
- package/src/server/group-identity.ts +104 -0
- package/src/server/i18n-catalogs.ts +42 -0
- package/src/server/i18n.ts +69 -0
- package/src/server/image-upload.ts +109 -0
- package/src/server/inline-moderation-actions.ts +129 -0
- package/src/server/install-actions.ts +124 -0
- package/src/server/install.ts +281 -0
- package/src/server/legacy-redirect.ts +83 -0
- package/src/server/legal.ts +43 -0
- package/src/server/location-header.ts +37 -0
- package/src/server/mail-brand.ts +43 -0
- package/src/server/mail-health.ts +41 -0
- package/src/server/mail-send.ts +44 -0
- package/src/server/mail-test-actions.ts +67 -0
- package/src/server/mail-test.ts +56 -0
- package/src/server/markdown-pipeline.ts +31 -0
- package/src/server/marketplace-actions.ts +47 -0
- package/src/server/marketplace-admin.ts +260 -0
- package/src/server/mention-actions.ts +21 -0
- package/src/server/mention-search.ts +35 -0
- package/src/server/message-actions.ts +110 -0
- package/src/server/messages.ts +141 -0
- package/src/server/modcp.ts +125 -0
- package/src/server/moderation-actions.ts +165 -0
- package/src/server/navigation-admin-actions.ts +217 -0
- package/src/server/navigation.ts +112 -0
- package/src/server/nonce.ts +13 -0
- package/src/server/notification-actions.ts +84 -0
- package/src/server/notification-audience.ts +10 -0
- package/src/server/notification-menu-actions.ts +82 -0
- package/src/server/notification-menu.ts +96 -0
- package/src/server/notifications.ts +93 -0
- package/src/server/onboarding-actions.ts +27 -0
- package/src/server/onboarding.ts +89 -0
- package/src/server/page-metadata.ts +14 -0
- package/src/server/passkey-challenge.ts +42 -0
- package/src/server/plugin-admin-actions.ts +232 -0
- package/src/server/plugin-admin.ts +276 -0
- package/src/server/plugin-host.ts +143 -0
- package/src/server/plugin-pages.ts +192 -0
- package/src/server/plugin-panel.ts +49 -0
- package/src/server/plugin-routes.ts +298 -0
- package/src/server/plugin-view.tsx +58 -0
- package/src/server/poll-actions.ts +104 -0
- package/src/server/poll-scope.ts +52 -0
- package/src/server/post-notifications.ts +71 -0
- package/src/server/post-scope.ts +86 -0
- package/src/server/presence.ts +177 -0
- package/src/server/profile-fields.ts +112 -0
- package/src/server/push-actions.ts +113 -0
- package/src/server/push.ts +40 -0
- package/src/server/redirect-back.ts +15 -0
- package/src/server/registration.ts +7 -0
- package/src/server/relation-actions.ts +89 -0
- package/src/server/relations.ts +45 -0
- package/src/server/reply-core.ts +173 -0
- package/src/server/report-actions.ts +165 -0
- package/src/server/report-scope.ts +21 -0
- package/src/server/reputation-actions.ts +146 -0
- package/src/server/reputation-target.ts +49 -0
- package/src/server/reputation.ts +70 -0
- package/src/server/request-fingerprint.ts +65 -0
- package/src/server/safe-path.ts +16 -0
- package/src/server/same-origin.ts +45 -0
- package/src/server/search-page.ts +313 -0
- package/src/server/search.ts +45 -0
- package/src/server/secret-auth.ts +20 -0
- package/src/server/see-other.ts +11 -0
- package/src/server/seed-board.ts +417 -0
- package/src/server/session-actions.ts +78 -0
- package/src/server/session-cookies.ts +124 -0
- package/src/server/session-key.ts +17 -0
- package/src/server/settings.ts +47 -0
- package/src/server/signatures.ts +62 -0
- package/src/server/sso-handshake.ts +79 -0
- package/src/server/stats.ts +63 -0
- package/src/server/subscription-actions.ts +161 -0
- package/src/server/surgery-actions.ts +180 -0
- package/src/server/syndication.ts +77 -0
- package/src/server/system-admin-actions.ts +134 -0
- package/src/server/system-admin.ts +90 -0
- package/src/server/test-container.ts +114 -0
- package/src/server/theme-admin-actions.ts +242 -0
- package/src/server/theme-admin.ts +203 -0
- package/src/server/theme-runtime.ts +89 -0
- package/src/server/theme-style.ts +279 -0
- package/src/server/theme.ts +52 -0
- package/src/server/thread-core.ts +207 -0
- package/src/server/thread-rating-actions.ts +55 -0
- package/src/server/thread-tool-actions.ts +154 -0
- package/src/server/two-factor-actions.ts +178 -0
- package/src/server/two-factor.ts +86 -0
- package/src/server/upgrade-notice.ts +41 -0
- package/src/server/user-admin-actions.ts +572 -0
- package/src/server/user-admin.ts +165 -0
- package/src/server/usercp-actions.ts +263 -0
- package/src/server/usercp-mail.ts +120 -0
- package/src/server/viewer-preferences.ts +64 -0
- package/src/server/warning-actions.ts +122 -0
- package/src/styles/globals.css +969 -0
- package/src/theme/contract.fixture.ts +793 -0
- package/src/view/account-copy.ts +351 -0
- package/src/view/admin-content-copy.ts +66 -0
- package/src/view/admin-copy.ts +106 -0
- package/src/view/admin-forum-tree-copy.ts +40 -0
- package/src/view/admin-group-copy.ts +80 -0
- package/src/view/admin-log.ts +58 -0
- package/src/view/admin-nav.ts +164 -0
- package/src/view/admin-navigation-copy.ts +58 -0
- package/src/view/admin-panel-copy.ts +194 -0
- package/src/view/admin-settings.ts +173 -0
- package/src/view/admin-theme-copy.ts +229 -0
- package/src/view/admin-user-copy.ts +96 -0
- package/src/view/attachments.ts +51 -0
- package/src/view/auth-copy.ts +147 -0
- package/src/view/board-index.ts +167 -0
- package/src/view/board-latest.ts +101 -0
- package/src/view/breadcrumb.ts +50 -0
- package/src/view/contacts.ts +85 -0
- package/src/view/content-copy.ts +118 -0
- package/src/view/contrast.ts +286 -0
- package/src/view/copy.ts +101 -0
- package/src/view/count.ts +8 -0
- package/src/view/discovery-view.ts +74 -0
- package/src/view/editor-toolbar.ts +84 -0
- package/src/view/error-notice.ts +52 -0
- package/src/view/feed.ts +130 -0
- package/src/view/forum-cursor.ts +54 -0
- package/src/view/forum-display.ts +152 -0
- package/src/view/forum-jump.ts +60 -0
- package/src/view/forum-notice.ts +24 -0
- package/src/view/inline-moderation.ts +87 -0
- package/src/view/install-copy.ts +95 -0
- package/src/view/legal.ts +58 -0
- package/src/view/locale.ts +40 -0
- package/src/view/marketplace-panel.ts +51 -0
- package/src/view/member-identity.ts +23 -0
- package/src/view/member-profile.ts +65 -0
- package/src/view/messages.ts +222 -0
- package/src/view/metadata.ts +75 -0
- package/src/view/modcp-nav.ts +76 -0
- package/src/view/moderation-copy.ts +84 -0
- package/src/view/moderation-queue.ts +67 -0
- package/src/view/navigation-arrange.ts +188 -0
- package/src/view/navigation.ts +173 -0
- package/src/view/notification-menu.ts +202 -0
- package/src/view/notifications.ts +84 -0
- package/src/view/onboarding.ts +26 -0
- package/src/view/pager.ts +191 -0
- package/src/view/panel-nav.ts +203 -0
- package/src/view/plugin-panel.ts +42 -0
- package/src/view/post-form.ts +61 -0
- package/src/view/post-link.ts +29 -0
- package/src/view/presence.ts +99 -0
- package/src/view/promotion-rules.ts +52 -0
- package/src/view/redirect-notice.ts +21 -0
- package/src/view/reputation.ts +107 -0
- package/src/view/search-controls.ts +103 -0
- package/src/view/search-results.ts +291 -0
- package/src/view/security-activity.ts +73 -0
- package/src/view/setting-groups.ts +43 -0
- package/src/view/shell.ts +164 -0
- package/src/view/slug-id.ts +12 -0
- package/src/view/sso-hand-off.ts +44 -0
- package/src/view/sso-notices.ts +48 -0
- package/src/view/subscriptions.ts +76 -0
- package/src/view/theme-draft.ts +167 -0
- package/src/view/theme-preference.ts +30 -0
- package/src/view/theme-tokens.ts +333 -0
- package/src/view/thread-view.ts +280 -0
- package/src/view/time.ts +31 -0
- package/src/view/timezone.ts +35 -0
- package/src/view/two-factor.ts +6 -0
- package/src/view/usercp-nav.ts +103 -0
- package/src/view/usercp.ts +196 -0
- package/src/view/warnings.ts +128 -0
- package/src/view/word-filter.ts +5 -0
|
@@ -0,0 +1,105 @@
|
|
|
1
|
+
'use client'
|
|
2
|
+
|
|
3
|
+
import { useEffect, useRef, useState } from 'react'
|
|
4
|
+
|
|
5
|
+
import { buttonVariants, cn } from '@meith/ui'
|
|
6
|
+
|
|
7
|
+
import { quotePostAction } from '@/server/content-actions'
|
|
8
|
+
|
|
9
|
+
import { type Copy, fromCopy, useCopy } from '../shell/copy'
|
|
10
|
+
import { composerField, insertQuotes } from './composer-field'
|
|
11
|
+
import {
|
|
12
|
+
addedNotice,
|
|
13
|
+
announceMultiquote,
|
|
14
|
+
clearMultiquote,
|
|
15
|
+
multiquoteIds,
|
|
16
|
+
selectionLabel,
|
|
17
|
+
takeMultiquote,
|
|
18
|
+
useMultiquote,
|
|
19
|
+
} from './multiquote'
|
|
20
|
+
|
|
21
|
+
async function addQuotes(
|
|
22
|
+
threadId: number,
|
|
23
|
+
ids: readonly number[],
|
|
24
|
+
reveal: boolean,
|
|
25
|
+
copy: Copy,
|
|
26
|
+
): Promise<string> {
|
|
27
|
+
const field = composerField()
|
|
28
|
+
if (field === null) return ''
|
|
29
|
+
|
|
30
|
+
try {
|
|
31
|
+
const quotes = (await Promise.all(ids.map((id) => quotePostAction(threadId, id)))).filter(
|
|
32
|
+
(quote): quote is string => quote !== null,
|
|
33
|
+
)
|
|
34
|
+
if (quotes.length > 0) {
|
|
35
|
+
takeMultiquote()
|
|
36
|
+
insertQuotes(field, quotes, { reveal })
|
|
37
|
+
}
|
|
38
|
+
return addedNotice(quotes.length, ids.length, copy)
|
|
39
|
+
} catch {
|
|
40
|
+
return addedNotice(0, ids.length, copy)
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
export function MultiQuoteSelection({
|
|
45
|
+
threadId,
|
|
46
|
+
insertOnMount = false,
|
|
47
|
+
}: {
|
|
48
|
+
threadId: number
|
|
49
|
+
insertOnMount?: boolean
|
|
50
|
+
}) {
|
|
51
|
+
const { ids, notice } = useMultiquote()
|
|
52
|
+
const copy = useCopy()
|
|
53
|
+
const [adding, setAdding] = useState(false)
|
|
54
|
+
const inserted = useRef(false)
|
|
55
|
+
|
|
56
|
+
useEffect(() => {
|
|
57
|
+
if (!insertOnMount || inserted.current) return
|
|
58
|
+
inserted.current = true
|
|
59
|
+
|
|
60
|
+
const held = multiquoteIds()
|
|
61
|
+
if (held.length === 0) return
|
|
62
|
+
|
|
63
|
+
void addQuotes(threadId, held, false, copy).then((message) => {
|
|
64
|
+
if (message !== '') announceMultiquote(message)
|
|
65
|
+
})
|
|
66
|
+
}, [insertOnMount, threadId, copy])
|
|
67
|
+
|
|
68
|
+
async function add(): Promise<void> {
|
|
69
|
+
setAdding(true)
|
|
70
|
+
const message = await addQuotes(threadId, ids, true, copy)
|
|
71
|
+
setAdding(false)
|
|
72
|
+
if (message !== '') announceMultiquote(message)
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
return (
|
|
76
|
+
<>
|
|
77
|
+
<p role="status" className="sr-only">
|
|
78
|
+
{notice}
|
|
79
|
+
</p>
|
|
80
|
+
|
|
81
|
+
{ids.length > 0 && (
|
|
82
|
+
<div className="flex flex-wrap items-center gap-2 rounded-md border border-border bg-muted/40 px-3 py-2 text-sm">
|
|
83
|
+
<span className="font-medium">{selectionLabel(ids.length, copy)}</span>
|
|
84
|
+
<button
|
|
85
|
+
type="button"
|
|
86
|
+
onClick={() => void add()}
|
|
87
|
+
disabled={adding}
|
|
88
|
+
className={cn(buttonVariants({ variant: 'outline', size: 'sm' }), 'ml-auto')}
|
|
89
|
+
>
|
|
90
|
+
{adding
|
|
91
|
+
? fromCopy(copy, 'composer.multiquote.adding')
|
|
92
|
+
: fromCopy(copy, 'composer.multiquote.addToReply')}
|
|
93
|
+
</button>
|
|
94
|
+
<button
|
|
95
|
+
type="button"
|
|
96
|
+
onClick={() => clearMultiquote(copy)}
|
|
97
|
+
className={buttonVariants({ variant: 'ghost', size: 'sm' })}
|
|
98
|
+
>
|
|
99
|
+
{fromCopy(copy, 'composer.multiquote.clear')}
|
|
100
|
+
</button>
|
|
101
|
+
</div>
|
|
102
|
+
)}
|
|
103
|
+
</>
|
|
104
|
+
)
|
|
105
|
+
}
|
|
@@ -0,0 +1,125 @@
|
|
|
1
|
+
'use client'
|
|
2
|
+
|
|
3
|
+
import { useSyncExternalStore } from 'react'
|
|
4
|
+
|
|
5
|
+
import { type Copy, formatFromCopy, fromCopy } from '../shell/copy'
|
|
6
|
+
|
|
7
|
+
const KEY = 'multiquote'
|
|
8
|
+
|
|
9
|
+
export interface MultiQuoteState {
|
|
10
|
+
readonly ids: readonly number[]
|
|
11
|
+
readonly notice: string
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
const EMPTY: MultiQuoteState = { ids: [], notice: '' }
|
|
15
|
+
|
|
16
|
+
let state: MultiQuoteState = EMPTY
|
|
17
|
+
const listeners = new Set<() => void>()
|
|
18
|
+
|
|
19
|
+
function read(): readonly number[] {
|
|
20
|
+
let raw: string | null
|
|
21
|
+
try {
|
|
22
|
+
raw = sessionStorage.getItem(KEY)
|
|
23
|
+
} catch {
|
|
24
|
+
return state.ids
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
try {
|
|
28
|
+
const parsed: unknown = JSON.parse(raw ?? '[]')
|
|
29
|
+
if (!Array.isArray(parsed)) return []
|
|
30
|
+
return [...new Set(parsed.map(Number).filter((id) => Number.isSafeInteger(id) && id > 0))]
|
|
31
|
+
} catch {
|
|
32
|
+
return []
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
function write(ids: readonly number[]): void {
|
|
37
|
+
try {
|
|
38
|
+
if (ids.length === 0) sessionStorage.removeItem(KEY)
|
|
39
|
+
else sessionStorage.setItem(KEY, JSON.stringify(ids))
|
|
40
|
+
} catch {
|
|
41
|
+
return
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
function same(left: readonly number[], right: readonly number[]): boolean {
|
|
46
|
+
return left.length === right.length && left.every((id, index) => id === right[index])
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
function publish(ids: readonly number[], notice: string): void {
|
|
50
|
+
state = { ids, notice }
|
|
51
|
+
for (const listener of listeners) listener()
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
export function selectionLabel(count: number, copy: Copy): string {
|
|
55
|
+
return formatFromCopy(copy, 'composer.multiquote.selectedToQuote', { count })
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
function selectionNotice(count: number, change: 'added' | 'removed', copy: Copy): string {
|
|
59
|
+
return formatFromCopy(
|
|
60
|
+
copy,
|
|
61
|
+
change === 'added' ? 'composer.multiquote.added' : 'composer.multiquote.removed',
|
|
62
|
+
{ count },
|
|
63
|
+
)
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
export function addedNotice(added: number, asked: number, copy: Copy): string {
|
|
67
|
+
if (added === 0) return fromCopy(copy, 'composer.multiquote.noneQuoted')
|
|
68
|
+
if (added === asked) return formatFromCopy(copy, 'composer.multiquote.quotesAdded', { added })
|
|
69
|
+
return formatFromCopy(copy, 'composer.multiquote.quotesPartial', {
|
|
70
|
+
added,
|
|
71
|
+
missed: asked - added,
|
|
72
|
+
})
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
export function multiquoteState(): MultiQuoteState {
|
|
76
|
+
const ids = read()
|
|
77
|
+
if (!same(ids, state.ids)) state = { ids, notice: state.notice }
|
|
78
|
+
return state
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
export function serverMultiquoteState(): MultiQuoteState {
|
|
82
|
+
return EMPTY
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
export function multiquoteIds(): readonly number[] {
|
|
86
|
+
return multiquoteState().ids
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
export function toggleMultiquote(postId: number, copy: Copy): void {
|
|
90
|
+
const { ids } = multiquoteState()
|
|
91
|
+
const held = ids.includes(postId)
|
|
92
|
+
const next = held ? ids.filter((id) => id !== postId) : [...ids, postId]
|
|
93
|
+
|
|
94
|
+
write(next)
|
|
95
|
+
publish(next, selectionNotice(next.length, held ? 'removed' : 'added', copy))
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
export function clearMultiquote(copy: Copy): void {
|
|
99
|
+
write([])
|
|
100
|
+
publish([], fromCopy(copy, 'composer.multiquote.cleared'))
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
export function takeMultiquote(): readonly number[] {
|
|
104
|
+
const { ids } = multiquoteState()
|
|
105
|
+
if (ids.length === 0) return ids
|
|
106
|
+
|
|
107
|
+
write([])
|
|
108
|
+
publish([], '')
|
|
109
|
+
return ids
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
export function announceMultiquote(notice: string): void {
|
|
113
|
+
publish(multiquoteState().ids, notice)
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
export function subscribeMultiquote(listener: () => void): () => void {
|
|
117
|
+
listeners.add(listener)
|
|
118
|
+
return () => {
|
|
119
|
+
listeners.delete(listener)
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
export function useMultiquote(): MultiQuoteState {
|
|
124
|
+
return useSyncExternalStore(subscribeMultiquote, multiquoteState, serverMultiquoteState)
|
|
125
|
+
}
|
|
@@ -0,0 +1,169 @@
|
|
|
1
|
+
'use client'
|
|
2
|
+
|
|
3
|
+
import { useActionState } from 'react'
|
|
4
|
+
|
|
5
|
+
import type { UploadLimits } from '@meith/attachments/limits'
|
|
6
|
+
import type { Draft } from '@meith/drafts'
|
|
7
|
+
import { Disclosure } from '@meith/ui'
|
|
8
|
+
|
|
9
|
+
import { EMPTY_STATE } from '@/server/auth-form-state'
|
|
10
|
+
import { createThreadAction } from '@/server/content-actions'
|
|
11
|
+
|
|
12
|
+
import { Field, FormError, SubmitButton } from '../auth/form-controls'
|
|
13
|
+
import { type Copy, formatFromCopy, fromCopy } from '../shell/copy'
|
|
14
|
+
import { AttachmentField } from './attachment-field'
|
|
15
|
+
import { ComposerIntents } from './composer-intents'
|
|
16
|
+
import { ComposerRecovery } from './composer-recovery'
|
|
17
|
+
import { MarkdownEditor } from './markdown-editor'
|
|
18
|
+
|
|
19
|
+
export interface PrefixOption {
|
|
20
|
+
readonly id: number
|
|
21
|
+
readonly label: string
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
export function NewThreadForm({
|
|
25
|
+
forumId,
|
|
26
|
+
prefixes,
|
|
27
|
+
requiresPrefix,
|
|
28
|
+
canSubscribe,
|
|
29
|
+
canPostPoll,
|
|
30
|
+
attachmentLimits,
|
|
31
|
+
draft,
|
|
32
|
+
toolbar = 'inline',
|
|
33
|
+
copy,
|
|
34
|
+
}: {
|
|
35
|
+
forumId: number
|
|
36
|
+
prefixes: readonly PrefixOption[]
|
|
37
|
+
requiresPrefix: boolean
|
|
38
|
+
canSubscribe: boolean
|
|
39
|
+
canPostPoll: boolean
|
|
40
|
+
attachmentLimits: UploadLimits | null
|
|
41
|
+
draft: Draft | null
|
|
42
|
+
toolbar?: 'inline' | 'external'
|
|
43
|
+
copy: Copy
|
|
44
|
+
}) {
|
|
45
|
+
const [state, action] = useActionState(createThreadAction, EMPTY_STATE)
|
|
46
|
+
|
|
47
|
+
const hasPollDraft =
|
|
48
|
+
(state.values?.pollQuestion ?? '') !== '' || (state.values?.pollOption ?? '') !== ''
|
|
49
|
+
|
|
50
|
+
return (
|
|
51
|
+
<form action={action} className="flex flex-col gap-4" noValidate>
|
|
52
|
+
<FormError message={state.error} />
|
|
53
|
+
{state.notice === 'saved' && <p role="status">{fromCopy(copy, 'composer.draftSaved')}</p>}
|
|
54
|
+
<input type="hidden" name="forumId" value={forumId} />
|
|
55
|
+
|
|
56
|
+
<Field
|
|
57
|
+
label={fromCopy(copy, 'composer.newThread.subject')}
|
|
58
|
+
name="title"
|
|
59
|
+
required
|
|
60
|
+
minLength={3}
|
|
61
|
+
maxLength={120}
|
|
62
|
+
defaultValue={state.values?.title ?? draft?.title}
|
|
63
|
+
/>
|
|
64
|
+
|
|
65
|
+
{prefixes.length > 0 && (
|
|
66
|
+
<label className="flex flex-col gap-1 text-sm">
|
|
67
|
+
<span className="font-medium">
|
|
68
|
+
{requiresPrefix
|
|
69
|
+
? fromCopy(copy, 'composer.newThread.prefix')
|
|
70
|
+
: fromCopy(copy, 'composer.newThread.prefixOptional')}
|
|
71
|
+
</span>
|
|
72
|
+
<select
|
|
73
|
+
name="prefixId"
|
|
74
|
+
defaultValue={state.values?.prefixId ?? draft?.prefixId?.toString() ?? ''}
|
|
75
|
+
className="h-10 rounded-md border border-border bg-background px-3 text-sm focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-ring"
|
|
76
|
+
>
|
|
77
|
+
<option value="">
|
|
78
|
+
{requiresPrefix
|
|
79
|
+
? fromCopy(copy, 'composer.newThread.choosePrefix')
|
|
80
|
+
: fromCopy(copy, 'composer.newThread.noPrefix')}
|
|
81
|
+
</option>
|
|
82
|
+
{prefixes.map((prefix) => (
|
|
83
|
+
<option key={prefix.id} value={prefix.id}>
|
|
84
|
+
{prefix.label}
|
|
85
|
+
</option>
|
|
86
|
+
))}
|
|
87
|
+
</select>
|
|
88
|
+
</label>
|
|
89
|
+
)}
|
|
90
|
+
|
|
91
|
+
<ComposerRecovery
|
|
92
|
+
storageKey={`meith:composer:new-thread:${forumId}`}
|
|
93
|
+
scope={{ forumId }}
|
|
94
|
+
serverUpdatedAt={draft?.updatedAt?.getTime() ?? 0}
|
|
95
|
+
copy={copy}
|
|
96
|
+
/>
|
|
97
|
+
|
|
98
|
+
<MarkdownEditor
|
|
99
|
+
required
|
|
100
|
+
defaultValue={state.values?.message ?? draft?.message}
|
|
101
|
+
preview={state.notice === 'preview' ? (state.preview ?? '') : undefined}
|
|
102
|
+
toolbar={toolbar}
|
|
103
|
+
{...(attachmentLimits !== null ? { attachTo: { kind: 'forum', forumId } } : {})}
|
|
104
|
+
/>
|
|
105
|
+
|
|
106
|
+
{attachmentLimits !== null && <AttachmentField limits={attachmentLimits} />}
|
|
107
|
+
|
|
108
|
+
{canPostPoll && (
|
|
109
|
+
<Disclosure
|
|
110
|
+
summary={fromCopy(copy, 'composer.newThread.addPoll')}
|
|
111
|
+
aside={fromCopy(copy, 'composer.newThread.optional')}
|
|
112
|
+
contentClassName="flex flex-col gap-2"
|
|
113
|
+
{...(hasPollDraft ? { open: true } : {})}
|
|
114
|
+
>
|
|
115
|
+
<Field
|
|
116
|
+
label={fromCopy(copy, 'composer.newThread.question')}
|
|
117
|
+
name="pollQuestion"
|
|
118
|
+
maxLength={250}
|
|
119
|
+
/>
|
|
120
|
+
{[1, 2, 3, 4].map((number) => (
|
|
121
|
+
<Field
|
|
122
|
+
key={number}
|
|
123
|
+
id={`field-pollOption-${number}`}
|
|
124
|
+
label={formatFromCopy(copy, 'composer.newThread.option', { number })}
|
|
125
|
+
name="pollOption"
|
|
126
|
+
maxLength={200}
|
|
127
|
+
/>
|
|
128
|
+
))}
|
|
129
|
+
<label className="flex flex-col gap-1 text-sm">
|
|
130
|
+
<span className="font-medium">{fromCopy(copy, 'composer.newThread.pollChoices')}</span>
|
|
131
|
+
<input
|
|
132
|
+
type="number"
|
|
133
|
+
name="pollMaxOptions"
|
|
134
|
+
min={0}
|
|
135
|
+
step={1}
|
|
136
|
+
defaultValue="1"
|
|
137
|
+
className="h-10 rounded-md border border-border bg-background px-3 text-sm focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-ring"
|
|
138
|
+
/>
|
|
139
|
+
<span className="text-xs text-muted-foreground">
|
|
140
|
+
{fromCopy(copy, 'composer.newThread.pollChoicesHint')}
|
|
141
|
+
</span>
|
|
142
|
+
</label>
|
|
143
|
+
<label className="flex items-center gap-2 text-sm">
|
|
144
|
+
<input type="checkbox" name="pollAllowRevote" value="1" className="size-4" />
|
|
145
|
+
<span>{fromCopy(copy, 'composer.newThread.pollRevote')}</span>
|
|
146
|
+
</label>
|
|
147
|
+
<label className="flex items-center gap-2 text-sm">
|
|
148
|
+
<input type="checkbox" name="pollPublicVotes" value="1" className="size-4" />
|
|
149
|
+
<span>{fromCopy(copy, 'composer.newThread.pollPublic')}</span>
|
|
150
|
+
</label>
|
|
151
|
+
</Disclosure>
|
|
152
|
+
)}
|
|
153
|
+
|
|
154
|
+
{canSubscribe && (
|
|
155
|
+
<label className="flex items-center gap-2 text-sm">
|
|
156
|
+
<input type="checkbox" name="subscribe" value="1" className="size-4" />
|
|
157
|
+
<span>{fromCopy(copy, 'composer.notifyReplies')}</span>
|
|
158
|
+
</label>
|
|
159
|
+
)}
|
|
160
|
+
|
|
161
|
+
<div className="flex flex-wrap items-center gap-2">
|
|
162
|
+
<SubmitButton className="w-auto">
|
|
163
|
+
{fromCopy(copy, 'composer.newThread.submit')}
|
|
164
|
+
</SubmitButton>
|
|
165
|
+
<ComposerIntents />
|
|
166
|
+
</div>
|
|
167
|
+
</form>
|
|
168
|
+
)
|
|
169
|
+
}
|
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
import { POLL_OPTION_LENGTH_MAX, POLL_QUESTION_MAX, type Poll } from '@meith/polls'
|
|
2
|
+
|
|
3
|
+
import { getTranslator } from '@/server/i18n'
|
|
4
|
+
import { editPollAction } from '@/server/poll-actions'
|
|
5
|
+
|
|
6
|
+
const NEW_OPTION_SLOTS = ['first', 'second', 'third'] as const
|
|
7
|
+
|
|
8
|
+
function inputValue(at: Date | null): string {
|
|
9
|
+
return at === null ? '' : at.toISOString().slice(0, 16)
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
export async function PollEditForm({ poll, threadId }: { poll: Poll; threadId: number }) {
|
|
13
|
+
const t = await getTranslator()
|
|
14
|
+
const voted = poll.options.some((option) => option.votes > 0)
|
|
15
|
+
|
|
16
|
+
return (
|
|
17
|
+
<form action={editPollAction} className="flex flex-col gap-4">
|
|
18
|
+
<input type="hidden" name="threadId" value={threadId} />
|
|
19
|
+
<input type="hidden" name="pollId" value={poll.id} />
|
|
20
|
+
|
|
21
|
+
<label className="flex flex-col gap-1 text-sm">
|
|
22
|
+
<span className="font-medium">{t.t('pollEdit.question')}</span>
|
|
23
|
+
<input
|
|
24
|
+
type="text"
|
|
25
|
+
name="question"
|
|
26
|
+
required
|
|
27
|
+
maxLength={POLL_QUESTION_MAX}
|
|
28
|
+
defaultValue={poll.question}
|
|
29
|
+
/>
|
|
30
|
+
</label>
|
|
31
|
+
|
|
32
|
+
{poll.options.map((option, index) => (
|
|
33
|
+
<label key={option.id} className="flex flex-col gap-1 text-sm">
|
|
34
|
+
<span className="font-medium">{t.t('pollEdit.option', { number: index + 1 })}</span>
|
|
35
|
+
<input type="hidden" name="optionRef" value={option.id} />
|
|
36
|
+
<input
|
|
37
|
+
type="text"
|
|
38
|
+
name="optionLabel"
|
|
39
|
+
maxLength={POLL_OPTION_LENGTH_MAX}
|
|
40
|
+
defaultValue={option.label}
|
|
41
|
+
/>
|
|
42
|
+
<span className="text-xs text-muted-foreground">
|
|
43
|
+
{option.votes > 0
|
|
44
|
+
? t.t('pollEdit.optionVoted', { count: option.votes })
|
|
45
|
+
: t.t('pollEdit.optionEmpty')}
|
|
46
|
+
</span>
|
|
47
|
+
</label>
|
|
48
|
+
))}
|
|
49
|
+
|
|
50
|
+
{NEW_OPTION_SLOTS.map((slot, index) => (
|
|
51
|
+
<label key={slot} className="flex flex-col gap-1 text-sm">
|
|
52
|
+
<span className="font-medium">
|
|
53
|
+
{t.t('pollEdit.option', { number: poll.options.length + index + 1 })}
|
|
54
|
+
</span>
|
|
55
|
+
<input type="hidden" name="optionRef" value="" />
|
|
56
|
+
<input type="text" name="optionLabel" maxLength={POLL_OPTION_LENGTH_MAX} />
|
|
57
|
+
</label>
|
|
58
|
+
))}
|
|
59
|
+
|
|
60
|
+
<label className="flex flex-col gap-1 text-sm">
|
|
61
|
+
<span className="font-medium">{t.t('pollEdit.maxOptions')}</span>
|
|
62
|
+
<input type="number" name="maxOptions" min={0} step={1} defaultValue={poll.maxOptions} />
|
|
63
|
+
<span className="text-xs text-muted-foreground">{t.t('pollEdit.maxOptionsHint')}</span>
|
|
64
|
+
</label>
|
|
65
|
+
|
|
66
|
+
<label className="flex flex-col gap-1 text-sm">
|
|
67
|
+
<span className="font-medium">{t.t('pollEdit.closesAt')}</span>
|
|
68
|
+
<input type="datetime-local" name="closesAt" defaultValue={inputValue(poll.closesAt)} />
|
|
69
|
+
<span className="text-xs text-muted-foreground">{t.t('pollEdit.closesAtHint')}</span>
|
|
70
|
+
</label>
|
|
71
|
+
|
|
72
|
+
<label className="flex items-center gap-2 text-sm">
|
|
73
|
+
<input type="checkbox" name="allowRevote" value="1" defaultChecked={poll.allowRevote} />
|
|
74
|
+
<span>{t.t('pollEdit.allowRevote')}</span>
|
|
75
|
+
</label>
|
|
76
|
+
|
|
77
|
+
<label className="flex flex-col gap-1 text-sm">
|
|
78
|
+
<span className="flex items-center gap-2">
|
|
79
|
+
<input
|
|
80
|
+
type="checkbox"
|
|
81
|
+
name="publicVotes"
|
|
82
|
+
value="1"
|
|
83
|
+
defaultChecked={poll.publicVotes}
|
|
84
|
+
disabled={voted && !poll.publicVotes}
|
|
85
|
+
/>
|
|
86
|
+
<span>{t.t('pollEdit.publicVotes')}</span>
|
|
87
|
+
</span>
|
|
88
|
+
<span className="text-xs text-muted-foreground">{t.t('pollEdit.publicVotesHint')}</span>
|
|
89
|
+
</label>
|
|
90
|
+
|
|
91
|
+
<div>
|
|
92
|
+
<button type="submit">{t.t('pollEdit.save')}</button>
|
|
93
|
+
</div>
|
|
94
|
+
</form>
|
|
95
|
+
)
|
|
96
|
+
}
|
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
import { POLL_CHOICES_UNLIMITED, type Poll } from '@meith/polls'
|
|
2
|
+
|
|
3
|
+
import { getTranslator } from '@/server/i18n'
|
|
4
|
+
import { votePollAction } from '@/server/poll-actions'
|
|
5
|
+
|
|
6
|
+
export async function PollForm({
|
|
7
|
+
poll,
|
|
8
|
+
threadId,
|
|
9
|
+
canVote,
|
|
10
|
+
editHref,
|
|
11
|
+
}: {
|
|
12
|
+
poll: Poll
|
|
13
|
+
threadId: number
|
|
14
|
+
canVote: boolean
|
|
15
|
+
editHref?: string | null
|
|
16
|
+
}) {
|
|
17
|
+
const total = poll.options.reduce((sum, option) => sum + option.votes, 0)
|
|
18
|
+
const t = await getTranslator()
|
|
19
|
+
|
|
20
|
+
const closed = poll.closesAt !== null && poll.closesAt <= new Date()
|
|
21
|
+
const hasVoted = poll.votedOptionIds.length > 0
|
|
22
|
+
const mayCast = canVote && !closed && (!hasVoted || poll.allowRevote)
|
|
23
|
+
const multiple = poll.maxOptions !== 1
|
|
24
|
+
|
|
25
|
+
return (
|
|
26
|
+
<section
|
|
27
|
+
aria-label={t.t('pollForm.label')}
|
|
28
|
+
className="mt-4 rounded-md border border-border p-4"
|
|
29
|
+
>
|
|
30
|
+
<h2 className="font-medium">{poll.question}</h2>
|
|
31
|
+
|
|
32
|
+
{multiple && (
|
|
33
|
+
<p className="mt-1 text-sm text-muted-foreground">
|
|
34
|
+
{poll.maxOptions === POLL_CHOICES_UNLIMITED
|
|
35
|
+
? t.t('pollForm.chooseAny')
|
|
36
|
+
: t.t('pollForm.chooseUpTo', { max: poll.maxOptions })}
|
|
37
|
+
</p>
|
|
38
|
+
)}
|
|
39
|
+
{poll.publicVotes && (
|
|
40
|
+
<p className="mt-1 text-sm text-muted-foreground">{t.t('pollForm.publicNotice')}</p>
|
|
41
|
+
)}
|
|
42
|
+
|
|
43
|
+
<form action={votePollAction} className="mt-3 flex flex-col gap-2">
|
|
44
|
+
<input type="hidden" name="threadId" value={threadId} />
|
|
45
|
+
<input type="hidden" name="pollId" value={poll.id} />
|
|
46
|
+
{poll.options.map((option) => (
|
|
47
|
+
<div key={option.id} className="flex flex-col gap-1">
|
|
48
|
+
<label className="flex items-center gap-2 text-sm">
|
|
49
|
+
<input
|
|
50
|
+
type={multiple ? 'checkbox' : 'radio'}
|
|
51
|
+
name="optionId"
|
|
52
|
+
value={option.id}
|
|
53
|
+
defaultChecked={poll.votedOptionIds.includes(option.id)}
|
|
54
|
+
disabled={!mayCast}
|
|
55
|
+
/>
|
|
56
|
+
<span>
|
|
57
|
+
{option.label} ({option.votes})
|
|
58
|
+
</span>
|
|
59
|
+
</label>
|
|
60
|
+
{poll.publicVotes && option.voters.length > 0 && (
|
|
61
|
+
<p className="pl-6 text-sm text-muted-foreground">
|
|
62
|
+
{t.t('pollForm.votedBy', {
|
|
63
|
+
names: option.voters.map((voter) => voter.username).join(', '),
|
|
64
|
+
})}
|
|
65
|
+
{option.votes > option.voters.length &&
|
|
66
|
+
` ${t.t('pollForm.moreVoters', { count: option.votes - option.voters.length })}`}
|
|
67
|
+
</p>
|
|
68
|
+
)}
|
|
69
|
+
</div>
|
|
70
|
+
))}
|
|
71
|
+
{mayCast ? (
|
|
72
|
+
<button type="submit">
|
|
73
|
+
{hasVoted ? t.t('pollForm.changeVote') : t.t('pollForm.vote')}
|
|
74
|
+
</button>
|
|
75
|
+
) : (
|
|
76
|
+
<p className="text-sm text-muted-foreground">
|
|
77
|
+
{closed ? t.t('pollForm.closed') : t.t('pollForm.votes', { count: total })}
|
|
78
|
+
</p>
|
|
79
|
+
)}
|
|
80
|
+
</form>
|
|
81
|
+
|
|
82
|
+
{typeof editHref === 'string' && (
|
|
83
|
+
<p className="mt-3 text-sm">
|
|
84
|
+
<a href={editHref}>{t.t('pollForm.edit')}</a>
|
|
85
|
+
</p>
|
|
86
|
+
)}
|
|
87
|
+
</section>
|
|
88
|
+
)
|
|
89
|
+
}
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
'use client'
|
|
2
|
+
|
|
3
|
+
import { useEffect } from 'react'
|
|
4
|
+
|
|
5
|
+
import { quotePostAction } from '@/server/content-actions'
|
|
6
|
+
|
|
7
|
+
import { composerField, insertQuotes } from './composer-field'
|
|
8
|
+
|
|
9
|
+
function quotedPostId(href: string): number | null {
|
|
10
|
+
const match = /[?&]quote=(\d+)(?:&|$)/.exec(href)
|
|
11
|
+
if (match === null) return null
|
|
12
|
+
const id = Number(match[1])
|
|
13
|
+
return Number.isSafeInteger(id) && id > 0 ? id : null
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
export function QuoteInPlace({ threadId }: { threadId: number }) {
|
|
17
|
+
useEffect(() => {
|
|
18
|
+
async function onClick(event: MouseEvent): Promise<void> {
|
|
19
|
+
if (event.defaultPrevented || event.button !== 0) return
|
|
20
|
+
if (event.metaKey || event.ctrlKey || event.shiftKey || event.altKey) return
|
|
21
|
+
|
|
22
|
+
const link = (event.target as Element | null)?.closest?.('a[href]')
|
|
23
|
+
if (!(link instanceof HTMLAnchorElement)) return
|
|
24
|
+
|
|
25
|
+
const postId = quotedPostId(link.getAttribute('href') ?? '')
|
|
26
|
+
if (postId === null) return
|
|
27
|
+
|
|
28
|
+
const field = composerField()
|
|
29
|
+
if (field === null) return
|
|
30
|
+
|
|
31
|
+
event.preventDefault()
|
|
32
|
+
|
|
33
|
+
try {
|
|
34
|
+
const quote = await quotePostAction(threadId, postId)
|
|
35
|
+
if (quote === null) {
|
|
36
|
+
window.location.assign(link.href)
|
|
37
|
+
return
|
|
38
|
+
}
|
|
39
|
+
insertQuotes(field, [quote], { reveal: true })
|
|
40
|
+
} catch {
|
|
41
|
+
window.location.assign(link.href)
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
const handler = (event: MouseEvent): void => void onClick(event)
|
|
46
|
+
document.addEventListener('click', handler)
|
|
47
|
+
return () => document.removeEventListener('click', handler)
|
|
48
|
+
}, [threadId])
|
|
49
|
+
|
|
50
|
+
return null
|
|
51
|
+
}
|