Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

new: file_server.sort #407

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open

Conversation

lollipopkit
Copy link

No description provided.

@lollipopkit
Copy link
Author

I'm sorry for opening this PR before the related PR is accepted.

Copy link
Member

@mholt mholt left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the docs! Just a few changes needed I think.

@@ -40,6 +40,7 @@ file_server [<matcher>] [browse] {
status <status>
disable_canonical_uris
pass_thru
sort <options...>
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
sort <options...>
sort <sort_field> [<direction>]

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This also needs to be moved to within the browse subdirective block above

@@ -69,6 +70,9 @@ file_server [<matcher>] [browse] {

- **pass_thru** <span id="pass_thru"/> enables pass-thru mode, which continues to the next HTTP handler in the route if the requested file is not found, instead of triggering a `404` error (invoking [`handle_errors`](handle_errors) routes). Practically, this is only useful inside of a [`route`](route) block with other handler directives following `file_server`, because this directive is effectively [ordered last](/docs/caddyfile/directives#directive-order).

- **sort** <span id="sort"/> specifies how to sort directory listings. The options are sortBy (`name`, `namedirfirst`, `size`, `time`) and order (`asc` or `desc`) separated by spaces. The first option must be `sortBy`, and the second option must be `order` (if exists). For example, `sort name desc` will sort by name in descending order.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
- **sort** <span id="sort"/> specifies how to sort directory listings. The options are sortBy (`name`, `namedirfirst`, `size`, `time`) and order (`asc` or `desc`) separated by spaces. The first option must be `sortBy`, and the second option must be `order` (if exists). For example, `sort name desc` will sort by name in descending order.
- **sort** <span id="sort"/> changes the default sort for directory listings. The first parameter is the field/column to sort by: `name`, `namedirfirst`, `size`, or `time`. The second argument is an optional direction: `asc` or `desc`. For example, `sort name desc` will sort by name in descending order.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This also needs to be moved up into the sub-list of browse.

Copy link
Author

@lollipopkit lollipopkit Aug 6, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Moved to browse, but the location of sort config...

It seems I need to change the caddy code again.

file_server browse {
	sort size desc
}
file_server {
	browse {
		sort size desc
	}
}

Change 1 to 2? or make both valid, but 2 has higher priority? or just keep current?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good question; I think the first one is not really a thing; i.e. it's just a shorthand for the default browse (no block).

So aim for the second one. Just put it inside the existing browse block. 👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants