private void StripImagesFromCssFiles(S2cSite site) { var lessFiles = site._lessFilesFactory.S2CFilesList; foreach (S2cFile lessFile in lessFiles) { try { using (StreamReader sr = new StreamReader(lessFile.FilePath)) { foreach (var url in sr.ReadToEnd().Split(' ')) { var imageFilePath = GetImageFileNameFromCssUrl(url); if (imageFilePath == null || !RegexHelper.FileExtensionRegex().Match(imageFilePath).Success) { continue; } var imagePath = GenerateFilePath(site.ResourcesFilepath, "img", imageFilePath.Split('/').Last().Split('?').FirstOrDefault()); var imageUrl = site.PageUrl + imageFilePath; S2CFilesList.Add(new S2cFile(imagePath, imageUrl)); } } } catch (Exception e) { Console.WriteLine("The file could not be read:"); Console.WriteLine(e.Message); Console.ReadLine(); } } }
//Transform Data Methods private void TransformJsonResourceData(S2cSite site, Dictionary <string, string> filePathDictionary, Dictionary <string, string> dataDictionary) { CreateScriptUri(site, JavascriptFilesList, site.PageObject["script"]); S2CFilesList.Add(new S2cFile(filePathDictionary["rightrailfilepath"], dataDictionary["rightraildata"])); S2CFilesList.Add(new S2cFile(filePathDictionary["scripturifilepath"], dataDictionary["scripturidata"])); }
private void TransformViewData(Dictionary <string, string> filePathDictionary, Dictionary <string, string> dataDictionary) { S2CFilesList.Add(new S2cFile(filePathDictionary["TopSerpBanner.cshtml"], dataDictionary["TopSerpBanner.cshtml"])); S2CFilesList.Add(new S2cFile(filePathDictionary["BottomSerpBanner.cshtml"], dataDictionary["BottomSerpBanner.cshtml"])); }
private void ToLessFilesFromImportStatementList(S2cSite site) { foreach (var url in LessImportsStatementsList) { string filename = ConvertCssExtToLessExt(PathCleanerHelper.CleanCSSPath(url)); var path = GenerateFilePath(site.ResourcesFilepath, "css", filename); S2CFilesList.Add(CreateLessFile(path, url)); } }
private void GenerateLessFiles(S2cSite site, CQ linkTagsCq) { foreach (var linkTagCq in linkTagsCq) { var filename = linkTagCq["href"].Split('/').Last(); if (linkTagCq["rel"] == "stylesheet" && RegexHelper.CssRegex().Match(filename).Success) { var file = ConvertCssExtToLessExt(filename); S2CFilesList.Add(CreateLessFile(GenerateFilePath(site.ResourcesFilepath, "css", file), linkTagCq["href"])); } } }
private void StripFilesFromImageTags(S2cSite site) { foreach (var tag in SiteDomTagsForProcessing) { if (tag["rel"] == "shortcut icon") { S2CFilesList.Add(CreateImageFile(tag["href"], site)); } else { S2CFilesList.Add(tag["data-src"] != null ? CreateImageFile(tag["data-src"], site) : CreateImageFile(tag["src"], site)); } } }