86 lines
No EOL
3.6 KiB
Text
86 lines
No EOL
3.6 KiB
Text
<%
|
|
const getMediaType = (filename) => {
|
|
const ext = filename.slice(((filename.lastIndexOf(".") - 2) >>> 0) + 2).toLowerCase();
|
|
const videoExts = ['.mp4', '.mov', '.avi', '.flv', '.mkv', '.wmv', '.webm'];
|
|
const imageExts = ['.jpg', '.jpeg', '.png', '.gif', '.bmp', '.svg', '.tiff', '.webp'];
|
|
|
|
if (videoExts.includes(ext)) return 'video';
|
|
if (imageExts.includes(ext)) return 'image';
|
|
return 'other';
|
|
};
|
|
|
|
function sanitizeId(filename) {
|
|
return filename.replace(/[^a-z0-9]/gi, '_');
|
|
}
|
|
%>
|
|
|
|
<% files.forEach(function(file) { %>
|
|
<li id="<%= file.path %>" class="show">
|
|
<div class="view">
|
|
<% const mediaType = getMediaType(file.path); %>
|
|
|
|
<% if (mediaType === 'video') { %>
|
|
<div class="video">
|
|
<% const sanitizedId = file.path.replace(/[^a-z0-9]/gi, '_'); %>
|
|
|
|
<div id="spinner-<%= sanitizedId %>" class="spinner" style="display: <%= file.isProcessed ? 'none' : 'block' %>;">
|
|
<div class="spinner-content">
|
|
Optimizing Video for Sharing...
|
|
</div>
|
|
</div>
|
|
|
|
<div id="media-container-<%= sanitizedId %>" class="video-container" style="display: <%= file.isProcessed ? 'block' : 'none' %>;">
|
|
<video class="image" autoplay loop muted playsinline>
|
|
<source src="/uploads/720p-<%= file.path %>">
|
|
</video>
|
|
</div>
|
|
|
|
<div class="overlay">
|
|
<% if(user.username === "admin" && file.username !== "admin") { %>
|
|
<small class="username"><%= file.username %></small>
|
|
<br>
|
|
<% } %>
|
|
<a href="/gifv/<%= file.path %>" onclick="copyA(event)">Copy as GIFv</a>
|
|
</div>
|
|
</div>
|
|
<% } else if (mediaType === 'image') { %>
|
|
<!-- Image container -->
|
|
<div class="video">
|
|
<img class="image"
|
|
src="/uploads/<%= file.path %>"
|
|
onclick="copyURI(event)"
|
|
loading="lazy">
|
|
|
|
<% if(user.username === "admin" && file.username !== "admin") { %>
|
|
<div class="overlay">
|
|
<small class="username"><%= file.username %></small>
|
|
</div>
|
|
<% } %>
|
|
</div>
|
|
|
|
<% } else { %>
|
|
<!-- Non-media file -->
|
|
<div class="nonmedia" onclick="copyPath('/uploads/<%= file.path %>')">
|
|
<p><%= file.path.split('.').pop().toUpperCase() %> file</p>
|
|
<% if(user.username === "admin" && file.username !== "admin") { %>
|
|
<div class="overlay">
|
|
<small class="username"><%= file.username %></small>
|
|
</div>
|
|
<% } %>
|
|
</div>
|
|
<% } %>
|
|
|
|
<label><%= file.path %></label>
|
|
<button class="destroy"
|
|
hx-get="<%= file.url %>/delete"
|
|
hx-trigger="click"
|
|
hx-target="#embedder-list"
|
|
hx-swap="innerHTML">
|
|
</button>
|
|
<button type="button"
|
|
class="fullsize"
|
|
onclick="openFullSize('/uploads/<%= file.path %>')">
|
|
</button>
|
|
</div>
|
|
</li>
|
|
<% }); %> |