Fixes up preview paths, adds more docs and ensures we throw exceptions when not absolute paths
This commit is contained in:
5
.gitignore
vendored
5
.gitignore
vendored
@@ -170,3 +170,8 @@ build/temp/
|
||||
/src/Umbraco.Web.UI.NetCore/wwwroot/Media/*
|
||||
/src/Umbraco.Web.UI.NetCore/wwwroot/is-cache/*
|
||||
/src/Umbraco.Tests.Integration/App_Data/*
|
||||
/src/Umbraco.Web.UI.NetCore/wwwroot/Umbraco/assets/*
|
||||
/src/Umbraco.Web.UI.NetCore/wwwroot/Umbraco/js/*
|
||||
/src/Umbraco.Web.UI.NetCore/wwwroot/Umbraco/lib/*
|
||||
/src/Umbraco.Web.UI.NetCore/wwwroot/Umbraco/views/*
|
||||
/src/Umbraco.Web.UI.NetCore/wwwroot/App_Data/TEMP/*
|
||||
|
||||
@@ -19,6 +19,12 @@ namespace Umbraco.Core.WebAssets
|
||||
/// </summary>
|
||||
/// <param name="bundleName"></param>
|
||||
/// <param name="filePaths"></param>
|
||||
/// <remarks>
|
||||
/// All files must be absolute paths, relative paths will throw <see cref="InvalidOperationException"/>
|
||||
/// </remarks>
|
||||
/// <exception cref="InvalidOperationException">
|
||||
/// Thrown if any of the paths specified are not absolute
|
||||
/// </exception>
|
||||
void CreateCssBundle(string bundleName, params string[] filePaths);
|
||||
|
||||
/// <summary>
|
||||
@@ -35,6 +41,12 @@ namespace Umbraco.Core.WebAssets
|
||||
/// </summary>
|
||||
/// <param name="bundleName"></param>
|
||||
/// <param name="filePaths"></param>
|
||||
/// <remarks>
|
||||
/// All files must be absolute paths, relative paths will throw <see cref="InvalidOperationException"/>
|
||||
/// </remarks>
|
||||
/// <exception cref="InvalidOperationException">
|
||||
/// Thrown if any of the paths specified are not absolute
|
||||
/// </exception>
|
||||
void CreateJsBundle(string bundleName, params string[] filePaths);
|
||||
|
||||
/// <summary>
|
||||
|
||||
@@ -44,23 +44,23 @@ namespace Umbraco.Web.WebAssets
|
||||
// Create bundles
|
||||
|
||||
_runtimeMinifier.CreateCssBundle(UmbracoInitCssBundleName,
|
||||
"lib/bootstrap-social/bootstrap-social.css",
|
||||
FormatPaths("lib/bootstrap-social/bootstrap-social.css",
|
||||
"assets/css/umbraco.css",
|
||||
"lib/font-awesome/css/font-awesome.min.css");
|
||||
"lib/font-awesome/css/font-awesome.min.css"));
|
||||
|
||||
_runtimeMinifier.CreateCssBundle(UmbracoUpgradeCssBundleName,
|
||||
"assets/css/umbraco.css",
|
||||
FormatPaths("assets/css/umbraco.css",
|
||||
"lib/bootstrap-social/bootstrap-social.css",
|
||||
"lib/font-awesome/css/font-awesome.min.css");
|
||||
"lib/font-awesome/css/font-awesome.min.css"));
|
||||
|
||||
_runtimeMinifier.CreateCssBundle(UmbracoPreviewCssBundleName,
|
||||
"assets/css/canvasdesigner.css");
|
||||
FormatPaths("assets/css/canvasdesigner.css"));
|
||||
|
||||
_runtimeMinifier.CreateJsBundle(UmbracoPreviewJsBundleName,
|
||||
GetScriptsForPreview().ToArray());
|
||||
FormatPaths(GetScriptsForPreview()));
|
||||
|
||||
_runtimeMinifier.CreateJsBundle(UmbracoTinyMceJsBundleName,
|
||||
GetScriptsForTinyMce().ToArray());
|
||||
FormatPaths(GetScriptsForTinyMce()));
|
||||
|
||||
var propertyEditorAssets = ScanPropertyEditors()
|
||||
.GroupBy(x => x.AssetType)
|
||||
@@ -68,13 +68,15 @@ namespace Umbraco.Web.WebAssets
|
||||
|
||||
_runtimeMinifier.CreateJsBundle(
|
||||
UmbracoJsBundleName,
|
||||
FormatPaths(
|
||||
GetScriptsForBackoffice(
|
||||
propertyEditorAssets.TryGetValue(AssetType.Javascript, out var scripts) ? scripts : Enumerable.Empty<string>()));
|
||||
propertyEditorAssets.TryGetValue(AssetType.Javascript, out var scripts) ? scripts : Enumerable.Empty<string>())));
|
||||
|
||||
_runtimeMinifier.CreateCssBundle(
|
||||
UmbracoCssBundleName,
|
||||
FormatPaths(
|
||||
GetStylesheetsForBackoffice(
|
||||
propertyEditorAssets.TryGetValue(AssetType.Css, out var styles) ? styles : Enumerable.Empty<string>()));
|
||||
propertyEditorAssets.TryGetValue(AssetType.Css, out var styles) ? styles : Enumerable.Empty<string>())));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -92,7 +94,7 @@ namespace Umbraco.Web.WebAssets
|
||||
foreach (var script in propertyEditorScripts)
|
||||
scripts.Add(script);
|
||||
|
||||
return new HashSet<string>(FormatPaths(scripts)).ToArray();
|
||||
return scripts.ToArray();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -118,27 +120,27 @@ namespace Umbraco.Web.WebAssets
|
||||
foreach (var stylesheet in propertyEditorStyles)
|
||||
stylesheets.Add(stylesheet);
|
||||
|
||||
return new HashSet<string>(FormatPaths(stylesheets)).ToArray();
|
||||
return stylesheets.ToArray();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns the scripts used for tinymce
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
private IEnumerable<string> GetScriptsForTinyMce()
|
||||
private string[] GetScriptsForTinyMce()
|
||||
{
|
||||
var resources = JsonConvert.DeserializeObject<JArray>(Resources.TinyMceInitialize);
|
||||
return resources.Where(x => x.Type == JTokenType.String).Select(x => x.ToString());
|
||||
return resources.Where(x => x.Type == JTokenType.String).Select(x => x.ToString()).ToArray();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns the scripts used for preview
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
private IEnumerable<string> GetScriptsForPreview()
|
||||
private string[] GetScriptsForPreview()
|
||||
{
|
||||
var resources = JsonConvert.DeserializeObject<JArray>(Resources.PreviewInitialize);
|
||||
return resources.Where(x => x.Type == JTokenType.String).Select(x => x.ToString());
|
||||
return resources.Where(x => x.Type == JTokenType.String).Select(x => x.ToString()).ToArray();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -146,7 +148,7 @@ namespace Umbraco.Web.WebAssets
|
||||
/// </summary>
|
||||
/// <param name="assets"></param>
|
||||
/// <returns></returns>
|
||||
private IEnumerable<string> FormatPaths(IEnumerable<string> assets)
|
||||
private string[] FormatPaths(params string[] assets)
|
||||
{
|
||||
var umbracoPath = _ioHelper.GetUmbracoMvcArea();
|
||||
|
||||
@@ -156,7 +158,7 @@ namespace Umbraco.Web.WebAssets
|
||||
// most declarations with be made relative to the /umbraco folder, so things
|
||||
// like lib/blah/blah.js so we need to turn them into absolutes here
|
||||
? umbracoPath.EnsureStartsWith('/').TrimEnd("/") + x.EnsureStartsWith('/')
|
||||
: x).ToList();
|
||||
: x).ToArray();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
||||
@@ -1,14 +1,14 @@
|
||||
[
|
||||
'../lib/jquery/jquery.min.js',
|
||||
'../lib/angular/angular.js',
|
||||
'../lib/underscore/underscore-min.js',
|
||||
'../lib/umbraco/Extensions.js',
|
||||
'../js/app.js',
|
||||
'../js/umbraco.resources.js',
|
||||
'../js/umbraco.services.js',
|
||||
'../js/umbraco.interceptors.js',
|
||||
'../ServerVariables',
|
||||
'../lib/signalr/jquery.signalR.js',
|
||||
'../BackOffice/signalr/hubs',
|
||||
'../js/umbraco.preview.js'
|
||||
'lib/jquery/jquery.min.js',
|
||||
'lib/angular/angular.js',
|
||||
'lib/underscore/underscore-min.js',
|
||||
'lib/umbraco/Extensions.js',
|
||||
'js/app.js',
|
||||
'js/umbraco.resources.js',
|
||||
'js/umbraco.services.js',
|
||||
'js/umbraco.interceptors.js',
|
||||
'ServerVariables',
|
||||
'lib/signalr/jquery.signalR.js',
|
||||
'BackOffice/signalr/hubs',
|
||||
'js/umbraco.preview.js'
|
||||
]
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
using Smidge;
|
||||
using Smidge.CompositeFiles;
|
||||
@@ -51,6 +52,9 @@ namespace Umbraco.Web.Common.RuntimeMinification
|
||||
// only issue with creating bundles like this is that we don't have full control over the bundle options, though that could
|
||||
public void CreateCssBundle(string bundleName, params string[] filePaths)
|
||||
{
|
||||
if (filePaths.Any(f => !f.StartsWith("/") && !f.StartsWith("~/")))
|
||||
throw new InvalidOperationException("All file paths must be absolute");
|
||||
|
||||
if (_bundles.Exists(bundleName))
|
||||
throw new InvalidOperationException($"The bundle name {bundleName} already exists");
|
||||
|
||||
@@ -65,6 +69,9 @@ namespace Umbraco.Web.Common.RuntimeMinification
|
||||
|
||||
public void CreateJsBundle(string bundleName, params string[] filePaths)
|
||||
{
|
||||
if (filePaths.Any(f => !f.StartsWith("/") && !f.StartsWith("~/")))
|
||||
throw new InvalidOperationException("All file paths must be absolute");
|
||||
|
||||
if (_bundles.Exists(bundleName))
|
||||
throw new InvalidOperationException($"The bundle name {bundleName} already exists");
|
||||
|
||||
|
||||
19
src/Umbraco.Web.UI.NetCore/HomeController.cs
Normal file
19
src/Umbraco.Web.UI.NetCore/HomeController.cs
Normal file
@@ -0,0 +1,19 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
|
||||
// For more information on enabling MVC for empty projects, visit https://go.microsoft.com/fwlink/?LinkID=397860
|
||||
|
||||
namespace Umbraco.Web.UI.BackOffice
|
||||
{
|
||||
public class HomeController : Controller
|
||||
{
|
||||
// GET: /<controller>/
|
||||
public IActionResult Index()
|
||||
{
|
||||
return View();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -25,9 +25,6 @@ namespace Umbraco.Web.WebAssets.CDF
|
||||
private readonly IIOHelper _ioHelper;
|
||||
private readonly ILogger _logger;
|
||||
private readonly IUmbracoVersion _umbracoVersion;
|
||||
private readonly IManifestParser _manifestParser;
|
||||
private readonly IGlobalSettings _globalSettings;
|
||||
private readonly PropertyEditorCollection _propertyEditorCollection;
|
||||
|
||||
public string CacheBuster => ClientDependencySettings.Instance.Version.ToString();
|
||||
|
||||
@@ -35,22 +32,19 @@ namespace Umbraco.Web.WebAssets.CDF
|
||||
IHttpContextAccessor httpContextAccessor,
|
||||
IIOHelper ioHelper,
|
||||
ILogger logger,
|
||||
IUmbracoVersion umbracoVersion,
|
||||
IManifestParser manifestParser,
|
||||
IGlobalSettings globalSettings,
|
||||
PropertyEditorCollection propertyEditorCollection)
|
||||
IUmbracoVersion umbracoVersion)
|
||||
{
|
||||
_httpContextAccessor = httpContextAccessor;
|
||||
_ioHelper = ioHelper;
|
||||
_logger = logger;
|
||||
_umbracoVersion = umbracoVersion;
|
||||
_manifestParser = manifestParser;
|
||||
_globalSettings = globalSettings;
|
||||
_propertyEditorCollection = propertyEditorCollection;
|
||||
}
|
||||
|
||||
public void CreateCssBundle(string bundleName, params string[] filePaths)
|
||||
{
|
||||
if (filePaths.Any(f => !f.StartsWith("/") && !f.StartsWith("~/")))
|
||||
throw new InvalidOperationException("All file paths must be absolute");
|
||||
|
||||
BundleManager.CreateCssBundle(
|
||||
bundleName,
|
||||
filePaths.Select(x => new CssFile(x)).ToArray());
|
||||
@@ -65,6 +59,9 @@ namespace Umbraco.Web.WebAssets.CDF
|
||||
|
||||
public void CreateJsBundle(string bundleName, params string[] filePaths)
|
||||
{
|
||||
if (filePaths.Any(f => !f.StartsWith("/") && !f.StartsWith("~/")))
|
||||
throw new InvalidOperationException("All file paths must be absolute");
|
||||
|
||||
BundleManager.CreateJsBundle(
|
||||
bundleName,
|
||||
filePaths.Select(x => new JavascriptFile(x)).ToArray());
|
||||
|
||||
Reference in New Issue
Block a user