webmusic/Pages/Index.cshtml

47 lines
1.5 KiB
Plaintext

@page
@model IndexModel
@{
ViewData["Title"] = $"webmusic on .NET {Environment.Version}";
}
@if (Model.Path.Contains("/..")) {
return;
}
@if (Model.Path.EndsWith(".lrc")) {
<h3>@Model.Path</h3>
<p>@Html.Raw((await System.IO.File.ReadAllTextAsync("music" + Model.Path)).Replace("\n", "<br/>"))</p>
}
else {
<h2>
@Model.Displaypath <span id="state"></span> <span id="flags"></span>
</h2>
<a class="action-muted">[..]</a>
<a href="?@Model.PathOneup" class="entry-muted cfont"> Go back</a>
<br/>
<a class="action-muted">[--]</a>
<a href="/playlist/@(Request.QueryString).m3u" class="entry-muted cfont"> Download playlist</a>
<br/>
<br/>
@foreach (var dir in Model.Dirs) {
<a class="action" href="#">[--]</a>
<a href="?@Model.Path/@dir"> @dir</a>
<br/>
}
@foreach (var file in Model.Files) {
var jspath = IndexModel.Encode(Model.Fullpath);
var jsfile = jspath + "/" + IndexModel.Encode(file);
var basename = System.IO.Path.GetFileNameWithoutExtension(file);
var lrcfile = basename + ".lrc";
var lrcpath = System.IO.Path.Combine(Model.Fullpath, lrcfile);
<script>queue.push('@Html.Raw(jsfile)')</script>
<a class="action" href="@Html.Raw(IndexModel.Encode(Model.Fullpath + "/" + file))" download>[DL]</a>
@if (System.IO.File.Exists(lrcpath)) {
<a class="action" href="?@Model.Path/@lrcfile" target="_blank">[LRC]</a>
}
else {
<a class="action" href="#">[---]</a>
}
<a href="#" onclick="playSong('@Html.Raw(jsfile)')"> @file</a>
<br/>
}
}