Project

General

Profile

Actions

Feature #613

closed

client-selectable directory list sorting, patch included

Added by Anonymous over 18 years ago. Updated over 2 years ago.

Status:
Fixed
Priority:
Normal
Category:
mod_dirlisting
Target version:
ASK QUESTIONS IN Forums:
No

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

mod_dirlist_sorting.patch (5.15 KB) mod_dirlist_sorting.patch patch for client-selectable directory list sorting mcosby, 2007-12-30 14:33
dirlisting-1.4.26.patch (5.05 KB) dirlisting-1.4.26.patch mcosby, 2010-04-05 06:59
dirlisting-1.4.64_den1.patch (7.5 KB) dirlisting-1.4.64_den1.patch original patched updated for 1.4.64 dennisn, 2022-05-17 18:56

Related issues 1 (0 open1 closed)

Related to Feature #2315: dir-listing.external-jsFixed2011-05-12Actions
Actions #1

Updated by Anonymous almost 17 years ago

I second that!

-- nixin

Actions #2

Updated by mcosby almost 17 years ago

I've created a patch against lighttpd 1.4.18 for this

Actions #3

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

Actions #4

Updated by icy about 16 years ago

  • Priority changed from High to Normal
  • Patch available set to No
Actions #5

Updated by icy about 16 years ago

  • Patch available changed from No to Yes
Actions #6

Updated by mcosby over 14 years ago

Patch updated for 1.4.26

Actions #7

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/).

Actions #8

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

Actions #9

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

Actions #10

Updated by gstrauss over 8 years ago

Actions #11

Updated by gstrauss about 8 years ago

  • Status changed from New to Patch Pending
  • Target version set to 1.4.42
Actions #12

Updated by gstrauss about 8 years ago

  • Status changed from Patch Pending to Fixed
  • % Done changed from 0 to 100
Actions #13

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.

Actions #14

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.

Actions #15

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;
}

Actions

Also available in: Atom