Error executing template "Designs/Swift/Swift_Fonts_Collection.cshtml"
System.UnauthorizedAccessException: Access to the path 'F:\Domains\Sites\gerflor.mydwsite4.com\Application\wwwroot\Files\Templates\Designs\Swift\_parsed\Swift_css\Swift_font_styles_3.css' is denied.
at Microsoft.Win32.SafeHandles.SafeFileHandle.CreateFile(String fullPath, FileMode mode, FileAccess access, FileShare share, FileOptions options)
at Microsoft.Win32.SafeHandles.SafeFileHandle.Open(String fullPath, FileMode mode, FileAccess access, FileShare share, FileOptions options, Int64 preallocationSize, Nullable`1 unixCreateMode)
at System.IO.Strategies.OSFileStreamStrategy..ctor(String path, FileMode mode, FileAccess access, FileShare share, FileOptions options, Int64 preallocationSize, Nullable`1 unixCreateMode)
at System.IO.FileStream..ctor(String path, FileMode mode, FileAccess access, FileShare share)
at Dynamicweb.Core.Helpers.TextFileHelper.WriteTextFileSafe(String value, String fullPath, Boolean appendToFile, Encoding encoding)
at Dynamicweb.Core.Helpers.TextFileHelper.WriteTextFile(String value, String path, Boolean appendToFile, Encoding encoding)
at Dynamicweb.Core.Helpers.TextFileHelper.WriteTextFile(String value, String path, Boolean appendToFile)
at CompiledRazorTemplates.Dynamic.RazorEngine_6cc58be2f34a45929d76fcceed00efc9.ExecuteAsync()
at RazorEngine.Templating.TemplateBase.Run(ExecuteContext context, TextWriter reader)
at RazorEngine.Templating.RazorEngineCore.RunTemplate(ICompiledTemplate template, TextWriter writer, Object model, DynamicViewBag viewBag)
at RazorEngine.Templating.RazorEngineService.Run(ITemplateKey key, TextWriter writer, Type modelType, Object model, DynamicViewBag viewBag)
at RazorEngine.Templating.DynamicWrapperService.Run(ITemplateKey key, TextWriter writer, Type modelType, Object model, DynamicViewBag viewBag)
at RazorEngine.Templating.RazorEngineServiceExtensions.Run(IRazorEngineService service, String name, TextWriter writer, Type modelType, Object model, DynamicViewBag viewBag)
at RazorEngine.Templating.RazorEngineServiceExtensions.<>c__DisplayClass23_0.<Run>b__0(TextWriter writer)
at RazorEngine.Templating.RazorEngineServiceExtensions.WithWriter(Action`1 withWriter)
at RazorEngine.Templating.RazorEngineServiceExtensions.Run(IRazorEngineService service, String name, Type modelType, Object model, DynamicViewBag viewBag)
at Dynamicweb.Rendering.RazorTemplateRenderingProvider.Render(Template template)
at Dynamicweb.Rendering.TemplateRenderingService.Render(Template template)
at Dynamicweb.Rendering.Template.RenderRazorTemplate()
1 @inherits Dynamicweb.Rendering.ViewModelTemplate<Dynamicweb.Frontend.PageViewModel>
@using Dynamicweb
@using Dynamicweb.Environment
@functions {
string GetCookieOptInPermission(string category)
{
bool categoryOrAllGranted = false;
if (CookieManager.IsCookieManagementActive)
{
var cookieOptInLevel = CookieManager.GetCookieOptInLevel();
var cookieOptInCategories = CookieManager.GetCookieOptInCategories();
categoryOrAllGranted = cookieOptInCategories.Contains(category) || cookieOptInLevel == CookieOptInLevel.All;
}
return categoryOrAllGranted ? "granted" : "denied";
}
bool AllowTracking()
{
bool allowTracking = true;
if (CookieManager.IsCookieManagementActive)
{
var cookieOptInLevel = CookieManager.GetCookieOptInLevel();
var cookieOptInCategories = CookieManager.GetCookieOptInCategories();
bool consentEither = (cookieOptInCategories.Contains("Statistical") || cookieOptInCategories.Contains("Marketing"));
bool consentFunctional = cookieOptInLevel == CookieOptInLevel.Functional;
bool consentAtLeastOne = cookieOptInLevel == CookieOptInLevel.All || (consentFunctional && consentEither);
allowTracking = consentAtLeastOne;
}
return allowTracking;
}
}
@{
string swiftVersion = ReadFile("/Files/Templates/Designs/Swift/swift_version.txt");
@* Branding Themes Fonts *@
var brandingPageId = Model.Area.Item.GetLink("BrandingPage") != null ? Model.Area.Item.GetLink("BrandingPage").PageId : 0;
var themePageId = Model.Area.Item.GetLink("ThemesPage") != null ? Model.Area.Item.GetLink("ThemesPage").PageId : 0;
var disableWideBreakpoints = Model.Area?.Item?.GetRawValueString("DisableWideBreakpoints", "default");
string customHeaderInclude = Model.Area.Item.GetFile("CustomHeaderInclude") != null ? Model.Area.Item.GetFile("CustomHeaderInclude").Name : string.Empty;
string masterTheme = !string.IsNullOrWhiteSpace(Model.Area.Item.GetRawValueString("Theme")) ? " theme " + Model.Area.Item.GetRawValueString("Theme").Replace(" ", "").Trim().ToLower() : "";
string favicon = Model.Area.Item.GetFile("Favicon") != null ? Model.Area.Item.GetFile("Favicon").Path : "/Files/Templates/Designs/Swift/Assets/Images/favicon.png";
var brandingPage = Dynamicweb.Content.Services.Pages?.GetPage(brandingPageId) ?? null;
var themesParagraphLastChanged = Dynamicweb.Content.Services.Paragraphs.GetParagraphsByPageId(themePageId).OrderByDescending(p => p.Audit.LastModifiedAt).FirstOrDefault();
var cssLastModified = brandingPage.Audit.LastModifiedAt > themesParagraphLastChanged.Audit.LastModifiedAt ? brandingPage.Audit.LastModifiedAt : themesParagraphLastChanged.Audit.LastModifiedAt;
var cssStyleFileInfo = new System.IO.FileInfo(Dynamicweb.Core.SystemInformation.MapPath("/Files/Templates/Designs/Swift/Assets/css/styles.css"));
var jsFileInfo = new System.IO.FileInfo(Dynamicweb.Core.SystemInformation.MapPath("/Files/Templates/Designs/Swift/Assets/js/scripts.js"));
string googleTagManagerID = Model.Area.Item.GetString("GoogleTagManagerID");
string googleAnalyticsMeasurementID = Pageview.AreaSettings.GetString("GoogleAnalyticsMeasurementID");
bool allowTracking = AllowTracking();
// Schema.org details for PDP
string productId = !string.IsNullOrEmpty(Dynamicweb.Context.Current.Request.QueryString.Get("ProductID")) ? Dynamicweb.Context.Current.Request.QueryString.Get("ProductID") : "";
bool isProductDetailsPage = !string.IsNullOrEmpty(productId);
bool isArticlePage = Model.ItemType == "Swift_Article";
string schemaOrgType = string.Empty;
if (isProductDetailsPage)
{
schemaOrgType = "itemscope=\"\" itemtype=\"https://schema.org/Product\"";
}
if (isArticlePage)
{
schemaOrgType = "itemscope=\"\" itemtype=\"https://schema.org/Article\"";
}
}
<!doctype html>
<html lang="@Pageview.Area.CultureInfo.TwoLetterISOLanguageName">
<head>
<!-- @swiftVersion -->
@* Required meta tags *@
<meta charset="utf-8">
<meta name="viewport" content="height=device-height, width=device-width, initial-scale=1.0">
<link rel="preload" href="/Files/Templates/Designs/Swift/Assets/css/styles.css?@cssStyleFileInfo.LastWriteTime.Ticks" as="style">
<link rel="preload" href="/Files/Templates/Designs/Swift/Assets/js/scripts.js?@jsFileInfo.LastWriteTime.Ticks" as="script">
<link rel="shortcut icon" href="@favicon">
<link rel="apple-touch-icon" href="/Files/Templates/Designs/Swift/Assets/Images/logo_transparent.png">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<meta name="googlebot-news" content="nosnippet">
@Model.MetaTags
<title>@Model.Title</title>
@* Bootstrap + Swift stylesheet *@
<link href="/Files/Templates/Designs/Swift/Assets/css/styles.css?@cssStyleFileInfo.LastWriteTime.Ticks" rel="stylesheet" media="all" type="text/css">
@if (disableWideBreakpoints != "disableBoth")
{
<style>
@@media ( min-width: 1600px ) {
.container-xxl,
.container-xl,
.container-lg,
.container-md,
.container-sm,
.container {
max-width: 1520px;
}
}
</style>
if (disableWideBreakpoints != "disableUltraWideOnly")
{
<style>
@@media ( min-width: 1920px ) {
.container-xxl,
.container-xl,
.container-lg,
.container-md,
.container-sm,
.container {
max-width: 1820px;
}
}
</style>
}
}
@* Branding and Themes min stylesheet *@
<link href="/Files/Templates/Designs/Swift/_parsed/Swift_css/Swift_styles_@(Model.Area.ID).min.css?@cssLastModified.Ticks" rel="stylesheet" media="all" type="text/css" data-last-modified-content="@cssLastModified">
<script src="/Files/Templates/Designs/Swift/Assets/js/scripts.js?@jsFileInfo.LastWriteTime.Ticks"></script>
<script type="module">
swift.Scroll.hideHeadersOnScroll();
swift.Scroll.handleAlternativeTheme();
//Only load if AOS
const aosColumns = document.querySelectorAll('[data-aos]');
if (aosColumns.length > 0) {
swift.AssetLoader.Load('/Files/Templates/Designs/Swift/Assets/js/aos.js?@jsFileInfo.LastWriteTime.Ticks', 'js');
document.addEventListener('load.swift.assetloader', function () {
AOS.init({ duration: 400, delay: 100, easing: 'ease-in-out', mirror: false, disable: window.matchMedia('(prefers-reduced-motion: reduce)') });
});
}
</script>
@* Google gtag method - always include even if it is not used for anything *@
<script>
window.dataLayer = window.dataLayer || [];
function gtag() { dataLayer.push(arguments); }
</script>
@* Google tag manager *@
@if (!string.IsNullOrWhiteSpace(googleTagManagerID))
{
<script>
gtag('consent', 'default', {
'ad_storage': 'denied',
'ad_user_data': 'denied',
'ad_personalization': 'denied',
'analytics_storage': 'denied'
});
</script>
<script>
(function (w, d, s, l, i) {
w[l] = w[l] || []; w[l].push({
'gtm.start':
new Date().getTime(), event: 'gtm.js'
}); var f = d.getElementsByTagName(s)[0],
j = d.createElement(s), dl = l != 'dataLayer' ? '&l=' + l : ''; j.async = true; j.src =
'https://www.googletagmanager.com/gtm.js?id=' + i + dl; f.parentNode.insertBefore(j, f);
})(window, document, 'script', 'dataLayer', '@(googleTagManagerID)');
</script>
if (allowTracking)
{
string adConsent = GetCookieOptInPermission("Marketing");
string analyticsConsent = GetCookieOptInPermission("Statistical");
<script>
gtag('consent', 'update', {
'ad_storage': '@adConsent',
'ad_user_data': '@adConsent',
'ad_personalization': '@adConsent',
'analytics_storage': '@analyticsConsent'
});
</script>
}
}
@if (!string.IsNullOrWhiteSpace(googleAnalyticsMeasurementID) && allowTracking)
{
var GoogleAnalyticsDebugMode = "";
if (Model.Area.Item.GetBoolean("EnableGoogleAnalyticsDebugMode"))
{
GoogleAnalyticsDebugMode = ", {'debug_mode': true}";
}
<script async src="https://www.googletagmanager.com/gtag/js?id=@googleAnalyticsMeasurementID"></script>
<script>
gtag('js', new Date());
gtag('config', '@googleAnalyticsMeasurementID'@GoogleAnalyticsDebugMode);
</script>
}
@if (!string.IsNullOrWhiteSpace(customHeaderInclude))
{
@RenderPartial($"Components/Custom/{customHeaderInclude}")
}
</head>
<body class="brand @(masterTheme)">
@* Google tag manager *@
@if (!string.IsNullOrWhiteSpace(googleTagManagerID) && allowTracking)
{
<noscript>
<iframe src="https://www.googletagmanager.com/ns.html?id=@(googleTagManagerID)"
height="0" width="0" style="display:none;visibility:hidden"></iframe>
</noscript>
}
<div data-intersect></div>
<main id="content" @(schemaOrgType)>
@inherits Dynamicweb.Rendering.ViewModelTemplate<Dynamicweb.Frontend.PageViewModel>
<style>
.font-wrapper > *{
font-family: var(--font-family);
font-weight: var(--font-weight);
font-style: var(--font-style);
}
</style>
<div class="container my-5">
<div class="grid gap-3 mb-5 pb-3 text-center border-bottom">
<div class="g-col-12">
<h1 class="h1">@Translate("Custom fonts") </h1>
<div class="lead">@Translate("A list of all custom fonts")</div>
</div>
</div>
<div class="grid gap-3">
@Model.Placeholder("content", "content", "default:true;sort:1")
</div>
</div>
@{
string tmpPath = Dynamicweb.Context.Current.Server.MapPath($"/Files/Templates/Designs/Swift/_parsed/Swift_css/Swift_font_styles_{Model.Area.ID}.tmp");
string cssPathFont = Dynamicweb.Context.Current.Server.MapPath($"/Files/Templates/Designs/Swift/_parsed/Swift_css/Swift_font_styles_{Model.Area.ID}.css");
string cssPathEcommerceBadges = Dynamicweb.Context.Current.Server.MapPath($"/Files/Templates/Designs/Swift/_parsed/Swift_css/Swift_ecommerce_badge_styles_{Model.Area.ID}.css");
string cssPathTheme = Dynamicweb.Context.Current.Server.MapPath($"/Files/Templates/Designs/Swift/_parsed/Swift_css/Swift_theme_styles_{Model.Area.ID}.css");
string cssPathBranding = Dynamicweb.Context.Current.Server.MapPath($"/Files/Templates/Designs/Swift/_parsed/Swift_css/Swift_branding_styles_{Model.Area.ID}.css");
string cssPathCombined = Dynamicweb.Context.Current.Server.MapPath($"/Files/Templates/Designs/Swift/_parsed/Swift_css/Swift_styles_{Model.Area.ID}.min.css");
Dynamicweb.Core.Helpers.TextFileHelper.WriteTextFile(Dynamicweb.Core.Helpers.TextFileHelper.ReadTextFile(tmpPath), cssPathFont, false);
System.IO.File.Delete(tmpPath);
string combinedCss = Dynamicweb.Core.Helpers.TextFileHelper.ReadTextFile(cssPathBranding);
combinedCss += Dynamicweb.Core.Helpers.TextFileHelper.ReadTextFile(cssPathFont);
combinedCss += Dynamicweb.Core.Helpers.TextFileHelper.ReadTextFile(cssPathTheme);
combinedCss += Dynamicweb.Core.Helpers.TextFileHelper.ReadTextFile(cssPathEcommerceBadges);
combinedCss = System.Text.RegularExpressions.Regex.Replace(combinedCss, @"\s+(?=([^']*'[^']*')*[^']*$)", ""); //minify the css.
combinedCss = combinedCss.Replace("\00a0", " "); //Re-insert spaces for content text
Dynamicweb.Core.Helpers.TextFileHelper.WriteTextFile(combinedCss, cssPathCombined, false);
}
</main>
@* Render any offcanvas menu here *@
@RenderSnippet("offcanvas")
</body>
</html>