+71
-76
src/components/backlinks.tsx
+71
-76
src/components/backlinks.tsx
···
24
24
const Backlinks = (props: { target: string }) => {
25
25
const fetchBacklinks = async () => {
26
26
const res = await getAllBacklinks(props.target);
27
-
setBacklinks(linksBySource(res.links));
28
-
return res;
27
+
return linksBySource(res.links);
29
28
};
30
29
31
30
const [response] = createResource(fetchBacklinks);
32
-
const [backlinks, setBacklinks] = createSignal<any>();
33
31
34
32
const [show, setShow] = createSignal<{
35
33
collection: string;
···
38
36
} | null>();
39
37
40
38
return (
41
-
<Show when={response()}>
42
-
<div class="flex w-full flex-col gap-1 text-sm wrap-anywhere">
43
-
<For each={backlinks()}>
44
-
{({ collection, path, counts }) => (
39
+
<div class="flex w-full flex-col gap-1 text-sm wrap-anywhere">
40
+
<Show when={response()?.length === 0}>
41
+
<p>No backlinks found.</p>
42
+
</Show>
43
+
<For each={response()}>
44
+
{({ collection, path, counts }) => (
45
+
<div>
45
46
<div>
46
-
<div>
47
-
<div title="Collection containing linking records" class="flex items-center gap-1">
48
-
<span class="iconify lucide--book-text shrink-0"></span>
49
-
{collection}
50
-
</div>
51
-
<div title="Record path where the link is found" class="flex items-center gap-1">
52
-
<span class="iconify lucide--route shrink-0"></span>
53
-
{path.slice(1)}
54
-
</div>
47
+
<div title="Collection containing linking records" class="flex items-center gap-1">
48
+
<span class="iconify lucide--book-text shrink-0"></span>
49
+
{collection}
50
+
</div>
51
+
<div title="Record path where the link is found" class="flex items-center gap-1">
52
+
<span class="iconify lucide--route shrink-0"></span>
53
+
{path.slice(1)}
55
54
</div>
56
-
<div class="ml-4.5">
57
-
<p>
58
-
<button
59
-
class="text-blue-400 hover:underline active:underline"
60
-
title="Show linking records"
61
-
onclick={() =>
62
-
(
63
-
show()?.collection === collection &&
64
-
show()?.path === path &&
65
-
!show()?.showDids
66
-
) ?
67
-
setShow(null)
68
-
: setShow({ collection, path, showDids: false })
69
-
}
70
-
>
71
-
{counts.records} record{counts.records < 2 ? "" : "s"}
72
-
</button>
73
-
{" from "}
74
-
<button
75
-
class="text-blue-400 hover:underline active:underline"
76
-
title="Show linking DIDs"
77
-
onclick={() =>
78
-
(
79
-
show()?.collection === collection &&
80
-
show()?.path === path &&
81
-
show()?.showDids
82
-
) ?
83
-
setShow(null)
84
-
: setShow({ collection, path, showDids: true })
85
-
}
86
-
>
87
-
{counts.distinct_dids} DID
88
-
{counts.distinct_dids < 2 ? "" : "s"}
89
-
</button>
90
-
</p>
91
-
<Show when={show()?.collection === collection && show()?.path === path}>
92
-
<Show when={show()?.showDids}>
93
-
{/* putting this in the `dids` prop directly failed to re-render. idk how to solidjs. */}
94
-
<p class="w-full font-semibold">Distinct identities</p>
95
-
<BacklinkItems
96
-
target={props.target}
97
-
collection={collection}
98
-
path={path}
99
-
dids={true}
100
-
/>
101
-
</Show>
102
-
<Show when={!show()?.showDids}>
103
-
<p class="w-full font-semibold">Records</p>
104
-
<BacklinkItems
105
-
target={props.target}
106
-
collection={collection}
107
-
path={path}
108
-
dids={false}
109
-
/>
110
-
</Show>
55
+
</div>
56
+
<div class="ml-4.5">
57
+
<p>
58
+
<button
59
+
class="text-blue-400 hover:underline active:underline"
60
+
title="Show linking records"
61
+
onclick={() =>
62
+
(
63
+
show()?.collection === collection &&
64
+
show()?.path === path &&
65
+
!show()?.showDids
66
+
) ?
67
+
setShow(null)
68
+
: setShow({ collection, path, showDids: false })
69
+
}
70
+
>
71
+
{counts.records} record{counts.records < 2 ? "" : "s"}
72
+
</button>
73
+
{" from "}
74
+
<button
75
+
class="text-blue-400 hover:underline active:underline"
76
+
title="Show linking DIDs"
77
+
onclick={() =>
78
+
show()?.collection === collection && show()?.path === path && show()?.showDids ?
79
+
setShow(null)
80
+
: setShow({ collection, path, showDids: true })
81
+
}
82
+
>
83
+
{counts.distinct_dids} DID
84
+
{counts.distinct_dids < 2 ? "" : "s"}
85
+
</button>
86
+
</p>
87
+
<Show when={show()?.collection === collection && show()?.path === path}>
88
+
<Show when={show()?.showDids}>
89
+
{/* putting this in the `dids` prop directly failed to re-render. idk how to solidjs. */}
90
+
<p class="w-full font-semibold">Distinct identities</p>
91
+
<BacklinkItems
92
+
target={props.target}
93
+
collection={collection}
94
+
path={path}
95
+
dids={true}
96
+
/>
97
+
</Show>
98
+
<Show when={!show()?.showDids}>
99
+
<p class="w-full font-semibold">Records</p>
100
+
<BacklinkItems
101
+
target={props.target}
102
+
collection={collection}
103
+
path={path}
104
+
dids={false}
105
+
/>
111
106
</Show>
112
-
</div>
107
+
</Show>
113
108
</div>
114
-
)}
115
-
</For>
116
-
</div>
117
-
</Show>
109
+
</div>
110
+
)}
111
+
</For>
112
+
</div>
118
113
);
119
114
};
120
115
+144
-84
src/components/create.tsx
+144
-84
src/components/create.tsx
···
1
1
import { Client } from "@atcute/client";
2
2
import { remove } from "@mary/exif-rm";
3
3
import { useNavigate, useParams } from "@solidjs/router";
4
-
import { createSignal, Show } from "solid-js";
4
+
import { createSignal, onCleanup, Show } from "solid-js";
5
5
import { Editor, editorView } from "../components/editor.jsx";
6
6
import { agent } from "../components/login.jsx";
7
7
import { setNotif } from "../layout.jsx";
···
15
15
const params = useParams();
16
16
const [openDialog, setOpenDialog] = createSignal(false);
17
17
const [notice, setNotice] = createSignal("");
18
-
const [uploading, setUploading] = createSignal(false);
18
+
const [openUpload, setOpenUpload] = createSignal(false);
19
+
let blobInput!: HTMLInputElement;
19
20
let formRef!: HTMLFormElement;
20
21
21
22
const placeholder = () => {
···
125
126
}
126
127
};
127
128
128
-
const uploadBlob = async () => {
129
-
setNotice("");
130
-
let blob: Blob;
129
+
const FileUpload = (props: { file: File }) => {
130
+
const [uploading, setUploading] = createSignal(false);
131
+
const [error, setError] = createSignal("");
131
132
132
-
const file = (document.getElementById("blob") as HTMLInputElement)?.files?.[0];
133
-
if (!file) return;
133
+
onCleanup(() => (blobInput.value = ""));
134
134
135
-
const mimetype = (document.getElementById("mimetype") as HTMLInputElement)?.value;
136
-
(document.getElementById("mimetype") as HTMLInputElement).value = "";
137
-
if (mimetype) blob = new Blob([file], { type: mimetype });
138
-
else blob = file;
135
+
const formatFileSize = (bytes: number) => {
136
+
if (bytes === 0) return "0 Bytes";
137
+
const k = 1024;
138
+
const sizes = ["Bytes", "KB", "MB", "GB"];
139
+
const i = Math.floor(Math.log(bytes) / Math.log(k));
140
+
return Math.round((bytes / Math.pow(k, i)) * 100) / 100 + " " + sizes[i];
141
+
};
142
+
143
+
const uploadBlob = async () => {
144
+
let blob: Blob;
145
+
146
+
const mimetype = (document.getElementById("mimetype") as HTMLInputElement)?.value;
147
+
(document.getElementById("mimetype") as HTMLInputElement).value = "";
148
+
if (mimetype) blob = new Blob([props.file], { type: mimetype });
149
+
else blob = props.file;
150
+
151
+
if ((document.getElementById("exif-rm") as HTMLInputElement).checked) {
152
+
const exifRemoved = remove(new Uint8Array(await blob.arrayBuffer()));
153
+
if (exifRemoved !== null) blob = new Blob([exifRemoved], { type: blob.type });
154
+
}
139
155
140
-
if ((document.getElementById("exif-rm") as HTMLInputElement).checked) {
141
-
const exifRemoved = remove(new Uint8Array(await blob.arrayBuffer()));
142
-
if (exifRemoved !== null) blob = new Blob([exifRemoved], { type: blob.type });
143
-
}
156
+
const rpc = new Client({ handler: agent()! });
157
+
setUploading(true);
158
+
const res = await rpc.post("com.atproto.repo.uploadBlob", {
159
+
input: blob,
160
+
});
161
+
setUploading(false);
162
+
if (!res.ok) {
163
+
setError(res.data.error);
164
+
return;
165
+
}
166
+
editorView.dispatch({
167
+
changes: {
168
+
from: editorView.state.selection.main.head,
169
+
insert: JSON.stringify(res.data.blob, null, 2),
170
+
},
171
+
});
172
+
setOpenUpload(false);
173
+
};
144
174
145
-
const rpc = new Client({ handler: agent()! });
146
-
setUploading(true);
147
-
const res = await rpc.post("com.atproto.repo.uploadBlob", {
148
-
input: blob,
149
-
});
150
-
setUploading(false);
151
-
(document.getElementById("blob") as HTMLInputElement).value = "";
152
-
if (!res.ok) {
153
-
setNotice(res.data.error);
154
-
return;
155
-
}
156
-
editorView.dispatch({
157
-
changes: {
158
-
from: editorView.state.selection.main.head,
159
-
insert: JSON.stringify(res.data.blob, null, 2),
160
-
},
161
-
});
175
+
return (
176
+
<div class="dark:bg-dark-300 dark:shadow-dark-800 absolute top-70 left-[50%] w-[20rem] -translate-x-1/2 rounded-lg border-[0.5px] border-neutral-300 bg-neutral-50 p-4 shadow-md transition-opacity duration-200 dark:border-neutral-700 starting:opacity-0">
177
+
<h2 class="mb-2 font-semibold">Upload blob</h2>
178
+
<div class="flex flex-col gap-2 text-sm">
179
+
<div class="flex flex-col gap-1">
180
+
<p class="flex gap-1">
181
+
<span class="truncate">{props.file.name}</span>
182
+
<span class="shrink-0 text-neutral-600 dark:text-neutral-400">
183
+
({formatFileSize(props.file.size)})
184
+
</span>
185
+
</p>
186
+
</div>
187
+
<div class="flex items-center gap-x-2">
188
+
<label for="mimetype" class="shrink-0 select-none">
189
+
MIME type
190
+
</label>
191
+
<TextInput id="mimetype" placeholder={props.file.type} />
192
+
</div>
193
+
<div class="flex items-center gap-1">
194
+
<input id="exif-rm" type="checkbox" checked />
195
+
<label for="exif-rm" class="select-none">
196
+
Remove EXIF data
197
+
</label>
198
+
</div>
199
+
<p class="text-xs text-neutral-600 dark:text-neutral-400">
200
+
Metadata will be pasted after the cursor
201
+
</p>
202
+
<Show when={error()}>
203
+
<span class="text-red-500 dark:text-red-400">Error: {error()}</span>
204
+
</Show>
205
+
<div class="flex justify-between gap-2">
206
+
<Button onClick={() => setOpenUpload(false)}>Cancel</Button>
207
+
<Show when={uploading()}>
208
+
<div class="flex items-center gap-1">
209
+
<span class="iconify lucide--loader-circle animate-spin"></span>
210
+
<span>Uploading</span>
211
+
</div>
212
+
</Show>
213
+
<Show when={!uploading()}>
214
+
<Button
215
+
onClick={uploadBlob}
216
+
class="dark:shadow-dark-800 flex items-center gap-1 rounded-lg bg-blue-500 px-2 py-1.5 text-xs text-white shadow-xs select-none hover:bg-blue-600 active:bg-blue-700 dark:bg-blue-600 dark:hover:bg-blue-500 dark:active:bg-blue-400"
217
+
>
218
+
Upload
219
+
</Button>
220
+
</Show>
221
+
</div>
222
+
</div>
223
+
</div>
224
+
);
162
225
};
163
226
164
227
return (
···
172
235
></span>
173
236
<span>{props.create ? "Creating" : "Editing"} record</span>
174
237
</div>
175
-
<button onclick={() => setOpenDialog(false)} class="flex items-center">
176
-
<span class="iconify lucide--x text-lg hover:text-neutral-500 dark:hover:text-neutral-400"></span>
238
+
<button
239
+
onclick={() => setOpenDialog(false)}
240
+
class="flex items-center rounded-lg p-1 hover:bg-neutral-200 active:bg-neutral-300 dark:hover:bg-neutral-700 dark:active:bg-neutral-600"
241
+
>
242
+
<span class="iconify lucide--x"></span>
177
243
</button>
178
244
</div>
179
245
<form ref={formRef} class="flex flex-col gap-y-2">
180
-
<div class="flex w-fit flex-col gap-y-1 text-xs sm:text-sm">
246
+
<div class="flex w-fit flex-col gap-y-1 text-sm">
181
247
<Show when={props.create}>
182
248
<div class="flex items-center gap-x-2">
183
249
<label for="collection" class="min-w-20 select-none">
···
186
252
<TextInput
187
253
id="collection"
188
254
name="collection"
189
-
placeholder="Optional (default: record type)"
255
+
placeholder="Optional (default: $type)"
190
256
class="w-[15rem]"
191
257
/>
192
258
</div>
···
216
282
<option value="false">False</option>
217
283
</select>
218
284
</div>
219
-
<div class="flex items-center gap-2">
220
-
<Show when={!uploading()}>
221
-
<div class="dark:hover:bg-dark-200 dark:shadow-dark-800 dark:active:bg-dark-100 flex rounded-lg border-[0.5px] border-neutral-300 bg-neutral-50 text-xs font-semibold shadow-xs hover:bg-neutral-100 active:bg-neutral-200 dark:border-neutral-700 dark:bg-neutral-800">
222
-
<input type="file" id="blob" class="sr-only" onChange={() => uploadBlob()} />
223
-
<label class="flex items-center gap-1 px-2 py-1.5 select-none" for="blob">
224
-
<span class="iconify lucide--upload text-sm"></span>
225
-
Upload
226
-
</label>
227
-
</div>
228
-
<p class="text-xs">Metadata will be pasted after the cursor</p>
229
-
</Show>
230
-
<Show when={uploading()}>
231
-
<span class="iconify lucide--loader-circle animate-spin text-xl"></span>
232
-
<p>Uploading...</p>
233
-
</Show>
234
-
</div>
235
-
<div class="flex flex-col gap-2 sm:flex-row sm:items-center sm:justify-between">
236
-
<div class="flex items-center gap-x-2">
237
-
<label for="mimetype" class="min-w-20 select-none">
238
-
MIME type
239
-
</label>
240
-
<TextInput id="mimetype" placeholder="Optional" class="w-[15rem]" />
241
-
</div>
242
-
<div class="flex items-center gap-1">
243
-
<input id="exif-rm" type="checkbox" checked />
244
-
<label for="exif-rm" class="select-none">
245
-
Remove EXIF data
246
-
</label>
247
-
</div>
248
-
</div>
249
285
</div>
250
286
<Editor
251
287
content={JSON.stringify(props.create ? placeholder() : props.record, null, 2)}
252
288
/>
253
289
<div class="flex flex-col gap-2">
254
290
<Show when={notice()}>
255
-
<div class="text-red-500 dark:text-red-400">{notice()}</div>
291
+
<div class="text-sm text-red-500 dark:text-red-400">{notice()}</div>
256
292
</Show>
257
-
<div class="flex items-center justify-end gap-2">
258
-
<Show when={!props.create}>
259
-
<div class="flex items-center gap-1">
260
-
<input id="recreate" name="recreate" type="checkbox" />
261
-
<label for="recreate" class="text-sm select-none">
262
-
Recreate record
263
-
</label>
264
-
</div>
265
-
</Show>
266
-
<Button
267
-
onClick={() =>
268
-
props.create ?
269
-
createRecord(new FormData(formRef))
270
-
: editRecord(new FormData(formRef))
271
-
}
293
+
<div class="flex justify-between gap-2">
294
+
<div class="dark:hover:bg-dark-200 dark:shadow-dark-800 dark:active:bg-dark-100 flex w-fit rounded-lg border-[0.5px] border-neutral-300 bg-neutral-50 text-xs shadow-xs hover:bg-neutral-100 active:bg-neutral-200 dark:border-neutral-700 dark:bg-neutral-800">
295
+
<input
296
+
type="file"
297
+
id="blob"
298
+
class="sr-only"
299
+
ref={blobInput}
300
+
onChange={(e) => {
301
+
if (e.target.files !== null) setOpenUpload(true);
302
+
}}
303
+
/>
304
+
<label class="flex items-center gap-1 px-2 py-1.5 select-none" for="blob">
305
+
<span class="iconify lucide--upload"></span>
306
+
Upload
307
+
</label>
308
+
</div>
309
+
<Modal
310
+
open={openUpload()}
311
+
onClose={() => setOpenUpload(false)}
312
+
closeOnClick={false}
272
313
>
273
-
{props.create ? "Create" : "Edit"}
274
-
</Button>
314
+
<FileUpload file={blobInput.files![0]} />
315
+
</Modal>
316
+
<div class="flex items-center justify-end gap-2">
317
+
<Show when={!props.create}>
318
+
<div class="flex items-center gap-1">
319
+
<input id="recreate" name="recreate" type="checkbox" />
320
+
<label for="recreate" class="text-sm select-none">
321
+
Recreate record
322
+
</label>
323
+
</div>
324
+
</Show>
325
+
<Button
326
+
onClick={() =>
327
+
props.create ?
328
+
createRecord(new FormData(formRef))
329
+
: editRecord(new FormData(formRef))
330
+
}
331
+
>
332
+
{props.create ? "Create" : "Edit"}
333
+
</Button>
334
+
</div>
275
335
</div>
276
336
</div>
277
337
</form>
+76
-18
src/components/search.tsx
+76
-18
src/components/search.tsx
···
2
2
import { A, useLocation, useNavigate } from "@solidjs/router";
3
3
import { createResource, createSignal, For, onCleanup, onMount, Show } from "solid-js";
4
4
import { isTouchDevice } from "../layout";
5
+
import { appHandleLink, appList, appName, AppUrl } from "../utils/app-urls";
5
6
import { createDebouncedValue } from "../utils/hooks/debounced";
7
+
import { Modal } from "./modal";
6
8
7
9
export const [showSearch, setShowSearch] = createSignal(false);
8
10
···
66
68
input = input.trim().replace(/^@/, "");
67
69
if (!input.length) return;
68
70
setShowSearch(false);
69
-
if (input === "me" && localStorage.getItem("lastSignedIn") !== null) {
70
-
navigate(`/at://${localStorage.getItem("lastSignedIn")}`);
71
-
} else if (
72
-
!input.startsWith("https://bsky.app/") &&
73
-
(input.startsWith("https://") || input.startsWith("http://"))
74
-
) {
75
-
navigate(`/${input.replace("https://", "").replace("http://", "").replace("/", "")}`);
76
-
} else if (search()?.length) {
71
+
if (search()?.length) {
77
72
navigate(`/at://${search()![0].did}`);
73
+
} else if (input.startsWith("https://") || input.startsWith("http://")) {
74
+
const hostLength = input.indexOf("/", 8);
75
+
const host = input.slice(0, hostLength).replace("https://", "").replace("http://", "");
76
+
77
+
if (!(host in appList)) {
78
+
navigate(`/${input.replace("https://", "").replace("http://", "").replace("/", "")}`);
79
+
} else {
80
+
const app = appList[host as AppUrl];
81
+
const path = input.slice(hostLength + 1).split("/");
82
+
83
+
const uri = appHandleLink[app](path);
84
+
navigate(`/${uri}`);
85
+
}
78
86
} else {
79
-
const uri = input
80
-
.replace("at://", "")
81
-
.replace("https://bsky.app/profile/", "")
82
-
.replace("/post/", "/app.bsky.feed.post/");
83
-
const uriParts = uri.split("/");
84
-
navigate(
85
-
`/at://${uriParts[0]}${uriParts.length > 1 ? `/${uriParts.slice(1).join("/")}` : ""}`,
86
-
);
87
+
navigate(`/at://${input.replace("at://", "")}`);
87
88
}
88
-
setShowSearch(false);
89
89
};
90
90
91
91
return (
···
114
114
value={input() ?? ""}
115
115
onInput={(e) => setInput(e.currentTarget.value)}
116
116
/>
117
-
<Show when={input()}>
117
+
<Show when={input()} fallback={ListUrlsTooltip()}>
118
118
<button
119
119
type="button"
120
120
class="flex items-center rounded-lg p-1 hover:bg-neutral-200 active:bg-neutral-300 dark:hover:bg-neutral-600 dark:active:bg-neutral-500"
···
144
144
</div>
145
145
</Show>
146
146
</form>
147
+
);
148
+
};
149
+
150
+
const ListUrlsTooltip = () => {
151
+
const [openList, setOpenList] = createSignal(false);
152
+
153
+
let urls: Record<string, AppUrl[]> = {};
154
+
for (const [appUrl, appView] of Object.entries(appList)) {
155
+
if (!urls[appView]) urls[appView] = [appUrl as AppUrl];
156
+
else urls[appView].push(appUrl as AppUrl);
157
+
}
158
+
159
+
return (
160
+
<>
161
+
<Modal open={openList()} onClose={() => setOpenList(false)}>
162
+
<div class="dark:bg-dark-300 dark:shadow-dark-800 absolute top-16 left-[50%] w-[22rem] -translate-x-1/2 rounded-lg border-[0.5px] border-neutral-300 bg-neutral-50 p-4 shadow-md transition-opacity duration-200 sm:w-[26rem] dark:border-neutral-700 starting:opacity-0">
163
+
<div class="mb-2 flex items-center gap-1 font-semibold">
164
+
<span class="iconify lucide--link"></span>
165
+
<span>Supported URLs</span>
166
+
</div>
167
+
<div class="mb-2 text-sm text-neutral-600 dark:text-neutral-400">
168
+
Links that will be parsed automatically, as long as all the data necessary is on the
169
+
URL.
170
+
</div>
171
+
<div class="flex flex-col gap-2 text-sm">
172
+
<For each={Object.entries(appName)}>
173
+
{([appView, name]) => {
174
+
return (
175
+
<div>
176
+
<p class="font-semibold">{name}</p>
177
+
<div class="grid grid-cols-2 gap-x-4 text-neutral-600 dark:text-neutral-400">
178
+
<For each={urls[appView]}>
179
+
{(url) => (
180
+
<a
181
+
href={`${url.startsWith("localhost:") ? "http://" : "https://"}${url}`}
182
+
target="_blank"
183
+
class="hover:underline active:underline"
184
+
>
185
+
{url}
186
+
</a>
187
+
)}
188
+
</For>
189
+
</div>
190
+
</div>
191
+
);
192
+
}}
193
+
</For>
194
+
</div>
195
+
</div>
196
+
</Modal>
197
+
<button
198
+
type="button"
199
+
class="flex items-center rounded-lg p-1 hover:bg-neutral-200 active:bg-neutral-300 dark:hover:bg-neutral-600 dark:active:bg-neutral-500"
200
+
onClick={() => setOpenList(true)}
201
+
>
202
+
<span class="iconify lucide--help-circle"></span>
203
+
</button>
204
+
</>
147
205
);
148
206
};
149
207
+1
-1
src/layout.tsx
+1
-1
src/layout.tsx
···
66
66
</Show>
67
67
</MetaProvider>
68
68
<header
69
-
class={`dark:shadow-dark-800 dark:bg-dark-300 mb-4 flex w-full items-center justify-between rounded-lg border-[0.5px] border-neutral-300 bg-neutral-50 bg-size-[95%] bg-right bg-no-repeat p-2 shadow-xs [--header-bg:#fafafa] dark:border-neutral-700 dark:[--header-bg:#2d2d2d] ${localStorage.getItem("hrt") === "true" ? "bg-[linear-gradient(to_left,transparent_0%,var(--header-bg)_80%),linear-gradient(to_bottom,#5BCEFA90_0%,#5BCEFA90_20%,#F5A9B890_20%,#F5A9B890_40%,#FFFFFF90_40%,#FFFFFF90_60%,#F5A9B890_60%,#F5A9B890_80%,#5BCEFA90_80%,#5BCEFA90_100%)]" : ""}`}
69
+
class={`dark:shadow-dark-800 dark:bg-dark-300 mb-4 flex w-full items-center justify-between rounded-lg border-[0.5px] border-neutral-300 bg-neutral-50 bg-size-[95%] bg-right bg-no-repeat p-2 shadow-xs [--header-bg:#fafafa] dark:border-neutral-700 dark:[--header-bg:#2d2d2d] ${localStorage.getItem("hrt") === "true" ? "bg-[linear-gradient(to_left,transparent_10%,var(--header-bg)_85%),linear-gradient(to_bottom,#5BCEFA90_0%,#5BCEFA90_20%,#F5A9B890_20%,#F5A9B890_40%,#FFFFFF90_40%,#FFFFFF90_60%,#F5A9B890_60%,#F5A9B890_80%,#5BCEFA90_80%,#5BCEFA90_100%)]" : ""}`}
70
70
style={{
71
71
"background-image":
72
72
props.params.repo in headers ?
+119
src/utils/app-urls.ts
+119
src/utils/app-urls.ts
···
1
+
export type AppUrl = `${string}.${string}` | `localhost:${number}`;
2
+
3
+
export enum App {
4
+
Bluesky,
5
+
Tangled,
6
+
Whitewind,
7
+
Frontpage,
8
+
Pinksea,
9
+
Linkat,
10
+
}
11
+
12
+
export const appName = {
13
+
[App.Bluesky]: "Bluesky",
14
+
[App.Tangled]: "Tangled",
15
+
[App.Whitewind]: "Whitewind",
16
+
[App.Frontpage]: "Frontpage",
17
+
[App.Pinksea]: "Pinksea",
18
+
[App.Linkat]: "Linkat",
19
+
};
20
+
21
+
export const appList: Record<AppUrl, App> = {
22
+
"localhost:19006": App.Bluesky,
23
+
"blacksky.community": App.Bluesky,
24
+
"bsky.app": App.Bluesky,
25
+
"catsky.social": App.Bluesky,
26
+
"deer.aylac.top": App.Bluesky,
27
+
"deer-social-ayla.pages.dev": App.Bluesky,
28
+
"deer.social": App.Bluesky,
29
+
"main.bsky.dev": App.Bluesky,
30
+
"social.daniela.lol": App.Bluesky,
31
+
"tangled.org": App.Tangled,
32
+
"whtwnd.com": App.Whitewind,
33
+
"frontpage.fyi": App.Frontpage,
34
+
"pinksea.art": App.Pinksea,
35
+
"linkat.blue": App.Linkat,
36
+
};
37
+
38
+
export const appHandleLink: Record<App, (url: string[]) => string> = {
39
+
[App.Bluesky]: (path) => {
40
+
const baseType = path[0];
41
+
const user = path[1];
42
+
43
+
if (baseType === "profile") {
44
+
if (path[2]) {
45
+
const type = path[2];
46
+
const rkey = path[3];
47
+
48
+
if (type === "post") {
49
+
return `at://${user}/app.bsky.feed.post/${rkey}`;
50
+
} else if (type === "list") {
51
+
return `at://${user}/app.bsky.graph.list/${rkey}`;
52
+
} else if (type === "feed") {
53
+
return `at://${user}/app.bsky.feed.generator/${rkey}`;
54
+
} else if (type === "follows") {
55
+
return `at://${user}/app.bsky.graph.follow/${rkey}`;
56
+
}
57
+
} else {
58
+
return `at://${user}`;
59
+
}
60
+
} else if (baseType === "starter-pack") {
61
+
return `at://${user}/app.bsky.graph.starterpack/${path[2]}`;
62
+
}
63
+
return `at://${user}`;
64
+
},
65
+
[App.Tangled]: (path) => {
66
+
if (path[0] === "strings") {
67
+
return `at://${path[1]}/sh.tangled.string/${path[2]}`;
68
+
}
69
+
70
+
let query: string | undefined;
71
+
if (path[path.length - 1].includes("?")) {
72
+
const split = path[path.length - 1].split("?");
73
+
query = split[1];
74
+
path[path.length - 1] = split[0];
75
+
}
76
+
77
+
const user = path[0].replace("@", "");
78
+
79
+
if (path.length === 1) {
80
+
if (query === "tab=repos") {
81
+
return `at://${user}/sh.tangled.repo`;
82
+
} else if (query === "tab=starred") {
83
+
return `at://${user}/sh.tangled.feed.star`;
84
+
} else if (query === "tab=strings") {
85
+
return `at://${user}/sh.tangled.string`;
86
+
}
87
+
} else if (path.length === 2) {
88
+
// no way to convert the repo name to an rkey afaik
89
+
// same reason why there's nothing related to issues in here
90
+
return `at://${user}/sh.tangled.repo`;
91
+
}
92
+
93
+
return `at://${user}`;
94
+
},
95
+
[App.Whitewind]: (path) => {
96
+
if (path.length === 2) {
97
+
return `at://${path[0]}/com.whtwnd.blog.entry/${path[1]}`;
98
+
}
99
+
100
+
return `at://${path[0]}/com.whtwnd.blog.entry`;
101
+
},
102
+
[App.Frontpage]: (path) => {
103
+
if (path.length === 3) {
104
+
return `at://${path[1]}/fyi.unravel.frontpage.post/${path[2]}`;
105
+
} else if (path.length === 5) {
106
+
return `at://${path[3]}/fyi.unravel.frontpage.comment/${path[4]}`;
107
+
}
108
+
109
+
return `at://${path[0]}`;
110
+
},
111
+
[App.Pinksea]: (path) => {
112
+
if (path.length === 2) {
113
+
return `at://${path[0]}/com.shinolabs.pinksea.oekaki/${path[1]}`;
114
+
}
115
+
116
+
return `at://${path[0]}`;
117
+
},
118
+
[App.Linkat]: (path) => `at://${path[0]}/blue.linkat.board/self`,
119
+
};
+3
-3
src/views/collection.tsx
+3
-3
src/views/collection.tsx
···
41
41
42
42
return (
43
43
<span
44
-
class="relative flex w-full items-baseline rounded px-0.5 hover:bg-neutral-200 active:bg-neutral-300 dark:hover:bg-neutral-700 dark:active:bg-neutral-600"
44
+
class="relative flex w-full min-w-0 items-baseline rounded px-0.5 hover:bg-neutral-200 active:bg-neutral-300 dark:hover:bg-neutral-700 dark:active:bg-neutral-600"
45
45
ref={rkeyRef}
46
46
onmouseover={() => setHover(true)}
47
47
onmouseleave={() => setHover(false)}
···
267
267
<Button onClick={() => setOpenDelete(false)}>Cancel</Button>
268
268
<Button
269
269
onClick={deleteRecords}
270
-
class={`dark:shadow-dark-800 rounded-lg px-2 py-1.5 text-xs font-semibold text-neutral-200 shadow-xs select-none ${recreate() ? "bg-green-500 hover:bg-green-400 dark:bg-green-600 dark:hover:bg-green-500" : "bg-red-500 hover:bg-red-400 active:bg-red-400"}`}
270
+
class={`dark:shadow-dark-800 rounded-lg px-2 py-1.5 text-xs text-white shadow-xs select-none ${recreate() ? "bg-green-500 hover:bg-green-400 dark:bg-green-600 dark:hover:bg-green-500" : "bg-red-500 hover:bg-red-400 active:bg-red-400"}`}
271
271
>
272
272
{recreate() ? "Recreate" : "Delete"}
273
273
</Button>
···
301
301
}}
302
302
>
303
303
<span
304
-
class={`iconify ${reverse() ? "lucide--rotate-ccw" : "lucide--rotate-cw"} text-sm`}
304
+
class={`iconify ${reverse() ? "lucide--rotate-ccw" : "lucide--rotate-cw"}`}
305
305
></span>
306
306
Reverse
307
307
</Button>
+4
-6
src/views/labels.tsx
+4
-6
src/views/labels.tsx
···
68
68
initQuery();
69
69
}}
70
70
>
71
-
<div class="w-full">
72
-
<label for="patterns" class="ml-0.5 text-sm">
73
-
URI Patterns (comma-separated)
74
-
</label>
75
-
</div>
76
-
<div class="flex w-full items-center gap-x-1">
71
+
<label for="patterns" class="ml-2 w-full text-sm">
72
+
URI Patterns (comma-separated)
73
+
</label>
74
+
<div class="flex w-full items-center gap-x-1 px-1">
77
75
<textarea
78
76
id="patterns"
79
77
name="patterns"
+1
src/views/logs.tsx
+1
src/views/logs.tsx
···
37
37
classList={{
38
38
"flex items-center rounded-full p-1.5": true,
39
39
"bg-neutral-700 dark:bg-neutral-200": activePlcEvent() === props.event,
40
+
"hover:bg-neutral-200 dark:hover:bg-neutral-700": activePlcEvent() !== props.event,
40
41
}}
41
42
onclick={() => setActivePlcEvent(activePlcEvent() === props.event ? undefined : props.event)}
42
43
>
+133
-43
src/views/pds.tsx
+133
-43
src/views/pds.tsx
···
2
2
import { Client, CredentialManager } from "@atcute/client";
3
3
import { InferXRPCBodyOutput } from "@atcute/lexicons";
4
4
import * as TID from "@atcute/tid";
5
-
import { A, useParams } from "@solidjs/router";
5
+
import { A, useLocation, useParams } from "@solidjs/router";
6
6
import { createResource, createSignal, For, Show } from "solid-js";
7
7
import { Button } from "../components/button";
8
8
import { Modal } from "../components/modal";
9
9
import { setPDS } from "../components/navbar";
10
10
import Tooltip from "../components/tooltip";
11
+
import { addToClipboard } from "../utils/copy";
11
12
import { localDateFromTimestamp } from "../utils/date";
12
13
13
14
const LIMIT = 1000;
14
15
15
16
const PdsView = () => {
16
17
const params = useParams();
18
+
const location = useLocation();
17
19
const [version, setVersion] = createSignal<string>();
18
20
const [serverInfos, setServerInfos] =
19
21
createSignal<InferXRPCBodyOutput<ComAtprotoServerDescribeServer.mainSchema["output"]>>();
···
28
30
setVersion((res.data as any).version);
29
31
};
30
32
33
+
const describeServer = async () => {
34
+
const res = await rpc.get("com.atproto.server.describeServer");
35
+
if (!res.ok) console.error(res.data.error);
36
+
else setServerInfos(res.data);
37
+
};
38
+
31
39
const fetchRepos = async () => {
32
40
getVersion();
33
-
const describeRes = await rpc.get("com.atproto.server.describeServer");
34
-
if (!describeRes.ok) console.error(describeRes.data.error);
35
-
else setServerInfos(describeRes.data);
41
+
describeServer();
36
42
const res = await rpc.get("com.atproto.sync.listRepos", {
37
43
params: { limit: LIMIT, cursor: cursor() },
38
44
});
···
58
64
</A>
59
65
<Show when={!repo.active}>
60
66
<Tooltip text={repo.status ?? "Unknown status"}>
61
-
<span class="iconify lucide--unplug"></span>
67
+
<span class="iconify lucide--unplug text-red-500 dark:text-red-400"></span>
62
68
</Tooltip>
63
69
</Show>
64
70
<button
···
103
109
);
104
110
};
105
111
112
+
const Tab = (props: { tab: "repos" | "info"; label: string }) => (
113
+
<div class="flex items-center gap-0.5">
114
+
<A
115
+
classList={{
116
+
"flex items-center gap-1 border-b-2": true,
117
+
"border-transparent hover:border-neutral-400 dark:hover:border-neutral-600":
118
+
(!!location.hash && location.hash !== `#${props.tab}`) ||
119
+
(!location.hash && props.tab !== "repos"),
120
+
}}
121
+
href={`/${params.pds}#${props.tab}`}
122
+
>
123
+
{props.label}
124
+
</A>
125
+
</div>
126
+
);
127
+
106
128
return (
107
129
<Show when={repos() || response()}>
108
-
<div class="flex w-full flex-col px-2">
109
-
<Show when={version()}>
110
-
{(version) => (
111
-
<div class="flex items-baseline gap-x-1">
112
-
<span class="font-semibold">Version</span>
113
-
<span class="truncate text-sm">{version()}</span>
130
+
<div class="flex w-full flex-col">
131
+
<div class="dark:shadow-dark-800 dark:bg-dark-300 mb-2 flex w-full justify-between rounded-lg border-[0.5px] border-neutral-300 bg-neutral-50 px-2 py-1.5 text-sm shadow-xs dark:border-neutral-700">
132
+
<div class="flex gap-3">
133
+
<Tab tab="repos" label="Repositories" />
134
+
<Tab tab="info" label="Info" />
135
+
</div>
136
+
<div class="flex gap-1">
137
+
<Tooltip text="Copy PDS">
138
+
<button
139
+
onClick={() => addToClipboard(params.pds)}
140
+
class="flex items-center rounded-lg p-1 hover:bg-neutral-200 active:bg-neutral-300 dark:hover:bg-neutral-700 dark:active:bg-neutral-600"
141
+
>
142
+
<span class="iconify lucide--copy"></span>
143
+
</button>
144
+
</Tooltip>
145
+
<Tooltip text="Firehose">
146
+
<A
147
+
href={`/firehose?instance=wss://${params.pds}`}
148
+
class="flex items-center rounded-lg p-1 hover:bg-neutral-200 active:bg-neutral-300 dark:hover:bg-neutral-700 dark:active:bg-neutral-600"
149
+
>
150
+
<span class="iconify lucide--radio-tower"></span>
151
+
</A>
152
+
</Tooltip>
153
+
</div>
154
+
</div>
155
+
<div class="flex flex-col gap-1 px-2">
156
+
<Show when={!location.hash || location.hash === "#repos"}>
157
+
<div class="flex flex-col divide-y-[0.5px] divide-neutral-300 dark:divide-neutral-700">
158
+
<For each={repos()}>{(repo) => <RepoCard {...repo} />}</For>
114
159
</div>
115
-
)}
116
-
</Show>
117
-
<Show when={serverInfos()}>
118
-
{(server) => (
119
-
<>
120
-
<Show when={server().inviteCodeRequired}>
121
-
<span class="font-semibold">Invite Code Required</span>
122
-
</Show>
123
-
<Show when={server().phoneVerificationRequired}>
124
-
<span class="font-semibold">Phone Verification Required</span>
125
-
</Show>
126
-
<Show when={server().availableUserDomains.length}>
127
-
<div class="flex flex-col">
128
-
<span class="font-semibold">Available User Domains</span>
129
-
<For each={server().availableUserDomains}>
130
-
{(domain) => <span class="text-sm wrap-anywhere">{domain}</span>}
131
-
</For>
160
+
</Show>
161
+
<Show when={location.hash === "#info"}>
162
+
<Show when={version()}>
163
+
{(version) => (
164
+
<div class="flex items-baseline gap-x-1">
165
+
<span class="font-semibold">Version</span>
166
+
<span class="truncate text-sm">{version()}</span>
132
167
</div>
133
-
</Show>
134
-
</>
135
-
)}
136
-
</Show>
137
-
<p class="w-full font-semibold">{repos()?.length} Repositories</p>
138
-
<div class="flex flex-col divide-y-[0.5px] divide-neutral-300 dark:divide-neutral-700">
139
-
<For each={repos()}>{(repo) => <RepoCard {...repo} />}</For>
168
+
)}
169
+
</Show>
170
+
<Show when={serverInfos()}>
171
+
{(server) => (
172
+
<>
173
+
<div class="flex items-baseline gap-x-1">
174
+
<span class="font-semibold">DID</span>
175
+
<span class="truncate text-sm">{server().did}</span>
176
+
</div>
177
+
<Show when={server().inviteCodeRequired}>
178
+
<span class="font-semibold">Invite Code Required</span>
179
+
</Show>
180
+
<Show when={server().phoneVerificationRequired}>
181
+
<span class="font-semibold">Phone Verification Required</span>
182
+
</Show>
183
+
<Show when={server().availableUserDomains.length}>
184
+
<div class="flex flex-col">
185
+
<span class="font-semibold">Available User Domains</span>
186
+
<For each={server().availableUserDomains}>
187
+
{(domain) => <span class="text-sm wrap-anywhere">{domain}</span>}
188
+
</For>
189
+
</div>
190
+
</Show>
191
+
<Show when={server().links?.privacyPolicy}>
192
+
<div class="flex flex-col">
193
+
<span class="font-semibold">Privacy Policy</span>
194
+
<a
195
+
href={server().links?.privacyPolicy}
196
+
class="text-sm hover:underline"
197
+
target="_blank"
198
+
>
199
+
{server().links?.privacyPolicy}
200
+
</a>
201
+
</div>
202
+
</Show>
203
+
<Show when={server().links?.termsOfService}>
204
+
<div class="flex flex-col">
205
+
<span class="font-semibold">Terms of Service</span>
206
+
<a
207
+
href={server().links?.termsOfService}
208
+
class="text-sm hover:underline"
209
+
target="_blank"
210
+
>
211
+
{server().links?.termsOfService}
212
+
</a>
213
+
</div>
214
+
</Show>
215
+
<Show when={server().contact?.email}>
216
+
<div class="flex flex-col">
217
+
<span class="font-semibold">Contact</span>
218
+
<a href={`mailto:${server().contact?.email}`} class="text-sm hover:underline">
219
+
{server().contact?.email}
220
+
</a>
221
+
</div>
222
+
</Show>
223
+
</>
224
+
)}
225
+
</Show>
226
+
</Show>
140
227
</div>
141
228
</div>
142
-
<Show when={cursor()}>
143
-
<div class="dark:bg-dark-500 fixed bottom-0 z-5 flex w-screen justify-center bg-neutral-100 py-3">
144
-
<Show when={!response.loading}>
145
-
<Button onClick={() => refetch()}>Load More</Button>
146
-
</Show>
147
-
<Show when={response.loading}>
148
-
<span class="iconify lucide--loader-circle animate-spin py-3.5 text-xl"></span>
149
-
</Show>
229
+
<Show when={!location.hash || location.hash === "#repos"}>
230
+
<div class="dark:bg-dark-500 fixed bottom-0 z-5 flex w-screen justify-center bg-neutral-100 py-2">
231
+
<div class="flex flex-col items-center gap-1 pb-2">
232
+
<p>{repos()?.length} loaded</p>
233
+
<Show when={!response.loading && cursor()}>
234
+
<Button onClick={() => refetch()}>Load More</Button>
235
+
</Show>
236
+
<Show when={response.loading}>
237
+
<span class="iconify lucide--loader-circle animate-spin py-3.5 text-xl"></span>
238
+
</Show>
239
+
</div>
150
240
</div>
151
241
</Show>
152
242
</Show>
+6
-5
src/views/record.tsx
+6
-5
src/views/record.tsx
···
10
10
import { JSONValue } from "../components/json.jsx";
11
11
import { agent } from "../components/login.jsx";
12
12
import { Modal } from "../components/modal.jsx";
13
-
import { pds, setCID } from "../components/navbar.jsx";
13
+
import { pds } from "../components/navbar.jsx";
14
14
import Tooltip from "../components/tooltip.jsx";
15
15
import { setNotif } from "../layout.jsx";
16
16
import { didDocCache, resolveLexiconAuthority, resolvePDS } from "../utils/api.js";
···
34
34
let rpc: Client;
35
35
36
36
const fetchRecord = async () => {
37
-
setCID(undefined);
38
37
setValidRecord(undefined);
39
38
setValidSchema(undefined);
40
39
setLexiconUri(undefined);
···
52
51
setNotice(res.data.error);
53
52
throw new Error(res.data.error);
54
53
}
55
-
setCID(res.data.cid);
56
54
setExternalLink(checkUri(res.data.uri, res.data.value));
57
55
resolveLexicon(params.collection as Nsid);
58
56
verify(res.data);
···
179
177
<Button onClick={() => setOpenDelete(false)}>Cancel</Button>
180
178
<Button
181
179
onClick={deleteRecord}
182
-
class="dark:shadow-dark-800 rounded-lg bg-red-500 px-2 py-1.5 text-xs font-semibold text-neutral-200 shadow-xs select-none hover:bg-red-400 active:bg-red-400"
180
+
class="dark:shadow-dark-800 rounded-lg bg-red-500 px-2 py-1.5 text-xs text-white shadow-xs select-none hover:bg-red-400 active:bg-red-400"
183
181
>
184
182
Delete
185
183
</Button>
···
198
196
label="Copy record"
199
197
icon="lucide--copy"
200
198
/>
199
+
<Show when={record()?.cid}>
200
+
{(cid) => <CopyMenu copyContent={cid()} label="Copy CID" icon="lucide--copy" />}
201
+
</Show>
201
202
<Show when={externalLink()}>
202
203
{(externalLink) => (
203
204
<NavMenu
···
286
287
<div>
287
288
<div class="flex items-center gap-1">
288
289
<span class="iconify lucide--scroll-text"></span>
289
-
<p class="font-semibold">Lexicon document</p>
290
+
<p class="font-semibold">Lexicon schema</p>
290
291
</div>
291
292
<div class="truncate text-xs">
292
293
<A