diff --git a/index.js b/index.js index 23358c4..a849ae3 100644 --- a/index.js +++ b/index.js @@ -180,7 +180,7 @@ app.get("/api/logout", authorized(), (req, res) => { }); app.post("/api/upload-video", authorized(), fileUpload({ limits: { fileSize: 2 ** 26 }, useTempFiles: true }), async (req, res) => { - const { title } = req.body; + const { title, description } = req.body; if (!title) { return res.status(400).json({ ok: false, error: "bad request" }); } @@ -229,7 +229,10 @@ app.post("/api/upload-video", authorized(), fileUpload({ limits: { fileSize: 2 * return; } - dbRun("INSERT INTO videos (id, user_id, title) VALUES (?, ?, ?)", id, userId, title); + dbRun( + "INSERT INTO videos (id, user_id, title, description, created_at) VALUES (?, ?, ?, ?, ?)", + id, userId, title, description ?? "", new Date().toISOString() + ); const index = videoQueue.indexOf(item => item.videoId === queueItem.videoId) videoQueue.splice(index, 1); @@ -250,7 +253,7 @@ app.get("/api/video-info", async (req, res) => { const id = req.query["id"]; const video = await dbGet(` - SELECT videos.id, videos.title, users.username AS author + SELECT videos.id, videos.title, videos.description, videos.created_at, users.username AS author FROM videos JOIN users ON users.id = videos.user_id WHERE videos.id = ? diff --git a/migration.sql b/migration.sql index dcff1ff..ea8d934 100644 --- a/migration.sql +++ b/migration.sql @@ -8,6 +8,8 @@ CREATE TABLE videos ( id TEXT PRIMARY KEY NOT NULL, user_id INTEGER, title TEXT NOT NULL, + description TEXT NOT NULL, + created_at TEXT NOT NULL, FOREIGN KEY(user_id) REFERENCES users(id) ); diff --git a/public/style.css b/public/style.css index d51fd76..1ec74b4 100644 --- a/public/style.css +++ b/public/style.css @@ -1,20 +1,39 @@ -*, *::before, *::after { - box-sizing: border-box; - appearance: none; -} - :root { color-scheme: light dark; --red: #c51e0e; } +@media (prefers-color-scheme: dark) { + :root { + --red: #F4511E; + } +} + +*, *::before, *::after { + box-sizing: border-box; + appearance: none; +} + +*:focus { + outline: 2px solid var(--red); +} + body { margin: 0 auto; padding: 0; text-align: center; } +a { + color: var(--red); +} + +textarea, input { + font-family: sans-serif; + font-size: 0.8em; +} + nav { margin-bottom: 20px; } @@ -135,7 +154,3 @@ input::file-selector-button { font-weight: bold; } -a { - color: var(--red); -} - diff --git a/public/upload/index.html b/public/upload/index.html index 9a264cb..a6e5296 100644 --- a/public/upload/index.html +++ b/public/upload/index.html @@ -5,6 +5,7 @@ MaoTube + @@ -12,6 +13,8 @@
+ +

@@ -19,6 +22,18 @@

View upload queue
+ + + + diff --git a/public/upload/script.js b/public/upload/script.js index 30436ea..80c31a6 100644 --- a/public/upload/script.js +++ b/public/upload/script.js @@ -1,14 +1,22 @@ -document.getElementById("upload-form").addEventListener("submit", async event => { +document.getElementById("upload-form").addEventListener("submit", event => { event.preventDefault(); const data = new FormData(event.target); - console.log(data); - await fetch("/api/upload-video", { + fetch("/api/upload-video", { method: "POST", body: data, + }) + .then(response => response.json()) + .then(response => { + if (!response.ok) { + error(response.error); + return; + } + + location.href = "/queue"; + }) + .catch(err => { + error("failed to upload video"); }); - - - location.href = "/queue"; }); diff --git a/public/watch/index.html b/public/watch/index.html index a4294e9..d6f117b 100644 --- a/public/watch/index.html +++ b/public/watch/index.html @@ -4,6 +4,8 @@ MaoTube + +

MaoTube

@@ -12,7 +14,11 @@

- +

+
+
+
+