diff --git a/ShareX.IndexerLib/IndexerHtml.cs b/ShareX.IndexerLib/IndexerHtml.cs
index 6748d11b7..d6df433c4 100644
--- a/ShareX.IndexerLib/IndexerHtml.cs
+++ b/ShareX.IndexerLib/IndexerHtml.cs
@@ -34,6 +34,7 @@ namespace ShareX.IndexerLib
public class IndexerHtml : Indexer
{
protected StringBuilder sbContent = new StringBuilder();
+ protected int prePathTrim = 0;
public IndexerHtml(IndexerSettings indexerSettings) : base(indexerSettings)
{
@@ -52,6 +53,9 @@ public override string Index(string folderPath)
sbHtmlIndex.AppendLine(HtmlHelper.EndTag("head"));
sbHtmlIndex.AppendLine(HtmlHelper.StartTag("body"));
+ folderPath = Path.GetFullPath(folderPath).TrimEnd('\\');
+ prePathTrim = folderPath.LastIndexOf(@"\") + 1;
+
FolderInfo folderInfo = GetFolderInfo(folderPath);
folderInfo.Update();
@@ -107,7 +111,7 @@ private string GetFolderNameRow(FolderInfo dir, int level)
if (dir.TotalFileCount > 0)
{
- folderNameRow += dir.TotalFileCount + " file" + (dir.TotalFileCount > 1 ? "s" : "");
+ folderNameRow += dir.TotalFileCount.ToString("n0") + " file" + (dir.TotalFileCount > 1 ? "s" : "");
}
if (dir.TotalFolderCount > 0)
@@ -117,16 +121,27 @@ private string GetFolderNameRow(FolderInfo dir, int level)
folderNameRow += ", ";
}
- folderNameRow += dir.TotalFolderCount + " folder" + (dir.TotalFolderCount > 1 ? "s" : "");
+ 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(dir.FolderName) + folderNameRow + HtmlHelper.EndTag("h" + heading);
+ return HtmlHelper.StartTag("h" + heading) + URLHelpers.HtmlEncode(pathTitle) + folderNameRow + HtmlHelper.EndTag("h" + heading);
}
private string GetFileNameRow(FileInfo fi, int level)
diff --git a/ShareX.IndexerLib/IndexerSettings.cs b/ShareX.IndexerLib/IndexerSettings.cs
index deb7d0b97..c8538dbdc 100644
--- a/ShareX.IndexerLib/IndexerSettings.cs
+++ b/ShareX.IndexerLib/IndexerSettings.cs
@@ -59,6 +59,12 @@ public class IndexerSettings
[Category("Indexer / HTML"), DefaultValue(false), Description("Use custom Cascading Style Sheet file.")]
public bool UseCustomCSSFile { get; set; }
+ [Category("Indexer / HTML"), DefaultValue(false), Description("Display the path for each subfolder.")]
+ public bool DisplayPath { get; set; }
+
+ [Category("Indexer / HTML"), DefaultValue(false), Description("Limit the display path to the selected root folder. Must have DisplayPath enabled.")]
+ public bool DisplayPathLimited { get; set; }
+
[Category("Indexer / HTML"), DefaultValue(""), Description("Custom Cascading Style Sheet file path."), Editor(typeof(CssFileNameEditor), typeof(UITypeEditor))]
public string CustomCSSFilePath { get; set; }