heystreamer/views/media.ejs
Bashy 6c7facadce
Some checks failed
CI / check (push) Has been cancelled
rework
2026-04-26 23:00:55 +03:00

53 lines
1.7 KiB
Text

<h2>Media library</h2>
<p><small>Upload audio (MP3, WAV, OGG) or video (MP4, WebM) files to use in actions. Max 50 MB.</small></p>
<form method="POST" action="/media/upload" enctype="multipart/form-data">
<div style="display:flex; gap:1rem; align-items:flex-end;">
<label style="flex:1;">
File
<input type="file" name="file" accept="audio/*,video/*" required>
</label>
<button type="submit">Upload</button>
</div>
</form>
<% if (files.length === 0) { %>
<p><em>No files uploaded yet.</em></p>
<% } else { %>
<figure>
<table>
<thead>
<tr>
<th>Name</th>
<th>Type</th>
<th>Size</th>
<th>Uploaded</th>
<th>Preview</th>
<th></th>
</tr>
</thead>
<tbody>
<% for (const f of files) { %>
<tr>
<td><%= f.original_name %></td>
<td><code><%= f.media_type %></code></td>
<td><%= (f.size_bytes / 1024).toFixed(0) %> KB</td>
<td><small><%= f.uploaded_at %></small></td>
<td>
<% if (f.media_type === 'audio') { %>
<audio controls src="/media/<%= f.filename %>" style="height:28px; width:160px;"></audio>
<% } else { %>
<video controls src="/media/<%= f.filename %>" style="height:40px; width:80px;"></video>
<% } %>
</td>
<td>
<form method="POST" action="/media/<%= f.id %>/delete" onsubmit="return confirm('Delete this file?')">
<button type="submit" class="outline" style="padding:0.2rem 0.6rem; font-size:0.8rem; color:#f88;">Delete</button>
</form>
</td>
</tr>
<% } %>
</tbody>
</table>
</figure>
<% } %>