diff --git a/client/main.js b/client/main.js index bef7414..06cfd74 100644 --- a/client/main.js +++ b/client/main.js @@ -1,10 +1,17 @@ import Route from "../route.js"; import auth from "../form/auth.js"; +import initDb from "../db.js"; + +let db = await initDb(); let main = new Route([auth], async function (req, res, input) { let { username } = input; + let videos = await db.all('SELECT * FROM video ORDER BY date DESC', [ + req.query.id + ]); return res.render('main', { - username + username, + videos }); }); diff --git a/client/upload.js b/client/upload.js index 1af2ec0..f21f555 100644 --- a/client/upload.js +++ b/client/upload.js @@ -8,7 +8,7 @@ let main = new Route([auth], async function (req, res, input) { data: [ { label: "Video file", type: "file", name: "file" }, { label: "Name", type: "text", name: "title" }, - { label: "Description", type: "text", name: "desc" } + { label: "Description", type: "textarea", name: "desc" } ], 'route': '/api/upload/upload', 'title': 'Upload Content', diff --git a/db.js b/db.js index 51338de..55a6d9e 100644 --- a/db.js +++ b/db.js @@ -14,7 +14,7 @@ async function initDb() { await db.run(`CREATE TABLE IF NOT EXISTS auth (username TEXT, password TEXT);`); await db.run(`CREATE TABLE IF NOT EXISTS token (username TEXT, token TEXT);`); - await db.run(`CREATE TABLE IF NOT EXISTS video (id TEXT, title TEXT, desc TEXT, username TEXT);`); + await db.run(`CREATE TABLE IF NOT EXISTS video (id TEXT, title TEXT, desc TEXT, username TEXT, date REAL);`); return db; } diff --git a/form/upload.js b/form/upload.js index a6b9193..da378f8 100644 --- a/form/upload.js +++ b/form/upload.js @@ -21,15 +21,17 @@ let main = new Route([auth], async function (req, res, input) { try { await execP(`ffmpeg -i ${path} videos/${id}.mp4`); + await execP(`ffmpeg -i videos/${id}.mp4 -frames:v 1 videos/${id}.png`); } catch (err) { return { 'success': false, 'message': 'Video is invalid'} } - await db.run('INSERT INTO video (id, title, desc, username) VALUES (?, ?, ?, ?)', [ + await db.run('INSERT INTO video (id, title, desc, username, date) VALUES (?, ?, ?, ?, ?)', [ id, title, desc, - username + username, + +new Date() ]); return { 'message': 'Video created', 'success': true, 'redirect': '/client/video?id='+id }; diff --git a/static/main.css b/static/main.css index a677b0c..0947bac 100644 --- a/static/main.css +++ b/static/main.css @@ -35,7 +35,8 @@ input, textarea, .button, .area, -form { +form, +.video { border: solid var(--dark-2) 3px; border-radius: 5px; @@ -113,4 +114,22 @@ form { video { width: 690px; +} + +.video img { + width: 200px; +} + +.videos { + display: flex; + flex-direction: row; + flex-wrap: wrap; +} + +.videos a{ + color: var(--dark-1); +} + +textarea { + display: block; } \ No newline at end of file diff --git a/views/form.ejs b/views/form.ejs index 2a6c2cd..fe0f734 100644 --- a/views/form.ejs +++ b/views/form.ejs @@ -7,8 +7,14 @@ <% for (let elem of data) { %> <%= elem.label %> - + + <% if (elem.type=='textarea' ) { %> + + <% } else { %> + + <% } %> - + <% } %> + <%- include('footer.ejs') -%> \ No newline at end of file diff --git a/views/main.ejs b/views/main.ejs index 6f67736..85df031 100644 --- a/views/main.ejs +++ b/views/main.ejs @@ -3,12 +3,19 @@

BiglyChat

Collab on videos... make creative animations... and more!

About

-

I am Onez, a self-taught developer from a young age. Following the unexpected growth - of Video Bot Thing, I made this as a home for the logo editing community. View the I am Onez, a self-taught developer from a young age. Following the + unexpected growth + of Video Bot Thing, I made this as a home for the video editing community. View the source if you want to contribute or make a fork.

<%if (username=='!nobody' ) { %>
Join
<% } %> +
+

Recent Videos

+
+ <%- include('videos.ejs') -%> +
+
<%- include('footer.ejs') -%> \ No newline at end of file diff --git a/views/player.ejs b/views/player.ejs index 347c0d2..d757e53 100644 --- a/views/player.ejs +++ b/views/player.ejs @@ -9,6 +9,7 @@
by <%= videoData.username %>
+
<%= videoData.desc %>
<%- include('footer.ejs') -%> \ No newline at end of file diff --git a/views/videos.ejs b/views/videos.ejs new file mode 100644 index 0000000..c8679c2 --- /dev/null +++ b/views/videos.ejs @@ -0,0 +1,14 @@ +<%for (videoData of videos) { %> + +
+ +
+ <%= videoData.title %> + +
+
by + <%= videoData.username %> +
+
+ + <% } %> \ No newline at end of file