mirror of
https://git.v0l.io/Kieran/void.cat.git
synced 2025-03-29 16:01:43 +01:00
Fallback to index
This commit is contained in:
parent
0249b1cedf
commit
d85dd7b937
@ -24,10 +24,7 @@ public class IndexController : Controller
|
||||
[Route("{id}")]
|
||||
public async Task<IActionResult> FilePreview(string id)
|
||||
{
|
||||
if (!id.TryFromBase58Guid(out var gid)) return NotFound();
|
||||
|
||||
var meta = await _fileMetadata.Get(gid);
|
||||
if (meta == default) return NotFound();
|
||||
id.TryFromBase58Guid(out var gid);
|
||||
|
||||
var manifestPath = Path.Combine(_webHost.WebRootPath, "asset-manifest.json");
|
||||
if (!System.IO.File.Exists(manifestPath)) return StatusCode(500);
|
||||
@ -35,14 +32,14 @@ public class IndexController : Controller
|
||||
var jsonManifest = await System.IO.File.ReadAllTextAsync(manifestPath);
|
||||
return View("~/Pages/Index.cshtml", new IndexModel
|
||||
{
|
||||
Meta = meta,
|
||||
Meta = await _fileMetadata.Get(gid),
|
||||
Manifest = JsonConvert.DeserializeObject<AssetManifest>(jsonManifest)!
|
||||
});
|
||||
}
|
||||
|
||||
public class IndexModel
|
||||
{
|
||||
public VoidFileMeta Meta { get; init; }
|
||||
public VoidFileMeta? Meta { get; init; }
|
||||
|
||||
public AssetManifest Manifest { get; init; }
|
||||
}
|
||||
|
@ -9,15 +9,43 @@
|
||||
<link rel="icon" href="/favicon.ico"/>
|
||||
<link rel="apple-touch-icon" href="/logo.png"/>
|
||||
<link rel="manifest" href="/manifest.json"/>
|
||||
|
||||
<title>void.cat - @Model.Meta.Name</title>
|
||||
<meta name="description" content="@Model.Meta.Description"/>
|
||||
|
||||
<meta property="og:site_name" content="void.cat"/>
|
||||
<meta property="og:title" content="@Model.Meta.Name"/>
|
||||
<meta property="og:description" content="@Model.Meta.Description"/>
|
||||
<meta property="og:url" content="@($"https://{Context.Request.Host}/{Model.Meta.Id.ToBase58()}")"/>
|
||||
|
||||
|
||||
@if (Model.Meta != default)
|
||||
{
|
||||
<title>void.cat - @Model.Meta.Name</title>
|
||||
<meta name="description" content="@Model.Meta.Description"/>
|
||||
<meta property="og:site_name" content="void.cat"/>
|
||||
<meta property="og:title" content="@Model.Meta.Name"/>
|
||||
<meta property="og:description" content="@Model.Meta.Description"/>
|
||||
<meta property="og:url" content="@($"https://{Context.Request.Host}/{Model.Meta.Id.ToBase58()}")"/>
|
||||
|
||||
var mime = Model.Meta.MimeType;
|
||||
if (mime != default)
|
||||
{
|
||||
var link = $"https://{Context.Request.Host}/d/{Model.Meta.Id.ToBase58()}";
|
||||
if (mime.StartsWith("image/"))
|
||||
{
|
||||
<meta property="og:image" content="@link"/>
|
||||
<meta property="og:image:type" content="@mime"/>
|
||||
}
|
||||
else if (mime.StartsWith("video/"))
|
||||
{
|
||||
<meta property="og:video" content="@link"/>
|
||||
<meta property="og:video:type" content="@mime"/>
|
||||
}
|
||||
else if (mime.StartsWith("audio/"))
|
||||
{
|
||||
<meta property="og:audio" content="@link"/>
|
||||
<meta property="og:audio:type" content="@mime"/>
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
<title>void.cat</title>
|
||||
<meta name="description" content="void.cat - free, simple file sharing."/>
|
||||
}
|
||||
|
||||
@foreach (var ep in Model.Manifest.Entrypoints)
|
||||
{
|
||||
switch (System.IO.Path.GetExtension(ep))
|
||||
@ -34,28 +62,6 @@
|
||||
}
|
||||
}
|
||||
}
|
||||
@{
|
||||
var mime = Model.Meta.MimeType;
|
||||
}
|
||||
@if (mime != default)
|
||||
{
|
||||
var link = $"https://{Context.Request.Host}/d/{Model.Meta.Id.ToBase58()}";
|
||||
if (mime.StartsWith("image/"))
|
||||
{
|
||||
<meta property="og:image" content="@link"/>
|
||||
<meta property="og:image:type" content="@mime"/>
|
||||
}
|
||||
else if (mime.StartsWith("video/"))
|
||||
{
|
||||
<meta property="og:video" content="@link"/>
|
||||
<meta property="og:video:type" content="@mime"/>
|
||||
}
|
||||
else if (mime.StartsWith("audio/"))
|
||||
{
|
||||
<meta property="og:audio" content="@link"/>
|
||||
<meta property="og:audio:type" content="@mime"/>
|
||||
}
|
||||
}
|
||||
</head>
|
||||
<body>
|
||||
<noscript>You need to enable JavaScript to run this app.</noscript>
|
||||
|
Loading…
x
Reference in New Issue
Block a user