add support for public content folders

This commit is contained in:
Shaun Walker
2021-05-26 12:01:35 -04:00
parent 1d171d2e56
commit c07e766e57
23 changed files with 281 additions and 123 deletions

View File

@ -1,4 +1,6 @@
using System;
using System.ComponentModel.DataAnnotations.Schema;
using Oqtane.Shared;
namespace Oqtane.Models
{
@ -41,7 +43,7 @@ namespace Oqtane.Models
/// This is calculated at time of Upload, so if the file is manually replaced, the value will be wrong.
/// </summary>
public int ImageHeight { get; set; }
/// <summary>
/// The width of an image (if the file is an image) in pixels.
/// This is calculated at time of Upload, so if the file is manually replaced, the value will be wrong.
@ -65,7 +67,7 @@ namespace Oqtane.Models
#endregion
#region Extended IAuditable Properties, may be moved to an Interface some day so not documented yet
public string DeletedBy { get; set; }
public DateTime? DeletedOn { get; set; }
public bool IsDeleted { get; set; }
@ -78,5 +80,11 @@ namespace Oqtane.Models
/// TODO: not sure if this is always populated, must verify and document
/// </summary>
public Folder Folder { get; set; }
/// <summary>
/// url for accessing file
/// </summary>
[NotMapped]
public string Url { get; set; }
}
}

View File

@ -23,6 +23,11 @@ namespace Oqtane.Models
/// </summary>
public int? ParentId { get; set; }
/// <summary>
/// Folder type - based on FolderTypes
/// </summary>
public string Type { get; set; }
/// <summary>
/// Folder name
/// </summary>

View File

@ -0,0 +1,6 @@
namespace Oqtane.Shared {
public class FolderTypes {
public const string Private = "Private";
public const string Public = "Public";
}
}

View File

@ -113,6 +113,23 @@ namespace Oqtane.Shared
url = (!url.StartsWith("/")) ? "/" + url : url;
return (alias != null && !string.IsNullOrEmpty(alias.Path)) ? "/" + alias.Path + url : url;
}
public static string FormatContent(string content, Alias alias, string operation)
{
switch (operation)
{
case "save":
content = content.Replace(UrlCombine("Content", "Tenants", alias.TenantId.ToString(), "Sites", alias.SiteId.ToString()), "[siteroot]");
content = content.Replace(alias.Path + Constants.ContentUrl, Constants.ContentUrl);
break;
case "render":
content = content.Replace("[siteroot]", UrlCombine("Content", "Tenants", alias.TenantId.ToString(), "Sites", alias.SiteId.ToString()));
content = content.Replace(Constants.ContentUrl, alias.Path + Constants.ContentUrl);
break;
}
return content;
}
public static string GetTypeName(string fullyqualifiedtypename)
{
if (fullyqualifiedtypename.Contains(","))
@ -325,6 +342,11 @@ namespace Oqtane.Shared
return Path.Combine(segments).TrimEnd();
}
public static string UrlCombine(params string[] segments)
{
return string.Join("/", segments);
}
public static bool IsPathValid(this Folder folder)
{
return IsPathOrFileValid(folder.Name);