diff --git a/src/Umbraco.Core/Models/File.cs b/src/Umbraco.Core/Models/File.cs
index d337b82bbe..3513e4e031 100644
--- a/src/Umbraco.Core/Models/File.cs
+++ b/src/Umbraco.Core/Models/File.cs
@@ -62,7 +62,7 @@ namespace Umbraco.Core.Models
}
///
- /// 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
///
[DataMember]
public virtual string Path
@@ -99,6 +99,11 @@ namespace Umbraco.Core.Models
}
}
+ ///
+ /// Gets or sets the file's virtual path (i.e. the file path relative to the root of the website)
+ ///
+ public string VirtualPath { get; set; }
+
///
/// Boolean indicating whether the file could be validated
///
diff --git a/src/Umbraco.Core/Models/IFile.cs b/src/Umbraco.Core/Models/IFile.cs
index b0cc96b56d..b4d0b75a79 100644
--- a/src/Umbraco.Core/Models/IFile.cs
+++ b/src/Umbraco.Core/Models/IFile.cs
@@ -19,7 +19,7 @@ namespace Umbraco.Core.Models
string Alias { get; }
///
- /// 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
///
string Path { get; set; }
@@ -28,6 +28,11 @@ namespace Umbraco.Core.Models
///
string Content { get; set; }
+ ///
+ /// Gets or sets the file's virtual path (i.e. the file path relative to the root of the website)
+ ///
+ string VirtualPath { get; set; }
+
///
/// Boolean indicating whether the file could be validated
///
diff --git a/src/Umbraco.Core/Persistence/Repositories/FileRepository.cs b/src/Umbraco.Core/Persistence/Repositories/FileRepository.cs
index 357173dfb9..f09ca2563a 100644
--- a/src/Umbraco.Core/Persistence/Repositories/FileRepository.cs
+++ b/src/Umbraco.Core/Persistence/Repositories/FileRepository.cs
@@ -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);
}
}
diff --git a/src/Umbraco.Core/Persistence/Repositories/PartialViewRepository.cs b/src/Umbraco.Core/Persistence/Repositories/PartialViewRepository.cs
index b61b7ff66b..66bc9966e3 100644
--- a/src/Umbraco.Core/Persistence/Repositories/PartialViewRepository.cs
+++ b/src/Umbraco.Core/Persistence/Repositories/PartialViewRepository.cs
@@ -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
diff --git a/src/Umbraco.Core/Persistence/Repositories/ScriptRepository.cs b/src/Umbraco.Core/Persistence/Repositories/ScriptRepository.cs
index 3feea435a3..a14507e8a4 100644
--- a/src/Umbraco.Core/Persistence/Repositories/ScriptRepository.cs
+++ b/src/Umbraco.Core/Persistence/Repositories/ScriptRepository.cs
@@ -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
diff --git a/src/Umbraco.Core/Persistence/Repositories/StylesheetRepository.cs b/src/Umbraco.Core/Persistence/Repositories/StylesheetRepository.cs
index dc240a2396..5537d65f07 100644
--- a/src/Umbraco.Core/Persistence/Repositories/StylesheetRepository.cs
+++ b/src/Umbraco.Core/Persistence/Repositories/StylesheetRepository.cs
@@ -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()
.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(sql);
return nodeDto == null ? 0 : nodeDto.NodeId;
}
@@ -90,7 +94,7 @@ namespace Umbraco.Core.Persistence.Repositories
.Select("*")
.From()
.Where("nodeObjectType = @NodeObjectType AND umbracoNode.text in (@aliases)",
- new
+ new
{
NodeObjectType = UmbracoObjectTypes.Stylesheet.GetGuid(),
aliases = paths.Select(x => x.TrimEnd(".css").Replace("\\", "/")).ToArray()