diff --git a/src/assets/js/temp/chromeos-install-redirector.js b/src/assets/js/temp/chromeos-install-redirector.js new file mode 100644 index 0000000000..3310644c80 --- /dev/null +++ b/src/assets/js/temp/chromeos-install-redirector.js @@ -0,0 +1,53 @@ +const oldToNew = { + 'configuring-web-app-support': '/get-started/install/chromeos/web', + + 'android-setup-without-android-studio': '/get-started/install/chromeos/android?tab=download#configure-android-development', + 'android-setup': '/get-started/install/chromeos/android?tab=download#configure-android-development', + 'configuring-android-app-support': '/get-started/install/chromeos/android?tab=download#configure-android-development', + 'set-up-your-android-device': '/get-started/install/chromeos/android#configure-your-target-android-device', + 'set-up-the-android-emulator': '/get-started/install/chromeos/android#configure-your-target-android-device', + 'agree-to-android-licenses': '/get-started/install/chromeos/android#agree-to-android-licenses', +}; + +function handleRedirect() { + const rawOldFragment = window.location.hash; + + // If no fragment was specified, don't do anything. + if (!rawOldFragment) { + return; + } + + const oldFragmentWithHash = rawOldFragment.trim().toLowerCase(); + + // If the fragment is empty, don't do anything. + if (oldFragmentWithHash.length === 0) { + return; + } + + const oldFragment = oldFragmentWithHash.substring(1); + + // If the fragment did not exist, don't do anything. + if (!(oldFragment in oldToNew)) { + return; + } + + const newDestination = oldToNew[oldFragment]; + + // If the desired destination exists, go there. + // Otherwise, don't go anywhere. + fetch(newDestination) + .then((response) => { + if (response.status === 200) { + window.location.replace(newDestination); + } + }).catch((_) => { + }); +} + +const currentLocation = window.location.pathname; + +if (currentLocation.includes('/get-started/install/chromeos') && + currentLocation.split('/') + .filter(value => value.trim().length !== 0).length === 3) { + handleRedirect(); +} diff --git a/src/assets/js/temp/linux-install-redirector.js b/src/assets/js/temp/linux-install-redirector.js new file mode 100644 index 0000000000..5a403708db --- /dev/null +++ b/src/assets/js/temp/linux-install-redirector.js @@ -0,0 +1,53 @@ +const oldToNew = { + 'linux-setup': '/get-started/install/linux/desktop', + + 'android-setup': '/get-started/install/linux/android#configure-android-development', + 'set-up-your-android-device': '/get-started/install/linux/android#configure-your-target-android-device', + 'set-up-the-android-emulator': '/get-started/install/linux/android#configure-your-target-android-device', + 'agree-to-android-licenses': '/get-started/install/linux/android#agree-to-android-licenses', + + 'update-your-path': '/get-started/install/linux/android?tab=download#add-flutter-to-your-path' +}; + +function handleRedirect() { + const rawOldFragment = window.location.hash; + + // If no fragment was specified, don't do anything. + if (!rawOldFragment) { + return; + } + + const oldFragmentWithHash = rawOldFragment.trim().toLowerCase(); + + // If the fragment is empty, don't do anything. + if (oldFragmentWithHash.length === 0) { + return; + } + + const oldFragment = oldFragmentWithHash.substring(1); + + // If the fragment did not exist, don't do anything. + if (!(oldFragment in oldToNew)) { + return; + } + + const newDestination = oldToNew[oldFragment]; + + // If the desired destination exists, go there. + // Otherwise, don't go anywhere. + fetch(newDestination) + .then((response) => { + if (response.status === 200) { + window.location.replace(newDestination); + } + }).catch((_) => { + }); +} + +const currentLocation = window.location.pathname; + +if (currentLocation.includes('/get-started/install/linux') && + currentLocation.split('/') + .filter(value => value.trim().length !== 0).length === 3) { + handleRedirect(); +} diff --git a/src/assets/js/temp/macos-install-redirector.js b/src/assets/js/temp/macos-install-redirector.js index 64fca2b506..bb30316a7e 100644 --- a/src/assets/js/temp/macos-install-redirector.js +++ b/src/assets/js/temp/macos-install-redirector.js @@ -10,6 +10,8 @@ const oldToNew = { 'set-up-your-android-device': '/get-started/install/macos/mobile-android#configure-your-target-android-device', 'set-up-the-android-emulator': '/get-started/install/macos/mobile-android#configure-your-target-android-device', 'agree-to-android-licenses': '/get-started/install/macos/mobile-android#agree-to-android-licenses', + + 'update-your-path': '/get-started/install/macos/mobile-ios?tab=download#add-flutter-to-your-path', }; function handleRedirect() { diff --git a/src/assets/js/temp/windows-install-redirector.js b/src/assets/js/temp/windows-install-redirector.js index 673fea5fbb..f3bddf3244 100644 --- a/src/assets/js/temp/windows-install-redirector.js +++ b/src/assets/js/temp/windows-install-redirector.js @@ -5,6 +5,8 @@ const oldToNew = { 'set-up-the-android-emulator': '/get-started/install/windows/mobile#configure-your-target-android-device', 'agree-to-android-licenses': '/get-started/install/windows/mobile#agree-to-android-licenses', 'android-setup': '/get-started/install/windows/mobile#configure-android-development', + + 'update-your-path': '/get-started/install/windows/mobile?tab=download#update-your-windows-path-variable', }; function handleRedirect() { diff --git a/src/get-started/install/chromeos/index.md b/src/get-started/install/chromeos/index.md index 5cadb54abd..77d9f98b04 100644 --- a/src/get-started/install/chromeos/index.md +++ b/src/get-started/install/chromeos/index.md @@ -3,6 +3,7 @@ title: Choose your first type of app description: Configure your system to develop Flutter on ChromeOS. short-title: ChromeOS target-list: [Android, Web] +js: [{url: '/assets/js/temp/chromeos-install-redirector.js'}] --- {% assign os = 'chromeos' -%} diff --git a/src/get-started/install/linux/index.md b/src/get-started/install/linux/index.md index 24552c8927..a06260b0ef 100644 --- a/src/get-started/install/linux/index.md +++ b/src/get-started/install/linux/index.md @@ -3,6 +3,7 @@ title: Choose your first type of app description: Configure your system to develop Flutter on Linux. short-title: Linux target-list: [Desktop, Android, Web] +js: [{url: '/assets/js/temp/linux-install-redirector.js'}] --- {% assign os = 'linux' -%}