public void ToEdit(IValueProvider valueProvider) { var jsFiles = valueProvider.GetFiles(FileType.Js); var remover = new V.JsEofTokenRemover(); Parallel.ForEach(jsFiles, item => { remover.Remove(item.Tree); }); }
public void ToEdit(IValueProvider valueProvider) { var jsFiles = valueProvider.GetFiles(Entities.FileType.Js); var jsWsEditor = new V.JsWsSymbolsEditor(); Parallel.ForEach(jsFiles, item => { jsWsEditor.Edit(item.Tree); }); }
public void ToEdit(IValueProvider valueProvider) { var htmlFiles = valueProvider.GetFiles(FileType.Html); var visitor = new V.HtmlCommentEditor(); Parallel.ForEach(htmlFiles, item => { visitor.Edit(item.Tree); }); }
public void ToEdit(IValueProvider valueProvider) { var htmlFiles = valueProvider.GetFiles(FileType.Html); var htmlWsSymbols = new V.HtmlWsSymbolsEditor(); Parallel.ForEach(htmlFiles, item => { htmlWsSymbols.Edit(item.Tree); }); }
public void ToEdit(IValueProvider valueProvider) { var images = valueProvider.GetFiles(Entities.FileType.Image); var optimizer = new ImageOptimizer(); optimizer.OptimalCompression = true; foreach (var item in images) { optimizer.LosslessCompress(item.Stream); } }
public void ToEdit(IValueProvider valueProvider) { var htmlFiles = valueProvider.GetFiles(Entities.FileType.Html); var editor = new HtmlJsLoader(); foreach (var item in htmlFiles) { editor.Replace(item.Tree, valueProvider); } var jsFiles = valueProvider.GetFiles(Entities.FileType.Js); foreach (var item in jsFiles) { if (item.IsExternal) { valueProvider.RemoveFile(item.SearchName); } } }
public void ToEdit(IValueProvider valueProvider) { var htmlFiles = valueProvider.GetFiles(Entities.FileType.Html); List <FileContext> files = new List <FileContext>(); var searcher = new HtmlJsFileSearcher(); foreach (var item in htmlFiles) { var list = searcher.Search(item.Tree); files.AddRange(list); } var uniqFiles = files.Distinct(); File commonFile = new File(); commonFile.FileName = IO.Path.GetRandomFileName(); commonFile.SearchName = commonFile.FileName; commonFile.Type = FileType.Js; ProgramContext program = new ProgramContext(null, 0); SourceElementsContext elems = new SourceElementsContext(program, 0); foreach (var item in uniqFiles) { var tree = item.File.Tree as ProgramContext; var treeElems = tree.sourceElements().sourceElement(); foreach (var elem in treeElems) { elems.AddChild(elem); } valueProvider.RemoveFile(item.File.FileName); } program.AddChild(elems); commonFile.Tree = program; valueProvider.AddFile(commonFile); HtmlAddScriptEditor htmlAdsScript = new HtmlAddScriptEditor(); foreach (var item in htmlFiles) { htmlAdsScript.Add(item.Tree, new File[] { commonFile }); } foreach (var item in files) { item.Context.Remove(); } }
public void ToEdit(IValueProvider valueProvider) { var cssFiles = valueProvider.GetFiles(Entities.FileType.Css) .Where(i => !isInternal ^ i.IsInternal); CssParser cssParser = new CssParser(); Parallel.ForEach(cssFiles, item => { var csso = new Csso(); var stream = csso.ToOptimize(item.Tree.GetStream()); item.Tree = cssParser.ToParse(stream); }); }
public void ToEdit(IValueProvider valueProvider) { var htmlFiles = valueProvider.GetFiles(Entities.FileType.Html); List <FileContext> files = new List <FileContext>(); var searcher = new HtmlStyleFilesSearcher(); foreach (var item in htmlFiles) { var list = searcher.Search(item.Tree); files.AddRange(list); } var uniqFiles = files.Distinct(); File commonFile = new File(); commonFile.FileName = IO.Path.GetRandomFileName() + ".css"; commonFile.SearchName = commonFile.FileName; commonFile.Type = FileType.Css; StylesheetContext context = new StylesheetContext(null, 0); foreach (var item in uniqFiles) { var style = item.File.Tree as StylesheetContext; var nesteds = style.nestedStatement(); foreach (var nested in nesteds) { nested.parent = context; context.AddChild(nested); } valueProvider.RemoveFile(item.File.FileName); } commonFile.Tree = context; valueProvider.AddFile(commonFile); HtmlAddStyleEditor htmlAddStyle = new HtmlAddStyleEditor(); foreach (var item in htmlFiles) { htmlAddStyle.Add(item.Tree, new File[] { commonFile }); } foreach (var item in files) { item.Context.Remove(); } }
public void ToEdit(IValueProvider valueProvider) { var htmlFiles = valueProvider.GetFiles(FileType.Html); HtmlStyleEditor htmlStyleEditor = new HtmlStyleEditor(); HtmlJsEditor htmlJsEditor = new HtmlJsEditor(); //Parallel.ForEach(htmlFiles, item => { foreach (var item in htmlFiles) { var pathProvider = new PathProvider(item.FileName); htmlStyleEditor.Edit(item.Tree, valueProvider, pathProvider); htmlJsEditor.Edit(item.Tree, valueProvider, pathProvider); } //}); }
public void ToEdit(IValueProvider valueProvider) { var jsFile = valueProvider.GetFiles(Entities.FileType.Js) .Where(i => !isInternal ^ i.IsInternal); var remover = new Js.Visitors.JsEofTokenRemover(); var wsEditor = new Js.Visitors.JsWsSymbolsEditor(); foreach (var item in jsFile) { var jso = new JsOptimizerFacade(); var result = jso.ToOptimize(item.FileName, item.Tree.GetStream(), valueProvider.GetOutputMessages()); if (result != null) { item.Tree = new JsParser().ToParse(result); remover.Remove(item.Tree); wsEditor.Edit(item.Tree); } } }
public void ToEdit(IValueProvider valueProvider) { var cssFiles = valueProvider.GetFiles(FileType.Css); var jsFiles = valueProvider.GetFiles(FileType.Js); var htmlFiles = valueProvider.GetFiles(FileType.Html); var idsFreqList = new FreqList <string>(); var classNamesFreqList = new FreqList <string>(); var cssIdsSearcher = new CssV.CssIdsSearcher(); var cssClassNamesSearcher = new CssV.CssClassNamesSearcher(); foreach (var item in cssFiles) { cssIdsSearcher.Search(item.Tree, idsFreqList); cssClassNamesSearcher.Search(item.Tree, classNamesFreqList); } var htmlIdsSercher = new HtmlV.HtmlIdsSercher(); var htmlClassNamesSearcher = new HtmlV.HtmlClassNamesSearcher(); foreach (var item in htmlFiles) { htmlIdsSercher.Search(item.Tree, idsFreqList); htmlClassNamesSearcher.Search(item.Tree, classNamesFreqList); } INameGenerator nameGen = new NameGenerator(); IFactoryNames factoryNames = new FactoryNames(nameGen); var idsMap = GetMapNames(idsFreqList.GetOrderedList(), factoryNames); var classNamesMap = GetMapNames(classNamesFreqList.GetOrderedList(), factoryNames); var cssIdsEditor = new CssV.CssIdsEditor(); var cssClassNamesEditor = new CssV.CssClassNamesEditor(); foreach (var item in cssFiles) { cssIdsEditor.Replace(item.Tree, idsMap); cssClassNamesEditor.Replace(item.Tree, classNamesMap); } var htmlIdsEditor = new HtmlV.HtmlIdsEditor(); var htmlClassNamesEditor = new HtmlV.HtmlClassNamesEditor(); foreach (var item in htmlFiles) { htmlIdsEditor.Replace(item.Tree, idsMap); htmlClassNamesEditor.Replace(item.Tree, classNamesMap); } var jsIdsEditor = new JsV.JsIdsEditor(); var jsClassNamesEditor = new JsV.JsClassNamesEditor(); foreach (var item in jsFiles) { jsIdsEditor.Replace(item.Tree, valueProvider, idsMap); jsClassNamesEditor.Replace(item.Tree, valueProvider, classNamesMap); } }