Welcome! Log In Create A New Profile

Advanced

Nginx Directory Autoindex

Posted by Luciano Mannucci 
Luciano Mannucci
Nginx Directory Autoindex
February 28, 2018 07:10PM
Hello all,

I have a directory served by nginx via autoindex (That works perfectly
as documented :). I need to show the content in reverse order (ls -r),
is there any rather simple method?

Thanks in advance,

Luciano.
--
/"\ /Via A. Salaino, 7 - 20144 Milano (Italy)
\ / ASCII RIBBON CAMPAIGN / PHONE : +39 2 485781 FAX: +39 2 48578250
X AGAINST HTML MAIL / E-MAIL: posthamster@sublink.sublink.ORG
/ \ AND POSTINGS / WWW: http://www.lesassaie.IT/
_______________________________________________
nginx mailing list
nginx@nginx.org
http://mailman.nginx.org/mailman/listinfo/nginx
Miguel C
Re: Nginx Directory Autoindex
March 01, 2018 12:40AM
I'm unsure if thats possible without 3rd party module...

I've used fancyindex before when I wanted sorting.

On Wednesday, February 28, 2018, Luciano Mannucci <[email protected]>
wrote:

>
> Hello all,
>
> I have a directory served by nginx via autoindex (That works perfectly
> as documented :). I need to show the content in reverse order (ls -r),
> is there any rather simple method?
>
> Thanks in advance,
>
> Luciano.
> --
> /"\ /Via A. Salaino, 7 - 20144 Milano (Italy)
> \ / ASCII RIBBON CAMPAIGN / PHONE : +39 2 485781 FAX: +39 2 48578250
> X AGAINST HTML MAIL / E-MAIL: posthamster@sublink.sublink.ORG
> / \ AND POSTINGS / WWW: http://www.lesassaie.IT/
> _______________________________________________
> nginx mailing list
> nginx@nginx.org
> http://mailman.nginx.org/mailman/listinfo/nginx
>


--
Miguel Clara,
IT Consuling
_______________________________________________
nginx mailing list
nginx@nginx.org
http://mailman.nginx.org/mailman/listinfo/nginx
Luciano Mannucci
Re: Nginx Directory Autoindex
March 01, 2018 01:00PM
On Wed, 28 Feb 2018 23:30:35 +0000
Miguel C <[email protected]> wrote:

> I'm unsure if thats possible without 3rd party module...
>
> I've used fancyindex before when I wanted sorting.
I don't find fancyindex module in 1.13.9. It seems that some of its
features are now in autoindex. It is probably trivial to add an option
to the configuration, something like "autoindex_reverse_sort" (set to
off by default), though I don'nt know if it would be usefull for other
nginx users...

Thanks for your answer,

Luciano.
--
/"\ /Via A. Salaino, 7 - 20144 Milano (Italy)
\ / ASCII RIBBON CAMPAIGN / PHONE : +39 2 485781 FAX: +39 2 48578250
X AGAINST HTML MAIL / E-MAIL: posthamster@sublink.sublink.ORG
/ \ AND POSTINGS / WWW: http://www.lesassaie.IT/
_______________________________________________
nginx mailing list
nginx@nginx.org
http://mailman.nginx.org/mailman/listinfo/nginx
Vladimir Homutov
Re: Nginx Directory Autoindex
March 01, 2018 01:20PM
On Wed, Feb 28, 2018 at 07:03:22PM +0100, Luciano Mannucci wrote:
>
> Hello all,
>
> I have a directory served by nginx via autoindex (That works perfectly
> as documented :). I need to show the content in reverse order (ls -r),
> is there any rather simple method?
>
> Thanks in advance,

Hello Luciano,

you can set http://nginx.org/en/docs/http/ngx_http_autoindex_module.html#autoindex_format
to XML and combine with http://nginx.org/en/docs/http/ngx_http_xslt_module.html
to get any listing that you desire.

>
> Luciano.
> --
> /"\ /Via A. Salaino, 7 - 20144 Milano (Italy)
> \ / ASCII RIBBON CAMPAIGN / PHONE : +39 2 485781 FAX: +39 2 48578250
> X AGAINST HTML MAIL / E-MAIL: posthamster@sublink.sublink.ORG
> / \ AND POSTINGS / WWW: http://www.lesassaie.IT/
> _______________________________________________
> nginx mailing list
> nginx@nginx.org
> http://mailman.nginx.org/mailman/listinfo/nginx
_______________________________________________
nginx mailing list
nginx@nginx.org
http://mailman.nginx.org/mailman/listinfo/nginx
Miguel C
Re: Nginx Directory Autoindex
March 01, 2018 01:20PM
Yeah I was looking in github and there's no update for a year now... which
tbh might be about the same time I last used it :D

there's a default sorting option for name/data etc
https://github.com/aperezdc/ngx-fancyindex#fancyindex-default-sort

I do see a default_sort as a directive but not for "ascending" "descending"
(doesn't since supper hard to implement in the code though, but I'm not a C
expert....

Vladimir Homutov just suggested a different approach with the autoindex
module and xslt that seems to serve you're need, and that way there's no
need to install a 3rd party moduel :)


Melhores Cumprimentos // Best Regards
-----------------------------------------------
*Miguel Clara*
*IT - Sys Admin & Developer*

On Thu, Mar 1, 2018 at 11:54 AM, Luciano Mannucci <[email protected]>
wrote:

> On Wed, 28 Feb 2018 23:30:35 +0000
> Miguel C <[email protected]> wrote:
>
> > I'm unsure if thats possible without 3rd party module...
> >
> > I've used fancyindex before when I wanted sorting.
> I don't find fancyindex module in 1.13.9. It seems that some of its
> features are now in autoindex. It is probably trivial to add an option
> to the configuration, something like "autoindex_reverse_sort" (set to
> off by default), though I don'nt know if it would be usefull for other
> nginx users...
>
> Thanks for your answer,
>
> Luciano.
> --
> /"\ /Via A. Salaino, 7 - 20144 Milano (Italy)
> \ / ASCII RIBBON CAMPAIGN / PHONE : +39 2 485781 FAX: +39 2 48578250
> X AGAINST HTML MAIL / E-MAIL: posthamster@sublink.sublink.ORG
> / \ AND POSTINGS / WWW: http://www.lesassaie.IT/
> _______________________________________________
> nginx mailing list
> nginx@nginx.org
> http://mailman.nginx.org/mailman/listinfo/nginx
>
_______________________________________________
nginx mailing list
nginx@nginx.org
http://mailman.nginx.org/mailman/listinfo/nginx
Luciano Mannucci
Re: Nginx Directory Autoindex
March 01, 2018 05:30PM
On Thu, 1 Mar 2018 12:16:34 +0000
Miguel C <[email protected]> wrote:

> there's a default sorting option for name/data etc
> https://github.com/aperezdc/ngx-fancyindex#fancyindex-default-sort
>
> I do see a default_sort as a directive but not for "ascending" "descending"
> (doesn't since supper hard to implement in the code though, but I'm not a C
> expert....
Yes, it sould'nt be that hard... :)

> Vladimir Homutov just suggested a different approach with the autoindex
> module and xslt that seems to serve you're need, and that way there's no
> need to install a 3rd party moduel :)
I'm not comfortable with XML/XSLT, so I just made a small hack to the
original autoindex that is quite enough for me (=works and made my
users happy :).

If there is some interest I can post my patch to the apropriate list
(nginx devel, if I recall correctly :).

Cheers,

Luciano.
--
/"\ /Via A. Salaino, 7 - 20144 Milano (Italy)
\ / ASCII RIBBON CAMPAIGN / PHONE : +39 2 485781 FAX: +39 2 48578250
X AGAINST HTML MAIL / E-MAIL: posthamster@sublink.sublink.ORG
/ \ AND POSTINGS / WWW: http://www.lesassaie.IT/
_______________________________________________
nginx mailing list
nginx@nginx.org
http://mailman.nginx.org/mailman/listinfo/nginx
Roman Arutyunyan
Re: Nginx Directory Autoindex
March 01, 2018 05:50PM
Hi,

On Thu, Mar 01, 2018 at 05:27:49PM +0100, Luciano Mannucci wrote:
> On Thu, 1 Mar 2018 12:16:34 +0000
> Miguel C <[email protected]> wrote:
>
> > there's a default sorting option for name/data etc
> > https://github.com/aperezdc/ngx-fancyindex#fancyindex-default-sort
> >
> > I do see a default_sort as a directive but not for "ascending" "descending"
> > (doesn't since supper hard to implement in the code though, but I'm not a C
> > expert....
> Yes, it sould'nt be that hard... :)
>
> > Vladimir Homutov just suggested a different approach with the autoindex
> > module and xslt that seems to serve you're need, and that way there's no
> > need to install a 3rd party moduel :)
> I'm not comfortable with XML/XSLT, so I just made a small hack to the
> original autoindex that is quite enough for me (=works and made my
> users happy :).
>
> If there is some interest I can post my patch to the apropriate list
> (nginx devel, if I recall correctly :).

Just in case you'll get back to XML/XSLT, here's a simple configuration to
sort the files:

location / {
autoindex on;
autoindex_format xml;
xslt_stylesheet conf/sort.xslt;
root html;
}


sort.xslt:

<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">;

<xsl:template match="/">
<html>
<body>
<table border="1">
<xsl:for-each select="list/*">
<xsl:sort select="text()"/>
<tr>
<td><xsl:value-of select="text()"/></td>
<td><xsl:value-of select="@mtime"/></td>
<td><xsl:value-of select="@size"/></td>
</tr>
</xsl:for-each>
</table>
</body>
</html>
</xsl:template>

</xsl:stylesheet>

--
Roman Arutyunyan
_______________________________________________
nginx mailing list
nginx@nginx.org
http://mailman.nginx.org/mailman/listinfo/nginx
Luciano Mannucci
Re: Nginx Directory Autoindex
March 01, 2018 06:40PM
On Thu, 1 Mar 2018 19:45:27 +0300
Roman Arutyunyan <[email protected]> wrote:

> Just in case you'll get back to XML/XSLT, here's a simple configuration to
> sort the files:
Many thanks!
I'll give it a try.

Cheers,

Luciano.
--
/"\ /Via A. Salaino, 7 - 20144 Milano (Italy)
\ / ASCII RIBBON CAMPAIGN / PHONE : +39 2 485781 FAX: +39 2 48578250
X AGAINST HTML MAIL / E-MAIL: posthamster@sublink.sublink.ORG
/ \ AND POSTINGS / WWW: http://www.lesassaie.IT/
_______________________________________________
nginx mailing list
nginx@nginx.org
http://mailman.nginx.org/mailman/listinfo/nginx
James
Re: Nginx Directory Autoindex
March 02, 2018 11:40AM
On 01/03/2018 11:54, Luciano Mannucci wrote:

> It is probably trivial to add an option
> to the configuration, something like "autoindex_reverse_sort" (set to
> off by default), though I don'nt know if it would be usefull for other
> nginx users...

I'd like the option of order by date, "ls -t", "ls -rt". This helps
because the text order of numbers is "10 11 8 9", see:

http://nginx.org/download/

The latest version is 2/3 of the way down and if I was looking for an
update then 1.13.10 would not be next to the current 1.13.9.
_______________________________________________
nginx mailing list
nginx@nginx.org
http://mailman.nginx.org/mailman/listinfo/nginx
Luciano Mannucci
Re: Nginx Directory Autoindex
March 02, 2018 12:40PM
On Fri, 2 Mar 2018 10:33:45 +0000
James <[email protected]> wrote:

> I'd like the option of order by date, "ls -t", "ls -rt". This helps
> because the text order of numbers is "10 11 8 9", see:
>
> http://nginx.org/download/
Well, this is way less trivial than simply add a flag to reverse sort
order. It belongs indeed to fancyindex, that already does that:

fancyindex_default_sort

Syntax: fancyindex_default_sort [name | size | date | name_desc |
size_desc | date_desc]

Though you need to compile your own nginx to get that working (and
follow the module installation instructions :-).

Cheers,

Luciano.
--
/"\ /Via A. Salaino, 7 - 20144 Milano (Italy)
\ / ASCII RIBBON CAMPAIGN / PHONE : +39 2 485781 FAX: +39 2 48578250
X AGAINST HTML MAIL / E-MAIL: posthamster@sublink.sublink.ORG
/ \ AND POSTINGS / WWW: http://www.lesassaie.IT/
_______________________________________________
nginx mailing list
nginx@nginx.org
http://mailman.nginx.org/mailman/listinfo/nginx
James
Re: Nginx Directory Autoindex
March 02, 2018 03:10PM
On 02/03/2018 11:33, Luciano Mannucci wrote:

>> I'd like the option of order by date, "ls -t", "ls -rt". This helps
>> because the text order of numbers is "10 11 8 9", see:
>>
>> http://nginx.org/download/
> Well, this is way less trivial than simply add a flag to reverse sort
> order. It belongs indeed to fancyindex, that already does that:
....
> Though you need to compile your own nginx to get that working (and
> follow the module installation instructions :-).

Perhaps I should have expressed it as I'd like other people to sort by
date and that isn't going to happen unless it's easy, ie, built in.

autoindex on | off | date | text | ... ;


James.
_______________________________________________
nginx mailing list
nginx@nginx.org
http://mailman.nginx.org/mailman/listinfo/nginx
Vladimir Homutov
Re: Nginx Directory Autoindex
March 02, 2018 03:20PM
On Fri, Mar 02, 2018 at 02:03:36PM +0000, James wrote:
> On 02/03/2018 11:33, Luciano Mannucci wrote:
>
> >> I'd like the option of order by date, "ls -t", "ls -rt". This helps
> >> because the text order of numbers is "10 11 8 9", see:
> >>
> >> http://nginx.org/download/
> > Well, this is way less trivial than simply add a flag to reverse sort
> > order. It belongs indeed to fancyindex, that already does that:
> ...
> > Though you need to compile your own nginx to get that working (and
> > follow the module installation instructions :-).
>
> Perhaps I should have expressed it as I'd like other people to sort by
> date and that isn't going to happen unless it's easy, ie, built in.
>
> autoindex on | off | date | text | ... ;
>
>
Well, if you want some interactive sorting, you have to do it in
javascript; the native autoindex module is able to output json/jsonp,
so a simple js script may be used to implement any desired behaviour.


_______________________________________________
nginx mailing list
nginx@nginx.org
http://mailman.nginx.org/mailman/listinfo/nginx
James
Re: Nginx Directory Autoindex
March 02, 2018 03:30PM
On 02/03/2018 14:17, Vladimir Homutov wrote:

>> Perhaps I should have expressed it as I'd like other people to sort by
>> date and that isn't going to happen unless it's easy, ie, built in.
>>
>> autoindex on | off | date | text | ... ;
>>
>>
> Well, if you want some interactive sorting, you have to do it in
> javascript; the native autoindex module is able to output json/jsonp,
> so a simple js script may be used to implement any desired behaviour.

No, I want *other* people to sort their indices by date where
appropriate. It's more likely to happen if it's easy - no plugin, no
scripting.

Having just done my monthly check for software updates on 421 projects I
have a reason. Many are in text sorted directory listings and would
benefit from date ordering.


James.


_______________________________________________
nginx mailing list
nginx@nginx.org
http://mailman.nginx.org/mailman/listinfo/nginx
Sorry, only registered users may post in this forum.

Click here to login