@commonpub/layer 0.1.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 +661 -0
- package/app.vue +7 -0
- package/components/AnnouncementBand.vue +117 -0
- package/components/AppToast.vue +108 -0
- package/components/AuthorCard.vue +119 -0
- package/components/AuthorRow.vue +81 -0
- package/components/CommentSection.vue +330 -0
- package/components/ContentCard.vue +340 -0
- package/components/ContentPicker.vue +240 -0
- package/components/ContentStarterForm.vue +214 -0
- package/components/ContentTypeBadge.vue +46 -0
- package/components/CountdownTimer.vue +68 -0
- package/components/CpubEditor.vue +87 -0
- package/components/DiscussionItem.vue +191 -0
- package/components/EditorPropertiesPanel.vue +393 -0
- package/components/EngagementBar.vue +131 -0
- package/components/FederatedContentCard.vue +291 -0
- package/components/FeedItem.vue +283 -0
- package/components/FilterChip.vue +21 -0
- package/components/HeatmapGrid.vue +92 -0
- package/components/ImageUpload.vue +219 -0
- package/components/MemberCard.vue +163 -0
- package/components/MessageThread.vue +120 -0
- package/components/NotificationItem.vue +103 -0
- package/components/ProgressTracker.vue +41 -0
- package/components/PublishErrorsModal.vue +116 -0
- package/components/RemoteActorCard.vue +206 -0
- package/components/RemoteUserSearch.vue +117 -0
- package/components/SearchFilters.vue +188 -0
- package/components/SearchSidebar.vue +181 -0
- package/components/SectionHeader.vue +17 -0
- package/components/ShareToHubModal.vue +189 -0
- package/components/SiteLogo.vue +21 -0
- package/components/SkillBar.vue +57 -0
- package/components/SortSelect.vue +30 -0
- package/components/StatBar.vue +14 -0
- package/components/TOCNav.vue +69 -0
- package/components/TimelineItem.vue +82 -0
- package/components/VideoCard.vue +106 -0
- package/components/blocks/BlockBuildStepView.vue +92 -0
- package/components/blocks/BlockCalloutView.vue +82 -0
- package/components/blocks/BlockCheckpointView.vue +50 -0
- package/components/blocks/BlockCodeView.vue +212 -0
- package/components/blocks/BlockContentRenderer.vue +143 -0
- package/components/blocks/BlockDividerView.vue +11 -0
- package/components/blocks/BlockDownloadsView.vue +126 -0
- package/components/blocks/BlockEmbedView.vue +61 -0
- package/components/blocks/BlockGalleryView.vue +57 -0
- package/components/blocks/BlockHeadingView.vue +29 -0
- package/components/blocks/BlockImageView.vue +34 -0
- package/components/blocks/BlockMarkdownView.vue +118 -0
- package/components/blocks/BlockMathView.vue +45 -0
- package/components/blocks/BlockPartsListView.vue +104 -0
- package/components/blocks/BlockQuizView.vue +239 -0
- package/components/blocks/BlockQuoteView.vue +41 -0
- package/components/blocks/BlockSectionHeaderView.vue +58 -0
- package/components/blocks/BlockSliderView.vue +236 -0
- package/components/blocks/BlockTextView.vue +41 -0
- package/components/blocks/BlockToolListView.vue +87 -0
- package/components/blocks/BlockVideoView.vue +89 -0
- package/components/editors/ArticleEditor.vue +545 -0
- package/components/editors/BlockCanvas.vue +487 -0
- package/components/editors/BlockInsertZone.vue +84 -0
- package/components/editors/BlockPicker.vue +285 -0
- package/components/editors/BlockWrapper.vue +192 -0
- package/components/editors/BlogEditor.vue +567 -0
- package/components/editors/EditorBlocks.vue +248 -0
- package/components/editors/EditorSection.vue +81 -0
- package/components/editors/EditorShell.vue +168 -0
- package/components/editors/EditorTagInput.vue +114 -0
- package/components/editors/EditorVisibility.vue +110 -0
- package/components/editors/ExplainerEditor.vue +503 -0
- package/components/editors/MarkdownImportDialog.vue +249 -0
- package/components/editors/ProjectEditor.vue +446 -0
- package/components/editors/blocks/BuildStepBlock.vue +102 -0
- package/components/editors/blocks/CalloutBlock.vue +122 -0
- package/components/editors/blocks/CheckpointBlock.vue +27 -0
- package/components/editors/blocks/CodeBlock.vue +177 -0
- package/components/editors/blocks/DividerBlock.vue +22 -0
- package/components/editors/blocks/DownloadsBlock.vue +41 -0
- package/components/editors/blocks/EmbedBlock.vue +20 -0
- package/components/editors/blocks/GalleryBlock.vue +236 -0
- package/components/editors/blocks/HeadingBlock.vue +96 -0
- package/components/editors/blocks/ImageBlock.vue +271 -0
- package/components/editors/blocks/MarkdownBlock.vue +258 -0
- package/components/editors/blocks/MathBlock.vue +37 -0
- package/components/editors/blocks/PartsListBlock.vue +358 -0
- package/components/editors/blocks/QuizBlock.vue +47 -0
- package/components/editors/blocks/QuoteBlock.vue +101 -0
- package/components/editors/blocks/SectionHeaderBlock.vue +130 -0
- package/components/editors/blocks/SliderBlock.vue +318 -0
- package/components/editors/blocks/TextBlock.vue +201 -0
- package/components/editors/blocks/ToolListBlock.vue +70 -0
- package/components/editors/blocks/VideoBlock.vue +22 -0
- package/components/hub/HubDiscussions.vue +47 -0
- package/components/hub/HubFeed.vue +199 -0
- package/components/hub/HubHero.vue +185 -0
- package/components/hub/HubLayout.vue +103 -0
- package/components/hub/HubMembers.vue +40 -0
- package/components/hub/HubProducts.vue +93 -0
- package/components/hub/HubProjects.vue +207 -0
- package/components/hub/HubSidebar.vue +12 -0
- package/components/hub/HubSidebarCard.vue +35 -0
- package/components/views/ArticleView.vue +771 -0
- package/components/views/BlogView.vue +667 -0
- package/components/views/ExplainerView.vue +688 -0
- package/components/views/ProjectView.vue +1500 -0
- package/composables/useApiError.ts +39 -0
- package/composables/useAuth.ts +87 -0
- package/composables/useBlockEditor.ts +187 -0
- package/composables/useContentSave.ts +253 -0
- package/composables/useContentTypes.ts +37 -0
- package/composables/useEngagement.ts +196 -0
- package/composables/useFeatures.ts +33 -0
- package/composables/useFederation.ts +72 -0
- package/composables/useJsonLd.ts +183 -0
- package/composables/useMarkdownImport.ts +77 -0
- package/composables/useMirrorContent.ts +105 -0
- package/composables/useNotifications.ts +73 -0
- package/composables/usePublishValidation.ts +65 -0
- package/composables/useSanitize.ts +34 -0
- package/composables/useSiteName.ts +4 -0
- package/composables/useTheme.ts +34 -0
- package/composables/useToast.ts +35 -0
- package/error.vue +129 -0
- package/layouts/admin.vue +213 -0
- package/layouts/auth.vue +63 -0
- package/layouts/default.vue +269 -0
- package/layouts/editor.vue +129 -0
- package/middleware/auth.ts +6 -0
- package/nuxt.config.ts +83 -0
- package/package.json +59 -0
- package/pages/[type]/[slug]/edit.vue +676 -0
- package/pages/[type]/[slug]/index.vue +313 -0
- package/pages/[type]/index.vue +118 -0
- package/pages/about.vue +100 -0
- package/pages/admin/audit.vue +66 -0
- package/pages/admin/content.vue +116 -0
- package/pages/admin/federation.vue +446 -0
- package/pages/admin/index.vue +62 -0
- package/pages/admin/reports.vue +88 -0
- package/pages/admin/settings.vue +167 -0
- package/pages/admin/users.vue +145 -0
- package/pages/auth/forgot-password.vue +103 -0
- package/pages/auth/login.vue +216 -0
- package/pages/auth/oauth/authorize.vue +178 -0
- package/pages/auth/register.vue +246 -0
- package/pages/auth/reset-password.vue +124 -0
- package/pages/auth/verify-email.vue +80 -0
- package/pages/cert/[code].vue +154 -0
- package/pages/contests/[slug]/edit.vue +153 -0
- package/pages/contests/[slug]/index.vue +556 -0
- package/pages/contests/[slug]/judge.vue +160 -0
- package/pages/contests/create.vue +192 -0
- package/pages/contests/index.vue +69 -0
- package/pages/create.vue +219 -0
- package/pages/dashboard.vue +521 -0
- package/pages/docs/[siteSlug]/[...pagePath].vue +704 -0
- package/pages/docs/[siteSlug]/edit.vue +480 -0
- package/pages/docs/[siteSlug]/index.vue +380 -0
- package/pages/docs/create.vue +60 -0
- package/pages/docs/index.vue +181 -0
- package/pages/explore.vue +422 -0
- package/pages/federated-hubs/[id]/index.vue +385 -0
- package/pages/federated-hubs/[id]/posts/[postId].vue +309 -0
- package/pages/federation/index.vue +157 -0
- package/pages/federation/search.vue +43 -0
- package/pages/federation/users/[handle].vue +221 -0
- package/pages/feed.vue +135 -0
- package/pages/hubs/[slug]/index.vue +513 -0
- package/pages/hubs/[slug]/members.vue +134 -0
- package/pages/hubs/[slug]/posts/[postId].vue +352 -0
- package/pages/hubs/[slug]/settings.vue +254 -0
- package/pages/hubs/create.vue +201 -0
- package/pages/hubs/index.vue +207 -0
- package/pages/index.vue +1005 -0
- package/pages/learn/[slug]/[lessonSlug]/edit.vue +413 -0
- package/pages/learn/[slug]/[lessonSlug]/index.vue +438 -0
- package/pages/learn/[slug]/edit.vue +414 -0
- package/pages/learn/[slug]/index.vue +341 -0
- package/pages/learn/create.vue +71 -0
- package/pages/learn/index.vue +360 -0
- package/pages/messages/[conversationId].vue +113 -0
- package/pages/messages/index.vue +303 -0
- package/pages/mirror/[id].vue +115 -0
- package/pages/notifications.vue +91 -0
- package/pages/products/[slug].vue +128 -0
- package/pages/products/index.vue +122 -0
- package/pages/search.vue +692 -0
- package/pages/settings/account.vue +170 -0
- package/pages/settings/appearance.vue +80 -0
- package/pages/settings/index.vue +81 -0
- package/pages/settings/notifications.vue +68 -0
- package/pages/settings/profile.vue +838 -0
- package/pages/tags/[slug].vue +111 -0
- package/pages/tags/index.vue +73 -0
- package/pages/u/[username]/followers.vue +86 -0
- package/pages/u/[username]/following.vue +94 -0
- package/pages/u/[username]/index.vue +837 -0
- package/pages/videos/[id].vue +212 -0
- package/pages/videos/index.vue +327 -0
- package/pages/videos/submit.vue +112 -0
- package/plugins/auth.ts +23 -0
- package/server/api/admin/audit.get.ts +17 -0
- package/server/api/admin/content/[id].delete.ts +15 -0
- package/server/api/admin/content/[id].patch.ts +37 -0
- package/server/api/admin/federation/activity.get.ts +31 -0
- package/server/api/admin/federation/clients.get.ts +9 -0
- package/server/api/admin/federation/clients.post.ts +16 -0
- package/server/api/admin/federation/hub-mirrors/index.get.ts +10 -0
- package/server/api/admin/federation/hub-mirrors/index.post.ts +42 -0
- package/server/api/admin/federation/mirrors/[id]/backfill.post.ts +39 -0
- package/server/api/admin/federation/mirrors/[id].delete.ts +11 -0
- package/server/api/admin/federation/mirrors/[id].get.ts +15 -0
- package/server/api/admin/federation/mirrors/[id].put.ts +22 -0
- package/server/api/admin/federation/mirrors/index.get.ts +9 -0
- package/server/api/admin/federation/mirrors/index.post.ts +30 -0
- package/server/api/admin/federation/pending.get.ts +22 -0
- package/server/api/admin/federation/refederate.post.ts +92 -0
- package/server/api/admin/federation/repair-types.post.ts +57 -0
- package/server/api/admin/federation/retry.post.ts +41 -0
- package/server/api/admin/federation/stats.get.ts +26 -0
- package/server/api/admin/reports/[id]/resolve.post.ts +12 -0
- package/server/api/admin/reports.get.ts +17 -0
- package/server/api/admin/settings.get.ts +22 -0
- package/server/api/admin/settings.put.ts +11 -0
- package/server/api/admin/stats.get.ts +9 -0
- package/server/api/admin/users/[id]/role.put.ts +12 -0
- package/server/api/admin/users/[id]/status.put.ts +12 -0
- package/server/api/admin/users/[id].delete.ts +10 -0
- package/server/api/admin/users.get.ts +18 -0
- package/server/api/auth/federated/callback.get.ts +67 -0
- package/server/api/auth/federated/login.post.ts +60 -0
- package/server/api/auth/oauth2/authorize.get.ts +30 -0
- package/server/api/auth/oauth2/authorize.post.ts +51 -0
- package/server/api/auth/oauth2/register.post.ts +41 -0
- package/server/api/auth/oauth2/token.post.ts +48 -0
- package/server/api/cert/[code].get.ts +13 -0
- package/server/api/content/[id]/build.post.ts +9 -0
- package/server/api/content/[id]/fork.post.ts +10 -0
- package/server/api/content/[id]/index.delete.ts +18 -0
- package/server/api/content/[id]/index.get.ts +15 -0
- package/server/api/content/[id]/index.put.ts +23 -0
- package/server/api/content/[id]/products/[productId].delete.ts +28 -0
- package/server/api/content/[id]/products-sync.post.ts +29 -0
- package/server/api/content/[id]/products.get.ts +9 -0
- package/server/api/content/[id]/products.post.ts +31 -0
- package/server/api/content/[id]/publish.post.ts +17 -0
- package/server/api/content/[id]/report.post.ts +17 -0
- package/server/api/content/[id]/versions.get.ts +9 -0
- package/server/api/content/[id]/view.post.ts +34 -0
- package/server/api/content/index.get.ts +23 -0
- package/server/api/content/index.post.ts +11 -0
- package/server/api/contests/[slug]/entries.get.ts +18 -0
- package/server/api/contests/[slug]/entries.post.ts +23 -0
- package/server/api/contests/[slug]/index.delete.ts +21 -0
- package/server/api/contests/[slug]/index.get.ts +11 -0
- package/server/api/contests/[slug]/index.put.ts +15 -0
- package/server/api/contests/[slug]/judge.post.ts +12 -0
- package/server/api/contests/[slug]/transition.post.ts +24 -0
- package/server/api/contests/index.get.ts +10 -0
- package/server/api/contests/index.post.ts +28 -0
- package/server/api/docs/[siteSlug]/index.delete.ts +14 -0
- package/server/api/docs/[siteSlug]/index.get.ts +17 -0
- package/server/api/docs/[siteSlug]/index.put.ts +20 -0
- package/server/api/docs/[siteSlug]/nav.get.ts +26 -0
- package/server/api/docs/[siteSlug]/pages/[pageId].delete.ts +14 -0
- package/server/api/docs/[siteSlug]/pages/[pageId].get.ts +31 -0
- package/server/api/docs/[siteSlug]/pages/[pageId].put.ts +15 -0
- package/server/api/docs/[siteSlug]/pages/index.get.ts +34 -0
- package/server/api/docs/[siteSlug]/pages/index.post.ts +28 -0
- package/server/api/docs/[siteSlug]/pages/reorder.post.ts +26 -0
- package/server/api/docs/[siteSlug]/search.get.ts +20 -0
- package/server/api/docs/[siteSlug]/versions.post.ts +11 -0
- package/server/api/docs/index.get.ts +6 -0
- package/server/api/docs/index.post.ts +10 -0
- package/server/api/federated-hubs/[id]/posts/[postId].get.ts +16 -0
- package/server/api/federated-hubs/[id]/posts.get.ts +15 -0
- package/server/api/federated-hubs/[id].get.ts +16 -0
- package/server/api/federation/boost.post.ts +21 -0
- package/server/api/federation/content/[id].get.ts +15 -0
- package/server/api/federation/follow.post.ts +16 -0
- package/server/api/federation/health.get.ts +56 -0
- package/server/api/federation/hub-follow.post.ts +27 -0
- package/server/api/federation/hub-post-like.post.ts +115 -0
- package/server/api/federation/hub-post-likes.get.ts +24 -0
- package/server/api/federation/hub-post-reply.post.ts +42 -0
- package/server/api/federation/hub-post.post.ts +33 -0
- package/server/api/federation/like.post.ts +21 -0
- package/server/api/federation/remote-actor.get.ts +22 -0
- package/server/api/federation/reply.post.ts +22 -0
- package/server/api/federation/search.post.ts +17 -0
- package/server/api/federation/timeline.get.ts +22 -0
- package/server/api/federation/unfollow.post.ts +17 -0
- package/server/api/files/[id].delete.ts +35 -0
- package/server/api/files/mine.get.ts +31 -0
- package/server/api/files/upload-from-url.post.ts +68 -0
- package/server/api/files/upload.post.ts +105 -0
- package/server/api/health.get.ts +4 -0
- package/server/api/hubs/[slug]/bans/[userId].delete.ts +13 -0
- package/server/api/hubs/[slug]/bans.get.ts +20 -0
- package/server/api/hubs/[slug]/bans.post.ts +23 -0
- package/server/api/hubs/[slug]/feed.xml.get.ts +60 -0
- package/server/api/hubs/[slug]/gallery.get.ts +21 -0
- package/server/api/hubs/[slug]/index.delete.ts +18 -0
- package/server/api/hubs/[slug]/index.get.ts +14 -0
- package/server/api/hubs/[slug]/index.put.ts +22 -0
- package/server/api/hubs/[slug]/invites.get.ts +20 -0
- package/server/api/hubs/[slug]/invites.post.ts +27 -0
- package/server/api/hubs/[slug]/join.post.ts +17 -0
- package/server/api/hubs/[slug]/leave.post.ts +13 -0
- package/server/api/hubs/[slug]/members/[userId].delete.ts +13 -0
- package/server/api/hubs/[slug]/members/[userId].put.ts +16 -0
- package/server/api/hubs/[slug]/members.get.ts +20 -0
- package/server/api/hubs/[slug]/posts/[postId]/like.post.ts +21 -0
- package/server/api/hubs/[slug]/posts/[postId]/lock.post.ts +17 -0
- package/server/api/hubs/[slug]/posts/[postId]/pin.post.ts +17 -0
- package/server/api/hubs/[slug]/posts/[postId]/replies.get.ts +16 -0
- package/server/api/hubs/[slug]/posts/[postId]/replies.post.ts +21 -0
- package/server/api/hubs/[slug]/posts/[postId].delete.ts +23 -0
- package/server/api/hubs/[slug]/posts/[postId].get.ts +16 -0
- package/server/api/hubs/[slug]/posts/index.get.ts +16 -0
- package/server/api/hubs/[slug]/posts/index.post.ts +36 -0
- package/server/api/hubs/[slug]/products.get.ts +26 -0
- package/server/api/hubs/[slug]/products.post.ts +18 -0
- package/server/api/hubs/[slug]/share.post.ts +39 -0
- package/server/api/hubs/index.get.ts +15 -0
- package/server/api/hubs/index.post.ts +11 -0
- package/server/api/image-proxy.get.ts +91 -0
- package/server/api/learn/[slug]/[lessonSlug]/complete.post.ts +13 -0
- package/server/api/learn/[slug]/[lessonSlug]/index.get.ts +68 -0
- package/server/api/learn/[slug]/enroll.post.ts +12 -0
- package/server/api/learn/[slug]/index.delete.ts +12 -0
- package/server/api/learn/[slug]/index.get.ts +14 -0
- package/server/api/learn/[slug]/index.put.ts +19 -0
- package/server/api/learn/[slug]/lessons/[lessonId].delete.ts +14 -0
- package/server/api/learn/[slug]/lessons/[lessonId].put.ts +24 -0
- package/server/api/learn/[slug]/lessons.post.ts +10 -0
- package/server/api/learn/[slug]/modules/[moduleId].delete.ts +14 -0
- package/server/api/learn/[slug]/modules/[moduleId].put.ts +15 -0
- package/server/api/learn/[slug]/modules.post.ts +14 -0
- package/server/api/learn/[slug]/publish.post.ts +13 -0
- package/server/api/learn/[slug]/unenroll.post.ts +12 -0
- package/server/api/learn/certificates.get.ts +9 -0
- package/server/api/learn/enrollments.get.ts +9 -0
- package/server/api/learn/index.get.ts +17 -0
- package/server/api/learn/index.post.ts +11 -0
- package/server/api/me.get.ts +13 -0
- package/server/api/messages/[conversationId]/info.get.ts +43 -0
- package/server/api/messages/[conversationId]/stream.get.ts +73 -0
- package/server/api/messages/[conversationId].get.ts +13 -0
- package/server/api/messages/[conversationId].post.ts +12 -0
- package/server/api/messages/index.get.ts +39 -0
- package/server/api/messages/index.post.ts +58 -0
- package/server/api/notifications/[id].delete.ts +11 -0
- package/server/api/notifications/count.get.ts +10 -0
- package/server/api/notifications/index.get.ts +24 -0
- package/server/api/notifications/read.post.ts +15 -0
- package/server/api/notifications/stream.get.ts +59 -0
- package/server/api/openapi.get.ts +5 -0
- package/server/api/products/[id].delete.ts +15 -0
- package/server/api/products/[id].put.ts +18 -0
- package/server/api/products/[slug]/content.get.ts +21 -0
- package/server/api/products/[slug].get.ts +16 -0
- package/server/api/products/index.get.ts +28 -0
- package/server/api/profile.get.ts +15 -0
- package/server/api/profile.put.ts +24 -0
- package/server/api/resolve-identity.post.ts +34 -0
- package/server/api/search/index.get.ts +24 -0
- package/server/api/search/trending.get.ts +22 -0
- package/server/api/social/bookmark.get.ts +16 -0
- package/server/api/social/bookmark.post.ts +15 -0
- package/server/api/social/bookmarks.get.ts +16 -0
- package/server/api/social/comments/[id].delete.ts +13 -0
- package/server/api/social/comments.get.ts +18 -0
- package/server/api/social/comments.post.ts +11 -0
- package/server/api/social/like.get.ts +17 -0
- package/server/api/social/like.post.ts +35 -0
- package/server/api/stats.get.ts +8 -0
- package/server/api/user/hubs.get.ts +22 -0
- package/server/api/users/[username]/content.get.ts +21 -0
- package/server/api/users/[username]/feed.xml.get.ts +65 -0
- package/server/api/users/[username]/follow.delete.ts +15 -0
- package/server/api/users/[username]/follow.post.ts +15 -0
- package/server/api/users/[username]/followers.get.ts +22 -0
- package/server/api/users/[username]/following.get.ts +22 -0
- package/server/api/users/[username]/learning.get.ts +18 -0
- package/server/api/users/[username].get.ts +25 -0
- package/server/api/users/index.get.ts +78 -0
- package/server/api/videos/[id].get.ts +18 -0
- package/server/api/videos/categories/[id].delete.ts +15 -0
- package/server/api/videos/categories/[id].put.ts +17 -0
- package/server/api/videos/categories.get.ts +7 -0
- package/server/api/videos/categories.post.ts +11 -0
- package/server/api/videos/index.get.ts +20 -0
- package/server/api/videos/index.post.ts +11 -0
- package/server/middleware/auth.ts +180 -0
- package/server/middleware/features.ts +31 -0
- package/server/middleware/security.ts +54 -0
- package/server/plugins/auto-admin.ts +69 -0
- package/server/plugins/federation-delivery.ts +74 -0
- package/server/routes/.well-known/nodeinfo.ts +15 -0
- package/server/routes/.well-known/webfinger.ts +86 -0
- package/server/routes/actor/followers.ts +34 -0
- package/server/routes/actor/following.ts +34 -0
- package/server/routes/actor/outbox.ts +31 -0
- package/server/routes/actor.ts +30 -0
- package/server/routes/feed.xml.ts +59 -0
- package/server/routes/hubs/[slug]/followers.ts +39 -0
- package/server/routes/hubs/[slug]/inbox.ts +35 -0
- package/server/routes/hubs/[slug]/outbox.ts +43 -0
- package/server/routes/hubs/[slug]/posts/[postId].ts +63 -0
- package/server/routes/hubs/[slug].ts +29 -0
- package/server/routes/inbox.ts +34 -0
- package/server/routes/nodeinfo/2.1.ts +27 -0
- package/server/routes/robots.txt.ts +19 -0
- package/server/routes/sitemap.xml.ts +105 -0
- package/server/routes/users/[username]/followers.ts +33 -0
- package/server/routes/users/[username]/following.ts +33 -0
- package/server/routes/users/[username]/inbox.ts +34 -0
- package/server/routes/users/[username]/outbox.ts +35 -0
- package/server/routes/users/[username].ts +62 -0
- package/server/utils/auth.ts +36 -0
- package/server/utils/db.ts +34 -0
- package/server/utils/errors.ts +24 -0
- package/server/utils/inbox.ts +122 -0
- package/server/utils/validate.ts +82 -0
- package/theme/base.css +283 -0
- package/theme/components.css +322 -0
- package/theme/dark.css +87 -0
- package/theme/editor-panels.css +63 -0
- package/theme/forms.css +216 -0
- package/theme/generics.css +68 -0
- package/theme/layouts.css +415 -0
- package/theme/prose.css +342 -0
- package/types/hub.ts +61 -0
|
@@ -0,0 +1,513 @@
|
|
|
1
|
+
<script setup lang="ts">
|
|
2
|
+
import type { Serialized, HubDetail, HubPostItem, HubMemberItem, PaginatedResponse, ContentListItem } from '@commonpub/server';
|
|
3
|
+
import type { HubViewModel, HubPostViewModel, HubMemberViewModel, HubTabDef } from '../../../types/hub';
|
|
4
|
+
|
|
5
|
+
const route = useRoute();
|
|
6
|
+
const slug = computed(() => route.params.slug as string);
|
|
7
|
+
|
|
8
|
+
// --- Data fetching (unchanged) ---
|
|
9
|
+
const { data: hub, pending: hubPending, error: hubError, refresh: refreshHub } = useLazyFetch<Serialized<HubDetail>>(() => `/api/hubs/${slug.value}`);
|
|
10
|
+
const { data: posts, refresh: refreshPosts } = useLazyFetch<Serialized<PaginatedResponse<HubPostItem>>>(() => `/api/hubs/${slug.value}/posts`, { default: () => ({ items: [], total: 0 }) });
|
|
11
|
+
const { data: membersData } = useLazyFetch<{ items: Serialized<HubMemberItem>[]; total: number }>(() => `/api/hubs/${slug.value}/members`);
|
|
12
|
+
const { data: gallery, refresh: refreshGallery } = useLazyFetch<PaginatedResponse<Serialized<ContentListItem>>>(() => `/api/hubs/${slug.value}/gallery`, { default: () => ({ items: [], total: 0 }) });
|
|
13
|
+
|
|
14
|
+
const hubType = computed(() => hub.value?.hubType ?? 'community');
|
|
15
|
+
const isProductHub = computed(() => hubType.value === 'product');
|
|
16
|
+
const isCompanyHub = computed(() => hubType.value === 'company');
|
|
17
|
+
|
|
18
|
+
const { data: products } = useLazyFetch<{ items: Array<{ id: string; name: string; description: string | null; imageUrl: string | null; category: string | null; status: string }>; total: number }>(
|
|
19
|
+
() => `/api/hubs/${slug.value}/products`,
|
|
20
|
+
{ default: () => ({ items: [], total: 0 }), immediate: isCompanyHub.value },
|
|
21
|
+
);
|
|
22
|
+
|
|
23
|
+
useSeoMeta({
|
|
24
|
+
title: () => hub.value ? `${hub.value.name} -- ${useSiteName()}` : `Hub -- ${useSiteName()}`,
|
|
25
|
+
description: () => hub.value?.description || '',
|
|
26
|
+
ogImage: '/og-default.png',
|
|
27
|
+
});
|
|
28
|
+
|
|
29
|
+
const { isAuthenticated, user: authUser } = useAuth();
|
|
30
|
+
const initialTab = hubType.value === 'community' || !hub.value?.hubType ? 'feed' : 'overview';
|
|
31
|
+
const activeTab = ref(initialTab);
|
|
32
|
+
|
|
33
|
+
// --- Map to view models ---
|
|
34
|
+
const hubVM = computed<HubViewModel | null>(() => {
|
|
35
|
+
if (!hub.value) return null;
|
|
36
|
+
return {
|
|
37
|
+
name: hub.value.name,
|
|
38
|
+
description: hub.value.description,
|
|
39
|
+
iconUrl: hub.value.iconUrl,
|
|
40
|
+
bannerUrl: hub.value.bannerUrl,
|
|
41
|
+
hubType: (hub.value.hubType as 'community' | 'product' | 'company') ?? 'community',
|
|
42
|
+
memberCount: hub.value.memberCount ?? 0,
|
|
43
|
+
postCount: hub.value.postCount ?? 0,
|
|
44
|
+
foundedLabel: new Date(hub.value.createdAt).toLocaleDateString('en-US', { month: 'short', year: 'numeric' }),
|
|
45
|
+
isOfficial: hub.value.isOfficial ?? false,
|
|
46
|
+
joinPolicy: hub.value.joinPolicy ?? null,
|
|
47
|
+
categories: hub.value.categories as string[] | null,
|
|
48
|
+
website: hub.value.website,
|
|
49
|
+
};
|
|
50
|
+
});
|
|
51
|
+
|
|
52
|
+
const postsVM = computed<HubPostViewModel[]>(() => {
|
|
53
|
+
return (posts.value?.items ?? []).map((p) => ({
|
|
54
|
+
id: p.id,
|
|
55
|
+
type: p.type,
|
|
56
|
+
content: p.content || '',
|
|
57
|
+
author: {
|
|
58
|
+
name: p.author?.displayName || p.author?.username || 'Unknown',
|
|
59
|
+
handle: null,
|
|
60
|
+
avatarUrl: p.author?.avatarUrl ?? null,
|
|
61
|
+
},
|
|
62
|
+
createdAt: p.createdAt,
|
|
63
|
+
likeCount: p.likeCount ?? 0,
|
|
64
|
+
replyCount: p.replyCount ?? 0,
|
|
65
|
+
isPinned: p.isPinned ?? false,
|
|
66
|
+
isLocked: p.isLocked ?? false,
|
|
67
|
+
linkTo: `/hubs/${slug.value}/posts/${p.id}`,
|
|
68
|
+
...(p.sharedContent ? {
|
|
69
|
+
sharedContent: {
|
|
70
|
+
type: (p.sharedContent as Record<string, unknown>).type as string,
|
|
71
|
+
slug: (p.sharedContent as Record<string, unknown>).slug as string,
|
|
72
|
+
title: (p.sharedContent as Record<string, unknown>).title as string,
|
|
73
|
+
description: ((p.sharedContent as Record<string, unknown>).description as string | null) ?? null,
|
|
74
|
+
coverImageUrl: ((p.sharedContent as Record<string, unknown>).coverImageUrl as string | null) ?? null,
|
|
75
|
+
},
|
|
76
|
+
} : {}),
|
|
77
|
+
}));
|
|
78
|
+
});
|
|
79
|
+
|
|
80
|
+
const membersVM = computed<HubMemberViewModel[]>(() => {
|
|
81
|
+
return (membersData.value?.items ?? []).map((m) => ({
|
|
82
|
+
name: m.user.displayName || m.user.username || 'Unknown',
|
|
83
|
+
username: m.user.username,
|
|
84
|
+
role: m.role,
|
|
85
|
+
avatarUrl: m.user.avatarUrl ?? null,
|
|
86
|
+
profileLink: `/u/${m.user.username}`,
|
|
87
|
+
joinedAt: m.joinedAt,
|
|
88
|
+
}));
|
|
89
|
+
});
|
|
90
|
+
|
|
91
|
+
const moderators = computed(() => {
|
|
92
|
+
return membersVM.value.filter((m) => m.role === 'owner' || m.role === 'moderator');
|
|
93
|
+
});
|
|
94
|
+
|
|
95
|
+
const hubRules = computed<string[]>(() => {
|
|
96
|
+
const raw = hub.value?.rules;
|
|
97
|
+
if (!raw) return [];
|
|
98
|
+
try {
|
|
99
|
+
const parsed = JSON.parse(raw as string);
|
|
100
|
+
if (Array.isArray(parsed)) return parsed as string[];
|
|
101
|
+
} catch { /* not JSON */ }
|
|
102
|
+
return (raw as string).split('\n').map((r: string) => r.trim()).filter(Boolean);
|
|
103
|
+
});
|
|
104
|
+
|
|
105
|
+
const tabDefs = computed<HubTabDef[]>(() => {
|
|
106
|
+
if (isProductHub.value) {
|
|
107
|
+
return [
|
|
108
|
+
{ value: 'overview', label: 'Overview', icon: 'fa-solid fa-info-circle' },
|
|
109
|
+
{ value: 'projects', label: 'Projects Using This', icon: 'fa-solid fa-folder-open', count: gallery.value?.total },
|
|
110
|
+
{ value: 'discussions', label: 'Discussions', icon: 'fa-solid fa-comments' },
|
|
111
|
+
];
|
|
112
|
+
}
|
|
113
|
+
if (isCompanyHub.value) {
|
|
114
|
+
return [
|
|
115
|
+
{ value: 'overview', label: 'Overview', icon: 'fa-solid fa-building' },
|
|
116
|
+
{ value: 'products', label: 'Products', icon: 'fa-solid fa-microchip', count: products.value?.total },
|
|
117
|
+
{ value: 'projects', label: 'Projects', icon: 'fa-solid fa-folder-open', count: gallery.value?.total },
|
|
118
|
+
{ value: 'discussions', label: 'Discussions', icon: 'fa-solid fa-comments' },
|
|
119
|
+
];
|
|
120
|
+
}
|
|
121
|
+
return [
|
|
122
|
+
{ value: 'feed', label: 'Feed', icon: 'fa-solid fa-rss', count: hub.value?.postCount },
|
|
123
|
+
{ value: 'projects', label: 'Projects', icon: 'fa-solid fa-folder-open', count: gallery.value?.total },
|
|
124
|
+
{ value: 'discussions', label: 'Discussions', icon: 'fa-solid fa-comments' },
|
|
125
|
+
{ value: 'members', label: 'Members', icon: 'fa-solid fa-users', count: hub.value?.memberCount },
|
|
126
|
+
];
|
|
127
|
+
});
|
|
128
|
+
|
|
129
|
+
const toast = useToast();
|
|
130
|
+
|
|
131
|
+
// --- Compose bar state (local-only, passed via slot) ---
|
|
132
|
+
const newPostContent = ref('');
|
|
133
|
+
const newPostType = ref<'text' | 'question' | 'discussion' | 'showcase'>('text');
|
|
134
|
+
const posting = ref(false);
|
|
135
|
+
const postError = ref('');
|
|
136
|
+
const imageInput = ref<HTMLInputElement | null>(null);
|
|
137
|
+
|
|
138
|
+
const postTypeOptions = [
|
|
139
|
+
{ value: 'text', label: 'Post', icon: 'fa-solid fa-pen' },
|
|
140
|
+
{ value: 'question', label: 'Question', icon: 'fa-solid fa-circle-question' },
|
|
141
|
+
{ value: 'discussion', label: 'Discussion', icon: 'fa-solid fa-comments' },
|
|
142
|
+
{ value: 'showcase', label: 'Showcase', icon: 'fa-solid fa-image' },
|
|
143
|
+
];
|
|
144
|
+
|
|
145
|
+
// --- Discussion compose state ---
|
|
146
|
+
const newDiscContent = ref('');
|
|
147
|
+
const newDiscType = ref<'discussion' | 'question'>('discussion');
|
|
148
|
+
const discPosting = ref(false);
|
|
149
|
+
|
|
150
|
+
async function handlePost(): Promise<void> {
|
|
151
|
+
if (!newPostContent.value.trim()) return;
|
|
152
|
+
posting.value = true;
|
|
153
|
+
try {
|
|
154
|
+
await $fetch(`/api/hubs/${slug.value}/posts`, {
|
|
155
|
+
method: 'POST',
|
|
156
|
+
body: { content: newPostContent.value, type: newPostType.value },
|
|
157
|
+
});
|
|
158
|
+
newPostContent.value = '';
|
|
159
|
+
newPostType.value = 'text';
|
|
160
|
+
postError.value = '';
|
|
161
|
+
await Promise.all([refreshHub(), refreshPosts()]);
|
|
162
|
+
} catch (e) {
|
|
163
|
+
const fetchErr = e as { data?: { statusMessage?: string }; message?: string };
|
|
164
|
+
postError.value = fetchErr?.data?.statusMessage || fetchErr?.message || 'Failed to create post';
|
|
165
|
+
} finally {
|
|
166
|
+
posting.value = false;
|
|
167
|
+
}
|
|
168
|
+
}
|
|
169
|
+
|
|
170
|
+
async function handleDiscPost(): Promise<void> {
|
|
171
|
+
if (!newDiscContent.value.trim()) return;
|
|
172
|
+
discPosting.value = true;
|
|
173
|
+
try {
|
|
174
|
+
await $fetch(`/api/hubs/${slug.value}/posts`, {
|
|
175
|
+
method: 'POST',
|
|
176
|
+
body: { content: newDiscContent.value, type: newDiscType.value },
|
|
177
|
+
});
|
|
178
|
+
newDiscContent.value = '';
|
|
179
|
+
newDiscType.value = 'discussion';
|
|
180
|
+
await Promise.all([refreshHub(), refreshPosts()]);
|
|
181
|
+
} catch {
|
|
182
|
+
toast.error('Failed to create post');
|
|
183
|
+
} finally {
|
|
184
|
+
discPosting.value = false;
|
|
185
|
+
}
|
|
186
|
+
}
|
|
187
|
+
|
|
188
|
+
function openImagePicker(): void {
|
|
189
|
+
imageInput.value?.click();
|
|
190
|
+
}
|
|
191
|
+
|
|
192
|
+
async function handleImageUpload(event: Event): Promise<void> {
|
|
193
|
+
const input = event.target as HTMLInputElement;
|
|
194
|
+
const file = input.files?.[0];
|
|
195
|
+
if (!file) return;
|
|
196
|
+
const formData = new FormData();
|
|
197
|
+
formData.append('file', file);
|
|
198
|
+
try {
|
|
199
|
+
const result = await $fetch<{ url: string }>('/api/files/upload', { method: 'POST', body: formData });
|
|
200
|
+
newPostContent.value += (newPostContent.value ? ' ' : '') + result.url;
|
|
201
|
+
toast.success('Image uploaded');
|
|
202
|
+
} catch {
|
|
203
|
+
toast.error('Upload failed');
|
|
204
|
+
}
|
|
205
|
+
input.value = '';
|
|
206
|
+
}
|
|
207
|
+
|
|
208
|
+
function handleLinkInsert(): void {
|
|
209
|
+
const url = prompt('Enter a URL:');
|
|
210
|
+
if (url) {
|
|
211
|
+
newPostContent.value += (newPostContent.value ? ' ' : '') + url;
|
|
212
|
+
}
|
|
213
|
+
}
|
|
214
|
+
|
|
215
|
+
async function handleJoin(): Promise<void> {
|
|
216
|
+
if (!isAuthenticated.value) {
|
|
217
|
+
await navigateTo(`/auth/login?redirect=/hubs/${slug.value}`);
|
|
218
|
+
return;
|
|
219
|
+
}
|
|
220
|
+
try {
|
|
221
|
+
await $fetch(`/api/hubs/${slug.value}/join`, { method: 'POST' });
|
|
222
|
+
toast.success('Joined hub!');
|
|
223
|
+
await refreshHub();
|
|
224
|
+
} catch {
|
|
225
|
+
toast.error('Failed to join hub');
|
|
226
|
+
}
|
|
227
|
+
}
|
|
228
|
+
|
|
229
|
+
async function handleShare(): Promise<void> {
|
|
230
|
+
const url = `${window.location.origin}/hubs/${slug.value}`;
|
|
231
|
+
if (navigator.share) {
|
|
232
|
+
await navigator.share({ title: hub.value?.name || 'Hub', url }).catch(() => {});
|
|
233
|
+
} else {
|
|
234
|
+
await navigator.clipboard.writeText(url);
|
|
235
|
+
toast.success('Link copied to clipboard');
|
|
236
|
+
}
|
|
237
|
+
}
|
|
238
|
+
|
|
239
|
+
async function onRefreshGallery(): Promise<void> {
|
|
240
|
+
await Promise.all([refreshGallery(), refreshPosts(), refreshHub()]);
|
|
241
|
+
}
|
|
242
|
+
</script>
|
|
243
|
+
|
|
244
|
+
<template>
|
|
245
|
+
<div v-if="hubPending" class="cpub-loading">Loading hub...</div>
|
|
246
|
+
<div v-else-if="hubError" class="cpub-fetch-error">
|
|
247
|
+
<div class="cpub-fetch-error-icon"><i class="fa-solid fa-triangle-exclamation"></i></div>
|
|
248
|
+
<div class="cpub-fetch-error-msg">Failed to load hub.</div>
|
|
249
|
+
<button class="cpub-btn cpub-btn-sm" @click="refreshHub()">Retry</button>
|
|
250
|
+
</div>
|
|
251
|
+
|
|
252
|
+
<HubLayout v-else-if="hubVM" v-model:active-tab="activeTab" :tabs="tabDefs">
|
|
253
|
+
<template #hero>
|
|
254
|
+
<HubHero :hub="hubVM" :gallery-total="gallery?.total">
|
|
255
|
+
<template #actions>
|
|
256
|
+
<button v-if="isAuthenticated && !hub?.currentUserRole" class="cpub-btn cpub-btn-primary" @click="handleJoin">
|
|
257
|
+
<i class="fa-solid fa-plus"></i> Join Hub
|
|
258
|
+
</button>
|
|
259
|
+
<span v-else-if="hub?.currentUserRole" class="cpub-member-badge">
|
|
260
|
+
<i class="fa-solid fa-check"></i> Joined
|
|
261
|
+
</span>
|
|
262
|
+
<button class="cpub-btn cpub-btn-sm" aria-label="Share hub" @click="handleShare"><i class="fa-solid fa-share-nodes"></i></button>
|
|
263
|
+
<NuxtLink v-if="hub?.currentUserRole === 'owner'" :to="`/hubs/${slug}/settings`" class="cpub-btn cpub-btn-sm" aria-label="Hub settings"><i class="fa-solid fa-gear"></i> Settings</NuxtLink>
|
|
264
|
+
</template>
|
|
265
|
+
<template #badges>
|
|
266
|
+
<span v-if="hub?.isOfficial" class="cpub-tag cpub-tag-accent"><i class="fa-solid fa-shield-halved" style="margin-right: 3px"></i>Verified</span>
|
|
267
|
+
<span v-if="hub?.joinPolicy === 'open'" class="cpub-tag cpub-tag-green">Open to All</span>
|
|
268
|
+
<span v-else-if="hub?.joinPolicy === 'approval'" class="cpub-tag cpub-tag-yellow">Approval Required</span>
|
|
269
|
+
<span v-else class="cpub-tag">Invite Only</span>
|
|
270
|
+
</template>
|
|
271
|
+
</HubHero>
|
|
272
|
+
</template>
|
|
273
|
+
|
|
274
|
+
<!-- Main content area -->
|
|
275
|
+
|
|
276
|
+
<!-- Feed tab -->
|
|
277
|
+
<HubFeed v-if="activeTab === 'feed'" :posts="postsVM">
|
|
278
|
+
<template v-if="isAuthenticated" #compose>
|
|
279
|
+
<div class="cpub-compose-bar">
|
|
280
|
+
<div class="cpub-compose-types">
|
|
281
|
+
<button
|
|
282
|
+
v-for="opt in postTypeOptions"
|
|
283
|
+
:key="opt.value"
|
|
284
|
+
class="cpub-compose-type-btn"
|
|
285
|
+
:class="{ active: newPostType === opt.value }"
|
|
286
|
+
@click="newPostType = opt.value as typeof newPostType"
|
|
287
|
+
>
|
|
288
|
+
<i :class="opt.icon"></i> {{ opt.label }}
|
|
289
|
+
</button>
|
|
290
|
+
</div>
|
|
291
|
+
<div class="cpub-compose-row">
|
|
292
|
+
<input
|
|
293
|
+
v-model="newPostContent"
|
|
294
|
+
class="cpub-compose-input"
|
|
295
|
+
type="text"
|
|
296
|
+
:placeholder="newPostType === 'question' ? 'Ask the community a question...' : newPostType === 'discussion' ? 'Start a discussion...' : newPostType === 'showcase' ? 'Share what you built...' : 'Write a post...'"
|
|
297
|
+
@keydown.enter="handlePost"
|
|
298
|
+
/>
|
|
299
|
+
<input ref="imageInput" type="file" accept="image/*" style="display: none" @change="handleImageUpload" />
|
|
300
|
+
<button class="cpub-btn cpub-btn-sm" aria-label="Upload image" @click="openImagePicker"><i class="fa-solid fa-image"></i></button>
|
|
301
|
+
<button class="cpub-btn cpub-btn-sm" aria-label="Insert link" @click="handleLinkInsert"><i class="fa-solid fa-link"></i></button>
|
|
302
|
+
<button class="cpub-btn cpub-btn-sm cpub-btn-primary" :disabled="posting" @click="handlePost">
|
|
303
|
+
<i class="fa-solid fa-paper-plane"></i> Post
|
|
304
|
+
</button>
|
|
305
|
+
</div>
|
|
306
|
+
</div>
|
|
307
|
+
<div v-if="postError" class="cpub-post-error">{{ postError }}</div>
|
|
308
|
+
</template>
|
|
309
|
+
</HubFeed>
|
|
310
|
+
|
|
311
|
+
<!-- Discussions tab -->
|
|
312
|
+
<HubDiscussions v-else-if="activeTab === 'discussions'" :posts="postsVM">
|
|
313
|
+
<template v-if="isAuthenticated" #compose>
|
|
314
|
+
<div class="cpub-compose-bar" style="margin-bottom: 16px">
|
|
315
|
+
<div class="cpub-compose-row">
|
|
316
|
+
<input
|
|
317
|
+
v-model="newDiscContent"
|
|
318
|
+
class="cpub-compose-input"
|
|
319
|
+
type="text"
|
|
320
|
+
placeholder="Start a discussion or ask a question..."
|
|
321
|
+
@keydown.enter="newDiscType = 'discussion'; handleDiscPost()"
|
|
322
|
+
/>
|
|
323
|
+
<button class="cpub-btn cpub-btn-sm" :class="{ 'cpub-btn-primary': newDiscType === 'question' }" @click="newDiscType = 'question'" title="Ask a question">
|
|
324
|
+
<i class="fa-solid fa-circle-question"></i>
|
|
325
|
+
</button>
|
|
326
|
+
<button class="cpub-btn cpub-btn-sm cpub-btn-primary" :disabled="discPosting" @click="newDiscType = 'discussion'; handleDiscPost()">
|
|
327
|
+
<i class="fa-solid fa-paper-plane"></i> Post
|
|
328
|
+
</button>
|
|
329
|
+
</div>
|
|
330
|
+
</div>
|
|
331
|
+
</template>
|
|
332
|
+
</HubDiscussions>
|
|
333
|
+
|
|
334
|
+
<!-- Members tab -->
|
|
335
|
+
<HubMembers v-else-if="activeTab === 'members'" :members="membersVM" />
|
|
336
|
+
|
|
337
|
+
<!-- Overview tab -->
|
|
338
|
+
<template v-else-if="activeTab === 'overview'">
|
|
339
|
+
<div class="cpub-product-overview">
|
|
340
|
+
<h3 class="cpub-section-title">{{ isProductHub ? 'About This Product' : 'About' }}</h3>
|
|
341
|
+
<p class="cpub-prose-p">{{ hub?.description || 'No description available.' }}</p>
|
|
342
|
+
<div v-if="hub?.website" class="cpub-meta-link">
|
|
343
|
+
<i class="fa-solid fa-link"></i>
|
|
344
|
+
<a :href="hub.website" target="_blank" rel="noopener">{{ hub.website }}</a>
|
|
345
|
+
</div>
|
|
346
|
+
</div>
|
|
347
|
+
</template>
|
|
348
|
+
|
|
349
|
+
<!-- Projects tab -->
|
|
350
|
+
<HubProjects
|
|
351
|
+
v-else-if="activeTab === 'projects'"
|
|
352
|
+
:slug="slug"
|
|
353
|
+
:gallery="gallery"
|
|
354
|
+
:is-authenticated="isAuthenticated"
|
|
355
|
+
:current-user-role="hub?.currentUserRole ?? null"
|
|
356
|
+
:is-product-hub="isProductHub"
|
|
357
|
+
:auth-user-id="authUser?.id"
|
|
358
|
+
@refresh-gallery="onRefreshGallery"
|
|
359
|
+
/>
|
|
360
|
+
|
|
361
|
+
<!-- Products tab -->
|
|
362
|
+
<HubProducts v-else-if="activeTab === 'products'" :products="products" />
|
|
363
|
+
|
|
364
|
+
<!-- Sidebar -->
|
|
365
|
+
<template #sidebar>
|
|
366
|
+
<HubSidebar>
|
|
367
|
+
<HubSidebarCard title="Moderators">
|
|
368
|
+
<div v-for="mod in moderators" :key="mod.username" class="cpub-mod-item">
|
|
369
|
+
<div class="cpub-mod-avatar">
|
|
370
|
+
<img v-if="mod.avatarUrl" :src="mod.avatarUrl" :alt="mod.name" class="cpub-mod-avatar-img" />
|
|
371
|
+
<span v-else>{{ mod.name.charAt(0).toUpperCase() }}</span>
|
|
372
|
+
</div>
|
|
373
|
+
<div class="cpub-mod-info">
|
|
374
|
+
<NuxtLink :to="mod.profileLink" class="cpub-mod-name">{{ mod.name }}</NuxtLink>
|
|
375
|
+
<div class="cpub-mod-role">{{ mod.role }}</div>
|
|
376
|
+
</div>
|
|
377
|
+
</div>
|
|
378
|
+
<p v-if="!moderators.length" class="cpub-sidebar-empty">No moderators listed.</p>
|
|
379
|
+
</HubSidebarCard>
|
|
380
|
+
|
|
381
|
+
<HubSidebarCard v-if="hubRules.length" title="Hub Rules">
|
|
382
|
+
<div v-for="(rule, i) in hubRules" :key="i" class="cpub-rule-item">
|
|
383
|
+
<span class="cpub-rule-num">{{ i + 1 }}</span>
|
|
384
|
+
<span>{{ rule }}</span>
|
|
385
|
+
</div>
|
|
386
|
+
</HubSidebarCard>
|
|
387
|
+
|
|
388
|
+
<HubSidebarCard v-if="hub?.website" title="Links">
|
|
389
|
+
<div class="cpub-resource-item">
|
|
390
|
+
<i class="fa-solid fa-link"></i>
|
|
391
|
+
<a :href="hub.website" target="_blank" rel="noopener">{{ hub.website }}</a>
|
|
392
|
+
</div>
|
|
393
|
+
</HubSidebarCard>
|
|
394
|
+
</HubSidebar>
|
|
395
|
+
</template>
|
|
396
|
+
</HubLayout>
|
|
397
|
+
|
|
398
|
+
<div v-else class="cpub-empty-state" style="padding: 64px 24px">
|
|
399
|
+
<p class="cpub-empty-state-title">Hub not found</p>
|
|
400
|
+
</div>
|
|
401
|
+
</template>
|
|
402
|
+
|
|
403
|
+
<style scoped>
|
|
404
|
+
/* Compose bar */
|
|
405
|
+
.cpub-compose-bar {
|
|
406
|
+
background: var(--surface);
|
|
407
|
+
border: 1px solid var(--border);
|
|
408
|
+
border-radius: 12px;
|
|
409
|
+
padding: 12px 14px;
|
|
410
|
+
margin-bottom: 16px;
|
|
411
|
+
display: flex;
|
|
412
|
+
flex-direction: column;
|
|
413
|
+
gap: 8px;
|
|
414
|
+
}
|
|
415
|
+
|
|
416
|
+
.cpub-compose-types { display: flex; gap: 4px; }
|
|
417
|
+
|
|
418
|
+
.cpub-compose-type-btn {
|
|
419
|
+
font-family: var(--font-mono);
|
|
420
|
+
font-size: 10px;
|
|
421
|
+
font-weight: 600;
|
|
422
|
+
text-transform: uppercase;
|
|
423
|
+
letter-spacing: 0.04em;
|
|
424
|
+
padding: 4px 10px;
|
|
425
|
+
background: none;
|
|
426
|
+
border: 1px solid var(--border);
|
|
427
|
+
border-radius: 6px;
|
|
428
|
+
color: var(--text-faint);
|
|
429
|
+
cursor: pointer;
|
|
430
|
+
display: flex;
|
|
431
|
+
align-items: center;
|
|
432
|
+
gap: 4px;
|
|
433
|
+
transition: border-color 0.1s, color 0.1s;
|
|
434
|
+
}
|
|
435
|
+
.cpub-compose-type-btn:hover { color: var(--text); border-color: var(--text-dim); }
|
|
436
|
+
.cpub-compose-type-btn.active { color: var(--accent); border-color: var(--accent); background: var(--accent-bg); }
|
|
437
|
+
|
|
438
|
+
.cpub-compose-row { display: flex; gap: 10px; align-items: center; }
|
|
439
|
+
|
|
440
|
+
.cpub-compose-input {
|
|
441
|
+
flex: 1;
|
|
442
|
+
background: var(--surface2);
|
|
443
|
+
border: 1px solid var(--border);
|
|
444
|
+
border-radius: 8px;
|
|
445
|
+
padding: 10px 14px;
|
|
446
|
+
font-size: 0.8125rem;
|
|
447
|
+
color: var(--text-faint);
|
|
448
|
+
cursor: pointer;
|
|
449
|
+
}
|
|
450
|
+
|
|
451
|
+
.cpub-post-error { font-size: 0.75rem; color: var(--red); background: var(--red-bg); border: 1px solid var(--red-border); border-radius: 8px; padding: 8px 12px; margin-bottom: 12px; }
|
|
452
|
+
|
|
453
|
+
/* Member badge */
|
|
454
|
+
.cpub-member-badge {
|
|
455
|
+
display: inline-flex;
|
|
456
|
+
align-items: center;
|
|
457
|
+
gap: 4px;
|
|
458
|
+
font-size: 0.6875rem;
|
|
459
|
+
font-weight: 600;
|
|
460
|
+
color: var(--green);
|
|
461
|
+
background: var(--green-bg);
|
|
462
|
+
padding: 4px 12px;
|
|
463
|
+
border: 1px solid var(--green-border);
|
|
464
|
+
border-radius: 20px;
|
|
465
|
+
}
|
|
466
|
+
|
|
467
|
+
/* Sidebar content */
|
|
468
|
+
.cpub-mod-item { display: flex; align-items: center; gap: 8px; margin-bottom: 8px; }
|
|
469
|
+
.cpub-mod-item:last-child { margin-bottom: 0; }
|
|
470
|
+
|
|
471
|
+
.cpub-mod-avatar {
|
|
472
|
+
width: 32px; height: 32px; border-radius: 50%;
|
|
473
|
+
background: var(--accent-bg); border: 1px solid var(--accent-border);
|
|
474
|
+
display: flex; align-items: center; justify-content: center;
|
|
475
|
+
font-size: 11px; font-weight: 600; color: var(--accent); flex-shrink: 0;
|
|
476
|
+
overflow: hidden;
|
|
477
|
+
}
|
|
478
|
+
.cpub-mod-avatar-img { width: 100%; height: 100%; object-fit: cover; border-radius: inherit; }
|
|
479
|
+
.cpub-mod-info { flex: 1; }
|
|
480
|
+
.cpub-mod-name { font-size: 11px; font-weight: 500; }
|
|
481
|
+
.cpub-mod-role { font-size: 0.6875rem; color: var(--text-faint); }
|
|
482
|
+
|
|
483
|
+
.cpub-rule-item {
|
|
484
|
+
display: flex; align-items: flex-start; gap: 8px; margin-bottom: 8px;
|
|
485
|
+
font-size: 11px; color: var(--text-dim);
|
|
486
|
+
}
|
|
487
|
+
.cpub-rule-num {
|
|
488
|
+
font-size: 10px; font-family: var(--font-mono); color: var(--text-faint);
|
|
489
|
+
width: 16px; flex-shrink: 0; margin-top: 1px;
|
|
490
|
+
}
|
|
491
|
+
|
|
492
|
+
.cpub-sidebar-empty { font-size: 11px; color: var(--text-faint); }
|
|
493
|
+
|
|
494
|
+
.cpub-resource-item {
|
|
495
|
+
display: flex; align-items: center; gap: 8px; font-size: 11px; color: var(--text-dim);
|
|
496
|
+
}
|
|
497
|
+
.cpub-resource-item i { font-size: 10px; color: var(--text-faint); width: 12px; }
|
|
498
|
+
.cpub-resource-item a { color: var(--accent); text-decoration: none; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
|
|
499
|
+
.cpub-resource-item a:hover { text-decoration: underline; }
|
|
500
|
+
|
|
501
|
+
/* Overview */
|
|
502
|
+
.cpub-product-overview { max-width: 720px; }
|
|
503
|
+
.cpub-section-title { font-size: 0.875rem; font-weight: 700; color: var(--text-dim); }
|
|
504
|
+
.cpub-prose-p { font-size: 14px; color: var(--text-dim); line-height: 1.7; margin-bottom: 16px; }
|
|
505
|
+
.cpub-meta-link { display: flex; align-items: center; gap: 8px; font-size: 12px; color: var(--text-faint); }
|
|
506
|
+
.cpub-meta-link a { color: var(--accent); text-decoration: none; }
|
|
507
|
+
.cpub-meta-link a:hover { text-decoration: underline; }
|
|
508
|
+
|
|
509
|
+
@media (max-width: 640px) {
|
|
510
|
+
.cpub-compose-bar { flex-wrap: wrap; }
|
|
511
|
+
.cpub-compose-input { min-width: 0; }
|
|
512
|
+
}
|
|
513
|
+
</style>
|
|
@@ -0,0 +1,134 @@
|
|
|
1
|
+
<script setup lang="ts">
|
|
2
|
+
const route = useRoute();
|
|
3
|
+
const slug = computed(() => route.params.slug as string);
|
|
4
|
+
const toast = useToast();
|
|
5
|
+
|
|
6
|
+
const { data: hub } = useLazyFetch(() => `/api/hubs/${slug.value}`);
|
|
7
|
+
const { data: membersData, refresh } = useLazyFetch<{ items: any[]; total: number }>(() => `/api/hubs/${slug.value}/members`);
|
|
8
|
+
const members = computed(() => membersData.value?.items ?? []);
|
|
9
|
+
|
|
10
|
+
const { user } = useAuth();
|
|
11
|
+
const currentUserRole = computed(() => hub.value?.currentUserRole ?? null);
|
|
12
|
+
const canManage = computed(() => currentUserRole.value === 'owner' || currentUserRole.value === 'admin');
|
|
13
|
+
|
|
14
|
+
useSeoMeta({ title: () => `Members — ${hub.value?.name ?? 'Hub'} — ${useSiteName()}` });
|
|
15
|
+
|
|
16
|
+
const roles = ['member', 'moderator', 'admin'] as const;
|
|
17
|
+
|
|
18
|
+
const roleColors: Record<string, string> = {
|
|
19
|
+
owner: 'var(--yellow)',
|
|
20
|
+
admin: 'var(--red)',
|
|
21
|
+
moderator: 'var(--accent)',
|
|
22
|
+
member: 'var(--text-faint)',
|
|
23
|
+
};
|
|
24
|
+
|
|
25
|
+
async function changeRole(userId: string, role: string): Promise<void> {
|
|
26
|
+
try {
|
|
27
|
+
await $fetch(`/api/hubs/${slug.value}/members/${userId}`, {
|
|
28
|
+
method: 'PUT',
|
|
29
|
+
body: { role },
|
|
30
|
+
});
|
|
31
|
+
toast.success('Role updated');
|
|
32
|
+
await refresh();
|
|
33
|
+
} catch {
|
|
34
|
+
toast.error('Failed to update role');
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
async function kickMember(userId: string, username: string): Promise<void> {
|
|
39
|
+
if (!confirm(`Remove @${username} from this hub?`)) return;
|
|
40
|
+
try {
|
|
41
|
+
await $fetch(`/api/hubs/${slug.value}/members/${userId}`, { method: 'DELETE' });
|
|
42
|
+
toast.success('Member removed');
|
|
43
|
+
await refresh();
|
|
44
|
+
} catch {
|
|
45
|
+
toast.error('Failed to remove member');
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
</script>
|
|
49
|
+
|
|
50
|
+
<template>
|
|
51
|
+
<div class="members-page">
|
|
52
|
+
<div class="members-header">
|
|
53
|
+
<NuxtLink :to="`/hubs/${slug}`" class="cpub-back-link"><i class="fa-solid fa-arrow-left"></i> {{ hub?.name ?? 'Hub' }}</NuxtLink>
|
|
54
|
+
<h1 class="members-title">Members</h1>
|
|
55
|
+
<p class="members-count" v-if="membersData?.total">{{ membersData.total }} members</p>
|
|
56
|
+
</div>
|
|
57
|
+
|
|
58
|
+
<div class="members-list" v-if="members?.length">
|
|
59
|
+
<div class="member-card" v-for="m in members" :key="m.userId">
|
|
60
|
+
<NuxtLink :to="`/u/${m.user.username}`" class="member-avatar">
|
|
61
|
+
<img v-if="m.user.avatarUrl" :src="m.user.avatarUrl" :alt="m.user.displayName || m.user.username" class="member-avatar-img" />
|
|
62
|
+
<span v-else>{{ (m.user.displayName || m.user.username).charAt(0).toUpperCase() }}</span>
|
|
63
|
+
</NuxtLink>
|
|
64
|
+
<div class="member-info">
|
|
65
|
+
<NuxtLink :to="`/u/${m.user.username}`" class="member-name">
|
|
66
|
+
{{ m.user.displayName || m.user.username }}
|
|
67
|
+
</NuxtLink>
|
|
68
|
+
<span class="member-handle">@{{ m.user.username }}</span>
|
|
69
|
+
</div>
|
|
70
|
+
<span class="member-role-badge" :style="{ color: roleColors[m.role] || 'var(--text-faint)', borderColor: roleColors[m.role] || 'var(--border2)' }">
|
|
71
|
+
{{ m.role }}
|
|
72
|
+
</span>
|
|
73
|
+
<time class="member-joined">{{ new Date(m.joinedAt).toLocaleDateString('en-US', { month: 'short', year: 'numeric' }) }}</time>
|
|
74
|
+
|
|
75
|
+
<!-- Admin actions -->
|
|
76
|
+
<div v-if="canManage && m.role !== 'owner' && m.userId !== user?.id" class="member-actions">
|
|
77
|
+
<select
|
|
78
|
+
class="member-role-select"
|
|
79
|
+
:value="m.role"
|
|
80
|
+
@change="changeRole(m.userId, ($event.target as HTMLSelectElement).value)"
|
|
81
|
+
>
|
|
82
|
+
<option v-for="r in roles" :key="r" :value="r">{{ r }}</option>
|
|
83
|
+
</select>
|
|
84
|
+
<button class="member-kick-btn" title="Remove member" @click="kickMember(m.userId, m.user.username)">
|
|
85
|
+
<i class="fa-solid fa-user-xmark"></i>
|
|
86
|
+
</button>
|
|
87
|
+
</div>
|
|
88
|
+
</div>
|
|
89
|
+
</div>
|
|
90
|
+
<div v-else class="members-empty">
|
|
91
|
+
<p>No members yet.</p>
|
|
92
|
+
</div>
|
|
93
|
+
</div>
|
|
94
|
+
</template>
|
|
95
|
+
|
|
96
|
+
<style scoped>
|
|
97
|
+
.members-page { max-width: 720px; margin: 0 auto; padding: 32px; }
|
|
98
|
+
.members-header { margin-bottom: 20px; }
|
|
99
|
+
.cpub-back-link { font-size: 11px; font-family: var(--font-mono); color: var(--text-faint); text-decoration: none; display: inline-flex; align-items: center; gap: 6px; margin-bottom: 12px; }
|
|
100
|
+
.cpub-back-link:hover { color: var(--accent); }
|
|
101
|
+
.members-title { font-size: 22px; font-weight: 700; margin-bottom: 2px; }
|
|
102
|
+
.members-count { font-size: 12px; font-family: var(--font-mono); color: var(--text-faint); }
|
|
103
|
+
|
|
104
|
+
.members-list { border: var(--border-width-default) solid var(--border); background: var(--surface); }
|
|
105
|
+
.member-card { display: flex; align-items: center; gap: 12px; padding: 12px 16px; border-bottom: var(--border-width-default) solid var(--border2); }
|
|
106
|
+
.member-card:last-child { border-bottom: none; }
|
|
107
|
+
|
|
108
|
+
.member-avatar { width: 36px; height: 36px; border-radius: 50%; background: var(--surface3); border: var(--border-width-default) solid var(--border); display: flex; align-items: center; justify-content: center; font-size: 14px; font-weight: 700; color: var(--accent); font-family: var(--font-mono); text-decoration: none; flex-shrink: 0; overflow: hidden; }
|
|
109
|
+
.member-avatar-img { width: 100%; height: 100%; object-fit: cover; border-radius: inherit; }
|
|
110
|
+
|
|
111
|
+
.member-info { flex: 1; min-width: 0; }
|
|
112
|
+
.member-name { font-size: 13px; font-weight: 600; color: var(--text); text-decoration: none; display: block; }
|
|
113
|
+
.member-name:hover { color: var(--accent); }
|
|
114
|
+
.member-handle { font-size: 11px; color: var(--text-faint); font-family: var(--font-mono); }
|
|
115
|
+
|
|
116
|
+
.member-role-badge { font-size: 10px; font-family: var(--font-mono); text-transform: uppercase; letter-spacing: 0.06em; padding: 2px 8px; border: var(--border-width-default) solid; flex-shrink: 0; }
|
|
117
|
+
|
|
118
|
+
.member-joined { font-size: 10px; color: var(--text-faint); font-family: var(--font-mono); flex-shrink: 0; }
|
|
119
|
+
|
|
120
|
+
.member-actions { display: flex; gap: 4px; flex-shrink: 0; }
|
|
121
|
+
.member-role-select { padding: 3px 6px; border: var(--border-width-default) solid var(--border2); background: var(--surface); color: var(--text-dim); font-size: 10px; font-family: var(--font-mono); text-transform: capitalize; cursor: pointer; }
|
|
122
|
+
.member-role-select:focus { border-color: var(--accent); outline: none; }
|
|
123
|
+
.member-kick-btn { background: none; border: var(--border-width-default) solid var(--border2); color: var(--text-faint); cursor: pointer; font-size: 10px; padding: 3px 6px; }
|
|
124
|
+
.member-kick-btn:hover { color: var(--red); border-color: var(--red); }
|
|
125
|
+
|
|
126
|
+
.members-empty { text-align: center; padding: 48px 0; color: var(--text-faint); }
|
|
127
|
+
|
|
128
|
+
@media (max-width: 768px) {
|
|
129
|
+
.members-page { padding: 16px; }
|
|
130
|
+
.member-card { flex-wrap: wrap; gap: 8px; padding: 10px 12px; }
|
|
131
|
+
.member-joined { display: none; }
|
|
132
|
+
.member-actions { width: 100%; justify-content: flex-end; }
|
|
133
|
+
}
|
|
134
|
+
</style>
|