Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/atwayne/sorted-directory-formatter
HtmlDirectoryFormatter that sorts output file list by LastModified
https://github.com/atwayne/sorted-directory-formatter
Last synced: 12 days ago
JSON representation
HtmlDirectoryFormatter that sorts output file list by LastModified
- Host: GitHub
- URL: https://github.com/atwayne/sorted-directory-formatter
- Owner: atwayne
- License: mit
- Created: 2021-05-06T06:01:13.000Z (over 3 years ago)
- Default Branch: master
- Last Pushed: 2021-05-17T00:28:24.000Z (over 3 years ago)
- Last Synced: 2023-08-05T12:11:31.647Z (over 1 year ago)
- Language: C#
- Size: 25.4 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
## General
A nuget package that provides a class `SortedHtmlDirectoryFormatter` derived from `HtmlDirectoryFormatter` [Link](https://github.com/dotnet/aspnetcore/blob/main/src/Middleware/StaticFiles/src/HtmlDirectoryFormatter.cs), which will render the file list sorted by the `LastModified` property in descending order.## Usage
[![SortedHtmlDirectoryFormatter on fuget.org](https://www.fuget.org/packages/SortedHtmlDirectoryFormatter/badge.svg)](https://www.fuget.org/packages/SortedHtmlDirectoryFormatter)
```bash
dotnet add package SortedHtmlDirectoryFormatter
``````csharp
public void Configure(IApplicationBuilder app, IWebHostEnvironment env)
{
app.UseDirectoryBrowser(new DirectoryBrowserOptions
{
FileProvider = new PhysicalFileProvider(rootDirectory),
RequestPath = "/your-request-path",
Formatter = new SortedHtmlDirectoryFormatter()
});
}
```## Background
The extension method `UseDirectoryBrowser` generates a table that sorts the output by filename. This is not a super helpful behavior when it comes to some scenarios. e.g. Directory Browser on a folder full of files with random file names.According to [this github issue](https://github.com/dotnet/aspnetcore/issues/20174) there is no plan to add a feature to sort this.
Hence I created this nuget package for this.
Another related github issue:
https://github.com/dotnet/aspnetcore/issues/29539