← Back to Files
Files.cshtml
@page "/files"
@model FilesModel
@{
ViewData["Title"] = "Files - KaiChat";
}
<div class="page-header">
<a href="/" class="back-link">← Back to Chat</a>
<h1>File Browser</h1>
</div>
<div class="file-browser">
<div class="file-path">
<a href="/files">~</a>
@if (!string.IsNullOrEmpty(Model.CurrentPath))
{
var parts = Model.CurrentPath.Split('/');
var accum = "";
foreach (var part in parts)
{
accum = string.IsNullOrEmpty(accum) ? part : $"{accum}/{part}";
<span>/</span>
<a href="/files?path=@Uri.EscapeDataString(accum)">@part</a>
}
}
</div>
<div class="file-list">
@if (!string.IsNullOrEmpty(Model.CurrentPath))
{
var parentPath = string.IsNullOrEmpty(Model.CurrentPath) ? "" :
Model.CurrentPath.Contains('/') ? Model.CurrentPath[..Model.CurrentPath.LastIndexOf('/')] : "";
<div class="file-item dir-item">
<a href="/files?path=@Uri.EscapeDataString(parentPath)" class="file-link">
<span class="file-icon">📁</span>
<span class="file-name">.. (parent)</span>
</a>
</div>
}
@foreach (var item in Model.Contents)
{
<div class="file-item @(item.IsDirectory ? "dir-item" : "file-item-actual")">
@if (item.IsDirectory)
{
<a href="/files?path=@Uri.EscapeDataString(item.RelativePath)" class="file-link">
<span class="file-icon">📁</span>
<span class="file-name">@item.Name/</span>
</a>
}
else
{
<a href="/file-view?path=@Uri.EscapeDataString(item.RelativePath)" class="file-link">
<span class="file-icon">📄</span>
<span class="file-name">@item.Name</span>
</a>
<span class="file-size">@item.SizeDisplay</span>
<span class="file-date">@item.LastModified.ToString("g")</span>
}
</div>
}
</div>
@if (Model.Contents.Count == 0)
{
<div class="file-empty">This folder is empty.</div>
}
</div>