public static string GetBundlesPath(IRequestHandler requestHandler) { if (string.IsNullOrEmpty(PathManager.bundlesPath)) { PathManager.bundlesPath = PathManager.Combine(PathManager.GetContentRootPath(requestHandler), "Bundles"); } PathManager.EnsurePathExists(PathManager.bundlesPath); return(PathManager.bundlesPath); }
private static string ConcatFiles(IRequestHandler requestHandler, IEnumerable <string> files) { StringBuilder result = new StringBuilder(); foreach (string file in files) { result.AppendLine(File.ReadAllText(PathManager.Combine(PathManager.GetContentRootPath(requestHandler), file))); } return(result.ToString()); }
public static string GetViewsPath(IRequestHandler requestHandler, string subdirectory) { if (string.IsNullOrEmpty(PathManager.viewsPath)) { PathManager.viewsPath = PathManager.Combine(PathManager.GetContentRootPath(requestHandler), "Views"); } if (string.IsNullOrEmpty(subdirectory)) { PathManager.EnsurePathExists(PathManager.viewsPath); return(PathManager.viewsPath); } string viewsPath = PathManager.Combine(PathManager.viewsPath, subdirectory); PathManager.EnsurePathExists(viewsPath); return(viewsPath); }
public static void RebuildBundle(IRequestHandler requestHandler, string bundleFilename) { try { dynamic bundle = JsonConvert.DeserializeObject(File.ReadAllText(PathManager.GetBundlePath(requestHandler, bundleFilename))); string outputFile = bundle.outputFile; IEnumerable <string> inputFiles = bundle.inputFiles.ToObject <IEnumerable <string> >(); string input = BandleManager.ConcatFiles(requestHandler, inputFiles); UglifyResult result = outputFile.EndsWith(".css") ? Uglify.Css(input) : outputFile.EndsWith(".js") ? Uglify.Js(input) : default(UglifyResult); if (!result.HasErrors) { string outputFilepath = PathManager.Combine(PathManager.GetContentRootPath(requestHandler), outputFile); PathManager.EnsureFilepathExists(outputFilepath); File.WriteAllText(outputFilepath, result.Code); } } catch { } }
public static string GetBundlePath(IRequestHandler requestHandler, string filename) { return(PathManager.Combine(PathManager.GetBundlesPath(requestHandler), filename)); }
public static string GetViewPath(IRequestHandler requestHandler, string subdirectory, string filename) { return(PathManager.Combine(PathManager.GetViewsPath(requestHandler, subdirectory), filename)); }