Skip to main content
Module

x/reader/pattern/fallback.ejs

A simple tool for transforming Markdown repositories into readable documents –
Go to Latest
File
<!DOCTYPE html><html lang="en-NL"> <head> <meta charset="UTF-8" /> <meta content="noarchive, notranslate, noindex" name="robots" /> <meta content="width=device-width, initial-scale=1, user-scalable=no" name="viewport" /> <!----> <title>&#65279;</title> <!----> <!----> <meta content="#f6f6f6" name="theme-color" /> <meta content="#f6f6f6" name="theme-color" media="(prefers-color-scheme: light)" /> <meta content="#171b22" name="theme-color" media="(prefers-color-scheme: dark)" /> <!----> <!----> <script> let shorts = { o: 'outline', p: 'people', s: 'search' }; let params = new URLSearchParams(globalThis.location.search).get(`redirect`) || ``; let active = globalThis.location.pathname.split(`/`).slice(1); let target = ''; if (active[active.length - 1] == ``) active.pop(); switch (true) { // ? try "/o/foo/boo[/][?redirect=...]" to "/outline/foo/boo[/][?redirect=...]" case active[0] in shorts: { active[0] = shorts[active[0]]; let path = `/${active.join(`/`)}`; target = params == `` ? `${path}` : `${path}?redirect=${params}`; } break; // ? try ".../foo/boo[?redirect=...]" to ".../foo/boo/[?redirect=...]" case !globalThis.location.pathname.endsWith(`/`): { let path = `/${active.join(`/`)}`; target = params == `` ? `${path}/` : `${path}/?redirect=${params}`; } break; // ? trusted fallback when root path was not resolvable case active.length == 0: { let rout = `${params || ''}`; let host = `${location.hostname}`; let path = `applic.dev/manual/reader/fallback-page`; target = `https://${path}?redirect=${rout}&redirect-origin=${host}`; } break; // ? redirect down ".../foo/boo/" to ".../foo?redirect=/boo/" default: { let rout = `/${active.pop()}${params || ''}`; let path = `/${active.join(`/`)}`; target = `${path}?redirect=${rout}`; } break; } globalThis.location.replace(target); </script> <!----> </head></html>