public SiteResourceViewModel Build(Item renderingContextItem, ID resourceLocationId, ID deviceId, string siteScriptFieldName, string pageScriptFieldName) { var model = new SiteResourceViewModel(); if (!string.IsNullOrWhiteSpace(siteScriptFieldName)) { var home = SiteContext.GetHomeItem(); if (home != null) { model.SiteResources = new HtmlString(home[siteScriptFieldName] ?? ""); } } if (renderingContextItem != null) { if (!string.IsNullOrWhiteSpace(pageScriptFieldName)) { model.PageResources = new HtmlString(renderingContextItem[pageScriptFieldName] ?? ""); } var theme = _themeRetriever.GetThemeFromContextItem(renderingContextItem); model.ThemeResources = new HtmlString(theme == null ? "" : _themeRetriever.GetThemeResources(theme, deviceId, resourceLocationId) ); } return(model); }
public void Process(GetSiteResourcesArgs args) { if (args.ContextItem == null) { return; } var theme = _themeRetriever.GetThemeFromContextItem(args.ContextItem); if (theme == null) { return; } var themeScripts = _themeRetriever.GetThemeResources(theme, args.DeviceId, args.ResourceLocationId); if (string.IsNullOrWhiteSpace(themeScripts)) { return; } args.Results.Add(new SiteResource("ThemeResources", themeScripts)); }