mirror of
https://github.com/ShareX/ShareX.git
synced 2024-10-05 20:54:31 +13:00
Merge pull request #4969 from JamieSharpe/master
Added display path options to folder listing module.
This commit is contained in:
commit
47f862cf89
2 changed files with 24 additions and 3 deletions
|
@ -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)
|
||||
|
|
|
@ -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; }
|
||||
|
||||
|
|
Loading…
Reference in a new issue