-
Notifications
You must be signed in to change notification settings - Fork 13
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Localtest: Sort files in directoryBrowser by LastModified (#9572)
Sorting by guid does not make any sense. Co-authored-by: Ivar <[email protected]>
- Loading branch information
Showing
2 changed files
with
19 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
using System.Text.Encodings.Web; | ||
using Microsoft.AspNetCore.StaticFiles; | ||
using Microsoft.Extensions.FileProviders; | ||
|
||
namespace LocalTest.Helpers; | ||
|
||
public class SortedHtmlDirectoryFormatter : HtmlDirectoryFormatter | ||
{ | ||
public SortedHtmlDirectoryFormatter() : base(HtmlEncoder.Default) { } | ||
|
||
public override Task GenerateContentAsync(HttpContext context, IEnumerable<IFileInfo> contents) | ||
{ | ||
var sorted = contents.OrderByDescending(f => f.LastModified); | ||
return base.GenerateContentAsync(context, sorted); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters