Refactoring the prop for getting the CDF version and its usages. Getting the HttpContext from httpContextAccessor. Removing FileMapDefaultFolder prop as it will be added in a new file
This commit is contained in:
@@ -7,8 +7,7 @@ namespace Umbraco.Core.Runtime
|
||||
{
|
||||
public interface IRuntimeMinifier
|
||||
{
|
||||
int Version { get; }
|
||||
string FileMapDefaultFolder { get; set; }
|
||||
string GetHashValue { get; }
|
||||
|
||||
//return type HtmlHelper
|
||||
string RequiresCss(string filePath, string pathNameAlias);
|
||||
|
||||
@@ -478,7 +478,7 @@ namespace Umbraco.Web.Editors
|
||||
var version = _runtimeState.SemanticVersion.ToSemanticString();
|
||||
|
||||
//the value is the hash of the version, cdf version and the configured state
|
||||
app.Add("cacheBuster", $"{version}.{_runtimeState.Level}.{_runtimeMinifier.Version}".GenerateHash());
|
||||
app.Add("cacheBuster", $"{version}.{_runtimeState.Level}.{_runtimeMinifier.GetHashValue}".GenerateHash());
|
||||
|
||||
//useful for dealing with virtual paths on the client side when hosted in virtual directories especially
|
||||
app.Add("applicationPath", _httpContextAccessor.GetRequiredHttpContext().Request.ApplicationPath.EnsureEndsWith('/'));
|
||||
|
||||
@@ -1,37 +1,26 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.Web;
|
||||
using System.Web.Mvc;
|
||||
using ClientDependency.Core;
|
||||
using ClientDependency.Core.CompositeFiles;
|
||||
using ClientDependency.Core.CompositeFiles.Providers;
|
||||
using ClientDependency.Core.Config;
|
||||
using Umbraco.Core.Assets;
|
||||
using Umbraco.Core.Runtime;
|
||||
|
||||
namespace Umbraco.Web.JavaScript
|
||||
namespace Umbraco.Web.JavaScript.CDF
|
||||
{
|
||||
public class ClientDependencyRuntimeMinifier : IRuntimeMinifier
|
||||
{
|
||||
private readonly IHttpContextAccessor _httpContextAccessor;
|
||||
private readonly HtmlHelper _htmlHelper;
|
||||
private readonly HttpContextBase _httpContext;
|
||||
|
||||
public int Version => ClientDependencySettings.Instance.Version;
|
||||
public string GetHashValue => ClientDependencySettings.Instance.Version.ToString();
|
||||
|
||||
public string FileMapDefaultFolder
|
||||
{
|
||||
get => XmlFileMapper.FileMapDefaultFolder;
|
||||
set => XmlFileMapper.FileMapDefaultFolder = value;
|
||||
}
|
||||
|
||||
public ClientDependencyRuntimeMinifier()
|
||||
public ClientDependencyRuntimeMinifier(IHttpContextAccessor httpContextAccessor)
|
||||
{
|
||||
_httpContextAccessor = httpContextAccessor;
|
||||
_htmlHelper = new HtmlHelper(new ViewContext(), new ViewPage());
|
||||
//_httpContext = httpContext;
|
||||
}
|
||||
|
||||
public string RequiresCss(string filePath, string pathNameAlias)
|
||||
@@ -76,7 +65,7 @@ namespace Umbraco.Web.JavaScript
|
||||
}
|
||||
|
||||
var renderer = ClientDependencySettings.Instance.MvcRendererCollection["Umbraco.DependencyPathRenderer"];
|
||||
renderer.RegisterDependencies(dependencies, new HashSet<IClientDependencyPath>(), out var scripts, out var stylesheets, _httpContext);
|
||||
renderer.RegisterDependencies(dependencies, new HashSet<IClientDependencyPath>(), out var scripts, out var stylesheets, _httpContextAccessor.HttpContext);
|
||||
|
||||
var toParse = assetType == AssetType.Javascript ? scripts : stylesheets;
|
||||
return toParse.Split(new[] { DependencyPathRenderer.Delimiter }, StringSplitOptions.RemoveEmptyEntries);
|
||||
@@ -146,7 +146,7 @@ namespace Umbraco.Web
|
||||
}
|
||||
|
||||
var version = Current.RuntimeState.SemanticVersion.ToSemanticString();
|
||||
return $"{version}.{Current.RuntimeMinifier.Version}".GenerateHash();
|
||||
return $"{version}.{Current.RuntimeMinifier.GetHashValue}".GenerateHash();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user