diff --git a/src/main/controllers/web.zig b/src/main/controllers/web.zig index 993b773..d176239 100644 --- a/src/main/controllers/web.zig +++ b/src/main/controllers/web.zig @@ -233,6 +233,7 @@ const user_details = struct { const drive = struct { const dir_tmpl = @embedFile("./web/drive/directory.tmpl.html"); + const file_tmpl = @embedFile("./web/drive/file.tmpl.html"); fn servePage(req: anytype, res: anytype, srv: anytype) !void { const info = try srv.driveGet(req.args.path); defer util.deepFree(srv.allocator, info); @@ -246,6 +247,14 @@ const drive = struct { try breadcrumbs.append(if (p.len != 0) p else continue); } + // TODO: put this into the db layer + const FileClass = enum { + image, + video, + audio, + other, + }; + switch (info) { .dir => |dir| try res.template(.ok, srv, dir_tmpl, .{ .dir = dir, @@ -253,7 +262,16 @@ const drive = struct { .mount_path = req.mount_path, .base_drive_path = "drive", }), - else => unreachable, + .file => |file| try res.template(.ok, srv, file_tmpl, .{ + .file = file, + .breadcrumbs = breadcrumbs.items, + .mount_path = req.mount_path, + .base_drive_path = "drive", + .class = if (std.mem.eql(u8, file.meta.content_type orelse "", "image/jpeg")) + FileClass.image + else + FileClass.other, + }), } } diff --git a/src/main/controllers/web/drive/file.tmpl.html b/src/main/controllers/web/drive/file.tmpl.html new file mode 100644 index 0000000..f3dd64d --- /dev/null +++ b/src/main/controllers/web/drive/file.tmpl.html @@ -0,0 +1,67 @@ +
+ + + + +
+

{.file.name.?}

+
+ {#if @isTag(.class, image) =} + + {#elif @isTag(.class, video) =} +
+
+

Metadata

+ +

Drive Path

+
{.file.path}
+ +

Filename

+
{.file.meta.filename}
+ +

Content Type

+
{.file.meta.content_type}
+ +

Sensitive?

+
{.file.meta.sensitive}
+ +

Description

+
{.file.meta.description}
+
+
+