diff --git a/Src/Sxc/ToSic.Sxc/DataSources/Internal/CmsData/AppFileDataRaw.cs b/Src/Sxc/ToSic.Sxc/DataSources/Internal/CmsData/AppFileDataRaw.cs index 6c5e918c0..65bcf45b8 100644 --- a/Src/Sxc/ToSic.Sxc/DataSources/Internal/CmsData/AppFileDataRaw.cs +++ b/Src/Sxc/ToSic.Sxc/DataSources/Internal/CmsData/AppFileDataRaw.cs @@ -25,12 +25,12 @@ public class AppFileDataRaw: AppFileDataRawBase { public const string TypeName = "File"; - public static DataFactoryOptions Options = new(typeName: TypeName, titleField: nameof(Name)); + public static DataFactoryOptions Options = new(typeName: TypeName, titleField: nameof(Path)); /// /// The file name with extension. /// - [ContentTypeAttributeSpecs(IsTitle = true, Description = "The file name without extension, like my-image")] + [ContentTypeAttributeSpecs(Description = "The file name without extension, like my-image")] public override string Name { get; set; } /// diff --git a/Src/Sxc/ToSic.Sxc/DataSources/Internal/CmsData/AppFileDataRawBase.cs b/Src/Sxc/ToSic.Sxc/DataSources/Internal/CmsData/AppFileDataRawBase.cs index a35646b92..820da2783 100644 --- a/Src/Sxc/ToSic.Sxc/DataSources/Internal/CmsData/AppFileDataRawBase.cs +++ b/Src/Sxc/ToSic.Sxc/DataSources/Internal/CmsData/AppFileDataRawBase.cs @@ -33,7 +33,7 @@ public abstract class AppFileDataRawBase: IRawEntity, IHasRelationshipKeys /// /// Starting in the App-Root /// - [ContentTypeAttributeSpecs(Description = "Full path. It starts at the root of the app or whatever other system you're asking for.")] + [ContentTypeAttributeSpecs(IsTitle = true, Description = "Full path. It starts at the root of the app or whatever other system you're asking for. Always end with slash, so root is `/` and it's easy to distinguish folders and files.")] public string Path { get; set; } /// @@ -50,13 +50,6 @@ public abstract class AppFileDataRawBase: IRawEntity, IHasRelationshipKeys [ContentTypeAttributeSpecs(Description = "The full url starting at the root of the site. Absolute but without protocol/domain.")] public string Url { get; set; } - /// - /// The relative URL based on where the data was requested from. From the App Root or ADAM Root. - /// - [ContentTypeAttributeSpecs(Description = "The relative URL based on where the data was requested from. From the App Root or ADAM Root.")] - public string UrlRelative { get; set; } - - /// /// Data but without Id, Guid, Created, Modified /// @@ -68,12 +61,10 @@ public virtual IDictionary Attributes(RawConvertOptions options) { nameof(FullName), FullName }, { nameof(Path), Path }, { nameof(Url), Url }, - { nameof(UrlRelative), UrlRelative }, { "Parent", new RawRelationship(key: $"Folder:{ParentFolderInternal}") }, // For debugging //{ nameof(ParentFolderInternal), ParentFolderInternal }, - }; [PrivateApi] diff --git a/Src/Sxc/ToSic.Sxc/DataSources/Internal/CmsData/AppFolderDataRaw.cs b/Src/Sxc/ToSic.Sxc/DataSources/Internal/CmsData/AppFolderDataRaw.cs index 32281088f..6a6a560c4 100644 --- a/Src/Sxc/ToSic.Sxc/DataSources/Internal/CmsData/AppFolderDataRaw.cs +++ b/Src/Sxc/ToSic.Sxc/DataSources/Internal/CmsData/AppFolderDataRaw.cs @@ -1,7 +1,6 @@ using ToSic.Eav.Data.Build; using ToSic.Eav.Data.Internal; using ToSic.Eav.Data.Raw; -using ToSic.Eav.Plumbing; namespace ToSic.Sxc.DataSources.Internal; @@ -26,20 +25,20 @@ public class AppFolderDataRaw: AppFileDataRawBase { public const string TypeName = "Folder"; - public static DataFactoryOptions Options = new(typeName: TypeName, titleField: nameof(Title)); + public static DataFactoryOptions Options = new(typeName: TypeName, titleField: nameof(Path)); /// /// The folder name - or blank when it's the root. /// - [ContentTypeAttributeSpecs(IsTitle = true, Description = "The folder name or blank when it's the root.")] + [ContentTypeAttributeSpecs(Description = "The folder name or blank when it's the root.")] public override string Name { get; set; } - /// - /// The folder name. - /// - [ContentTypeAttributeSpecs(IsTitle = true, Description = "The folder name or 'root' when it's the root")] - //public string Title { get => field.NullIfNoValue() ?? "root"; set => field = value; } - public string Title => Name.NullIfNoValue() ?? "root"; + ///// + ///// The folder name. + ///// + //[ContentTypeAttributeSpecs(IsTitle = true, Description = "The folder name or 'root' when it's the root")] + ////public string Title { get => field.NullIfNoValue() ?? "root"; set => field = value; } + //public string Title => Name.NullIfNoValue() ?? "root"; [PrivateApi] @@ -48,7 +47,7 @@ public override IDictionary Attributes(RawConvertOptions options { { "Folders", new RawRelationship(key: $"FolderIn:{Path}") }, { "Files", new RawRelationship(key: $"FileIn:{Path}") }, - { nameof(Title), Title } + //{ nameof(Title), Title }, }; [PrivateApi] diff --git a/Src/Sxc/ToSic.Sxc/DataSources/Internal/CmsProviders/AdamDataSourceProvider.cs b/Src/Sxc/ToSic.Sxc/DataSources/Internal/CmsProviders/AdamDataSourceProvider.cs index 907ad179e..21b719dcb 100644 --- a/Src/Sxc/ToSic.Sxc/DataSources/Internal/CmsProviders/AdamDataSourceProvider.cs +++ b/Src/Sxc/ToSic.Sxc/DataSources/Internal/CmsProviders/AdamDataSourceProvider.cs @@ -19,24 +19,13 @@ public class AdamDataSourceProvider : ServiceBase> adamContext, + ISxcContextResolver ctxResolver) + : MyServicesBase(connect: [adamContext, ctxResolver]) { - public LazySvc> AdamContext { get; } - public ISxcContextResolver CtxResolver { get; } - - /// - /// Note that we will use Generators for safety, because in rare cases the dependencies could be re-used to create a sub-data-source - /// - public MyServices( - LazySvc> adamContext, - ISxcContextResolver ctxResolver - ) - { - ConnectLogs([ - AdamContext = adamContext, - CtxResolver = ctxResolver - ]); - } + public LazySvc> AdamContext { get; } = adamContext; + public ISxcContextResolver CtxResolver { get; } = ctxResolver; } protected AdamDataSourceProvider(MyServices services) : base(services, $"{SxcLogName}.AdamDs") diff --git a/Src/Sxc/ToSic.Sxc/DataSources/Internal/CmsProviders/AppAssetsDataSourceProvider.cs b/Src/Sxc/ToSic.Sxc/DataSources/Internal/CmsProviders/AppAssetsDataSourceProvider.cs index 8500548ab..87454ac03 100644 --- a/Src/Sxc/ToSic.Sxc/DataSources/Internal/CmsProviders/AppAssetsDataSourceProvider.cs +++ b/Src/Sxc/ToSic.Sxc/DataSources/Internal/CmsProviders/AppAssetsDataSourceProvider.cs @@ -77,17 +77,16 @@ public AppAssetsDataSourceProvider Configure( //var fullName = FullNameWithoutAppFolder(f.FullName, _appPaths, _root); var fullNameFromAppRoot = FullNameWithoutAppFolder(f.FullName, pathsFromRoot); var name = Path.GetFileNameWithoutExtension(f.FullName); + var path = fullNameFromAppRoot.TrimPrefixSlash(); return new AppFileDataRaw { Name = name, Extension = f.Extension.TrimStart('.'), // Extension is without the dot FullName = $"{name}{f.Extension}", - ParentFolderInternal = fullNameFromAppRoot.BeforeLast("/").SuffixSlash(), - Path = fullNameFromAppRoot, + ParentFolderInternal = path.BeforeLast("/").SuffixSlash(), + Path = path, // TODO convert characters for safe HTML Url = $"{_appPaths.Path}{fullNameFromAppRoot}", - UrlRelative = fullNameFromAppRoot, - Size = f.Length, Created = f.CreationTime, @@ -125,16 +124,16 @@ private AppFolderDataRaw ToFolderData(DirectoryInfo d, PreparedPaths pathsFromRo // Name is the name of the folder, but if an alternative name is provided, use that instead // this is for the root, which should have an "empty" name var name = altName ?? Path.GetFileName(d.FullName); + return new() { Name = altName ?? name, FullName = name, - ParentFolderInternal = fullNameFromAppRoot.BeforeLast("/").SuffixSlash(), - Path = fullNameFromAppRoot.SuffixSlash(), + ParentFolderInternal = fullNameFromAppRoot.TrimPrefixSlash().BeforeLast("/").SuffixSlash(), + Path = fullNameFromAppRoot.TrimPrefixSlash().SuffixSlash(), Created = d.CreationTime, Modified = d.LastWriteTime, Url = $"{_appPaths.Path}{fullNameFromAppRoot}", - UrlRelative = fullNameFromAppRoot, }; }