waschinski / photo-stream

Self-hosted, super simple photo stream
https://github.com/waschinski/photo-stream
MIT License
448 stars 68 forks source link

Add option to reverse image sort by default #43

Closed mschader closed 1 year ago

mschader commented 1 year ago

Hi,

first of all thank you for this project, I really like the minimal approach of the gallery which take away the need for a bloated backend, user management or database. I just started using the project and stumbled upon the exact issue mentioned in Issue #42. The proposed JS "hack" worked kinda wonky for me and at least in Safari I had some quick sort-changes during loading the page and it did not always end up in the correct sort order I intended. Therefore I would like to propose the change in this MR.

This MR will add a new variable in the .env file called DEFAULT_REVERSE_SORT which when set to 1 will add the liquid reverse filter to the images array assignment inside the index.html. This allows the templates to stay clean of any filters, keeping the logic in the index file without the need to change the JavaScript which might behave different for each browser.

This change was tested with both variable values set using the docker-compose file building locally and it worked at least on my machine as intended.

Let me know if you see any improvements which can be done to that approach or if you want any other variable naming.

JesseRiemens commented 1 year ago

I tried this, works well for me! Thanks for thinking up a better solution, this indeed works better since no reversing is done after loading.

waschinski commented 1 year ago

Thank you for the PR, Markus!

A new release including it will probably have to wait until I am back from vacation though.