Add razor page support

This commit is contained in:
jvyden 2021-11-19 21:35:15 -05:00
commit 0d5139489a
No known key found for this signature in database
GPG key ID: 18BCF2BE0262B278
6 changed files with 41 additions and 2 deletions

View file

@ -2,6 +2,7 @@ using System;
using System.IO;
using Kettu;
using LBPUnion.ProjectLighthouse.Logging;
using LBPUnion.ProjectLighthouse.Types.Settings;
namespace LBPUnion.ProjectLighthouse.Helpers
{
@ -50,6 +51,7 @@ namespace LBPUnion.ProjectLighthouse.Helpers
public static string CommitHash { get; set; }
public static string Branch { get; set; }
public static string FullVersion => $"{ServerStatics.ServerName} {Branch}@{CommitHash}";
public static bool IsDirty => CommitHash.EndsWith("-dirty");
public static bool CanCheckForUpdates { get; set; }
}

View file

@ -0,0 +1,21 @@
@page "/"
@using LBPUnion.ProjectLighthouse.Helpers
@model LBPUnion.ProjectLighthouse.Controllers.ExternalAuth.LandingPage
@{
Layout = null;
}
<!DOCTYPE html>
<html>
<head>
<title>Project Lighthouse External Auth</title>
</head>
<body>
test
</body>
<footer>
<p>Page generated by @GitVersionHelper.FullVersion</p>
</footer>
</html>

View file

@ -0,0 +1,10 @@
using Microsoft.AspNetCore.Mvc;
using Microsoft.AspNetCore.Mvc.RazorPages;
namespace LBPUnion.ProjectLighthouse.Controllers.ExternalAuth
{
public class LandingPage : PageModel
{
public IActionResult OnGet() => this.Page();
}
}

View file

@ -29,7 +29,7 @@ namespace LBPUnion.ProjectLighthouse
Logger.AddLogger(new LighthouseFileLogger());
Logger.Log("Welcome to Project Lighthouse!", LoggerLevelStartup.Instance);
Logger.Log($"Running {ServerStatics.ServerName} {GitVersionHelper.CommitHash}@{GitVersionHelper.Branch}", LoggerLevelStartup.Instance);
Logger.Log($"Running {GitVersionHelper.FullVersion}", LoggerLevelStartup.Instance);
// This loads the config, see ServerSettings.cs for more information
Logger.Log("Loaded config file version " + ServerSettings.Instance.ConfigVersion, LoggerLevelStartup.Instance);

View file

@ -32,6 +32,10 @@
</EmbeddedResource>
</ItemGroup>
<ItemGroup>
<Folder Include="Controllers\ExternalAuth"/>
</ItemGroup>
<Target Name="PreBuild" BeforeTargets="PreBuildEvent">
<Exec Command="git describe --long --always --dirty --exclude=\* --abbrev=8 &gt; &quot;$(ProjectDir)/gitVersion.txt&quot;"/>
<Exec Command="git branch --show-current &gt; &quot;$(ProjectDir)/gitBranch.txt&quot;"/>

View file

@ -29,6 +29,7 @@ namespace LBPUnion.ProjectLighthouse
public void ConfigureServices(IServiceCollection services)
{
services.AddControllers();
services.AddRazorPages().WithRazorPagesAtContentRoot();
services.AddMvc
(
@ -152,7 +153,8 @@ namespace LBPUnion.ProjectLighthouse
app.UseRouting();
app.UseEndpoints(endpoints => endpoints.MapControllers());
// app.UseEndpoints(endpoints => endpoints.MapControllers());
app.UseEndpoints(endpoints => endpoints.MapRazorPages());
}
}
}