gap-system / GapWWW

Source for the GAP website
https://www.gap-system.org
Other
11 stars 26 forks source link

Allow query string in URL for packages list #355

Closed fingolfin closed 2 months ago

fingolfin commented 2 months ago

It would be great if one could do something like https://www.gap-system.org/packages/?q=library and then that URL would prefill "library" into the search fill.

Perhaps @schnellecom can be motivated to have a look at it ;-)

fingolfin commented 2 months ago

Clearly that would require some Javascript tweaks. Perhaps the https://datatables.net library we use even already has support for such a thing?

fingolfin commented 2 months ago

I implemented this in be1618094786e30b02f308aefd3a6a40722738e6 but it is not quite good enough, because the query string is just used in the normal "full text search/filtering". Which is already quite useful and e.g. https://www.gap-system.org/Packages/utils.html now redirects to https://www.gap-system.org/packages/?q=utils and that just shows the "utils" package as desired.

But e.g. https://www.gap-system.org/Packages/ace.html redirects to https://www.gap-system.org/packages/?q=ace which shows 28 packages -- "ace" of course occurs in words like "space", "face", "interface".

So this is a start but not the end.

In principle we can restrict the search to just the first column (just replace table.search by table.columns(1).search), but doing that then is not reflect in the UI, which might confuse users. Also it still doesn't quite do it because 7 packages have names that include "ace".

Perhaps a better alternative then is to bring back a page that has the only purpose of showing a description of a specific package. Something like https://www.gap-system.org/packages/desc?q=example and the JavaScript on that page renders the table -- but do we really want such pages?

olexandr-konovalov commented 2 months ago

Can we also make use of keywords in PackageInfo.g?

schnellecom commented 2 months ago

There is a very simple way to add it and I created a PR for it. The search term is just written in the URL after a # and if there is something written there it will be filled into the search field. See https://github.com/gap-system/GapWWW/pull/358

schnellecom commented 2 months ago

BTW the code is completely copied from this discussion and seems to just work: https://datatables.net/forums/discussion/30747/prepopulating-the-search-text-box

fingolfin commented 2 months ago

@schnellecom nice! but as I wrote above I already implemented something in be1618094786e30b02f308aefd3a6a40722738e6, but your PR certainly is nicer. But it should then also remove what I added, and adjust the redirects (as set up in my commit).

schnellecom commented 2 months ago

Now done with https://github.com/gap-system/GapWWW/pull/358