@jant/core 0.3.25 → 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 +67 -562
- package/dist/client.js +1 -0
- 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/lib/avatar-upload.js +134 -0
- package/dist/lib/config.js +39 -0
- package/dist/lib/constants.js +10 -10
- 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/navigation.js +23 -3
- package/dist/lib/render.js +10 -1
- package/dist/lib/schemas.js +31 -0
- package/dist/lib/timezones.js +388 -0
- package/dist/lib/view.js +1 -1
- package/dist/routes/api/posts.js +1 -1
- 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/dash/collections.js +23 -415
- package/dist/routes/dash/media.js +12 -392
- package/dist/routes/dash/pages.js +7 -330
- package/dist/routes/dash/redirects.js +18 -12
- package/dist/routes/dash/settings.js +198 -577
- package/dist/routes/feed/rss.js +2 -1
- package/dist/routes/feed/sitemap.js +4 -2
- package/dist/routes/pages/featured.js +5 -1
- package/dist/routes/pages/home.js +26 -1
- package/dist/routes/pages/latest.js +45 -0
- package/dist/services/post.js +30 -50
- 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/ui/color-themes.js +33 -33
- package/dist/ui/compose/ComposeDialog.js +36 -21
- package/dist/ui/dash/PageForm.js +21 -15
- package/dist/ui/dash/PostForm.js +22 -16
- 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/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/ui/font-themes.js +36 -0
- package/dist/ui/layouts/BaseLayout.js +24 -2
- package/dist/ui/layouts/SiteLayout.js +47 -19
- package/package.json +1 -1
- package/src/app.tsx +93 -553
- package/src/client.ts +1 -0
- package/src/i18n/locales/en.po +240 -175
- package/src/i18n/locales/en.ts +1 -1
- package/src/i18n/locales/zh-Hans.po +240 -175
- package/src/i18n/locales/zh-Hans.ts +1 -1
- package/src/i18n/locales/zh-Hant.po +240 -175
- package/src/i18n/locales/zh-Hant.ts +1 -1
- 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__/timezones.test.ts +61 -0
- package/src/lib/__tests__/view.test.ts +2 -2
- package/src/lib/avatar-upload.ts +165 -0
- package/src/lib/config.ts +47 -0
- package/src/lib/constants.ts +19 -11
- 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/navigation.ts +33 -2
- package/src/lib/render.tsx +15 -1
- package/src/lib/schemas.ts +39 -0
- package/src/lib/timezones.ts +325 -0
- package/src/lib/view.ts +1 -1
- package/src/routes/api/posts.ts +1 -1
- 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/dash/__tests__/settings-avatar.test.ts +89 -0
- package/src/routes/dash/collections.tsx +17 -366
- package/src/routes/dash/media.tsx +12 -414
- package/src/routes/dash/pages.tsx +8 -348
- package/src/routes/dash/redirects.tsx +20 -14
- package/src/routes/dash/settings.tsx +243 -534
- package/src/routes/feed/__tests__/rss.test.ts +141 -0
- package/src/routes/feed/rss.ts +3 -1
- package/src/routes/feed/sitemap.ts +4 -2
- package/src/routes/pages/featured.tsx +7 -1
- package/src/routes/pages/home.tsx +25 -2
- package/src/routes/pages/latest.tsx +59 -0
- package/src/services/post.ts +34 -66
- package/src/styles/components.css +0 -65
- package/src/styles/tokens.css +1 -1
- package/src/styles/ui.css +24 -40
- 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 -644
- package/src/ui/__tests__/font-themes.test.ts +34 -0
- package/src/ui/color-themes.ts +34 -34
- package/src/ui/compose/ComposeDialog.tsx +40 -21
- package/src/ui/dash/PageForm.tsx +25 -19
- package/src/ui/dash/PostForm.tsx +26 -20
- 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/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/ui/font-themes.ts +54 -0
- package/src/ui/layouts/BaseLayout.tsx +17 -0
- package/src/ui/layouts/SiteLayout.tsx +45 -31
|
@@ -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 { useLingui as $_useLingui } from "@jant/core/i18n";
|
|
10
5
|
import { DashLayout } from "../../ui/layouts/DashLayout.js";
|
|
11
|
-
import { EmptyState, DangerZone } from "../../ui/dash/index.js";
|
|
12
|
-
import * as time from "../../lib/time.js";
|
|
13
|
-
import { getMediaUrl, getImageUrl, getPublicUrlForProvider } from "../../lib/image.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
|
});
|