@jant/core 0.3.24 → 0.3.26
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/dist/app.js +101 -571
- package/dist/client.js +1 -0
- package/dist/db/schema.js +1 -1
- package/dist/i18n/locales/en.js +1 -1
- package/dist/i18n/locales/zh-Hans.js +1 -1
- package/dist/i18n/locales/zh-Hant.js +1 -1
- package/dist/index.js +3 -9
- package/dist/lib/avatar-upload.js +134 -0
- package/dist/lib/config.js +39 -0
- package/dist/lib/constants.js +10 -9
- package/dist/lib/favicon.js +102 -0
- package/dist/lib/image.js +13 -17
- package/dist/lib/media-helpers.js +2 -2
- package/dist/lib/nav-reorder.js +1 -1
- package/dist/lib/navigation.js +48 -3
- package/dist/lib/pagination.js +44 -0
- package/dist/lib/render.js +16 -11
- package/dist/lib/schemas.js +34 -3
- package/dist/lib/theme.js +4 -4
- package/dist/lib/timeline.js +24 -48
- package/dist/lib/timezones.js +388 -0
- package/dist/lib/view.js +3 -3
- package/dist/routes/api/collections.js +124 -0
- package/dist/routes/api/nav-items.js +104 -0
- package/dist/routes/api/pages.js +91 -0
- package/dist/routes/api/posts.js +3 -3
- package/dist/routes/api/search.js +2 -2
- package/dist/routes/api/settings.js +68 -0
- package/dist/routes/api/upload.js +3 -3
- package/dist/routes/auth/reset.js +221 -0
- package/dist/routes/auth/setup.js +194 -0
- package/dist/routes/auth/signin.js +176 -0
- package/dist/routes/compose.js +48 -0
- package/dist/routes/dash/collections.js +24 -416
- package/dist/routes/dash/index.js +1 -1
- package/dist/routes/dash/media.js +13 -393
- package/dist/routes/dash/pages.js +112 -86
- package/dist/routes/dash/posts.js +3 -5
- package/dist/routes/dash/redirects.js +20 -14
- package/dist/routes/dash/settings.js +213 -518
- package/dist/routes/feed/rss.js +4 -3
- package/dist/routes/feed/sitemap.js +5 -3
- package/dist/routes/pages/archive.js +3 -6
- package/dist/routes/pages/collection.js +3 -6
- package/dist/routes/pages/collections.js +28 -0
- package/dist/routes/pages/featured.js +36 -0
- package/dist/routes/pages/home.js +33 -49
- package/dist/routes/pages/latest.js +45 -0
- package/dist/routes/pages/page.js +29 -32
- package/dist/routes/pages/post.js +3 -6
- package/dist/routes/pages/search.js +3 -6
- package/dist/services/page.js +5 -1
- package/dist/services/post.js +45 -31
- package/dist/services/search.js +1 -1
- package/dist/types/bindings.js +3 -0
- package/dist/types/config.js +147 -0
- package/dist/types/constants.js +27 -0
- package/dist/types/entities.js +3 -0
- package/dist/types/operations.js +3 -0
- package/dist/types/props.js +3 -0
- package/dist/types/views.js +5 -0
- package/dist/types.js +8 -111
- package/dist/{theme → ui}/color-themes.js +33 -33
- package/dist/ui/compose/ComposeDialog.js +467 -0
- package/dist/ui/compose/ComposePrompt.js +55 -0
- package/dist/{theme/components/TypeBadge.js → ui/dash/FormatBadge.js} +1 -2
- package/dist/{theme/components → ui/dash}/PageForm.js +21 -15
- package/dist/{theme/components → ui/dash}/PostForm.js +22 -43
- package/dist/{theme/components → ui/dash}/PostList.js +6 -6
- package/dist/{theme/components/VisibilityBadge.js → ui/dash/StatusBadge.js} +1 -2
- package/dist/ui/dash/collections/CollectionForm.js +152 -0
- package/dist/ui/dash/collections/CollectionsListContent.js +68 -0
- package/dist/ui/dash/collections/ViewCollectionContent.js +96 -0
- package/dist/{theme/components → ui/dash}/index.js +3 -6
- package/dist/ui/dash/media/MediaListContent.js +166 -0
- package/dist/ui/dash/media/ViewMediaContent.js +212 -0
- package/dist/ui/dash/pages/LinkFormContent.js +130 -0
- package/dist/ui/dash/pages/UnifiedPagesContent.js +193 -0
- package/dist/ui/dash/settings/AccountContent.js +209 -0
- package/dist/ui/dash/settings/AppearanceContent.js +259 -0
- package/dist/ui/dash/settings/GeneralContent.js +536 -0
- package/dist/ui/dash/settings/SettingsNav.js +41 -0
- package/dist/{themes/threads/timeline → ui/feed}/LinkCard.js +6 -2
- package/dist/{themes/threads/timeline → ui/feed}/NoteCard.js +11 -6
- package/dist/{themes/threads/timeline → ui/feed}/QuoteCard.js +10 -6
- package/dist/{themes/threads/timeline → ui/feed}/ThreadPreview.js +7 -9
- package/dist/ui/feed/TimelineFeed.js +41 -0
- package/dist/ui/feed/TimelineItem.js +27 -0
- package/dist/ui/font-themes.js +36 -0
- package/dist/{theme → ui}/layouts/BaseLayout.js +34 -2
- package/dist/{theme → ui}/layouts/DashLayout.js +0 -8
- package/dist/ui/layouts/SiteLayout.js +169 -0
- package/dist/{themes/threads → ui}/pages/ArchivePage.js +16 -14
- package/dist/{themes/threads → ui}/pages/CollectionPage.js +6 -1
- package/dist/ui/pages/CollectionsPage.js +76 -0
- package/dist/ui/pages/FeaturedPage.js +24 -0
- package/dist/ui/pages/HomePage.js +24 -0
- package/dist/{themes/threads → ui}/pages/PostPage.js +13 -8
- package/dist/{themes/threads → ui}/pages/SearchPage.js +9 -7
- package/dist/{themes/threads → ui}/pages/SinglePage.js +3 -2
- package/dist/{theme/components → ui/shared}/MediaGallery.js +1 -1
- package/dist/{theme/components → ui/shared}/Pagination.js +41 -2
- package/dist/{theme/components → ui/shared}/ThreadView.js +2 -2
- package/dist/ui/shared/index.js +5 -0
- package/package.json +1 -9
- package/src/__tests__/helpers/db.ts +3 -0
- package/src/app.tsx +131 -561
- package/src/client.ts +1 -0
- package/src/db/migrations/0006_rename_slug_to_path.sql +5 -0
- package/src/db/migrations/meta/_journal.json +7 -0
- package/src/db/schema.ts +1 -1
- package/src/i18n/locales/en.po +477 -261
- package/src/i18n/locales/en.ts +1 -1
- package/src/i18n/locales/zh-Hans.po +477 -261
- package/src/i18n/locales/zh-Hans.ts +1 -1
- package/src/i18n/locales/zh-Hant.po +477 -261
- package/src/i18n/locales/zh-Hant.ts +1 -1
- package/src/index.ts +7 -36
- package/src/lib/__tests__/config.test.ts +192 -0
- package/src/lib/__tests__/favicon.test.ts +151 -0
- package/src/lib/__tests__/image.test.ts +2 -6
- package/src/lib/__tests__/schemas.test.ts +60 -19
- package/src/lib/__tests__/timeline.test.ts +45 -81
- package/src/lib/__tests__/timezones.test.ts +61 -0
- package/src/lib/__tests__/view.test.ts +15 -9
- package/src/lib/avatar-upload.ts +165 -0
- package/src/lib/config.ts +47 -0
- package/src/lib/constants.ts +19 -10
- package/src/lib/favicon.ts +115 -0
- package/src/lib/image.ts +13 -21
- package/src/lib/media-helpers.ts +2 -2
- package/src/lib/nav-reorder.ts +1 -1
- package/src/lib/navigation.ts +73 -4
- package/src/lib/pagination.ts +50 -0
- package/src/lib/render.tsx +22 -15
- package/src/lib/schemas.ts +47 -6
- package/src/lib/theme.ts +5 -5
- package/src/lib/timeline.ts +28 -57
- package/src/lib/timezones.ts +325 -0
- package/src/lib/view.ts +3 -3
- package/src/preset.css +2 -1
- package/src/routes/__tests__/compose.test.ts +199 -0
- package/src/routes/api/__tests__/collections.test.ts +249 -0
- package/src/routes/api/__tests__/nav-items.test.ts +222 -0
- package/src/routes/api/__tests__/pages.test.ts +218 -0
- package/src/routes/api/__tests__/settings.test.ts +132 -0
- package/src/routes/api/collections.ts +143 -0
- package/src/routes/api/nav-items.ts +115 -0
- package/src/routes/api/pages.ts +101 -0
- package/src/routes/api/posts.ts +3 -3
- package/src/routes/api/search.ts +2 -2
- package/src/routes/api/settings.ts +91 -0
- package/src/routes/api/upload.ts +2 -3
- package/src/routes/auth/reset.tsx +239 -0
- package/src/routes/auth/setup.tsx +189 -0
- package/src/routes/auth/signin.tsx +163 -0
- package/src/routes/compose.ts +63 -0
- package/src/routes/dash/__tests__/pages.test.ts +225 -0
- package/src/routes/dash/__tests__/settings-avatar.test.ts +89 -0
- package/src/routes/dash/collections.tsx +18 -367
- package/src/routes/dash/index.tsx +1 -1
- package/src/routes/dash/media.tsx +13 -415
- package/src/routes/dash/pages.tsx +131 -98
- package/src/routes/dash/posts.tsx +3 -7
- package/src/routes/dash/redirects.tsx +22 -16
- package/src/routes/dash/settings.tsx +265 -478
- package/src/routes/feed/__tests__/rss.test.ts +141 -0
- package/src/routes/feed/rss.ts +5 -3
- package/src/routes/feed/sitemap.ts +5 -3
- package/src/routes/pages/__tests__/collections.test.ts +94 -0
- package/src/routes/pages/__tests__/featured.test.ts +94 -0
- package/src/routes/pages/archive.tsx +2 -6
- package/src/routes/pages/collection.tsx +2 -6
- package/src/routes/pages/collections.tsx +36 -0
- package/src/routes/pages/featured.tsx +44 -0
- package/src/routes/pages/home.tsx +30 -53
- package/src/routes/pages/latest.tsx +59 -0
- package/src/routes/pages/page.tsx +28 -30
- package/src/routes/pages/post.tsx +2 -5
- package/src/routes/pages/search.tsx +2 -6
- package/src/services/__tests__/page.test.ts +106 -0
- package/src/services/__tests__/post.test.ts +114 -15
- package/src/services/page.ts +13 -1
- package/src/services/post.ts +58 -40
- package/src/services/search.ts +2 -2
- package/src/styles/components.css +0 -65
- package/src/styles/tokens.css +47 -0
- package/src/styles/ui.css +475 -0
- package/src/types/bindings.ts +30 -0
- package/src/types/config.ts +183 -0
- package/src/types/constants.ts +26 -0
- package/src/types/entities.ts +109 -0
- package/src/types/operations.ts +88 -0
- package/src/types/props.ts +115 -0
- package/src/types/views.ts +172 -0
- package/src/types.ts +8 -774
- package/src/ui/__tests__/font-themes.test.ts +34 -0
- package/src/{theme → ui}/color-themes.ts +34 -34
- package/src/ui/compose/ComposeDialog.tsx +414 -0
- package/src/ui/compose/ComposePrompt.tsx +55 -0
- package/src/{theme/components/TypeBadge.tsx → ui/dash/FormatBadge.tsx} +2 -3
- package/src/{theme/components → ui/dash}/PageForm.tsx +25 -19
- package/src/{theme/components → ui/dash}/PostForm.tsx +26 -45
- package/src/{theme/components → ui/dash}/PostList.tsx +7 -7
- package/src/{theme/components/VisibilityBadge.tsx → ui/dash/StatusBadge.tsx} +2 -3
- package/src/ui/dash/collections/CollectionForm.tsx +153 -0
- package/src/ui/dash/collections/CollectionsListContent.tsx +85 -0
- package/src/ui/dash/collections/ViewCollectionContent.tsx +92 -0
- package/src/ui/dash/index.ts +10 -0
- package/src/ui/dash/media/MediaListContent.tsx +201 -0
- package/src/ui/dash/media/ViewMediaContent.tsx +208 -0
- package/src/ui/dash/pages/LinkFormContent.tsx +119 -0
- package/src/ui/dash/pages/UnifiedPagesContent.tsx +203 -0
- package/src/ui/dash/settings/AccountContent.tsx +176 -0
- package/src/ui/dash/settings/AppearanceContent.tsx +254 -0
- package/src/ui/dash/settings/GeneralContent.tsx +533 -0
- package/src/ui/dash/settings/SettingsNav.tsx +56 -0
- package/src/{themes/threads/timeline → ui/feed}/LinkCard.tsx +9 -4
- package/src/{themes/threads/timeline → ui/feed}/NoteCard.tsx +13 -8
- package/src/{themes/threads/timeline → ui/feed}/QuoteCard.tsx +13 -8
- package/src/{themes/threads/timeline → ui/feed}/ThreadPreview.tsx +7 -8
- package/src/ui/feed/TimelineFeed.tsx +49 -0
- package/src/ui/feed/TimelineItem.tsx +45 -0
- package/src/ui/font-themes.ts +54 -0
- package/src/{theme → ui}/layouts/BaseLayout.tsx +28 -1
- package/src/{theme → ui}/layouts/DashLayout.tsx +0 -10
- package/src/ui/layouts/SiteLayout.tsx +164 -0
- package/src/{themes/threads → ui}/pages/ArchivePage.tsx +22 -17
- package/src/{themes/threads → ui}/pages/CollectionPage.tsx +14 -5
- package/src/ui/pages/CollectionsPage.tsx +73 -0
- package/src/ui/pages/FeaturedPage.tsx +31 -0
- package/src/{themes/threads → ui}/pages/HomePage.tsx +11 -15
- package/src/{themes/threads → ui}/pages/PostPage.tsx +23 -14
- package/src/{themes/threads → ui}/pages/SearchPage.tsx +13 -11
- package/src/{themes/threads → ui}/pages/SinglePage.tsx +4 -4
- package/src/{theme/components → ui/shared}/MediaGallery.tsx +1 -1
- package/src/{theme/components → ui/shared}/Pagination.tsx +67 -4
- package/src/{theme/components → ui/shared}/ThreadView.tsx +2 -2
- package/src/ui/shared/__tests__/pagination.test.ts +46 -0
- package/src/ui/shared/index.ts +12 -0
- package/bin/jant.js +0 -185
- package/dist/lib/theme-components.js +0 -46
- package/dist/routes/dash/navigation.js +0 -289
- package/dist/theme/index.js +0 -18
- package/dist/theme/layouts/index.js +0 -2
- package/dist/themes/threads/ThreadsSiteLayout.js +0 -172
- package/dist/themes/threads/index.js +0 -81
- package/dist/themes/threads/pages/HomePage.js +0 -25
- package/dist/themes/threads/timeline/TimelineFeed.js +0 -58
- package/dist/themes/threads/timeline/TimelineItem.js +0 -36
- package/dist/themes/threads/timeline/TimelineLoadMore.js +0 -23
- package/dist/themes/threads/timeline/groupByDate.js +0 -22
- package/dist/themes/threads/timeline/timelineMore.js +0 -107
- package/src/lib/__tests__/theme-components.test.ts +0 -105
- package/src/lib/theme-components.ts +0 -65
- package/src/routes/dash/navigation.tsx +0 -317
- package/src/theme/components/index.ts +0 -23
- package/src/theme/index.ts +0 -22
- package/src/theme/layouts/index.ts +0 -7
- package/src/themes/threads/ThreadsSiteLayout.tsx +0 -194
- package/src/themes/threads/index.ts +0 -100
- package/src/themes/threads/style.css +0 -336
- package/src/themes/threads/timeline/TimelineFeed.tsx +0 -62
- package/src/themes/threads/timeline/TimelineItem.tsx +0 -67
- package/src/themes/threads/timeline/TimelineLoadMore.tsx +0 -35
- package/src/themes/threads/timeline/groupByDate.ts +0 -30
- package/src/themes/threads/timeline/timelineMore.tsx +0 -130
- /package/dist/{theme/components → ui/dash}/ActionButtons.js +0 -0
- /package/dist/{theme/components → ui/dash}/CrudPageHeader.js +0 -0
- /package/dist/{theme/components → ui/dash}/DangerZone.js +0 -0
- /package/dist/{theme/components → ui/dash}/ListItemRow.js +0 -0
- /package/dist/{theme/components → ui/shared}/EmptyState.js +0 -0
- /package/src/{theme/components → ui/dash}/ActionButtons.tsx +0 -0
- /package/src/{theme/components → ui/dash}/CrudPageHeader.tsx +0 -0
- /package/src/{theme/components → ui/dash}/DangerZone.tsx +0 -0
- /package/src/{theme/components → ui/dash}/ListItemRow.tsx +0 -0
- /package/src/{theme/components → ui/shared}/EmptyState.tsx +0 -0
|
@@ -1,395 +1,18 @@
|
|
|
1
|
-
import { jsx as _jsx,
|
|
2
|
-
import { getSiteName } from "../../lib/config.js";
|
|
1
|
+
import { jsx as _jsx, Fragment as _Fragment } from "hono/jsx/jsx-runtime";
|
|
3
2
|
/**
|
|
4
3
|
* Dashboard Media Routes
|
|
5
|
-
*
|
|
6
|
-
* Media management with Datastar-powered uploads.
|
|
7
|
-
* Uses SSE for real-time UI updates without page reloads.
|
|
8
4
|
*/ import { Hono } from "hono";
|
|
9
|
-
import {
|
|
10
|
-
import { DashLayout } from "../../theme/layouts/index.js";
|
|
11
|
-
import { EmptyState, DangerZone } from "../../theme/components/index.js";
|
|
12
|
-
import * as time from "../../lib/time.js";
|
|
13
|
-
import { getMediaUrl, getImageUrl, getPublicUrlForProvider } from "../../lib/image.js";
|
|
5
|
+
import { DashLayout } from "../../ui/layouts/DashLayout.js";
|
|
14
6
|
import { dsRedirect } from "../../lib/sse.js";
|
|
7
|
+
import { getSiteName } from "../../lib/config.js";
|
|
8
|
+
import { getMediaUrl, getImageUrl, getPublicUrlForProvider } from "../../lib/image.js";
|
|
9
|
+
import { MediaListContent } from "../../ui/dash/media/MediaListContent.js";
|
|
10
|
+
import { ViewMediaContent } from "../../ui/dash/media/ViewMediaContent.js";
|
|
15
11
|
export const mediaRoutes = new Hono();
|
|
16
|
-
/**
|
|
17
|
-
* Format file size for display
|
|
18
|
-
*/ function formatSize(bytes) {
|
|
19
|
-
if (bytes < 1024) return `${bytes} B`;
|
|
20
|
-
if (bytes < 1024 * 1024) return `${(bytes / 1024).toFixed(1)} KB`;
|
|
21
|
-
return `${(bytes / (1024 * 1024)).toFixed(1)} MB`;
|
|
22
|
-
}
|
|
23
|
-
/**
|
|
24
|
-
* Media card component for the grid
|
|
25
|
-
*/ function MediaCard({ media, r2PublicUrl, imageTransformUrl, s3PublicUrl }) {
|
|
26
|
-
const publicUrl = getPublicUrlForProvider(media.provider, r2PublicUrl, s3PublicUrl);
|
|
27
|
-
const fullUrl = getMediaUrl(media.id, media.storageKey, publicUrl);
|
|
28
|
-
const thumbnailUrl = getImageUrl(fullUrl, imageTransformUrl, {
|
|
29
|
-
width: 300,
|
|
30
|
-
quality: 80,
|
|
31
|
-
format: "auto",
|
|
32
|
-
fit: "cover"
|
|
33
|
-
});
|
|
34
|
-
const isImage = media.mimeType.startsWith("image/");
|
|
35
|
-
return /*#__PURE__*/ _jsxs("div", {
|
|
36
|
-
class: "group relative",
|
|
37
|
-
"data-media-id": media.id,
|
|
38
|
-
children: [
|
|
39
|
-
isImage ? /*#__PURE__*/ _jsx("button", {
|
|
40
|
-
type: "button",
|
|
41
|
-
class: "block w-full aspect-square bg-muted rounded-lg overflow-hidden border hover:border-primary cursor-pointer",
|
|
42
|
-
onclick: `document.getElementById('lightbox-img').src = '${fullUrl}'; document.getElementById('lightbox').showModal()`,
|
|
43
|
-
children: /*#__PURE__*/ _jsx("img", {
|
|
44
|
-
src: thumbnailUrl,
|
|
45
|
-
alt: media.alt || media.originalName,
|
|
46
|
-
class: "w-full h-full object-cover",
|
|
47
|
-
loading: "lazy"
|
|
48
|
-
})
|
|
49
|
-
}) : /*#__PURE__*/ _jsx("a", {
|
|
50
|
-
href: `/dash/media/${media.id}`,
|
|
51
|
-
class: "block aspect-square bg-muted rounded-lg overflow-hidden border hover:border-primary",
|
|
52
|
-
children: /*#__PURE__*/ _jsx("div", {
|
|
53
|
-
class: "w-full h-full flex items-center justify-center text-muted-foreground",
|
|
54
|
-
children: /*#__PURE__*/ _jsx("span", {
|
|
55
|
-
class: "text-xs",
|
|
56
|
-
children: media.mimeType
|
|
57
|
-
})
|
|
58
|
-
})
|
|
59
|
-
}),
|
|
60
|
-
/*#__PURE__*/ _jsx("a", {
|
|
61
|
-
href: `/dash/media/${media.id}`,
|
|
62
|
-
class: "block mt-2 text-xs truncate hover:underline",
|
|
63
|
-
title: media.originalName,
|
|
64
|
-
children: media.originalName
|
|
65
|
-
}),
|
|
66
|
-
/*#__PURE__*/ _jsx("div", {
|
|
67
|
-
class: "text-xs text-muted-foreground",
|
|
68
|
-
children: formatSize(media.size)
|
|
69
|
-
})
|
|
70
|
-
]
|
|
71
|
-
});
|
|
72
|
-
}
|
|
73
|
-
/**
|
|
74
|
-
* Media list page content
|
|
75
|
-
*
|
|
76
|
-
* Upload is handled by media-upload.ts (client module) + Datastar @post for SSE.
|
|
77
|
-
*/ function MediaListContent({ mediaList, r2PublicUrl, imageTransformUrl, s3PublicUrl }) {
|
|
78
|
-
const { i18n: $__i18n, _: $__ } = $_useLingui();
|
|
79
|
-
const processingText = $__i18n._({
|
|
80
|
-
id: "k1ifdL",
|
|
81
|
-
message: "Processing..."
|
|
82
|
-
});
|
|
83
|
-
const uploadingText = $__i18n._({
|
|
84
|
-
id: "GxkJXS",
|
|
85
|
-
message: "Uploading..."
|
|
86
|
-
});
|
|
87
|
-
const uploadText = $__i18n._({
|
|
88
|
-
id: "ONWvwQ",
|
|
89
|
-
message: "Upload"
|
|
90
|
-
});
|
|
91
|
-
const errorText = $__i18n._({
|
|
92
|
-
id: "pZq3aX",
|
|
93
|
-
message: "Upload failed. Please try again."
|
|
94
|
-
});
|
|
95
|
-
return /*#__PURE__*/ _jsxs(_Fragment, {
|
|
96
|
-
children: [
|
|
97
|
-
/*#__PURE__*/ _jsx("form", {
|
|
98
|
-
id: "upload-form",
|
|
99
|
-
class: "hidden",
|
|
100
|
-
enctype: "multipart/form-data",
|
|
101
|
-
"data-on:submit__prevent": "@post('/api/upload', {contentType: 'form'})",
|
|
102
|
-
children: /*#__PURE__*/ _jsx("input", {
|
|
103
|
-
id: "upload-file-input",
|
|
104
|
-
type: "file",
|
|
105
|
-
name: "file"
|
|
106
|
-
})
|
|
107
|
-
}),
|
|
108
|
-
/*#__PURE__*/ _jsxs("div", {
|
|
109
|
-
class: "flex items-center justify-between mb-6",
|
|
110
|
-
children: [
|
|
111
|
-
/*#__PURE__*/ _jsx("h1", {
|
|
112
|
-
class: "text-2xl font-semibold",
|
|
113
|
-
children: $__i18n._({
|
|
114
|
-
id: "xYilR2",
|
|
115
|
-
message: "Media"
|
|
116
|
-
})
|
|
117
|
-
}),
|
|
118
|
-
/*#__PURE__*/ _jsxs("label", {
|
|
119
|
-
class: "btn cursor-pointer",
|
|
120
|
-
children: [
|
|
121
|
-
/*#__PURE__*/ _jsx("span", {
|
|
122
|
-
children: uploadText
|
|
123
|
-
}),
|
|
124
|
-
/*#__PURE__*/ _jsx("input", {
|
|
125
|
-
type: "file",
|
|
126
|
-
class: "hidden",
|
|
127
|
-
accept: "image/*",
|
|
128
|
-
"data-media-upload": true,
|
|
129
|
-
"data-text-processing": processingText,
|
|
130
|
-
"data-text-uploading": uploadingText,
|
|
131
|
-
"data-text-error": errorText
|
|
132
|
-
})
|
|
133
|
-
]
|
|
134
|
-
})
|
|
135
|
-
]
|
|
136
|
-
}),
|
|
137
|
-
/*#__PURE__*/ _jsx("div", {
|
|
138
|
-
class: "card mb-6",
|
|
139
|
-
children: /*#__PURE__*/ _jsx("section", {
|
|
140
|
-
class: "text-sm text-muted-foreground",
|
|
141
|
-
children: /*#__PURE__*/ _jsx("p", {
|
|
142
|
-
children: $__i18n._({
|
|
143
|
-
id: "x+doid",
|
|
144
|
-
message: "Images are automatically optimized: resized to max 1920px, converted to WebP, and metadata stripped."
|
|
145
|
-
})
|
|
146
|
-
})
|
|
147
|
-
})
|
|
148
|
-
}),
|
|
149
|
-
/*#__PURE__*/ _jsx("div", {
|
|
150
|
-
id: "media-content",
|
|
151
|
-
children: mediaList.length === 0 ? /*#__PURE__*/ _jsx("div", {
|
|
152
|
-
id: "empty-state",
|
|
153
|
-
children: /*#__PURE__*/ _jsx(EmptyState, {
|
|
154
|
-
message: $__i18n._({
|
|
155
|
-
id: "ST+lN2",
|
|
156
|
-
message: "No media uploaded yet."
|
|
157
|
-
})
|
|
158
|
-
})
|
|
159
|
-
}) : /*#__PURE__*/ _jsx("div", {
|
|
160
|
-
id: "media-grid",
|
|
161
|
-
class: "grid grid-cols-2 sm:grid-cols-3 md:grid-cols-4 lg:grid-cols-5 gap-4",
|
|
162
|
-
children: mediaList.map((m)=>/*#__PURE__*/ _jsx(MediaCard, {
|
|
163
|
-
media: m,
|
|
164
|
-
r2PublicUrl: r2PublicUrl,
|
|
165
|
-
imageTransformUrl: imageTransformUrl,
|
|
166
|
-
s3PublicUrl: s3PublicUrl
|
|
167
|
-
}, m.id))
|
|
168
|
-
})
|
|
169
|
-
}),
|
|
170
|
-
/*#__PURE__*/ _jsx("dialog", {
|
|
171
|
-
id: "lightbox",
|
|
172
|
-
class: "p-0 m-auto bg-transparent backdrop:bg-black/80",
|
|
173
|
-
onclick: "event.target === this && this.close()",
|
|
174
|
-
children: /*#__PURE__*/ _jsx("img", {
|
|
175
|
-
id: "lightbox-img",
|
|
176
|
-
src: "",
|
|
177
|
-
alt: "",
|
|
178
|
-
class: "max-w-[90vw] max-h-[90vh] object-contain rounded-lg"
|
|
179
|
-
})
|
|
180
|
-
})
|
|
181
|
-
]
|
|
182
|
-
});
|
|
183
|
-
}
|
|
184
|
-
/**
|
|
185
|
-
* View single media content
|
|
186
|
-
*/ function ViewMediaContent({ media, r2PublicUrl, imageTransformUrl, s3PublicUrl }) {
|
|
187
|
-
const { i18n: $__i18n, _: $__ } = $_useLingui();
|
|
188
|
-
const publicUrl = getPublicUrlForProvider(media.provider, r2PublicUrl, s3PublicUrl);
|
|
189
|
-
const url = getMediaUrl(media.id, media.storageKey, publicUrl);
|
|
190
|
-
const thumbnailUrl = getImageUrl(url, imageTransformUrl, {
|
|
191
|
-
width: 600,
|
|
192
|
-
quality: 85,
|
|
193
|
-
format: "auto"
|
|
194
|
-
});
|
|
195
|
-
const isImage = media.mimeType.startsWith("image/");
|
|
196
|
-
return /*#__PURE__*/ _jsxs(_Fragment, {
|
|
197
|
-
children: [
|
|
198
|
-
/*#__PURE__*/ _jsxs("div", {
|
|
199
|
-
class: "flex items-center justify-between mb-6",
|
|
200
|
-
children: [
|
|
201
|
-
/*#__PURE__*/ _jsxs("div", {
|
|
202
|
-
children: [
|
|
203
|
-
/*#__PURE__*/ _jsx("h1", {
|
|
204
|
-
class: "text-2xl font-semibold",
|
|
205
|
-
children: media.originalName
|
|
206
|
-
}),
|
|
207
|
-
/*#__PURE__*/ _jsxs("p", {
|
|
208
|
-
class: "text-muted-foreground mt-1",
|
|
209
|
-
children: [
|
|
210
|
-
formatSize(media.size),
|
|
211
|
-
" · ",
|
|
212
|
-
media.mimeType,
|
|
213
|
-
" ·",
|
|
214
|
-
" ",
|
|
215
|
-
time.formatDate(media.createdAt)
|
|
216
|
-
]
|
|
217
|
-
})
|
|
218
|
-
]
|
|
219
|
-
}),
|
|
220
|
-
/*#__PURE__*/ _jsx("a", {
|
|
221
|
-
href: "/dash/media",
|
|
222
|
-
class: "btn-outline",
|
|
223
|
-
children: $__i18n._({
|
|
224
|
-
id: "iH8pgl",
|
|
225
|
-
message: "Back"
|
|
226
|
-
})
|
|
227
|
-
})
|
|
228
|
-
]
|
|
229
|
-
}),
|
|
230
|
-
/*#__PURE__*/ _jsxs("div", {
|
|
231
|
-
class: "grid gap-6 md:grid-cols-2",
|
|
232
|
-
children: [
|
|
233
|
-
/*#__PURE__*/ _jsxs("div", {
|
|
234
|
-
class: "card",
|
|
235
|
-
children: [
|
|
236
|
-
/*#__PURE__*/ _jsx("header", {
|
|
237
|
-
children: /*#__PURE__*/ _jsx("h2", {
|
|
238
|
-
children: $__i18n._({
|
|
239
|
-
id: "rdUucN",
|
|
240
|
-
message: "Preview"
|
|
241
|
-
})
|
|
242
|
-
})
|
|
243
|
-
}),
|
|
244
|
-
/*#__PURE__*/ _jsx("section", {
|
|
245
|
-
children: isImage ? /*#__PURE__*/ _jsxs(_Fragment, {
|
|
246
|
-
children: [
|
|
247
|
-
/*#__PURE__*/ _jsx("button", {
|
|
248
|
-
type: "button",
|
|
249
|
-
class: "cursor-pointer",
|
|
250
|
-
onclick: `document.getElementById('lightbox-img').src = '${url}'; document.getElementById('lightbox').showModal()`,
|
|
251
|
-
children: /*#__PURE__*/ _jsx("img", {
|
|
252
|
-
src: thumbnailUrl,
|
|
253
|
-
alt: media.alt || media.originalName,
|
|
254
|
-
class: "max-w-full rounded-lg hover:opacity-90 transition-opacity"
|
|
255
|
-
})
|
|
256
|
-
}),
|
|
257
|
-
/*#__PURE__*/ _jsx("p", {
|
|
258
|
-
class: "text-xs text-muted-foreground mt-2",
|
|
259
|
-
children: $__i18n._({
|
|
260
|
-
id: "M1RvTd",
|
|
261
|
-
message: "Click image to view full size"
|
|
262
|
-
})
|
|
263
|
-
})
|
|
264
|
-
]
|
|
265
|
-
}) : /*#__PURE__*/ _jsx("div", {
|
|
266
|
-
class: "aspect-video bg-muted rounded-lg flex items-center justify-center text-muted-foreground",
|
|
267
|
-
children: /*#__PURE__*/ _jsx("span", {
|
|
268
|
-
children: media.mimeType
|
|
269
|
-
})
|
|
270
|
-
})
|
|
271
|
-
})
|
|
272
|
-
]
|
|
273
|
-
}),
|
|
274
|
-
/*#__PURE__*/ _jsxs("div", {
|
|
275
|
-
class: "space-y-6",
|
|
276
|
-
children: [
|
|
277
|
-
/*#__PURE__*/ _jsxs("div", {
|
|
278
|
-
class: "card",
|
|
279
|
-
children: [
|
|
280
|
-
/*#__PURE__*/ _jsx("header", {
|
|
281
|
-
children: /*#__PURE__*/ _jsx("h2", {
|
|
282
|
-
children: $__i18n._({
|
|
283
|
-
id: "IagCbF",
|
|
284
|
-
message: "URL"
|
|
285
|
-
})
|
|
286
|
-
})
|
|
287
|
-
}),
|
|
288
|
-
/*#__PURE__*/ _jsxs("section", {
|
|
289
|
-
children: [
|
|
290
|
-
/*#__PURE__*/ _jsxs("div", {
|
|
291
|
-
class: "flex items-center gap-2",
|
|
292
|
-
children: [
|
|
293
|
-
/*#__PURE__*/ _jsx("input", {
|
|
294
|
-
type: "text",
|
|
295
|
-
class: "input flex-1 font-mono text-sm",
|
|
296
|
-
value: url,
|
|
297
|
-
readonly: true
|
|
298
|
-
}),
|
|
299
|
-
/*#__PURE__*/ _jsx("button", {
|
|
300
|
-
type: "button",
|
|
301
|
-
class: "btn-outline",
|
|
302
|
-
onclick: `navigator.clipboard.writeText('${url}')`,
|
|
303
|
-
children: $__i18n._({
|
|
304
|
-
id: "he3ygx",
|
|
305
|
-
message: "Copy"
|
|
306
|
-
})
|
|
307
|
-
})
|
|
308
|
-
]
|
|
309
|
-
}),
|
|
310
|
-
/*#__PURE__*/ _jsx("p", {
|
|
311
|
-
class: "text-xs text-muted-foreground mt-2",
|
|
312
|
-
children: $__i18n._({
|
|
313
|
-
id: "K9NcLu",
|
|
314
|
-
message: "Use this URL to embed the media in your posts."
|
|
315
|
-
})
|
|
316
|
-
})
|
|
317
|
-
]
|
|
318
|
-
})
|
|
319
|
-
]
|
|
320
|
-
}),
|
|
321
|
-
/*#__PURE__*/ _jsxs("div", {
|
|
322
|
-
class: "card",
|
|
323
|
-
children: [
|
|
324
|
-
/*#__PURE__*/ _jsx("header", {
|
|
325
|
-
children: /*#__PURE__*/ _jsx("h2", {
|
|
326
|
-
children: $__i18n._({
|
|
327
|
-
id: "u6Hp4N",
|
|
328
|
-
message: "Markdown"
|
|
329
|
-
})
|
|
330
|
-
})
|
|
331
|
-
}),
|
|
332
|
-
/*#__PURE__*/ _jsx("section", {
|
|
333
|
-
children: /*#__PURE__*/ _jsxs("div", {
|
|
334
|
-
class: "flex items-center gap-2",
|
|
335
|
-
children: [
|
|
336
|
-
/*#__PURE__*/ _jsx("input", {
|
|
337
|
-
type: "text",
|
|
338
|
-
class: "input flex-1 font-mono text-sm",
|
|
339
|
-
value: ``,
|
|
340
|
-
readonly: true
|
|
341
|
-
}),
|
|
342
|
-
/*#__PURE__*/ _jsx("button", {
|
|
343
|
-
type: "button",
|
|
344
|
-
class: "btn-outline",
|
|
345
|
-
onclick: `navigator.clipboard.writeText('')`,
|
|
346
|
-
children: $__i18n._({
|
|
347
|
-
id: "he3ygx",
|
|
348
|
-
message: "Copy"
|
|
349
|
-
})
|
|
350
|
-
})
|
|
351
|
-
]
|
|
352
|
-
})
|
|
353
|
-
})
|
|
354
|
-
]
|
|
355
|
-
}),
|
|
356
|
-
/*#__PURE__*/ _jsx(DangerZone, {
|
|
357
|
-
actionLabel: $__i18n._({
|
|
358
|
-
id: "wM5UXj",
|
|
359
|
-
message: "Delete Media"
|
|
360
|
-
}),
|
|
361
|
-
formAction: `/dash/media/${media.id}/delete`,
|
|
362
|
-
confirmMessage: "Are you sure you want to delete this media?",
|
|
363
|
-
description: $__i18n._({
|
|
364
|
-
id: "E80cJw",
|
|
365
|
-
message: "Deleting this media will remove it permanently from storage."
|
|
366
|
-
})
|
|
367
|
-
})
|
|
368
|
-
]
|
|
369
|
-
})
|
|
370
|
-
]
|
|
371
|
-
}),
|
|
372
|
-
isImage && /*#__PURE__*/ _jsx("dialog", {
|
|
373
|
-
id: "lightbox",
|
|
374
|
-
class: "p-0 m-auto bg-transparent backdrop:bg-black/80",
|
|
375
|
-
onclick: "event.target === this && this.close()",
|
|
376
|
-
children: /*#__PURE__*/ _jsx("img", {
|
|
377
|
-
id: "lightbox-img",
|
|
378
|
-
src: "",
|
|
379
|
-
alt: "",
|
|
380
|
-
class: "max-w-[90vw] max-h-[90vh] object-contain rounded-lg"
|
|
381
|
-
})
|
|
382
|
-
})
|
|
383
|
-
]
|
|
384
|
-
});
|
|
385
|
-
}
|
|
386
12
|
// List media
|
|
387
13
|
mediaRoutes.get("/", async (c)=>{
|
|
388
14
|
const mediaList = await c.var.services.media.list(100);
|
|
389
15
|
const siteName = await getSiteName(c);
|
|
390
|
-
const r2PublicUrl = c.env.R2_PUBLIC_URL;
|
|
391
|
-
const imageTransformUrl = c.env.IMAGE_TRANSFORM_URL;
|
|
392
|
-
const s3PublicUrl = c.env.S3_PUBLIC_URL;
|
|
393
16
|
return c.html(/*#__PURE__*/ _jsx(DashLayout, {
|
|
394
17
|
c: c,
|
|
395
18
|
title: "Media",
|
|
@@ -397,9 +20,9 @@ mediaRoutes.get("/", async (c)=>{
|
|
|
397
20
|
currentPath: "/dash/media",
|
|
398
21
|
children: /*#__PURE__*/ _jsx(MediaListContent, {
|
|
399
22
|
mediaList: mediaList,
|
|
400
|
-
r2PublicUrl:
|
|
401
|
-
imageTransformUrl:
|
|
402
|
-
s3PublicUrl:
|
|
23
|
+
r2PublicUrl: c.env.R2_PUBLIC_URL,
|
|
24
|
+
imageTransformUrl: c.env.IMAGE_TRANSFORM_URL,
|
|
25
|
+
s3PublicUrl: c.env.S3_PUBLIC_URL
|
|
403
26
|
})
|
|
404
27
|
}));
|
|
405
28
|
});
|
|
@@ -419,7 +42,7 @@ mediaRoutes.get("/picker", async (c)=>{
|
|
|
419
42
|
return c.html(/*#__PURE__*/ _jsx(_Fragment, {
|
|
420
43
|
children: mediaList.filter((m)=>m.mimeType.startsWith("image/")).map((m)=>{
|
|
421
44
|
const pUrl = getPublicUrlForProvider(m.provider, r2PublicUrl, s3PublicUrl);
|
|
422
|
-
const url = getMediaUrl(m.
|
|
45
|
+
const url = getMediaUrl(m.storageKey, pUrl);
|
|
423
46
|
const thumbUrl = getImageUrl(url, imageTransformUrl, {
|
|
424
47
|
width: 150,
|
|
425
48
|
quality: 80,
|
|
@@ -449,9 +72,6 @@ mediaRoutes.get("/:id", async (c)=>{
|
|
|
449
72
|
const media = await c.var.services.media.getById(id);
|
|
450
73
|
if (!media) return c.notFound();
|
|
451
74
|
const siteName = await getSiteName(c);
|
|
452
|
-
const r2PublicUrl = c.env.R2_PUBLIC_URL;
|
|
453
|
-
const imageTransformUrl = c.env.IMAGE_TRANSFORM_URL;
|
|
454
|
-
const s3PublicUrl = c.env.S3_PUBLIC_URL;
|
|
455
75
|
return c.html(/*#__PURE__*/ _jsx(DashLayout, {
|
|
456
76
|
c: c,
|
|
457
77
|
title: media.originalName,
|
|
@@ -459,9 +79,9 @@ mediaRoutes.get("/:id", async (c)=>{
|
|
|
459
79
|
currentPath: "/dash/media",
|
|
460
80
|
children: /*#__PURE__*/ _jsx(ViewMediaContent, {
|
|
461
81
|
media: media,
|
|
462
|
-
r2PublicUrl:
|
|
463
|
-
imageTransformUrl:
|
|
464
|
-
s3PublicUrl:
|
|
82
|
+
r2PublicUrl: c.env.R2_PUBLIC_URL,
|
|
83
|
+
imageTransformUrl: c.env.IMAGE_TRANSFORM_URL,
|
|
84
|
+
s3PublicUrl: c.env.S3_PUBLIC_URL
|
|
465
85
|
})
|
|
466
86
|
}));
|
|
467
87
|
});
|