Feature #613
closedclient-selectable directory list sorting, patch included
Description
Hello
Could you please add the possibility to sort the default dir listing by date, not only by name ( ?M=A / ?M=D from apache) ?
best Regards
-- wolfy
Files
Updated by mcosby almost 17 years ago
I've created a patch against lighttpd 1.4.18 for this
Updated by Anonymous almost 17 years ago
The patch seems to work perfectly. Thanks a lot !
Please consider including it as default for the future versions of lighty.
-- wolfy
Updated by icy about 16 years ago
- Priority changed from High to Normal
- Patch available set to No
Updated by mcosby over 14 years ago
- File dirlisting-1.4.26.patch dirlisting-1.4.26.patch added
Patch updated for 1.4.26
Updated by stbuehler over 14 years ago
- Assignee deleted (
jan) - Missing in 1.5.x set to No
I'd prefer client side sorting via javascript; see our dirlist module for 2.0 (http://cgit.lighttpd.net/lighttpd/sandbox/plain/src/modules/mod_dirlist.c, demo here: http://download.lighttpd.net/lighttpd/).
Updated by ghost_1987 almost 13 years ago
stbuehler wrote:
I'd prefer client side sorting via javascript; see our dirlist module for 2.0 (http://cgit.lighttpd.net/lighttpd/sandbox/plain/src/modules/mod_dirlist.c, demo here: http://download.lighttpd.net/lighttpd/).
this does not work on IE8 and older
please consider adding sorting feature as provided by the patch
Updated by gstrauss over 8 years ago
FYI: IE 8 is no longer supported on mainstream OS, so a client-side sort in javascript is now a more reasonable solution.
https://support.microsoft.com/en-us/lifecycle/search?sort=PN&alpha=internet%20explorer
https://support.microsoft.com/en-us/lifecycle#gp/Microsoft-Internet-Explorer
Updated by gstrauss over 8 years ago
- Related to Feature #2315: dir-listing.external-js added
Updated by gstrauss about 8 years ago
- Status changed from New to Patch Pending
- Target version set to 1.4.42
Updated by gstrauss about 8 years ago
- Status changed from Patch Pending to Fixed
- % Done changed from 0 to 100
Applied in changeset cfa3d27fc3f6c62350ea12f52a95e1c54ee547b7.
Updated by dennisn over 2 years ago
Please reopen. Javascript-only sorting is unacceptable. (I'm hoping for the javascript-cancer that has infected websites to be cured (eradicated) soon.) At the moment, many great non-javascript browsers are unable to sort.
I've attached a (probably clumsily and recklessly) updated version of this original patch, that compiles against 1.4.64. It seems to work great so far.
Updated by gstrauss over 2 years ago
- ASK QUESTIONS IN Forums set to No
I've attached a (probably clumsily and recklessly) updated version of this original patch, that compiles against 1.4.64. It seems to work great so far.
Reckless is an apt description for your patch. You modified the structure in plugin.h which affects ALL lighttpd plugins. That is completely unnecessary even for what you think you want to do, and there is no way that your patch will be accepted as-is since it requires updating all lighttpd plugins. I am surprised that other plugins are not crashing with your change. They almost certainly should be generating worrisome compiler warnings, if not errors. Also, I don't see where the sort
and sort_dir
arguments are assigned to be passed in the patch that requires modifying plugin.h or subrequest or subrequest_start. Any proposed changes to mod_dirlisting.c should be self-contained in mod_dirlisting.c.
All that said, why should (a cleaned up version of) your patch be accepted into lighttpd? If lighttpd mod_dirlisting does not meet your needs, why don't you write your own CGI script to do so, e.g. /index.py
run by mod_indexfile and mod_cgi. Alternatively, write you own "mod_dirlisting" by extending lua mod_dirlisting run from mod_magnet.
Updated by gstrauss over 2 years ago
I think you want to move the parsing of the query-string from http_list_directory
to mod_dirlisting_response
, and then pass sort
and sort_dir
into http_list_directory_header
and http_list_directory
.
Do your changes to http_list_directory_header
to create hrefs break javascript sorting?
Your changes to http_list_directory_header
hard-code magic numbers. I think you want to use preprocessor directive ##
to paste token stringification (#
) strings instead of hard-coding the magic numbers.
While it might be cleaner to pass to http_dirls_sort
a function pointer to a comparator function, it will probably be faster without too much extra code to specialize http_dirls_sort
for each of the 6 combinations. (And possibly more clever to sort as 3 combinations ascending, and to read the list backwards if descending sorting was desired.) Then again, the existing patch could reduce code duplication with something like (untested)
off_t res = type == SORT_ALPHA ? strcmp(DIRLIST_ENT_NAME(ent[i]), DIRLIST_ENT_NAME(ent[j])) : type == SORT_MODIFIED ? ent[i]->mtime - ent[j]->mtime : /*(type == SORT_SIZE)*/ ent[i]->size - ent[j]->size; if ((dir == SORT_DIR_ASC ? res : -res) > 0) { tmp = ent[i]; ent[i] = ent[j]; ent[j] = tmp; swapped = 1; }
Also available in: Atom