Skip to content

Commit

Permalink
fix: Add redirects to old demos. (#6657)
Browse files Browse the repository at this point in the history
  • Loading branch information
NeilFraser authored Nov 25, 2022
1 parent 3d5f53e commit 351a696
Show file tree
Hide file tree
Showing 2 changed files with 77 additions and 20 deletions.
53 changes: 52 additions & 1 deletion appengine/app.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,58 @@ handlers:
- url: /static/apps/.*
static_files: redirect.html
upload: redirect.html
# Certain demos were moved on 25 Nov 2022.
- url: /static/demos/fixed/.*
static_files: redirect.html
upload: redirect.html
- url: /static/demos/resizable/.*
static_files: redirect.html
upload: redirect.html
- url: /static/demos/toolbox/.*
static_files: redirect.html
upload: redirect.html
- url: /static/demos/maxBlocks/.*
static_files: redirect.html
upload: redirect.html
- url: /static/demos/generator/.*
static_files: redirect.html
upload: redirect.html
- url: /static/demos/headless/.*
static_files: redirect.html
upload: redirect.html
- url: /static/demos/interpreter/step-execution.*
static_files: redirect.html
upload: redirect.html
- url: /static/demos/interpreter/async-execution.*
static_files: redirect.html
upload: redirect.html
- url: /static/demos/graph/.*
static_files: redirect.html
upload: redirect.html
- url: /static/demos/rtl/.*
static_files: redirect.html
upload: redirect.html
- url: /static/demos/custom-dialogs/.*
static_files: redirect.html
upload: redirect.html
- url: /static/demos/custom-fields/turtle/.*
static_files: redirect.html
upload: redirect.html
- url: /static/demos/custom-fields/pitch/.*
static_files: redirect.html
upload: redirect.html
- url: /static/demos/mirror/.*
static_files: redirect.html
upload: redirect.html
- url: /static/demos/plane/.*
static_files: redirect.html
upload: redirect.html
- url: /static/demos/keyboard_nav/.*
static_files: redirect.html
upload: redirect.html
- url: /static/demos/custom-fields/.*
static_files: redirect.html
upload: redirect.html

# Blockly files.
- url: /static
Expand Down Expand Up @@ -50,4 +102,3 @@ handlers:
- url: /.*
script: auto
secure: always

44 changes: 25 additions & 19 deletions appengine/redirect.html
Original file line number Diff line number Diff line change
Expand Up @@ -47,51 +47,57 @@
}
}

if (loc.match('/apps/puzzle/')) {
if (loc.includes('/apps/puzzle/')) {
// Puzzle moved to Blockly Games on 15 Oct 2014.
loc = 'https://blockly.games/puzzle';
} else if (loc.match('/apps/maze/')) {
} else if (loc.includes('/apps/maze/')) {
// Maze moved to Blockly Games on 10 Nov 2014.
loc = 'https://blockly.games/maze';
} else if (loc.match('/apps/turtle/')) {
} else if (loc.includes('/apps/turtle/')) {
// Turtle moved to Blockly Games on 10 Nov 2014.
loc = 'https://blockly.games/turtle';
} else if (loc.match('/apps/')) {
} else if (loc.includes('/apps/')) {
// Remaining apps moved to demos on 20 Nov 2014.
loc = loc.replace('/apps/', '/demos/');
}

// Demos without saved data were moved to Blockly Samples in 2021.
if (loc.match('/demos/fixed/')) {
if (loc.includes('/demos/fixed/')) {
loc = 'https://google.github.io/blockly-samples/examples/fixed-demo/';
} else if (loc.match('/demos/resizable/')) {
} else if (loc.includes('/demos/resizable/overlay')) {
loc = 'https://google.github.io/blockly-samples/examples/resizable-demo/overlay.html';
} else if (loc.includes('/demos/resizable/')) {
loc = 'https://google.github.io/blockly-samples/examples/resizable-demo/';
} else if (loc.match('/demos/toolbox/')) {
} else if (loc.includes('/demos/toolbox/')) {
loc = 'https://google.github.io/blockly-samples/examples/toolbox-demo/';
} else if (loc.match('/demos/maxBlocks/')) {
} else if (loc.includes('/demos/maxBlocks/')) {
loc = 'https://google.github.io/blockly-samples/examples/max-blocks-demo/';
} else if (loc.match('/demos/generator/')) {
} else if (loc.includes('/demos/generator/')) {
loc = 'https://google.github.io/blockly-samples/examples/generator-demo/';
} else if (loc.match('/demos/headless/')) {
} else if (loc.includes('/demos/headless/')) {
loc = 'https://google.github.io/blockly-samples/examples/headless-demo/';
} else if (loc.match('/demos/interpreter/step-execution')) {
} else if (loc.includes('/demos/interpreter/step-execution')) {
loc = 'https://google.github.io/blockly-samples/examples/interpreter-demo/step-execution.html';
} else if (loc.match('/demos/interpreter/async-execution')) {
} else if (loc.includes('/demos/interpreter/async-execution')) {
loc = 'https://google.github.io/blockly-samples/examples/interpreter-demo/async-execution.html';
} else if (loc.match('/demos/graph/')) {
} else if (loc.includes('/demos/graph/')) {
loc = 'https://google.github.io/blockly-samples/examples/graph-demo/';
} else if (loc.match('/demos/rtl/')) {
} else if (loc.includes('/demos/rtl/')) {
loc = 'https://google.github.io/blockly-samples/examples/rtl-demo/';
} else if (loc.match('/demos/custom-dialogs/')) {
} else if (loc.includes('/demos/custom-dialogs/')) {
loc = 'https://google.github.io/blockly-samples/examples/custom-dialogs-demo';
} else if (loc.match('/demos/custom-fields/turtle/')) {
} else if (loc.includes('/demos/custom-fields/turtle/')) {
loc = 'https://google.github.io/blockly-samples/examples/turtle-field-demo/';
} else if (loc.match('/demos/custom-fields/pitch/')) {
} else if (loc.includes('/demos/custom-fields/pitch/')) {
loc = 'https://google.github.io/blockly-samples/examples/pitch-field-demo/';
} else if (loc.match('/demos/mirror/')) {
} else if (loc.includes('/demos/mirror/')) {
loc = 'https://google.github.io/blockly-samples/examples/mirror-demo/';
} else if (loc.match('/demos/plane/')) {
} else if (loc.includes('/demos/plane/')) {
loc = 'https://google.github.io/blockly-samples/examples/plane-demo/';
} else if (loc.includes('/demos/keyboard_nav/')) {
loc = 'https://google.github.io/blockly-samples/plugins/keyboard-navigation/test/';
} else if (loc.includes('/demos/custom-fields/')) {
loc = 'https://google.github.io/blockly-samples/examples/pitch-field-demo/';
}

location = loc;
Expand Down

0 comments on commit 351a696

Please sign in to comment.