aperezdc / ngx-fancyindex

Fancy indexes module for the Nginx web server
Other
857 stars 127 forks source link

How to Remove Date row / How to get longer filenames ? #133

Open ghost opened 2 years ago

ghost commented 2 years ago

Hey folks,

first off I really like this nginx extension, I've implemented it with OpenResty, and it almost works like a charm :D But still, there are two things I was not able to answer myself, especially because I'm not a C developer I guess.

  1. Is there any way to remove the "Date" row from the HTML view at the browser? I'm working with a Cashed remote File system in the background, so I always see the last timestamp of the updated cache, every file gets the same date, which makes sense but looks ugly ;)
  2. Some of my files have quite long names, and it seems that this extension does a cutoff according to the filenames character-length. Can I change this to a higher value?

It would also be awesome to understand the difference between template.h and template.html

Thanks in advance

ryandesign commented 2 years ago
  1. Is there any way to remove the "Date" row from the HTML view at the browser? I'm working with a Cashed remote File system in the background, so I always see the last timestamp of the updated cache, every file gets the same date, which makes sense but looks ugly ;)

I don't think you can configure ngx-fancyindex not to send this column. You can configure the date/time format to make it send an empty date:

fancyindex_time_format "";

And you can use a custom stylesheet to hide the column in the browser. The date cells helpfully have the date css class so you'd think you could just do:

#list .date { display: none; }

And you can, except that the header cell doesn't have this class so it remains visible. I might consider that a bug: the headers should have classes too so that they can be addressed more easily. However, failing that, a workaround is to just hide the third column, assuming that the third column will always be the date column:

#list td:nth-of-type(3), #list th:nth-of-type(3) { display: none; }

The widths of the remaining columns will technically be wrong at that point, since they were specified as percentages in the html, but you could adjust the column widths in css if needed.

  1. Some of my files have quite long names, and it seems that this extension does a cutoff according to the filenames character-length. Can I change this to a higher value?

With the latest released version of ngx-fancyindex (0.5.2), the default is to truncate file names at 50 characters but you can increase it like this:

fancyindex_name_length 255;

With the next version that will be released after that (0.6.0 or 1.0.0), this option has been removed and the full name will always be sent.

ryandesign commented 2 years ago

It would also be awesome to understand the difference between template.h and template.html

HACKING.md explains some of this already; I recommend reading it.

template.html is an HTML template that gets embedded into ngx-fancyindex when it is compiled. It uses parts extracted from this template when sending output to the browser.

ngx-fancyindex is written in the C programming language, and there isn't a mechanism in C to directly include an HTML file into a program. Therefore, template.html has to be converted to a form that can be included in a C program: namely, a C header file. That's what template.h is. Every time template.html is modified, template.h must be regenerated using the template.awk AWK script.

ryandesign commented 2 years ago

I don't think you can configure ngx-fancyindex not to send this column.

The request to allow reordering of columns was previously made in #66. Allowing columns to be omitted would probably be easy to implement at the same time.

ghost commented 2 years ago

Hey folks, thanks for your response, really appreciate that. In the meantime, I have rebuilt the module the way I needed it. I now removed the CSS relevant stuff and also the generation of the Date information within the C code. It was kinda fuc***-up as I'm not familiar with C at all. Anyways, it was possible in the end and I now have a flawless working module, epic!

The background of all this was that I'm using FancyIndex together with an rclone mount that again uses a local cache and refreshes every 24 hrs. So I always had the same date information on all files, kinda ugly for the end user if you ask me.

So again thanks for all your great work onto this module!

wilbert-vb commented 2 years ago

The header cells don't have a helpful css class, though.

See: issue-1367131802