private MetaContent BuildMetaContent(string file) { MetaContent metaContent; var content = File.ReadAllText(file); var isPage = file.Contains(Paths.PagesPath); Trace.TraceInformation("Reading file {0}", file); if (isPage) { var parsed = pageParser.ParsePage(content); metaContent = new MetaContent(file) { Page = parsed }; metaContent.Page.Url = metaContent.GetTargetFileName(Paths).Replace(Paths.OutputPath, "").Replace('\\', '/'); } else { var parsed = pageParser.ParsePost(content); metaContent = new MetaContent(file) { Post = parsed }; metaContent.Post.Url = metaContent.GetTargetFileName(Paths).Replace(Paths.OutputPath, "").Replace('\\', '/'); } return(metaContent); }
private void EnsureMetaContentControl() { if (metaContentControl == null) { metaContentControl = Master.FindControl("MetaContent") as MetaContent; } }
private void Export(MetaContent metaContent, dynamic metadata) { var targetPath = metaContent.GetTargetFileName(Paths); if (!metaContent.HasValidTemplate()) { Trace.TraceWarning("No template given for file {0}", metaContent.FileName); return; } FileSystem.EnsureDirectory(targetPath); var result = internalTemplater.Transform(Paths.TemplatePath, metaContent.GetTemplate(), metadata); File.WriteAllText(targetPath, result); }
private void HandleFile(string file, WorkspaceFiles workspaceFiles) { MetaContent metaContent = null; try { metaContent = BuildMetaContent(file); } catch (InvalidPageException) { Trace.TraceWarning("Invalid YAML Front Matter for file " + file); var fileExtension = Path.GetExtension(file); if (!string.IsNullOrWhiteSpace(fileExtension) && (fileExtension.ToLowerInvariant() == ".html" || fileExtension.ToLowerInvariant() == ".htm")) { workspaceFiles.FilesNotToParse.Add(file); } } if (metaContent != null) { workspaceFiles.FilesToParse.Add(metaContent); } }
private void DoWork(BackgroundWorker worker, IEnumerable<MetaItem> items) { var rootFolder = Path.GetDirectoryName(Application.StartupPath); var metaOutput = new MetaContent() { GeneratedTimestamp = ConvertToTimestamp(DateTime.Now), Type = "cache_meta_content" }; foreach(var item in items) { var gameEntry = new MetaContent.GameEntry { Targets = item.Targets }; var gameTarget = item.Targets.Split('|')[0]; var files = Directory.GetFiles(item.MapInfoPath, "*.mapinfo"); foreach (var file in files) { var fi = new FileInfo(file); var continueProcessing = true; foreach (var block in blfBlockList.Where(block => fi.Name.StartsWith(block))) continueProcessing = false; if (!continueProcessing) continue; var mapInfo = new MapInfo(file); var metaEntry = new MetaContent.GameEntry.MetaDataEntry { English_Name = mapInfo.MapInformation.MapNames[0], English_Desc = mapInfo.MapInformation.MapDescriptions[0], InternalName = mapInfo.MapInformation.InternalName, PhysicalName = mapInfo.MapInformation.PhysicalName, MapId = mapInfo.MapInformation.MapID }; var extraSuffix = ""; if (gameTarget.StartsWith("Halo4")) extraSuffix = "_card"; var blfFile1 = new PureBLF(string.Format("{0}\\{1}{2}.blf", item.BlfPath, mapInfo.MapInformation.PhysicalName, extraSuffix)); var blfFile = new List<byte>(blfFile1.BLFChunks[1].ChunkData); blfFile1.Close(); blfFile.RemoveRange(0, 0x08); var blfFileSmall1 = new PureBLF(string.Format("{0}\\{1}_sm.blf", item.BlfPath, mapInfo.MapInformation.PhysicalName)); var blfFileSmall = new List<byte>(blfFileSmall1.BLFChunks[1].ChunkData); blfFileSmall1.Close(); blfFileSmall.RemoveRange(0, 0x08); if (!Directory.Exists(string.Format("{0}\\{1}\\maps\\", rootFolder, gameTarget))) Directory.CreateDirectory(string.Format("{0}\\{1}\\maps\\", rootFolder, gameTarget)); File.WriteAllBytes( string.Format("{0}\\{1}\\maps\\{2}.jpg", rootFolder, gameTarget, mapInfo.MapInformation.PhysicalName), blfFile.ToArray<byte>()); File.WriteAllBytes( string.Format("{0}\\{1}\\maps\\{2}_small.jpg", rootFolder, gameTarget, mapInfo.MapInformation.PhysicalName), blfFileSmall.ToArray<byte>()); metaEntry.ImageMetaData = new MetaContent.GameEntry.MetaDataEntry.ImageMetaDataEntry { Large = string.Format("{0}/maps/{1}.jpg", gameTarget, mapInfo.MapInformation.PhysicalName), Small = string.Format("{0}/maps/{1}_small.jpg", gameTarget, mapInfo.MapInformation.PhysicalName) }; gameEntry.MetaData.Add(metaEntry); } metaOutput.Games.Add(gameEntry); } File.WriteAllText(string.Format("{0}/content.aidf", rootFolder), JsonConvert.SerializeObject(metaOutput)); }