protected override string MinifyFile(string fileContents, ClientDependencyType type) { switch (type) { case ClientDependencyType.Css: return(MinifyCss ? CssMin.CompressCSS(fileContents) : fileContents); case ClientDependencyType.Javascript: return(MinifyJs ? JSMin.CompressJS(fileContents) : fileContents); default: return(fileContents); } }
/// <summary> /// Minifies the file /// </summary> /// <param name="fileContents"></param> /// <param name="type"></param> /// <returns></returns> protected virtual string MinifyFile(string fileContents, ClientDependencyType type) { switch (type) { case ClientDependencyType.Css: return(EnableCssMinify ? CssMin.CompressCSS(fileContents) : fileContents); case ClientDependencyType.Javascript: return(EnableJsMinify ? JSMin.CompressJS(fileContents) : fileContents); default: return(fileContents); } }
public HttpResponseMessage Css(int tabid, int portalid) { List <string> templates = new List <string>(); StringBuilder css = new StringBuilder(); var tab = TabController.Instance.GetTab(tabid, portalid); foreach (ModuleInfo module in tab.Modules.Cast <ModuleInfo>().Where(m => m.ModuleDefinition.DefinitionName == App.Config.Opencontent && !m.IsDeleted)) { var moduleSettings = module.OpenContentSettings(); if (moduleSettings.Template != null) { var filePath = moduleSettings.Template.MainTemplateUri().FilePath; if (!templates.Contains(filePath)) { var cssfilename = new FileUri(Path.ChangeExtension(filePath, "css")); if (cssfilename.FileExists) { if (UserInfo.IsSuperUser) { css.Append("/*").Append((cssfilename.FilePath)).AppendLine("*/"); } css.AppendLine(CssMin.CompressCSS(File.ReadAllText(cssfilename.PhysicalFilePath))); } templates.Add(filePath); } } } var res = new HttpResponseMessage(HttpStatusCode.OK) { Content = new StringContent(css.ToString(), Encoding.UTF8, "text/css") }; res.Headers.CacheControl = new CacheControlHeaderValue { MaxAge = new TimeSpan(365, 0, 0, 0), Public = true, Private = false }; return(res); }