public void AddLinksToRecipes() { foreach (var stuff in Locate.GetCategorizedRecipes()) AddRecipeGroup(stuff.Key, stuff.Value); DivStart("categorySection"); AddGroupHeader("Miscellaneous"); AddHTML("<div style='margin-left: 1em;'><a href='all_recipes.html'>Single page with all recipes</a></div>"); DivEnd(); }
private static void MakeCategoryPages(string OutputFolderPath, RecipeSource[] Recipes) { string categoryFolderPath = Path.Combine(OutputFolderPath, "category"); if (!Directory.Exists(categoryFolderPath)) { Directory.CreateDirectory(categoryFolderPath); } List <KeyValuePair <string, IRecipe[]> > recipesByCategory = Locate.GetCategorizedRecipes(); foreach (KeyValuePair <string, IRecipe[]> pair in recipesByCategory) { string categoryFolderName = pair.Value.First().Category.Folder; string thisCategoryFolderPath = Path.Combine(categoryFolderPath, categoryFolderName); if (!Directory.Exists(thisCategoryFolderPath)) { Directory.CreateDirectory(thisCategoryFolderPath); } MakeCategoryPage(thisCategoryFolderPath, Recipes); } }
private static void MakeIndexPage(string OutputFolderPath, RecipeSource[] Recipes) { Console.WriteLine("Creating index page ..."); string categoryHeaderTemplate = "<div class='fs-1 mt-4' style='font-weight: 500;' id='{{ANCHOR}}'>" + " <a href='#{{ANCHOR}}' class='text-dark'>{{TITLE}}</a>" + "</div>" + "<div class='mb-3'>{{SUBTITLE}}</div>"; string recipeTemplate = "<div class='row py-3'>" + " <div class='col-4'>" + " <a href='{{RECIPEURL}}'><img src='{{IMAGEURL}}' style='max-width: 100%'></a>" + " </div>" + " <div class='col'>" + " <div class='fw-bold'><a href='{{RECIPEURL}}'>{{TITLE}}</a></div>" + " <div>{{DESCRIPTION}}</div>" + " </div>" + "</div>"; StringBuilder sb = new(); sb.AppendLine($"Generated by ScottPlot {ScottPlot.Plot.Version} on {DateTime.Now.ToShortDateString()} <br />"); // CATEGORY LIST sb.AppendLine("<h4>Customization</h4>"); sb.AppendLine("<ul>"); foreach (KeyValuePair <string, IRecipe[]> pair in Locate.GetCategorizedRecipes()) { if (pair.Value.First().Category.ToString() !.Contains("PlotType")) { continue; } ICategory category = pair.Value.First().Category; if (category.Name == "Miscellaneous" || category.Name == "Statistics") { continue; } sb.AppendLine($"<li><a href='#{GetAnchor(category)}'>{category.Name}</a> - {category.Description}</li>"); } sb.AppendLine("</ul>"); sb.AppendLine("<h4>Plot Types</h4>"); sb.AppendLine("<ul>"); foreach (KeyValuePair <string, IRecipe[]> pair in Locate.GetCategorizedRecipes()) { if (!pair.Value.First().Category.ToString() !.Contains("PlotType")) { continue; } ICategory category = pair.Value.First().Category; sb.AppendLine($"<li><a href='#{GetAnchor(category)}'>{category.Name}</a> - {category.Description}</li>"); } sb.AppendLine("</ul>"); sb.AppendLine("<h4>Additional Examples</h4>"); sb.AppendLine("<ul>"); foreach (KeyValuePair <string, IRecipe[]> pair in Locate.GetCategorizedRecipes()) { if (pair.Value.First().Category.ToString() !.Contains("PlotType")) { continue; } ICategory category = pair.Value.First().Category; if (category.Name == "Miscellaneous" || category.Name == "Statistics") { sb.AppendLine($"<li><a href='#{GetAnchor(category)}'>{category.Name}</a> - {category.Description}</li>"); } } sb.AppendLine("</ul>"); sb.AppendLine("<h4>Colors</h4>"); sb.AppendLine("<ul>"); sb.AppendLine("<li><a href='colors/'>Color</a> - Lists of colors in each color palette for representing categorical data</li>"); sb.AppendLine("<li><a href='colormaps/'>Colormaps</a> - Color gradients available to represent continuous data</li>"); sb.AppendLine("</ul>"); // SEPARATION sb.AppendLine("<hr class='my-5' />"); // EVERY RECIPE foreach (KeyValuePair <string, IRecipe[]> pair in Locate.GetCategorizedRecipes()) { ICategory category = pair.Value.First().Category; string categoryUrl = $"category/{category.Folder}/"; sb.AppendLine(categoryHeaderTemplate .Replace("{{ANCHOR}}", GetAnchor(category)) .Replace("{{TITLE}}", category.Name) .Replace("{{SUBTITLE}}", category.Description)); foreach (var recipe in Recipes.Where(x => x.CategoryFolder == category.Folder)) { sb.AppendLine(recipeTemplate .Replace("{{IMAGEURL}}", "images/" + recipe.ID.ToLower() + "_thumb.jpg") .Replace("{{RECIPEURL}}", categoryUrl + "#" + GetAnchor(recipe)) .Replace("{{TITLE}}", recipe.Title) .Replace("{{DESCRIPTION}}", recipe.Description)); } } Template.CreateMarkdownPage( mdFilePath: Path.Combine(OutputFolderPath, "index_.md"), body: sb.ToString(), title: "ScottPlot 4.1 Cookbook", description: "Example plots shown next to the code used to create them", url: "/cookbook/4.1/"); Template.CreateHtmlPage( filePath: Path.Combine(OutputFolderPath, "index.dev.html"), bodyHtml: sb.ToString().Replace("/#", "/index.dev.html#"), title: "ScottPlot 4.1 Cookbook", description: "Example plots shown next to the code used to create them"); }