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

Change date format YYYY-MM-DD HH:MM:SS #21

Open
drbeco opened this issue Feb 3, 2022 · 5 comments
Open

Change date format YYYY-MM-DD HH:MM:SS #21

drbeco opened this issue Feb 3, 2022 · 5 comments

Comments

@drbeco
Copy link

drbeco commented Feb 3, 2022

Hello, thanks for the nice work.

Please, how would I change the date format to something more universal like:

YYYY-MM-DD HH:MM:SS

@jmlemetayer
Copy link
Owner

Hi Ruben,

If you want to change the format for your installation only, check the installed .abba/js/script.js and look for this part of code:
https://github.com/jmlemetayer/abba/blob/main/_includes/js/abba/autoindex.js#L218

As I am using the moment.js library to parse the apache date. Then depending on the delta with the current time the date field is updated:

I like the first (< 1 day) format as it is easy to check for new files. The rest can be changed.

I invite you to create a pull request to fix this. I will be happy to accept it.

@drbeco
Copy link
Author

drbeco commented Feb 3, 2022

A good idea would be a config.ini file where the user could set various options. Something like:

dateformat="YYY-MM-DD HH:mm"

and use it to tune the style.

(For now I only added a line with the format I wanted , and it worked just fine. But this was a workaround that should not be a pull request.)

@jmlemetayer
Copy link
Owner

I guess dynamically loading a JSON configuration file with jQuery.getJSON() could be a solution.

It would be necessary to manage the case where the file does not exist with default values.

But we could extend this for all the things that are done in the javascript (navbar, breadcrumb, table, column order, sort behavior, icons, ...).

Thanks for the idea. I'll try to find some time to do an initial PoC!

@drbeco
Copy link
Author

drbeco commented Feb 7, 2022

One simple way to handle default values is to populate the config.ini with all variables and their default values. And to be sure the installation adds the file, so it always exist. (Ofc if the user delete the file or delete some lines, then he/she is responsible for breaking the installation).

/srv/httpd/htdocs/somewebsite/public_html/.abba/config.ini:

dateformat="YYY-MM-DD HH:mm"
navbar="tick"
breadcrumb="true"
table="left"
order="name,size"
sort="name"
icons="/srv/httpd/htdocs/somewebsite/public_html/.abba/images/icons"

I would advise against json. It is easier to program, but it would not be so user-friendly to edit and change. Take a look at how dokuwiki configuration is. Very easy to set up.

@jmlemetayer
Copy link
Owner

I understand that INI format is preferred from JSON for user friendly configuration files. I would say that TOML is even better.

But - and it is a big "but" (no joke) - JSON parsing is natively supported by javascript. So no external library is needed.

So if I have some time for this development, I will start with a simple JSON configuration file, and take more time for the handling (what to configure in the header, in the table ...). Then I will try to make it more user friendly by finding a good library to parse INI or TOML.

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

No branches or pull requests

2 participants