Adds a VirtualPath property to IFile which is the relative path of the file to the root of the website.
This commit is contained in:
@@ -62,7 +62,7 @@ namespace Umbraco.Core.Models
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the Path to the File from the root of the site
|
||||
/// Gets or sets the Path to the File from the root of the file's associated IFileSystem
|
||||
/// </summary>
|
||||
[DataMember]
|
||||
public virtual string Path
|
||||
@@ -99,6 +99,11 @@ namespace Umbraco.Core.Models
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the file's virtual path (i.e. the file path relative to the root of the website)
|
||||
/// </summary>
|
||||
public string VirtualPath { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Boolean indicating whether the file could be validated
|
||||
/// </summary>
|
||||
|
||||
@@ -19,7 +19,7 @@ namespace Umbraco.Core.Models
|
||||
string Alias { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the Path to the File from the root of the site
|
||||
/// Gets or sets the Path to the File from the root of the file's associated IFileSystem
|
||||
/// </summary>
|
||||
string Path { get; set; }
|
||||
|
||||
@@ -28,6 +28,11 @@ namespace Umbraco.Core.Models
|
||||
/// </summary>
|
||||
string Content { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the file's virtual path (i.e. the file path relative to the root of the website)
|
||||
/// </summary>
|
||||
string VirtualPath { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Boolean indicating whether the file could be validated
|
||||
/// </summary>
|
||||
|
||||
@@ -140,6 +140,7 @@ namespace Umbraco.Core.Persistence.Repositories
|
||||
//the id can be the hash
|
||||
entity.Id = entity.Path.GetHashCode();
|
||||
entity.Key = entity.Path.EncodeAsGuid();
|
||||
entity.VirtualPath = FileSystem.GetUrl(entity.Path);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -153,6 +154,7 @@ namespace Umbraco.Core.Persistence.Repositories
|
||||
//the id can be the hash
|
||||
entity.Id = entity.Path.GetHashCode();
|
||||
entity.Key = entity.Path.EncodeAsGuid();
|
||||
entity.VirtualPath = FileSystem.GetUrl(entity.Path);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -39,6 +39,7 @@ namespace Umbraco.Core.Persistence.Repositories
|
||||
var created = FileSystem.GetCreated(path).UtcDateTime;
|
||||
var updated = FileSystem.GetLastModified(path).UtcDateTime;
|
||||
|
||||
|
||||
var script = new PartialView(path)
|
||||
{
|
||||
//id can be the hash
|
||||
@@ -46,7 +47,8 @@ namespace Umbraco.Core.Persistence.Repositories
|
||||
Content = content,
|
||||
Key = path.EncodeAsGuid(),
|
||||
CreateDate = created,
|
||||
UpdateDate = updated
|
||||
UpdateDate = updated,
|
||||
VirtualPath = FileSystem.GetUrl(id)
|
||||
};
|
||||
|
||||
//on initial construction we don't want to have dirty properties tracked
|
||||
|
||||
@@ -52,7 +52,8 @@ namespace Umbraco.Core.Persistence.Repositories
|
||||
Content = content,
|
||||
Key = path.EncodeAsGuid(),
|
||||
CreateDate = created,
|
||||
UpdateDate = updated
|
||||
UpdateDate = updated,
|
||||
VirtualPath = FileSystem.GetUrl(id)
|
||||
};
|
||||
|
||||
//on initial construction we don't want to have dirty properties tracked
|
||||
|
||||
@@ -18,10 +18,10 @@ namespace Umbraco.Core.Persistence.Repositories
|
||||
private readonly IDatabaseUnitOfWork _dbwork;
|
||||
|
||||
internal StylesheetRepository(IUnitOfWork work, IDatabaseUnitOfWork db, IFileSystem fileSystem)
|
||||
: base(work, fileSystem)
|
||||
{
|
||||
: base(work, fileSystem)
|
||||
{
|
||||
_dbwork = db;
|
||||
}
|
||||
}
|
||||
|
||||
public StylesheetRepository(IUnitOfWork work, IDatabaseUnitOfWork db)
|
||||
: this(work, db, new PhysicalFileSystem(SystemDirectories.Css))
|
||||
@@ -43,7 +43,7 @@ namespace Umbraco.Core.Persistence.Repositories
|
||||
{
|
||||
byte[] bytes = new byte[stream.Length];
|
||||
stream.Position = 0;
|
||||
stream.Read(bytes, 0, (int) stream.Length);
|
||||
stream.Read(bytes, 0, (int)stream.Length);
|
||||
content = Encoding.UTF8.GetString(bytes);
|
||||
}
|
||||
|
||||
@@ -52,20 +52,21 @@ namespace Umbraco.Core.Persistence.Repositories
|
||||
var updated = FileSystem.GetLastModified(path).UtcDateTime;
|
||||
|
||||
var stylesheet = new Stylesheet(path)
|
||||
{
|
||||
Content = content,
|
||||
Key = path.EncodeAsGuid(),
|
||||
CreateDate = created,
|
||||
UpdateDate = updated,
|
||||
Id = GetStylesheetId(path)
|
||||
};
|
||||
{
|
||||
Content = content,
|
||||
Key = path.EncodeAsGuid(),
|
||||
CreateDate = created,
|
||||
UpdateDate = updated,
|
||||
Id = GetStylesheetId(path),
|
||||
VirtualPath = FileSystem.GetUrl(id)
|
||||
};
|
||||
|
||||
//on initial construction we don't want to have dirty properties tracked
|
||||
// http://issues.umbraco.org/issue/U4-1946
|
||||
stylesheet.ResetDirtyProperties(false);
|
||||
|
||||
return stylesheet;
|
||||
|
||||
|
||||
}
|
||||
|
||||
// Fix for missing Id's on FileService.GetStylesheets() call. This is needed as sytlesheets can only bo loaded in the editor via
|
||||
@@ -77,8 +78,11 @@ namespace Umbraco.Core.Persistence.Repositories
|
||||
.Select("*")
|
||||
.From<NodeDto>()
|
||||
.Where("nodeObjectType = @NodeObjectType AND umbracoNode.text = @Alias",
|
||||
new { NodeObjectType = UmbracoObjectTypes.Stylesheet.GetGuid(),
|
||||
Alias = path.TrimEnd(".css").Replace("\\", "/") });
|
||||
new
|
||||
{
|
||||
NodeObjectType = UmbracoObjectTypes.Stylesheet.GetGuid(),
|
||||
Alias = path.TrimEnd(".css").Replace("\\", "/")
|
||||
});
|
||||
var nodeDto = _dbwork.Database.FirstOrDefault<NodeDto>(sql);
|
||||
return nodeDto == null ? 0 : nodeDto.NodeId;
|
||||
}
|
||||
@@ -90,7 +94,7 @@ namespace Umbraco.Core.Persistence.Repositories
|
||||
.Select("*")
|
||||
.From<NodeDto>()
|
||||
.Where("nodeObjectType = @NodeObjectType AND umbracoNode.text in (@aliases)",
|
||||
new
|
||||
new
|
||||
{
|
||||
NodeObjectType = UmbracoObjectTypes.Stylesheet.GetGuid(),
|
||||
aliases = paths.Select(x => x.TrimEnd(".css").Replace("\\", "/")).ToArray()
|
||||
|
||||
Reference in New Issue
Block a user