caddy-s3browser
caddy-s3browser copied to clipboard
Mark latest directory as Latest
I haven't have a chance to test yet, wanted to make a PR while it was fresh in my head.
Thanks for PR :)
I'm not sure this is where this should be, as looking at the test output latest is true for more than just the current release.
{
"Path": "/",
"Folders": [
"1.1.0",
"1.1",
"1.10.0-rc1",
"1.10.0",
"1.10",
"1.11.0",
"1.2.0-dev",
"1.2.0",
"1",
"one"
],
"Files": {
"main.txt": {
"Bytes": 12,
"Date": "2021-02-05T19:19:50.932Z"
},
"second.txt": {
"Bytes": 14,
"Date": "2021-02-05T19:19:50.952Z"
}
},
"RenderedDirs": [
{
"Name": "1.11.0",
"Icon": "current",
"Description": "Current Release 1.11.0",
"Class": "current",
"Latest": true
},
{
"Name": "1.10.0",
"Icon": "release",
"Description": "Previous Release 1.10.0",
"Class": "",
"Latest": false
},
{
"Name": "1.10",
"Icon": "working",
"Description": "Development branch for 1.10",
"Class": "",
"Latest": true
},
{
"Name": "1.10.0-rc1",
"Icon": "working",
"Description": "Release Candidate rc1 for 1.10.0",
"Class": "",
"Latest": true
},
{
"Name": "1.2.0",
"Icon": "release",
"Description": "Previous Release 1.2.0",
"Class": "",
"Latest": false
},
{
"Name": "1.2.0-dev",
"Icon": "working",
"Description": "Development branch for 1.2.0",
"Class": "",
"Latest": true
},
{
"Name": "1.1.0",
"Icon": "release",
"Description": "Previous Release 1.1.0",
"Class": "",
"Latest": false
},
{
"Name": "1.1",
"Icon": "older",
"Description": "Maintenance branch for 1.1",
"Class": "",
"Latest": false
},
{
"Name": "1",
"Icon": "working",
"Description": "Development branch for 1",
"Class": "",
"Latest": true
},
{
"Name": "one",
"Icon": "folder",
"Description": "",
"Class": "",
"Latest": false
}
],
"RenderedFiles": [
{
"Name": "main.txt",
"Icon": "file",
"Description": "",
"Class": "",
"Bytes": 12,
"Date": "2021-02-05T19:19:50.932Z"
},
{
"Name": "second.txt",
"Icon": "file",
"Description": "",
"Class": "",
"Bytes": 14,
"Date": "2021-02-05T19:19:50.952Z"
}
]
}
Yeah....this is tricky because it seems that some of this only applies to customized rendering.
Under semver sorting the first item in the slice would be latest, but I'm not sure what to do if semver sorting is turned off.