appendix: 23 Code-Ausschnitte aus dem Houston-Repository
Pin nixpkgs to the revision used by itc.componentware: the channel version ships a latexminted that crashes on Python 3.14, which made every listing fail and sent latexmk into an endless error prompt. Also force nonstopmode/halt-on-error so a broken listing can never loop again.
This commit is contained in:
@@ -0,0 +1,61 @@
|
||||
using Houston.Model.Documents;
|
||||
using Microsoft.AspNetCore.Authorization;
|
||||
using Microsoft.AspNetCore.Http.Extensions;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Microsoft.AspNetCore.Mvc.RazorPages;
|
||||
|
||||
namespace Houston.Pages.Document;
|
||||
|
||||
/// <summary>
|
||||
/// Anonymous landing page for shared document links. It exposes only metadata derived from the
|
||||
/// document id and never fetches or renders file contents.
|
||||
/// </summary>
|
||||
public class Share : PageModel
|
||||
{
|
||||
[BindProperty(SupportsGet = true)]
|
||||
public string Id { get; set; } = String.Empty;
|
||||
|
||||
public string Title { get; private set; } = "Dokument";
|
||||
|
||||
public string ImageUrl { get; private set; } = String.Empty;
|
||||
|
||||
public string ExplorerUrl { get; private set; } = String.Empty;
|
||||
|
||||
public IActionResult OnGet()
|
||||
{
|
||||
var docId = new DocumentId(Id);
|
||||
|
||||
if (!docId.TryDecode(out var relativePath))
|
||||
return NotFound();
|
||||
|
||||
var type = relativePath.Value.Type;
|
||||
var name = relativePath.Value.Name;
|
||||
var iconPath = type.PreviewPath;
|
||||
|
||||
Title = name.DisplayName;
|
||||
ImageUrl = AbsoluteUrl(iconPath);
|
||||
ExplorerUrl = AbsoluteUrl("/documents", BuildExplorerQuery(type, name), $"#{Documents.DocumentViewId(docId)}");
|
||||
|
||||
return Page();
|
||||
}
|
||||
|
||||
private static QueryString BuildExplorerQuery(DocumentType? type, DocumentName name)
|
||||
{
|
||||
return new QueryBuilder {
|
||||
{ "q", name.DisplayName },
|
||||
{ "types", type.Name }
|
||||
}.ToQueryString();
|
||||
}
|
||||
|
||||
private string AbsoluteUrl(string path, QueryString query = default, string? fragment = null)
|
||||
{
|
||||
return UriHelper.BuildAbsolute(
|
||||
Request.Scheme,
|
||||
Request.Host,
|
||||
Request.PathBase,
|
||||
path,
|
||||
query,
|
||||
fragment: fragment is null ? default : new FragmentString(fragment)
|
||||
);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user