protected override void IndexFolder(FolderInfo dir, int level = 0) { sbContent.AppendLine(GetFolderNameRow(dir, level)); string divClass = level > 0 ? "FolderBorder" : "MainFolderBorder"; sbContent.AppendLine(HtmlHelper.StartTag("div", "", $"class=\"{divClass}\"")); if (dir.Files.Count > 0) { sbContent.AppendLine(HtmlHelper.StartTag("ul")); foreach (FileInfo fi in dir.Files) { sbContent.AppendLine(GetFileNameRow(fi, level)); } sbContent.AppendLine(HtmlHelper.EndTag("ul")); } foreach (FolderInfo subdir in dir.Folders) { IndexFolder(subdir, level + 1); } sbContent.AppendLine(HtmlHelper.EndTag("div")); }
protected override string GetFolderNameRow(FolderInfo dir, int level) { int heading = (level + 1).Between(1, 6); string folderInfoText = string.Empty; if (!dir.IsEmpty) { folderInfoText = dir.Size.ToSizeString(config.BinaryUnits) + " ("; if (dir.TotalFileCount > 0) { folderInfoText += dir.TotalFileCount + " file" + (dir.TotalFileCount > 1 ? "s" : ""); } if (dir.TotalFolderCount > 0) { if (dir.TotalFileCount > 0) { folderInfoText += ", "; } folderInfoText += dir.TotalFolderCount + " folder" + (dir.TotalFolderCount > 1 ? "s" : ""); } folderInfoText += ")"; folderInfoText = " " + HtmlHelper.Tag("span", folderInfoText, "", "class=\"folderinfo\""); } return(HtmlHelper.StartTag("h" + heading) + URLHelpers.HtmlEncode(dir.FolderName) + folderInfoText + HtmlHelper.EndTag("h" + heading)); }
public override string Index(string folderPath) { StringBuilder sbHtmlIndex = new StringBuilder(); sbHtmlIndex.AppendLine("<!DOCTYPE html>"); sbHtmlIndex.AppendLine(HtmlHelper.StartTag("html")); sbHtmlIndex.AppendLine(HtmlHelper.StartTag("head")); sbHtmlIndex.AppendLine("<meta charset=\"UTF-8\">"); sbHtmlIndex.AppendLine("<meta http-equiv=\"X-UA-Compatible\" content=\"IE=edge\">"); sbHtmlIndex.AppendLine(HtmlHelper.Tag("title", "Index for " + Path.GetFileName(folderPath))); sbHtmlIndex.AppendLine(GetCssStyle()); sbHtmlIndex.AppendLine(HtmlHelper.EndTag("head")); sbHtmlIndex.AppendLine(HtmlHelper.StartTag("body")); FolderInfo folderInfo = GetFolderInfo(folderPath); folderInfo.Update(); IndexFolder(folderInfo); string index = sbContent.ToString().Trim(); sbHtmlIndex.AppendLine(index); if (settings.AddFooter) { sbHtmlIndex.AppendLine(HtmlHelper.StartTag("div") + GetFooter() + HtmlHelper.EndTag("div")); } sbHtmlIndex.AppendLine(HtmlHelper.EndTag("body")); sbHtmlIndex.AppendLine(HtmlHelper.EndTag("html")); return(sbHtmlIndex.ToString().Trim()); }
private string GetFileNameRow(FileInfo fi, int level) { string fileNameRow = HtmlHelper.StartTag("li") + URLHelpers.HtmlEncode(fi.Name); if (settings.ShowSizeInfo) { fileNameRow += " " + HtmlHelper.Tag("span", fi.Length.ToSizeString(settings.BinaryUnits), "", "class=\"FileSize\""); } fileNameRow += HtmlHelper.EndTag("li"); return(fileNameRow); }
private string GetFolderNameRow(FolderInfo dir, int level) { string folderNameRow = ""; if (!dir.IsEmpty) { if (settings.ShowSizeInfo) { folderNameRow += dir.Size.ToSizeString(settings.BinaryUnits) + " "; } folderNameRow += "("; if (dir.TotalFileCount > 0) { folderNameRow += dir.TotalFileCount.ToString("n0") + " file" + (dir.TotalFileCount > 1 ? "s" : ""); } if (dir.TotalFolderCount > 0) { if (dir.TotalFileCount > 0) { folderNameRow += ", "; } folderNameRow += dir.TotalFolderCount.ToString("n0") + " folder" + (dir.TotalFolderCount > 1 ? "s" : ""); } folderNameRow += ")"; folderNameRow = " " + HtmlHelper.Tag("span", folderNameRow, "", "class=\"FolderInfo\""); } string pathTitle; if (settings.DisplayPath) { pathTitle = settings.DisplayPathLimited ? dir.FolderPath.Substring(prePathTrim) : dir.FolderPath; } else { pathTitle = dir.FolderName; } int heading = (level + 1).Clamp(1, 6); return(HtmlHelper.StartTag("h" + heading) + URLHelpers.HtmlEncode(pathTitle) + folderNameRow + HtmlHelper.EndTag("h" + heading)); }
private string GetFolderNameRow(FolderInfo dir, int level) { string folderNameRow = ""; if (!dir.IsEmpty) { if (settings.ShowSizeInfo) { folderNameRow += dir.Size.ToSizeString(settings.BinaryUnits) + " "; } folderNameRow += "("; if (dir.TotalFileCount > 0) { folderNameRow += dir.TotalFileCount + " file" + (dir.TotalFileCount > 1 ? "s" : ""); } if (dir.TotalFolderCount > 0) { if (dir.TotalFileCount > 0) { folderNameRow += ", "; } folderNameRow += dir.TotalFolderCount + " folder" + (dir.TotalFolderCount > 1 ? "s" : ""); } folderNameRow += ")"; folderNameRow = " " + HtmlHelper.Tag("span", folderNameRow, "", "class=\"FolderInfo\""); } int heading = (level + 1).Clamp(1, 6); return(HtmlHelper.StartTag("h" + heading) + URLHelpers.HtmlEncode(dir.FolderName) + folderNameRow + HtmlHelper.EndTag("h" + heading)); }
public override string Index(string folderPath) { StringBuilder sbHtmlIndex = new StringBuilder(); sbHtmlIndex.AppendLine(Resources.doctype_xhtml); sbHtmlIndex.AppendLine(HtmlHelper.Tag("title", "Index for " + Path.GetFileName(folderPath))); sbHtmlIndex.AppendLine(GetCssStyle()); sbHtmlIndex.AppendLine(HtmlHelper.EndTag("head")); sbHtmlIndex.AppendLine(HtmlHelper.StartTag("body")); string index = base.Index(folderPath).Trim(); sbHtmlIndex.AppendLine(index); if (config.AddFooter) { sbHtmlIndex.AppendLine(HtmlHelper.StartTag("div") + GetFooter() + HtmlHelper.EndTag("div")); } if (config.AddValidationIcons) { sbHtmlIndex.AppendLine(Resources.valid_xhtml); } sbHtmlIndex.AppendLine(HtmlHelper.EndTag("body")); sbHtmlIndex.AppendLine(HtmlHelper.EndTag("html")); return(sbHtmlIndex.ToString().Trim()); }
protected override string GetFileNameRow(FileInfo fi, int level) { string size = " " + HtmlHelper.Tag("span", fi.Length.ToSizeString(config.BinaryUnits), "", "class=\"filesize\""); return(HtmlHelper.StartTag("li") + URLHelpers.HtmlEncode(fi.Name) + size + HtmlHelper.EndTag("li")); }