/// <summary> /// Returns the JavaScript to load the back office's assets /// </summary> /// <returns></returns> public static async Task <string> GetScriptForLoadingBackOfficeAsync( this IRuntimeMinifier minifier, GlobalSettings globalSettings, IHostingEnvironment hostingEnvironment, IManifestParser manifestParser) { var files = new HashSet <string>(StringComparer.InvariantCultureIgnoreCase); foreach (var file in await minifier.GetJsAssetPathsAsync(BackOfficeWebAssets.UmbracoCoreJsBundleName)) { files.Add(file); } foreach (var file in await minifier.GetJsAssetPathsAsync(BackOfficeWebAssets.UmbracoExtensionsJsBundleName)) { files.Add(file); } // process the independent bundles if (manifestParser.CombinedManifest.Scripts.TryGetValue(BundleOptions.Independent, out IReadOnlyList <ManifestAssets>?independentManifestAssetsList)) { foreach (ManifestAssets manifestAssets in independentManifestAssetsList) { var bundleName = BackOfficeWebAssets.GetIndependentPackageBundleName(manifestAssets, AssetType.Javascript); foreach (var asset in await minifier.GetJsAssetPathsAsync(bundleName)) { files.Add(asset); } } } // process the "None" bundles, meaning we'll just render the script as-is foreach (var asset in await minifier.GetJsAssetPathsAsync(BackOfficeWebAssets .UmbracoNonOptimizedPackageJsBundleName)) { files.Add(asset); } var result = BackOfficeJavaScriptInitializer.GetJavascriptInitialization( files, "umbraco", globalSettings, hostingEnvironment); result += await GetStylesheetInitializationAsync(minifier, manifestParser); return(result); }
public BackOfficeWebAssets( IRuntimeMinifier runtimeMinifier, IManifestParser parser, PropertyEditorCollection propertyEditorCollection, IHostingEnvironment hostingEnvironment, IOptions <GlobalSettings> globalSettings, CustomBackOfficeAssetsCollection customBackOfficeAssetsCollection) { _runtimeMinifier = runtimeMinifier; _parser = parser; _propertyEditorCollection = propertyEditorCollection; _hostingEnvironment = hostingEnvironment; _globalSettings = globalSettings.Value; _customBackOfficeAssetsCollection = customBackOfficeAssetsCollection; }
/// <summary> /// Return the Url for an action with a cache-busting hash appended /// </summary> /// <returns></returns> public static string GetUrlWithCacheBust( this IUrlHelper url, string actionName, string controllerName, RouteValueDictionary routeVals, IHostingEnvironment hostingEnvironment, IUmbracoVersion umbracoVersion, IRuntimeMinifier runtimeMinifier) { var applicationJs = url.Action(actionName, controllerName, routeVals); applicationJs = applicationJs + "?umb__rnd=" + GetCacheBustHash(hostingEnvironment, umbracoVersion, runtimeMinifier); return(applicationJs); }
public static async Task <IHtmlContent> AngularValueTinyMceAssetsAsync(this IHtmlHelper html, IRuntimeMinifier runtimeMinifier) { IEnumerable <string> files = await runtimeMinifier.GetJsAssetPathsAsync(BackOfficeWebAssets.UmbracoTinyMceJsBundleName); var sb = new StringBuilder(); sb.AppendLine(@"app.value(""tinyMceAssets"","); sb.AppendLine(JsonConvert.SerializeObject(files)); sb.AppendLine(@");"); return(html.Raw(sb.ToString())); }
public BackOfficeServerVariables( LinkGenerator linkGenerator, IRuntimeState runtimeState, UmbracoFeatures features, IOptionsMonitor <GlobalSettings> globalSettings, IUmbracoVersion umbracoVersion, IOptionsMonitor <ContentSettings> contentSettings, IHttpContextAccessor httpContextAccessor, TreeCollection treeCollection, IHostingEnvironment hostingEnvironment, IOptionsMonitor <RuntimeSettings> runtimeSettings, IOptionsMonitor <SecuritySettings> securitySettings, IRuntimeMinifier runtimeMinifier, IBackOfficeExternalLoginProviders externalLogins, IImageUrlGenerator imageUrlGenerator, PreviewRoutes previewRoutes, IEmailSender emailSender, IOptionsMonitor <MemberPasswordConfigurationSettings> memberPasswordConfigurationSettings, IOptionsMonitor <DataTypesSettings> dataTypesSettings) { _linkGenerator = linkGenerator; _runtimeState = runtimeState; _features = features; _globalSettings = globalSettings.CurrentValue; _umbracoVersion = umbracoVersion; _contentSettings = contentSettings.CurrentValue ?? throw new ArgumentNullException(nameof(contentSettings)); _httpContextAccessor = httpContextAccessor; _treeCollection = treeCollection ?? throw new ArgumentNullException(nameof(treeCollection)); _hostingEnvironment = hostingEnvironment; _runtimeSettings = runtimeSettings.CurrentValue; _securitySettings = securitySettings.CurrentValue; _runtimeMinifier = runtimeMinifier; _externalLogins = externalLogins; _imageUrlGenerator = imageUrlGenerator; _previewRoutes = previewRoutes; _emailSender = emailSender; _memberPasswordConfigurationSettings = memberPasswordConfigurationSettings.CurrentValue; _dataTypesSettings = dataTypesSettings.CurrentValue; globalSettings.OnChange(x => _globalSettings = x); contentSettings.OnChange(x => _contentSettings = x); runtimeSettings.OnChange(x => _runtimeSettings = x); securitySettings.OnChange(x => _securitySettings = x); dataTypesSettings.OnChange(x => _dataTypesSettings = x); memberPasswordConfigurationSettings.OnChange(x => _memberPasswordConfigurationSettings = x); }
public BackOfficeController( IBackOfficeUserManager userManager, IRuntimeState runtimeState, IRuntimeMinifier runtimeMinifier, IOptionsSnapshot <GlobalSettings> globalSettings, IHostingEnvironment hostingEnvironment, ILocalizedTextService textService, IGridConfig gridConfig, BackOfficeServerVariables backOfficeServerVariables, AppCaches appCaches, IBackOfficeSignInManager signInManager, IBackOfficeSecurityAccessor backofficeSecurityAccessor, ILogger <BackOfficeController> logger, IJsonSerializer jsonSerializer, IBackOfficeExternalLoginProviders externalLogins, IHttpContextAccessor httpContextAccessor, IBackOfficeTwoFactorOptions backOfficeTwoFactorOptions, IManifestParser manifestParser, ServerVariablesParser serverVariables, IOptions <SecuritySettings> securitySettings) { _userManager = userManager; _runtimeState = runtimeState; _runtimeMinifier = runtimeMinifier; _globalSettings = globalSettings.Value; _hostingEnvironment = hostingEnvironment; _textService = textService; _gridConfig = gridConfig ?? throw new ArgumentNullException(nameof(gridConfig)); _backOfficeServerVariables = backOfficeServerVariables; _appCaches = appCaches; _signInManager = signInManager; _backofficeSecurityAccessor = backofficeSecurityAccessor; _logger = logger; _jsonSerializer = jsonSerializer; _externalLogins = externalLogins; _httpContextAccessor = httpContextAccessor; _backOfficeTwoFactorOptions = backOfficeTwoFactorOptions; _manifestParser = manifestParser; _serverVariables = serverVariables; _securitySettings = securitySettings; }
public BackOfficeController( IBackOfficeUserManager userManager, IRuntimeState runtimeState, IRuntimeMinifier runtimeMinifier, IOptions <GlobalSettings> globalSettings, IHostingEnvironment hostingEnvironment, ILocalizedTextService textService, IGridConfig gridConfig, BackOfficeServerVariables backOfficeServerVariables, AppCaches appCaches, IBackOfficeSignInManager signInManager, IBackOfficeSecurityAccessor backofficeSecurityAccessor, ILogger <BackOfficeController> logger, IJsonSerializer jsonSerializer, IBackOfficeExternalLoginProviders externalLogins, IHttpContextAccessor httpContextAccessor, IBackOfficeTwoFactorOptions backOfficeTwoFactorOptions, IManifestParser manifestParser, ServerVariablesParser serverVariables) : this(userManager, runtimeState, runtimeMinifier, globalSettings, hostingEnvironment, textService, gridConfig, backOfficeServerVariables, appCaches, signInManager, backofficeSecurityAccessor, logger, jsonSerializer, externalLogins, httpContextAccessor, backOfficeTwoFactorOptions, manifestParser, serverVariables, StaticServiceProvider.Instance.GetRequiredService <IOptions <SecuritySettings> >() ) { }
/// <summary> /// Gets the back office css bundle paths and formats a JS call to lazy load them /// </summary> private static async Task <string> GetStylesheetInitializationAsync( IRuntimeMinifier minifier, IManifestParser manifestParser) { var files = new HashSet <string>(StringComparer.InvariantCultureIgnoreCase); foreach (var file in await minifier.GetCssAssetPathsAsync(BackOfficeWebAssets.UmbracoCssBundleName)) { files.Add(file); } // process the independent bundles if (manifestParser.CombinedManifest.Stylesheets.TryGetValue(BundleOptions.Independent, out IReadOnlyList <ManifestAssets>?independentManifestAssetsList)) { foreach (ManifestAssets manifestAssets in independentManifestAssetsList) { var bundleName = BackOfficeWebAssets.GetIndependentPackageBundleName(manifestAssets, AssetType.Css); foreach (var asset in await minifier.GetCssAssetPathsAsync(bundleName)) { files.Add(asset); } } } // process the "None" bundles, meaning we'll just render the script as-is foreach (var asset in await minifier.GetCssAssetPathsAsync(BackOfficeWebAssets .UmbracoNonOptimizedPackageCssBundleName)) { files.Add(asset); } var sb = new StringBuilder(); foreach (var file in files) { sb.AppendFormat("{0}LazyLoad.css('{1}');", Environment.NewLine, file); } return(sb.ToString()); }
public InstallController( IBackOfficeSecurityAccessor backofficeSecurityAccessor, InstallHelper installHelper, IRuntimeState runtime, IOptions <GlobalSettings> globalSettings, IRuntimeMinifier runtimeMinifier, IHostingEnvironment hostingEnvironment, IUmbracoVersion umbracoVersion, ILogger <InstallController> logger, LinkGenerator linkGenerator) { _backofficeSecurityAccessor = backofficeSecurityAccessor; _installHelper = installHelper; _runtime = runtime; _globalSettings = globalSettings.Value; _runtimeMinifier = runtimeMinifier; _hostingEnvironment = hostingEnvironment; _umbracoVersion = umbracoVersion; _logger = logger; _linkGenerator = linkGenerator; }
public BackOfficeServerVariables( LinkGenerator linkGenerator, IRuntimeState runtimeState, UmbracoFeatures features, IOptionsMonitor <GlobalSettings> globalSettings, IUmbracoVersion umbracoVersion, IOptionsMonitor <ContentSettings> contentSettings, IHttpContextAccessor httpContextAccessor, TreeCollection treeCollection, IHostingEnvironment hostingEnvironment, IOptionsMonitor <RuntimeSettings> runtimeSettings, IOptionsMonitor <SecuritySettings> securitySettings, IRuntimeMinifier runtimeMinifier, IBackOfficeExternalLoginProviders externalLogins, IImageUrlGenerator imageUrlGenerator, PreviewRoutes previewRoutes, IEmailSender emailSender, IOptionsMonitor <MemberPasswordConfigurationSettings> memberPasswordConfigurationSettings) : this( linkGenerator, runtimeState, features, globalSettings, umbracoVersion, contentSettings, httpContextAccessor, treeCollection, hostingEnvironment, runtimeSettings, securitySettings, runtimeMinifier, externalLogins, imageUrlGenerator, previewRoutes, emailSender, memberPasswordConfigurationSettings, StaticServiceProvider.Instance.GetRequiredService <IOptionsMonitor <DataTypesSettings> >()) { }
public PreviewController( UmbracoFeatures features, IOptionsSnapshot <GlobalSettings> globalSettings, IPublishedSnapshotService publishedSnapshotService, IBackOfficeSecurityAccessor backofficeSecurityAccessor, ILocalizationService localizationService, IHostingEnvironment hostingEnvironment, ICookieManager cookieManager, IRuntimeMinifier runtimeMinifier, ICompositeViewEngine viewEngines, IUmbracoContextAccessor umbracoContextAccessor) { _features = features; _globalSettings = globalSettings.Value; _publishedSnapshotService = publishedSnapshotService; _backofficeSecurityAccessor = backofficeSecurityAccessor; _localizationService = localizationService; _hostingEnvironment = hostingEnvironment; _cookieManager = cookieManager; _runtimeMinifier = runtimeMinifier; _viewEngines = viewEngines; _umbracoContextAccessor = umbracoContextAccessor; }
/// <summary> /// </summary> /// <returns></returns> public static string GetCacheBustHash(IHostingEnvironment hostingEnvironment, IUmbracoVersion umbracoVersion, IRuntimeMinifier runtimeMinifier) { // make a hash of umbraco and client dependency version // in case the user bypasses the installer and just bumps the web.config or client dependency config // if in debug mode, always burst the cache if (hostingEnvironment.IsDebugMode) { return(DateTime.Now.Ticks.ToString(CultureInfo.InvariantCulture).GenerateHash()); } var version = umbracoVersion.SemanticVersion.ToSemanticString(); return($"{version}.{runtimeMinifier.CacheBuster}".GenerateHash()); }