Skip to content

176 web animation techniques, each a live demo with plain settings and a ready-made prompt for your AI assistant. No dependencies, no build step.

feat: the 404 page sends /finder and /find to the finder with its answers, and offers it as a third way back

matind4f05483c14c
diff --git a/404.html b/404.html
index 01c922d7..6875bf26 100644
--- a/404.html
+++ b/404.html
@@ -18,12 +18,17 @@
// Where a missing address leads: {go} to move on at once, else {words} for the search box. rest is the address's query
// and fragment. GitHub Pages tells capital letters from small ones, so an address with capitals moves to its lowercase
// path (percent escapes keep their case, so a lowercase path never moves again), and only within the handbook, so it
-// never leaves the site. /animations/ and a category folder have no page of their own: they open Browse all. Any other
-// address offers the words of its last part ("rotate-inn" gives "rotate inn"), skipping an index or readme file; a part
-// made only of digits offers none.
+// never leaves the site. /animations/ and a category folder have no page of their own: they open Browse all; /finder and
+// /find open the finder, a view of the home page, keeping only its answers (what, when and how). Any other address offers
+// the words of its last part ("rotate-inn" gives "rotate inn"), skipping an index or readme file; a part made only of
+// digits offers none.
function whereTo(path,rest){
var lower=path.replace(/%[0-9A-Fa-f]{2}|[A-Z]+/g,function(s){return s.charAt(0)==='%'?s:s.toLowerCase();});
if(/^\/animation-handbook\/animations(\/\d\d-[a-z0-9-]+)?(\/(index\.html?)?)?$/.test(lower))return {go:'/animation-handbook/?view=all#results'};
+ if(/^\/animation-handbook\/find(er)?\/?$/.test(lower)){
+ var keep=(rest||'').replace(/#.*$/,'').replace(/^\?/,'').split('&').filter(function(p){return /^(what|when|how)=[a-z]+$/.test(p);});
+ return {go:'/animation-handbook/?view=find'+(keep.length?'&'+keep.join('&'):'')};
+ }
if(lower!==path&&lower.indexOf('/animation-handbook/')===0)return {go:lower+(rest||'')};
var parts=path.split('/').filter(Boolean);
if(parts[0]==='animation-handbook')parts.shift();
@@ -123,6 +128,7 @@ button,input{font:inherit;color:inherit}
<nav class="ways" aria-label="Ways back">
<a class="way" href="/animation-handbook/">Go to the home page</a>
<a class="way" href="/animation-handbook/?view=all#results">Browse all 166 animations</a>
+ <a class="way" href="/animation-handbook/?view=find">Find an animation by what you saw</a>
</nav>
</main>
</body>
diff --git a/tests/pages.test.js b/tests/pages.test.js
index 93178a32..9facab13 100644
--- a/tests/pages.test.js
+++ b/tests/pages.test.js
@@ -684,6 +684,26 @@ test('the 404 page sends a mistyped address where it belongs and never off the s
for (const [where, rest, want] of cases) assert.deepEqual({ ...whereTo(where, rest) }, want, where + rest);
});
+test('the 404 page sends /finder and /find to the finder, keeping only its answers, and offers it as a way back', () => {
+ const html = read(path.join(ROOT, '404.html'));
+ const start = html.indexOf('function whereTo(');
+ assert.ok(start >= 0, 'whereTo in 404.html');
+ let depth = 0, end = html.indexOf('{', start);
+ for (; end < html.length; end++) { if (html[end] === '{') depth++; else if (html[end] === '}' && --depth === 0) break; }
+ const whereTo = vm.runInNewContext('(' + html.slice(start, end + 1) + ')');
+ const cases = [
+ ['/animation-handbook/finder', '', { go: '/animation-handbook/?view=find' }],
+ ['/animation-handbook/find/', '', { go: '/animation-handbook/?view=find' }],
+ ['/animation-handbook/Finder/', '?what=text&when=scroll&how=draw#top', { go: '/animation-handbook/?view=find&what=text&when=scroll&how=draw' }],
+ ['/animation-handbook/FIND', '?q=fade&how=fade&utm_source=x', { go: '/animation-handbook/?view=find&how=fade' }],
+ ['/animation-handbook/finder', '?what=%3Cb%3E', { go: '/animation-handbook/?view=find' }],
+ ['/animation-handbook/finders', '', { words: 'finders' }],
+ ['/animation-handbook/animations/finder/', '', { words: 'finder' }]
+ ];
+ for (const [where, rest, want] of cases) assert.deepEqual({ ...whereTo(where, rest) }, want, where + rest);
+ assert.ok(html.includes('<a class="way" href="/animation-handbook/?view=find">Find an animation by what you saw</a>'), 'the third way back');
+});
+
// Where the bracket that opens at HOME[from] ('[' or '{') is closed. It steps over strings and // comments, so a quote or bracket
// inside either does not count.
function blockEnd(from) {