build-public.ts 21 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715
  1. import path from 'node:path';
  2. import fs from 'node:fs';
  3. import fsp from 'node:fs/promises';
  4. import { task } from './trace';
  5. import { treeDir, TreeFileType } from './lib/tree-dir';
  6. import type { TreeType, TreeTypeArray } from './lib/tree-dir';
  7. import { OUTPUT_MOCK_DIR, OUTPUT_MODULES_RULES_DIR, PUBLIC_DIR, ROOT_DIR } from './constants/dir';
  8. import { fastStringCompare, writeFile } from './lib/misc';
  9. import type { VoidOrVoidArray } from './lib/misc';
  10. import picocolors from 'picocolors';
  11. import { tagged as html } from 'foxts/tagged';
  12. import { compareAndWriteFile } from './lib/create-file';
  13. const priorityOrder: Record<'default' | string & {}, number> = {
  14. LICENSE: 0,
  15. domainset: 10,
  16. non_ip: 20,
  17. ip: 30,
  18. List: 40,
  19. Surge: 50,
  20. Clash: 60,
  21. 'sing-box': 70,
  22. Surfboard: 80,
  23. LegacyClashPremium: 81,
  24. Modules: 90,
  25. Script: 100,
  26. Mock: 110,
  27. Assets: 120,
  28. Internal: 130,
  29. default: Number.MAX_VALUE
  30. };
  31. async function copyDirContents(srcDir: string, destDir: string, promises: Array<Promise<VoidOrVoidArray>> = []): Promise<Array<Promise<VoidOrVoidArray>>> {
  32. for await (const entry of await fsp.opendir(srcDir)) {
  33. const src = path.join(srcDir, entry.name);
  34. const dest = path.join(destDir, entry.name);
  35. if (entry.isDirectory()) {
  36. console.warn(picocolors.red('[build public] cant copy directory'), src);
  37. } else {
  38. promises.push(fsp.copyFile(src, dest, fs.constants.COPYFILE_FICLONE));
  39. }
  40. }
  41. return promises;
  42. }
  43. export const buildPublic = task(require.main === module, __filename)(async (span) => {
  44. await span.traceChildAsync('copy rest of the files', async () => {
  45. const p: Array<Promise<any>> = [];
  46. fs.mkdirSync(OUTPUT_MODULES_RULES_DIR, { recursive: true });
  47. p.push(copyDirContents(path.join(ROOT_DIR, 'Modules'), OUTPUT_MODULES_RULES_DIR, p));
  48. fs.mkdirSync(OUTPUT_MOCK_DIR, { recursive: true });
  49. p.push(copyDirContents(path.join(ROOT_DIR, 'Mock'), OUTPUT_MOCK_DIR, p));
  50. await Promise.all(p);
  51. });
  52. const html = await span
  53. .traceChild('generate index.html')
  54. .traceAsyncFn(() => treeDir(PUBLIC_DIR).then(generateHtml));
  55. await Promise.all([
  56. compareAndWriteFile(
  57. span,
  58. [
  59. '/*',
  60. ' cache-control: public, max-age=240, stale-while-revalidate=60, stale-if-error=15',
  61. 'https://:project.pages.dev/*',
  62. ' X-Robots-Tag: noindex',
  63. ...Object.keys(priorityOrder)
  64. .map((name) => `/${name}/*\n content-type: text/plain; charset=utf-8\n X-Robots-Tag: noindex`)
  65. ],
  66. path.join(PUBLIC_DIR, '_headers')
  67. ),
  68. compareAndWriteFile(
  69. span,
  70. [
  71. '# <pre>',
  72. '#########################################',
  73. '# Sukka\'s Ruleset - 404 Not Found',
  74. '################## EOF ##################</pre>'
  75. ],
  76. path.join(PUBLIC_DIR, '404.html')
  77. ),
  78. compareAndWriteFile(
  79. span,
  80. [
  81. '# The source code is located at [Sukkaw/Surge](https://github.com/Sukkaw/Surge)',
  82. '',
  83. '![GitHub repo size](https://img.shields.io/github/repo-size/sukkalab/ruleset.skk.moe?style=flat-square)'
  84. ],
  85. path.join(PUBLIC_DIR, 'README.md')
  86. )
  87. ]);
  88. return writeFile(path.join(PUBLIC_DIR, 'index.html'), html);
  89. });
  90. const prioritySorter = (a: TreeType, b: TreeType) => ((priorityOrder[a.name] || priorityOrder.default) - (priorityOrder[b.name] || priorityOrder.default)) || fastStringCompare(a.name, b.name);
  91. function treeHtml(tree: TreeTypeArray, level = 0) {
  92. let result = '';
  93. tree.sort(prioritySorter);
  94. for (let i = 0, len = tree.length; i < len; i++) {
  95. const entry = tree[i];
  96. if (entry.type === TreeFileType.DIRECTORY) {
  97. result += html`
  98. <li class="folder">
  99. <details ${level === 0 ? 'open' : ''}>
  100. <summary>${entry.name}</summary>
  101. <ul>${treeHtml(entry.children, level + 1)}</ul>
  102. </details>
  103. </li>
  104. `;
  105. } else if (/* entry.type === 'file' && */ !entry.name.endsWith('.html') && !entry.name.startsWith('_')) {
  106. result += html`
  107. <li class="file"><a class="file-link" href="${entry.path}">${entry.name}</a></li>
  108. `;
  109. }
  110. }
  111. return result;
  112. }
  113. function generateHtml(tree: TreeTypeArray) {
  114. return html`
  115. <!DOCTYPE html>
  116. <html lang="en">
  117. <head>
  118. <meta charset="utf-8">
  119. <title>Surge Ruleset Server | Sukka (@SukkaW)</title>
  120. <meta name="viewport" content="width=device-width,initial-scale=1,viewport-fit=cover">
  121. <link href="https://cdn.skk.moe/favicon.ico" rel="icon" type="image/ico">
  122. <link href="https://cdn.skk.moe/favicon/apple-touch-icon.png" rel="apple-touch-icon" sizes="180x180">
  123. <link href="https://cdn.skk.moe/favicon/android-chrome-192x192.png" rel="icon" type="image/png" sizes="192x192">
  124. <link href="https://cdn.skk.moe/favicon/favicon-32x32.png" rel="icon" type="image/png" sizes="32x32">
  125. <link href="https://cdn.skk.moe/favicon/favicon-16x16.png" rel="icon" type="image/png" sizes="16x16">
  126. <meta name="description" content="Sukka 自用的 Surge / Clash Premium 规则组">
  127. <meta property="og:title" content="Surge Ruleset | Sukka (@SukkaW)">
  128. <meta property="og:type" content="Website">
  129. <meta property="og:url" content="https://ruleset.skk.moe/">
  130. <meta property="og:image" content="https://cdn.skk.moe/favicon/android-chrome-192x192.png">
  131. <meta property="og:description" content="Sukka 自用的 Surge / Clash Premium 规则组">
  132. <meta name="twitter:card" content="summary">
  133. <link rel="canonical" href="https://ruleset.skk.moe/">
  134. <style>
  135. :root {
  136. --font-family: system-ui, -apple-system, "Segoe UI", "Roboto", "Ubuntu", "Cantarell", "Noto Sans", sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol", "Noto Color Emoji";
  137. --line-height: 1.5;
  138. --font-weight: 400;
  139. --font-size: 16px;
  140. --border-radius: 0.25rem;
  141. --border-width: 1px;
  142. --outline-width: 3px;
  143. --spacing: 1rem;
  144. --typography-spacing-vertical: 1.5rem;
  145. --block-spacing-vertical: calc(var(--spacing)*2);
  146. --block-spacing-horizontal: var(--spacing);
  147. --nav-element-spacing-vertical: 1rem;
  148. --nav-element-spacing-horizontal: 0.5rem;
  149. --nav-link-spacing-vertical: 0.5rem;
  150. --nav-link-spacing-horizontal: 0.5rem;
  151. --form-label-font-weight: var(--font-weight);
  152. --transition: 0.2s ease-in-out
  153. }
  154. @media (min-width:576px) {
  155. :root {
  156. --font-size: 17px
  157. }
  158. }
  159. @media (min-width:768px) {
  160. :root {
  161. --font-size: 18px
  162. }
  163. }
  164. @media (min-width:992px) {
  165. :root {
  166. --font-size: 19px
  167. }
  168. }
  169. @media (min-width:1200px) {
  170. :root {
  171. --font-size: 20px
  172. }
  173. }
  174. a {
  175. --text-decoration: none
  176. }
  177. a.contrast,
  178. a.secondary {
  179. --text-decoration: underline
  180. }
  181. small {
  182. --font-size: 0.875em
  183. }
  184. h1,
  185. h2,
  186. h3,
  187. h4,
  188. h5,
  189. h6 {
  190. --font-weight: 700
  191. }
  192. h1 {
  193. --font-size: 2rem;
  194. --typography-spacing-vertical: 3rem
  195. }
  196. :not(thead):not(tfoot)>*>td {
  197. --font-size: 0.875em
  198. }
  199. code,
  200. kbd,
  201. pre,
  202. samp {
  203. --font-family: "Menlo", "Consolas", "Roboto Mono", "Ubuntu Monospace", "Noto Mono", "Oxygen Mono", "Liberation Mono", monospace, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol", "Noto Color Emoji"
  204. }
  205. kbd {
  206. --font-weight: bolder
  207. }
  208. :root:not([data-theme=dark]),
  209. [data-theme=light] {
  210. --background-color: #fff;
  211. --color: #415462;
  212. --h1-color: #1b2832;
  213. --h2-color: #24333e;
  214. --h3-color: #2c3d49;
  215. --h4-color: #374956;
  216. --h5-color: #415462;
  217. --h6-color: #4d606d;
  218. --muted-color: #73828c;
  219. --muted-border-color: #edf0f3;
  220. --primary: #1095c1;
  221. --primary-hover: #08769b;
  222. --primary-focus: rgba(16, 149, 193, .125);
  223. --primary-inverse: #fff;
  224. --secondary: #596b78;
  225. --secondary-hover: #415462;
  226. --secondary-focus: rgba(89, 107, 120, .125);
  227. --secondary-inverse: #fff;
  228. --contrast: #1b2832;
  229. --contrast-hover: #000;
  230. --contrast-focus: rgba(89, 107, 120, .125);
  231. --contrast-inverse: #fff;
  232. --mark-background-color: #fff2ca;
  233. --mark-color: #543a26;
  234. --modal-overlay-background-color: rgba(213, 220, 226, .8);
  235. --loading-spinner-opacity: 0.5;
  236. --icon-folder: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' fill='none' stroke='%23415462' stroke-width='1.5' viewBox='0 0 24 24'%3E%3Cpath stroke-linecap='round' stroke-linejoin='round' d='M2.25 12.75V12A2.25 2.25 0 0 1 4.5 9.75h15A2.25 2.25 0 0 1 21.75 12v.75m-8.69-6.44-2.12-2.12a1.5 1.5 0 0 0-1.06-.44H4.5A2.25 2.25 0 0 0 2.25 6v12a2.25 2.25 0 0 0 2.25 2.25h15A2.25 2.25 0 0 0 21.75 18V9a2.25 2.25 0 0 0-2.25-2.25h-5.38a1.5 1.5 0 0 1-1.06-.44Z'/%3E%3C/svg%3E");
  237. --icon-file: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' fill='none' stroke='%23415462' stroke-width='1.5' viewBox='0 0 24 24'%3E%3Cpath stroke-linecap='round' stroke-linejoin='round' d='M19.5 14.25v-2.63a3.38 3.38 0 0 0-3.38-3.37h-1.5a1.13 1.13 0 0 1-1.12-1.13v-1.5a3.38 3.38 0 0 0-3.38-3.37H8.25m0 12.75h7.5m-7.5 3H12M10.5 2.25H5.62c-.62 0-1.12.5-1.12 1.13v17.25c0 .62.5 1.12 1.13 1.12h12.75c.62 0 1.12-.5 1.12-1.13v-9.37a9 9 0 0 0-9-9Z'/%3E%3C/svg%3E");
  238. --icon-folder-open: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' fill='none' stroke='%23415462' stroke-width='1.5' viewBox='0 0 24 24'%3E%3Cpath stroke-linecap='round' stroke-linejoin='round' d='M3.75 9.78c.11-.02.23-.03.34-.03h15.82c.11 0 .23 0 .34.03m-16.5 0a2.25 2.25 0 0 0-1.88 2.54l.85 6a2.25 2.25 0 0 0 2.23 1.93h14.1a2.25 2.25 0 0 0 2.23-1.93l.85-6a2.25 2.25 0 0 0-1.88-2.54m-16.5 0V6A2.25 2.25 0 0 1 6 3.75h3.88a1.5 1.5 0 0 1 1.06.44l2.12 2.12a1.5 1.5 0 0 0 1.06.44H18A2.25 2.25 0 0 1 20.25 9v.78'/%3E%3C/svg%3E");
  239. color-scheme: light
  240. }
  241. @media only screen and (prefers-color-scheme:dark) {
  242. :root:not([data-theme=light]) {
  243. --background-color: #11191f;
  244. --color: #bbc6ce;
  245. --h1-color: #edf0f3;
  246. --h2-color: #e1e6eb;
  247. --h3-color: #d5dce2;
  248. --h4-color: #c8d1d8;
  249. --h5-color: #bbc6ce;
  250. --h6-color: #afbbc4;
  251. --muted-color: #73828c;
  252. --muted-border-color: #1f2d38;
  253. --primary: #1095c1;
  254. --primary-hover: #1ab3e6;
  255. --primary-focus: rgba(16, 149, 193, .25);
  256. --primary-inverse: #fff;
  257. --secondary: #596b78;
  258. --secondary-hover: #73828c;
  259. --secondary-focus: rgba(115, 130, 140, .25);
  260. --secondary-inverse: #fff;
  261. --contrast: #edf0f3;
  262. --contrast-hover: #fff;
  263. --contrast-focus: rgba(115, 130, 140, .25);
  264. --contrast-inverse: #000;
  265. --mark-background-color: #d1c284;
  266. --mark-color: #11191f;
  267. --modal-overlay-background-color: rgba(36, 51, 62, .9);
  268. --loading-spinner-opacity: 0.5;
  269. --icon-folder: url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='24' height='24' fill='none' stroke='%23bbc6ce' stroke-linecap='round' stroke-linejoin='round' stroke-width='2'%3E%3Cpath d='M22 19a2 2 0 0 1-2 2H4a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h5l2 3h9a2 2 0 0 1 2 2z'/%3E%3C/svg%3E");
  270. --icon-file: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' fill='none' stroke='%23bbc6ce' stroke-width='1.5' viewBox='0 0 24 24'%3E%3Cpath stroke-linecap='round' stroke-linejoin='round' d='M19.5 14.25v-2.63a3.38 3.38 0 0 0-3.38-3.37h-1.5a1.13 1.13 0 0 1-1.12-1.13v-1.5a3.38 3.38 0 0 0-3.38-3.37H8.25m0 12.75h7.5m-7.5 3H12M10.5 2.25H5.62c-.62 0-1.12.5-1.12 1.13v17.25c0 .62.5 1.12 1.13 1.12h12.75c.62 0 1.12-.5 1.12-1.13v-9.37a9 9 0 0 0-9-9Z'/%3E%3C/svg%3E");
  271. --icon-folder-open: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' fill='none' stroke='%23bbc6ce' stroke-width='1.5' viewBox='0 0 24 24'%3E%3Cpath stroke-linecap='round' stroke-linejoin='round' d='M3.75 9.78c.11-.02.23-.03.34-.03h15.82c.11 0 .23 0 .34.03m-16.5 0a2.25 2.25 0 0 0-1.88 2.54l.85 6a2.25 2.25 0 0 0 2.23 1.93h14.1a2.25 2.25 0 0 0 2.23-1.93l.85-6a2.25 2.25 0 0 0-1.88-2.54m-16.5 0V6A2.25 2.25 0 0 1 6 3.75h3.88a1.5 1.5 0 0 1 1.06.44l2.12 2.12a1.5 1.5 0 0 0 1.06.44H18A2.25 2.25 0 0 1 20.25 9v.78'/%3E%3C/svg%3E");
  272. color-scheme: dark
  273. }
  274. }
  275. *,
  276. :after,
  277. :before {
  278. background-repeat: no-repeat;
  279. box-sizing: border-box
  280. }
  281. :after,
  282. :before {
  283. text-decoration: inherit;
  284. vertical-align: inherit
  285. }
  286. :where(:root) {
  287. -webkit-tap-highlight-color: transparent;
  288. -webkit-text-size-adjust: 100%;
  289. -moz-text-size-adjust: 100%;
  290. text-size-adjust: 100%;
  291. background-color: var(--background-color);
  292. color: var(--color);
  293. cursor: default;
  294. font-family: var(--font-family);
  295. font-size: var(--font-size);
  296. font-weight: var(--font-weight);
  297. line-height: var(--line-height);
  298. overflow-wrap: break-word;
  299. -moz-tab-size: 4;
  300. -o-tab-size: 4;
  301. tab-size: 4;
  302. text-rendering: optimizeLegibility
  303. }
  304. main {
  305. display: block
  306. }
  307. body {
  308. margin: 0;
  309. width: 100%
  310. }
  311. body>footer,
  312. body>header,
  313. body>main {
  314. margin-left: auto;
  315. margin-right: auto;
  316. padding: var(--block-spacing-vertical) 0;
  317. width: 100%
  318. }
  319. .container,
  320. .container-fluid {
  321. margin-left: auto;
  322. margin-right: auto;
  323. padding-left: var(--spacing);
  324. padding-right: var(--spacing);
  325. width: 100%
  326. }
  327. @media (min-width:576px) {
  328. .container {
  329. max-width: 510px;
  330. padding-left: 0;
  331. padding-right: 0
  332. }
  333. }
  334. @media (min-width:768px) {
  335. .container {
  336. max-width: 700px
  337. }
  338. }
  339. @media (min-width:992px) {
  340. .container {
  341. max-width: 920px
  342. }
  343. }
  344. @media (min-width:1200px) {
  345. .container {
  346. max-width: 1130px
  347. }
  348. }
  349. section {
  350. margin-bottom: var(--block-spacing-vertical)
  351. }
  352. b,
  353. strong {
  354. font-weight: bolder
  355. }
  356. address,
  357. blockquote,
  358. dl,
  359. figure,
  360. form,
  361. ol,
  362. p,
  363. pre,
  364. table,
  365. ul {
  366. color: var(--color);
  367. font-size: var(--font-size);
  368. font-style: normal;
  369. font-weight: var(--font-weight);
  370. margin-bottom: var(--typography-spacing-vertical);
  371. margin-top: 0
  372. }
  373. [role=link],
  374. a:not(.file-link) {
  375. --color: var(--primary);
  376. --background-color: transparent;
  377. background-color: var(--background-color);
  378. color: var(--color);
  379. outline: none;
  380. -webkit-text-decoration: var(--text-decoration);
  381. text-decoration: var(--text-decoration)
  382. }
  383. [role=link]:is([aria-current], :hover, :active, :focus):not(.file-link),
  384. a:is([aria-current], :hover, :active, :focus):not(.file-link) {
  385. color: var(--primary-hover);
  386. text-decoration: underline
  387. }
  388. [role=link]:focus:not(.file-link),
  389. a:focus:not(.file-link) {
  390. --background-color: var(--primary-focus)
  391. }
  392. h1,
  393. h2,
  394. h3,
  395. h4,
  396. h5,
  397. h6 {
  398. color: var(--color);
  399. font-family: var(--font-family);
  400. font-size: var(--font-size);
  401. font-weight: var(--font-weight);
  402. margin-bottom: var(--typography-spacing-vertical);
  403. margin-top: 0
  404. }
  405. h1 {
  406. --color: var(--h1-color)
  407. }
  408. h2 {
  409. --color: var(--h2-color)
  410. }
  411. h3 {
  412. --color: var(--h3-color)
  413. }
  414. h4 {
  415. --color: var(--h4-color)
  416. }
  417. h5 {
  418. --color: var(--h5-color)
  419. }
  420. h6 {
  421. --color: var(--h6-color)
  422. }
  423. :where(address, blockquote, dl, figure, form, ol, p, pre, table, ul)~:is(h1, h2, h3, h4, h5, h6) {
  424. margin-top: var(--typography-spacing-vertical)
  425. }
  426. p {
  427. margin-bottom: var(--typography-spacing-vertical)
  428. }
  429. small {
  430. font-size: var(--font-size)
  431. }
  432. :where(dl, ol, ul) {
  433. -webkit-padding-start: var(--spacing);
  434. -webkit-padding-end: 0;
  435. padding-left: var(--spacing);
  436. padding-right: 0;
  437. padding-inline-end: 0;
  438. padding-inline-start: var(--spacing)
  439. }
  440. :where(dl, ol, ul) li {
  441. margin-bottom: calc(var(--typography-spacing-vertical)*.25)
  442. }
  443. :where(dl, ol, ul) :is(dl, ol, ul) {
  444. margin: 0;
  445. margin-top: calc(var(--typography-spacing-vertical)*.25)
  446. }
  447. mark {
  448. background-color: var(--mark-background-color);
  449. color: var(--mark-color);
  450. padding: .125rem .25rem;
  451. vertical-align: baseline
  452. }
  453. ::-moz-selection {
  454. background-color: var(--primary-focus)
  455. }
  456. ::selection {
  457. background-color: var(--primary-focus)
  458. }
  459. :where(audio, canvas, iframe, img, svg, video) {
  460. vertical-align: middle
  461. }
  462. img {
  463. border-style: none;
  464. height: auto;
  465. max-width: 100%
  466. }
  467. :where(svg:not([fill])) {
  468. fill: currentColor
  469. }
  470. svg:not(:root) {
  471. overflow: hidden
  472. }
  473. legend {
  474. color: inherit;
  475. max-width: 100%;
  476. padding: 0;
  477. white-space: normal
  478. }
  479. ::-webkit-inner-spin-button,
  480. ::-webkit-outer-spin-button {
  481. height: auto
  482. }
  483. ::-moz-focus-inner {
  484. border-style: none;
  485. padding: 0
  486. }
  487. :-moz-focusring {
  488. outline: none
  489. }
  490. :-moz-ui-invalid {
  491. box-shadow: none
  492. }
  493. ::-ms-expand {
  494. display: none
  495. }
  496. fieldset {
  497. border: 0;
  498. margin: 0;
  499. margin-bottom: var(--spacing);
  500. padding: 0
  501. }
  502. fieldset legend,
  503. label {
  504. display: block;
  505. font-weight: var(--form-label-font-weight, var(--font-weight));
  506. margin-bottom: calc(var(--spacing)*.25)
  507. }
  508. [aria-controls] {
  509. cursor: pointer
  510. }
  511. [aria-disabled=true],
  512. [disabled] {
  513. cursor: not-allowed
  514. }
  515. [aria-hidden=false][hidden] {
  516. display: initial
  517. }
  518. [aria-hidden=false][hidden]:not(:focus) {
  519. clip: rect(0, 0, 0, 0);
  520. position: absolute
  521. }
  522. [tabindex],
  523. a,
  524. area,
  525. button,
  526. input,
  527. label,
  528. select,
  529. summary,
  530. textarea {
  531. -ms-touch-action: manipulation
  532. }
  533. .tree {
  534. --tree-spacing: 1.5rem;
  535. --radius: 10px;
  536. }
  537. .tree a {
  538. border-bottom: 1px solid transparent;
  539. border-color: var(--secondary);
  540. color: var(--color);
  541. text-decoration: none;
  542. transition: all 0.2s ease;
  543. }
  544. .tree a:hover {
  545. border-color: var(--secondary-hover);
  546. color: var(--h3-color);
  547. }
  548. .tree,
  549. .tree ul,
  550. .tree li {
  551. list-style: none;
  552. list-style-type: none;
  553. }
  554. .tree .folder li {
  555. display: block;
  556. position: relative;
  557. padding-left: calc(2 * var(--tree-spacing) - var(--radius) - 2px);
  558. }
  559. .tree ul {
  560. margin-left: calc(var(--radius) - var(--tree-spacing));
  561. padding-left: 0;
  562. }
  563. .tree summary {
  564. display: block;
  565. cursor: pointer;
  566. }
  567. .tree summary::marker,
  568. .tree summary::-webkit-details-marker {
  569. display: none;
  570. }
  571. .tree summary:focus {
  572. outline: none;
  573. }
  574. .tree summary:focus-visible {
  575. outline: 1px dotted #000;
  576. }
  577. .tree li.file::before {
  578. margin-right: 10px;
  579. vertical-align: middle;
  580. height: 20px;
  581. width: 20px;
  582. content: '';
  583. display: inline-block;
  584. background-image: var(--icon-file);
  585. background-position: top;
  586. background-size: 75% auto;
  587. }
  588. .tree li.folder>details>summary::before {
  589. z-index: 1;
  590. margin-right: 10px;
  591. vertical-align: middle;
  592. height: 20px;
  593. width: 20px;
  594. content: '';
  595. display: inline-block;
  596. background-image: var(--icon-folder);
  597. background-position: top;
  598. background-size: 75% auto;
  599. }
  600. .tree li.folder>details[open]>summary::before {
  601. background-image: var(--icon-folder-open);
  602. }
  603. </style>
  604. </head>
  605. <body>
  606. <main class="container">
  607. <h1>Sukka Ruleset Server</h1>
  608. <p>
  609. Made by <a href="https://skk.moe">Sukka</a> | <a href="https://github.com/SukkaW/Surge/">Source @ GitHub</a> | Licensed under <a href="/LICENSE" target="_blank">AGPL-3.0</a>
  610. </p>
  611. <p>Last Build: ${new Date().toISOString()}</p>
  612. <br>
  613. <ul class="tree">
  614. ${treeHtml(tree)}
  615. </ul>
  616. </main>
  617. </body>
  618. </html>
  619. `;
  620. }