IPaths updates

This commit is contained in:
2021-08-11 15:47:42 +02:00
parent f8ec7320d2
commit e2c98e5144
4 changed files with 20 additions and 15 deletions
+17 -8
View File
@@ -1,4 +1,5 @@
using System;
using Microsoft.AspNetCore.Hosting;
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
@@ -8,10 +9,14 @@ namespace zero.Core
{
public class Paths : IPaths
{
public string Root { get; set; }
public string WebRoot { get; set; }
public string ContentRoot { get; set; }
public string Media { get; set; }
protected IWebHostEnvironment Env { get; set; }
private bool IsDebug { get; set; }
public const string MEDIA_FOLDER = "Uploads";
@@ -29,11 +34,13 @@ namespace zero.Core
};
public Paths(string root, bool isDebug)
public Paths(IWebHostEnvironment env, bool isDebug)
{
Env = env;
IsDebug = isDebug;
Root = root;
Media = Path.Combine(root, MEDIA_FOLDER);
WebRoot = env.WebRootPath;
ContentRoot = env.ContentRootPath;
Media = Path.Combine(WebRoot, MEDIA_FOLDER);
}
@@ -42,7 +49,7 @@ namespace zero.Core
/// </summary>
public string Map(string path)
{
return Path.Combine(Root, path);
return Path.Combine(WebRoot, path);
}
/// <summary>
@@ -50,7 +57,7 @@ namespace zero.Core
/// </summary>
public string Map(params string[] paths)
{
return Path.Combine(Root, Path.Combine(paths));
return Path.Combine(WebRoot, Path.Combine(paths));
}
@@ -116,7 +123,9 @@ namespace zero.Core
public interface IPaths
{
string Root { get; set; }
string ContentRoot { get; set; }
string WebRoot { get; set; }
string Media { get; set; }
+1 -1
View File
@@ -249,7 +249,7 @@ a.ui-table-row:hover, button.ui-table-row:hover
.ui-table-cell .-minor
{
color: var(--color-text-dim-one);
color: var(--color-text-dim);
font-weight: 400;
font-size: var(--font-size-xs);
}
+1 -1
View File
@@ -97,7 +97,7 @@ namespace zero.Web.Controllers
return File(content, contentType, DateTimeOffset.Now, EntityTagHeaderValue.Any);
}
string fullPath = Path.Combine(Paths.Root, path?.Trim('/') ?? String.Empty);
string fullPath = Path.Combine(Paths.WebRoot, path?.Trim('/') ?? String.Empty);
if (path == null || !System.IO.File.Exists(fullPath))
{
+1 -5
View File
@@ -118,11 +118,7 @@ namespace zero.Web
Services.AddHttpContextAccessor();
Services.AddTransient<IZeroVue, ZeroVue>();
Services.AddTransient<IPaths>(factory =>
{
IWebHostEnvironment env = factory.GetService<IWebHostEnvironment>();
return new Paths(env.WebRootPath, true);
});
Services.AddScoped<IPaths>(factory => new Paths(factory.GetService<IWebHostEnvironment>(), true));
Services.AddTransient<IHandlerHolder, HandlerHolder>();