extension: Improve routes.html w icons, top text.

This commit is contained in:
Omar Rizwan 2021-09-13 06:17:46 -07:00
parent b8258aaa01
commit c5228d4ac0

View file

@ -675,22 +675,26 @@ Routes["/runtime/routes.html"] = makeRouteWithContents(async () => {
return null; // did not find return null; // did not find
} }
return ` return `
<!doctype html>
<html> <html>
<head> <head>
<meta charset="utf-8">
<style> <style>
dt:not(:first-of-type) { margin-top: 1em; } dt:not(:first-of-type) { margin-top: 1em; }
</style> </style>
</head> </head>
<body> <body>
<p>This page is automatically generated from <a href="https://github.com/osnr/TabFS/blob/master/extension/background.js">extension/background.js in the TabFS source code</a>.</p>
<p>It documents each of the folders and files that TabFS serves up from your browser.</p>
<p>(work in progress)</p> <p>(work in progress)</p>
<dl> <dl>
` + Object.entries(Routes).map(([path, {usage, description, __isInfill}]) => { ` + Object.entries(Routes).map(([path, {usage, description, __isInfill, readdir}]) => {
if (__isInfill) { return ''; } if (__isInfill) { return ''; }
let usages = usage ? (Array.isArray(usage) ? usage : [usage]) : []; let usages = usage ? (Array.isArray(usage) ? usage : [usage]) : [];
usages = usages.map(u => u.replace('\$0', path.substring(1) /* drop leading / */)); usages = usages.map(u => u.replace('\$0', path.substring(1) /* drop leading / */));
const lineRange = findRouteLineRange(path); const lineRange = findRouteLineRange(path);
return ` return `
<dt>${path.substring(1)}</dt> <dt>${readdir ? '&#x1F4C1;' : '&#x1F4C4;'} ${path.substring(1)}</dt>
${description ? `<dd>Description: ${description}</dd>` : ${description ? `<dd>Description: ${description}</dd>` :
'<dd style="background-color: #f99">No description found!</dd>'} '<dd style="background-color: #f99">No description found!</dd>'}
${usages.length > 0 ? `<dd>Usage: ${usages.length > 0 ? `<dd>Usage: