nixos-homepage icon indicating copy to clipboard operation
nixos-homepage copied to clipboard

Compatibility with old options api

Open makefu opened this issue 5 years ago • 8 comments

As of right now, all links to the original options are redirecting to the new search, however the anchor is not used for the search. For backwards compatibility it would be great if a search would be directly triggered if an anchor is present or if at least the anchor is added into the search field so the user only needs to push "search".

The wiki did use the linking feature quite extensively ( e.g. https://nixos.wiki/index.php?title=Encrypted_DNS#Stubby ) and the silent breakage is quite unfortunate.

makefu avatar Aug 30 '20 17:08 makefu

The app should detect the presence of an anchor on the options page, and feed it to the query parameter at boot, I suppose.

The following URL

  • https://nixos.org/nixos/options.html#firefox

Goes to:

  • https://search.nixos.org/options#firefox

As far as the wiki is concerned, there was also a template, I'm switching it to the new URL scheme.

samueldr avatar Aug 30 '20 21:08 samueldr

I wouldn't like to add this complexity to the search, especially if this is only for backwards compatibility.

I would first try to solve this with a rewrite rules: https://docs.netlify.com/routing/redirects/redirect-options/#splats.

I would really like if somebody gives this a try.

garbas avatar Sep 01 '20 15:09 garbas

It is simply impossible to do a server-side rewrite on the fragment part (#abc) of a request.

The fragment is not sent to the server.

I don't think that breaking links for the sake of not making things too complex is nice.

As an alternative, to reduce complexity, this is something that could be done before booting the Elm app, some non-Elm JavaScript snippet just before booting the app, to further insulate the compatibility layer complexities from the app.

samueldr avatar Sep 01 '20 18:09 samueldr

A quick search for "nixos/options.html" reveals there are at least 2300 pages which link to the old options search. Surely not all pages use the anchor deeplinking but i think it is still significant

makefu avatar Sep 02 '20 07:09 makefu

@makefu I fixed quite few links in nixos.wiki. it wasn't 2300 pages but few hundred.

how did you search for "nixos/options.html". I used wget to create a mirror and grep the results.

garbas avatar Sep 24 '20 21:09 garbas

@garbas for the first clone i have used git-mediawiki but with the current size the checkout will very likely take some time. In discourse there will also be a lot of broken links, i am unsure if it was really worth the hassle to change every external link instead of injecting javascript code which performs the redirect :) nevertheless, thank you a lot for your efforts!

makefu avatar Sep 26 '20 17:09 makefu

I think this should be rather simple thing to implement in Elm. I can try to spike the implementation and you can decide if it adds too much complexity based on PR if you want.

It is simply impossible to do a server-side rewrite on the fragment part (#abc) of a request.

Correct - browsers don't even send fragment in HTTP request at all

something that could be done before booting the Elm app

That would be also an option and would be also relatively simple but might be harder to maintain.

turboMaCk avatar Oct 27 '20 14:10 turboMaCk

@turboMaCk This puts us in a corner in the future where we can not use fragment in search.nixos.org.

@makefu would it be possible to push nixos.wiki clone to github somewhere?

garbas avatar Oct 27 '20 23:10 garbas