Public
HTTP (deprecated)
Forked from stevekrouse/sqlite_admin
stevekrouse-blob_admin.web.val.run
August 2, 2024
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
/** @jsxImportSource https://esm.sh/hono@4.0.8/jsx **/
import { modifyFetchHandler } from "https://esm.town/v/andreterron/codeOnValTown?v=50";
import view_route from "https://esm.town/v/pomdtr/blob_admin_blob";
import create_route from "https://esm.town/v/pomdtr/blob_admin_create";
import delete_route from "https://esm.town/v/pomdtr/blob_admin_delete";
import edit_route from "https://esm.town/v/pomdtr/blob_admin_edit";
import upload_route from "https://esm.town/v/pomdtr/blob_admin_upload";
import { passwordAuth } from "https://esm.town/v/pomdtr/password_auth?v=74";
import { blob } from "https://esm.town/v/std/blob?v=11";
import { Hono } from "npm:hono@4.0.8";
import { jsxRenderer } from "npm:hono@4.0.8/jsx-renderer";
const app = new Hono();
app.use(
jsxRenderer(({ children }) => {
return (
<html>
<head>
<link
rel="stylesheet"
href="https://cdn.jsdelivr.net/npm/@picocss/pico@2/css/pico.min.css"
/>
<script
type="module"
src="https://cdn.jsdelivr.net/npm/code-mirror-web-component@0.0.8/dist/code-mirror.js"
>
</script>
<title>Blob Admin</title>
</head>
<body>
<main class="container">
{children}
</main>
</body>
</html>
);
}),
);
app.get("/", async (c) => {
let blobs = await blob.list(c.req.query("search"));
return c.render(
<div class="overflow-auto">
<h1>Blob Admin</h1>
<form action="/" method="GET" class="mb-4">
<input type="text" name="search" placeholder="Search blobs..." class="p-2 border rounded" />
<button type="submit" class="bg-blue-500 text-white px-4 py-2 rounded">Search</button>
</form>
<section
style={{
display: "flex",
gap: "0.5em",
}}
>
<a href="/create">New Blob</a>
<a href="/upload">Upload Blob</a>
</section>
<section>
<table>
<thead>
<tr>
<th>Name</th>
<th>Size (kb)</th>
<th>Last Modified</th>
<th
style={{
textAlign: "center",
}}
>
Edit
</th>
<th
style={{
textAlign: "center",
}}
>
Delete
</th>
<th
style={{
textAlign: "center",
}}
>
Download
</th>
</tr>
</thead>
{blobs.map(b => (
<tr>
<td>
<a href={`/view/${encodeURIComponent(b.key)}`}>
{b.key}
</a>
</td>
<td>{b.size / 1000}</td>
<td>{new Date(b.lastModified).toLocaleString()}</td>
<td
Val Town is a social website to write and deploy JavaScript.
Build APIs and schedule functions from your browser.
August 2, 2024
Instead of instructing the user to fork the val, why not suggest the user to create a new val referencing your own ?
It would allow the user to automatically get update from your, or control them using the version query param.
Excellent idea! That's how @rodrigotello/hnFollow works.
This way is slightly easier to customize, that way is slightly easier to manage updates.
In theory, Val Town could help users manage forks like Github does:
Or even notify users that they should "pull" from the remote val because it has new changes.
The question of when to use something as a dependency vs as a fork is a fascinating one. I'm eager to see what patterns emerge
I see importing as an installation method a val to my val.town account, while forking is just copying a specific version of a val.
I can see myself using, it depends as if I see myself as a user or a contributor.
Even for the same val, I can see myself having my prod endpoint and my dev endpoint.
comments really need an edit button 😅
It's not working anymore. I'm getting an error message. "message": "{"statusCode":500,"error":"Internal Server Error","message":"Failed to create Turso DB: Namespace store has shutdown"}",
Sorry about that @loshmyy. We haven't seen that error message before. Is everything working properly now?
@pomdtr
And a like button too, even reply or quote button.
PS. I just notice I can 'edit' the comment easily now.
@stevekrouse Everything is working now, thank you!