libkiwix
libkiwix copied to clipboard
Option to sort libraries shown on kiwix-serve
When viewing the library of zim files on the kiwix-serve home page, the files have no apparent order to them (either by title, filename, age of the zim file, or the order the files were added to library.xml).
Could we add options to control the order of the zim files? There are a few different options that should cover most people's requirements:
- Sort alphabetically by title
- Sort alphabetically by filename
- List by the order the zim files were added to library.xml
- Allow a config file which lists each zim filename, in the order the admin would like them listed
And going one step further, it could also be helpful to have options for the number of columns, and whether to organize the list down then across, or across then down.
At the very least, it would be nice to have the list sorted by title as the default. If you have several zim files downloaded then this feature would group the similar content, for example all of the wiki* libraries would be organized together.
@Shdwdrgn I think we should start from concrete examples. Would you be able please to give three simple and realistic scenarios which don't deliver what you expected (details about what you expected each time are welcome).
# rm library.xml
# kiwix-manage library.xml add /pub/Documents/kiwix/wikipedia_en_all_maxi_2021-12.zim
# kiwix-manage library.xml add /pub/Documents/kiwix/wikiversity_en_all_maxi_2021-03.zim
# kiwix-manage library.xml add /pub/Documents/kiwix/khan-academy-videos_en_chemistry_2021-04.zim
# service kiwix restart
The kiwix web page shows Wikiversity, Wikipedia, Chemistry Expected to see these in the order added: Wikipedia, Wikiversity, Chemistry
# rm library.xml
# kiwix-manage library.xml add /pub/Documents/kiwix/gutenberg_en_all_2022-03.zim
# kiwix-manage library.xml add /pub/Documents/kiwix/wikibooks_en_all_maxi_2021-03.zim
# kiwix-manage library.xml add /pub/Documents/kiwix/zimgit-food-preparation_en_2022-03.zim
# service kiwix restart
The kiwix page shows Wikibooks, Food Prep, Gutenberg Expected to see Gutenberg, Wikibooks, Food Prep
# rm library.xml
# kiwix-manage library.xml add /pub/Documents/kiwix/wikibooks_en_all_maxi_2021-03.zim
# kiwix-manage library.xml add /pub/Documents/kiwix/wikipedia_en_all_maxi_2021-12.zim
# kiwix-manage library.xml add /pub/Documents/kiwix/wikiversity_en_all_maxi_2021-03.zim
# service kiwix restart
The kiwix page shows Wikiversity, Wikibooks, Wikipedia Expected to see Wikibooks, Wikipedia, Wikiversity
In each of these cases sorting by the library title would be preferrable, or for more precise control sorting by the order they were added the library.xml, but there is no apparent reason for the order they are currently sorted in. I did notice that it does not matter which order I add the zim files to library.xml, they always get shown on the web page in the same order, which indicates there is some method that is being used to sort these entries, however if you have a larger number of zim files you will see that (for example) the wiki* entries are scattered throughout the list rather than being grouped together.
[Edited because the leading hash from my original cut&paste was misinterpreted by markdown)
@Shdwdrgn What I understand of your examples is that: you, as a kiwix-serve instance manager, wants to be able to define the (at least default) order in which the books are displayed (assuming they match the filter). Right?
Correct... either to be able to define the order specifically, or to have them sorted by some easily-identifiable method like the title shown on the web page or the filename so that the outcome is more predictable.
@Shdwdrgn Thx for clarifying your request. This is a feature request that you are not alone to ask for. This is pretty specific and as long as we didn't had proper filters, this kind of feature request was not high prioritised. This seems legitim and I believe we could/should do something in one of the next milestones.
That said, we still need to discuss the "how". This other ticket requests improvements around books sorting: #702.
At this stage, I don't really have an opinion about the fact of inserting a visual way in kiwix-serve to specify the order. But that does not way there is not a way (via the URL for example) to specify it. Anyway, this is not really what is requested here.
Specifying the order directly based on the order in the XML file seems odd and not a good approach (because far too implicit).
Maybe we should just create a new attribute order
in the XML?
From what I can tell of the other ticket, that request seems to be looking for a way for users to sort the content, while I am looking for a sorting option on the administrative side. However I can certainly see the advantage of merging both of these requests together so an admin could set the default sorting, but then users could select other options.
I agree that simply setting the order based on how each entry appears in the xml file is a bit 'clunky' but thought that could be the fastest way to modify the code so that admins could manage it. Adding an 'order' attribute to each 'book' tag would allow for more direct management though and be easier to work with if someone created their own editor. Or even a general 'sort' attribute under the 'library' tag to specify sorting by path, title, or name would be useful.
The books are probably sorted by their uuid, which is somehow a random (but stable) value. So indeed the sorting order make no sens but books are always sorted the same way.
Without adding a option to specify the wanted order, it should be pretty simple (for now) to at least sort the books by title or creation date (more recent first). We could add a option for the user later (when #702 will be done)
This issue has been automatically marked as stale because it has not had recent activity. It will be now be reviewed manually. Thank you for your contributions.
I will close the ticket as I have a strong will to not complexify much the UI. I still understand that the admin of a kiwix-serve might want to propose content in a certain order, but now that we have multiple filter it will be difficult to garanty it. For the rest, the future popularity property will be take in account to sort the content, so it should be used and abused to force the sorting.