HelloZeroNet / Documentation

ZeroNet Documentation
https://zeronet.readthedocs.org/
GNU General Public License v2.0
74 stars 107 forks source link

Redirect old docs to new docs #103

Closed anoadragon453 closed 5 years ago

anoadragon453 commented 5 years ago

Here is some JavaScript to redirect the old docs pages to the new site. A little pop up notice shows if it detects you're on the old site, and offers to take you to the new one.

If the page you're currently on is available on the new site, it will take you directly there, otherwise you'll be taken to the homepage.

I've set up a little demo that you can try here, treating my own site as the old site. CORS is still required for this to function properly, but as the docs pages are very similar at the moment I've gone ahead and made the check assume the page always exists.

HelloZeroNet commented 5 years ago

I have added some tweaks, because it was under the "v:latest" bottom right button and the redirect checked does not worked, because it was done in async. Modified to do it on hover, so it should be hidden from the user in most cases, but still does not trigger automatically on every page load

https://github.com/HelloZeroNet/Documentation/commit/053609c5c628a4189850f13801206135aea0cb07

anoadragon453 commented 5 years ago

The popup doesn't trigger or the redirect?

HelloZeroNet commented 5 years ago

The problem was with these lines:

    request.open('GET', newDocsURL, true); 
    request.send(); 
    return (request.status == 200) 

Since the request was async the request.status was always 0, as it does not waited for the result

anoadragon453 commented 5 years ago

Ahh, I see. I thought this line:

Modified to do it on hover, so it should be hidden from the user in most cases, but still does not trigger automatically on every page load

Meant there was still a problem. I assume it is instead working? :)

If so, I don't yet see it on https://zeronet.readthedocs.io

HelloZeroNet commented 5 years ago

Probably its just caching of docs.js, I can see it in multiple browsers

anoadragon453 commented 5 years ago

Ohh, I was expecting the little slide up thing. Didn't realize it had moved to the top :)

Works well!