build-public.ts 21 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717
  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. '# This is a Robot-managed repo containing only output',
  82. '# The source code is located at [Sukkaw/Surge](https://github.com/Sukkaw/Surge)',
  83. '# Please follow the development at the source code repo instead',
  84. '',
  85. '![GitHub repo size](https://img.shields.io/github/repo-size/sukkalab/ruleset.skk.moe?style=flat-square)'
  86. ],
  87. path.join(PUBLIC_DIR, 'README.md')
  88. )
  89. ]);
  90. return writeFile(path.join(PUBLIC_DIR, 'index.html'), html);
  91. });
  92. const prioritySorter = (a: TreeType, b: TreeType) => ((priorityOrder[a.name] || priorityOrder.default) - (priorityOrder[b.name] || priorityOrder.default)) || fastStringCompare(a.name, b.name);
  93. function treeHtml(tree: TreeTypeArray, level = 0) {
  94. let result = '';
  95. tree.sort(prioritySorter);
  96. for (let i = 0, len = tree.length; i < len; i++) {
  97. const entry = tree[i];
  98. if (entry.type === TreeFileType.DIRECTORY) {
  99. result += html`
  100. <li class="folder">
  101. <details ${level === 0 ? 'open' : ''}>
  102. <summary>${entry.name}</summary>
  103. <ul>${treeHtml(entry.children, level + 1)}</ul>
  104. </details>
  105. </li>
  106. `;
  107. } else if (/* entry.type === 'file' && */ !entry.name.endsWith('.html') && !entry.name.startsWith('_')) {
  108. result += html`
  109. <li class="file"><a class="file-link" href="${entry.path}">${entry.name}</a></li>
  110. `;
  111. }
  112. }
  113. return result;
  114. }
  115. function generateHtml(tree: TreeTypeArray) {
  116. return html`
  117. <!DOCTYPE html>
  118. <html lang="en">
  119. <head>
  120. <meta charset="utf-8">
  121. <title>Surge Ruleset Server | Sukka (@SukkaW)</title>
  122. <meta name="viewport" content="width=device-width,initial-scale=1,viewport-fit=cover">
  123. <link href="https://cdn.skk.moe/favicon.ico" rel="icon" type="image/ico">
  124. <link href="https://cdn.skk.moe/favicon/apple-touch-icon.png" rel="apple-touch-icon" sizes="180x180">
  125. <link href="https://cdn.skk.moe/favicon/android-chrome-192x192.png" rel="icon" type="image/png" sizes="192x192">
  126. <link href="https://cdn.skk.moe/favicon/favicon-32x32.png" rel="icon" type="image/png" sizes="32x32">
  127. <link href="https://cdn.skk.moe/favicon/favicon-16x16.png" rel="icon" type="image/png" sizes="16x16">
  128. <meta name="description" content="Sukka 自用的 Surge / Clash Premium 规则组">
  129. <meta property="og:title" content="Surge Ruleset | Sukka (@SukkaW)">
  130. <meta property="og:type" content="Website">
  131. <meta property="og:url" content="https://ruleset.skk.moe/">
  132. <meta property="og:image" content="https://cdn.skk.moe/favicon/android-chrome-192x192.png">
  133. <meta property="og:description" content="Sukka 自用的 Surge / Clash Premium 规则组">
  134. <meta name="twitter:card" content="summary">
  135. <link rel="canonical" href="https://ruleset.skk.moe/">
  136. <style>
  137. :root {
  138. --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";
  139. --line-height: 1.5;
  140. --font-weight: 400;
  141. --font-size: 16px;
  142. --border-radius: 0.25rem;
  143. --border-width: 1px;
  144. --outline-width: 3px;
  145. --spacing: 1rem;
  146. --typography-spacing-vertical: 1.5rem;
  147. --block-spacing-vertical: calc(var(--spacing)*2);
  148. --block-spacing-horizontal: var(--spacing);
  149. --nav-element-spacing-vertical: 1rem;
  150. --nav-element-spacing-horizontal: 0.5rem;
  151. --nav-link-spacing-vertical: 0.5rem;
  152. --nav-link-spacing-horizontal: 0.5rem;
  153. --form-label-font-weight: var(--font-weight);
  154. --transition: 0.2s ease-in-out
  155. }
  156. @media (min-width:576px) {
  157. :root {
  158. --font-size: 17px
  159. }
  160. }
  161. @media (min-width:768px) {
  162. :root {
  163. --font-size: 18px
  164. }
  165. }
  166. @media (min-width:992px) {
  167. :root {
  168. --font-size: 19px
  169. }
  170. }
  171. @media (min-width:1200px) {
  172. :root {
  173. --font-size: 20px
  174. }
  175. }
  176. a {
  177. --text-decoration: none
  178. }
  179. a.contrast,
  180. a.secondary {
  181. --text-decoration: underline
  182. }
  183. small {
  184. --font-size: 0.875em
  185. }
  186. h1,
  187. h2,
  188. h3,
  189. h4,
  190. h5,
  191. h6 {
  192. --font-weight: 700
  193. }
  194. h1 {
  195. --font-size: 2rem;
  196. --typography-spacing-vertical: 3rem
  197. }
  198. :not(thead):not(tfoot)>*>td {
  199. --font-size: 0.875em
  200. }
  201. code,
  202. kbd,
  203. pre,
  204. samp {
  205. --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"
  206. }
  207. kbd {
  208. --font-weight: bolder
  209. }
  210. :root:not([data-theme=dark]),
  211. [data-theme=light] {
  212. --background-color: #fff;
  213. --color: #415462;
  214. --h1-color: #1b2832;
  215. --h2-color: #24333e;
  216. --h3-color: #2c3d49;
  217. --h4-color: #374956;
  218. --h5-color: #415462;
  219. --h6-color: #4d606d;
  220. --muted-color: #73828c;
  221. --muted-border-color: #edf0f3;
  222. --primary: #1095c1;
  223. --primary-hover: #08769b;
  224. --primary-focus: rgba(16, 149, 193, .125);
  225. --primary-inverse: #fff;
  226. --secondary: #596b78;
  227. --secondary-hover: #415462;
  228. --secondary-focus: rgba(89, 107, 120, .125);
  229. --secondary-inverse: #fff;
  230. --contrast: #1b2832;
  231. --contrast-hover: #000;
  232. --contrast-focus: rgba(89, 107, 120, .125);
  233. --contrast-inverse: #fff;
  234. --mark-background-color: #fff2ca;
  235. --mark-color: #543a26;
  236. --modal-overlay-background-color: rgba(213, 220, 226, .8);
  237. --loading-spinner-opacity: 0.5;
  238. --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");
  239. --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");
  240. --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");
  241. color-scheme: light
  242. }
  243. @media only screen and (prefers-color-scheme:dark) {
  244. :root:not([data-theme=light]) {
  245. --background-color: #11191f;
  246. --color: #bbc6ce;
  247. --h1-color: #edf0f3;
  248. --h2-color: #e1e6eb;
  249. --h3-color: #d5dce2;
  250. --h4-color: #c8d1d8;
  251. --h5-color: #bbc6ce;
  252. --h6-color: #afbbc4;
  253. --muted-color: #73828c;
  254. --muted-border-color: #1f2d38;
  255. --primary: #1095c1;
  256. --primary-hover: #1ab3e6;
  257. --primary-focus: rgba(16, 149, 193, .25);
  258. --primary-inverse: #fff;
  259. --secondary: #596b78;
  260. --secondary-hover: #73828c;
  261. --secondary-focus: rgba(115, 130, 140, .25);
  262. --secondary-inverse: #fff;
  263. --contrast: #edf0f3;
  264. --contrast-hover: #fff;
  265. --contrast-focus: rgba(115, 130, 140, .25);
  266. --contrast-inverse: #000;
  267. --mark-background-color: #d1c284;
  268. --mark-color: #11191f;
  269. --modal-overlay-background-color: rgba(36, 51, 62, .9);
  270. --loading-spinner-opacity: 0.5;
  271. --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");
  272. --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");
  273. --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");
  274. color-scheme: dark
  275. }
  276. }
  277. *,
  278. :after,
  279. :before {
  280. background-repeat: no-repeat;
  281. box-sizing: border-box
  282. }
  283. :after,
  284. :before {
  285. text-decoration: inherit;
  286. vertical-align: inherit
  287. }
  288. :where(:root) {
  289. -webkit-tap-highlight-color: transparent;
  290. -webkit-text-size-adjust: 100%;
  291. -moz-text-size-adjust: 100%;
  292. text-size-adjust: 100%;
  293. background-color: var(--background-color);
  294. color: var(--color);
  295. cursor: default;
  296. font-family: var(--font-family);
  297. font-size: var(--font-size);
  298. font-weight: var(--font-weight);
  299. line-height: var(--line-height);
  300. overflow-wrap: break-word;
  301. -moz-tab-size: 4;
  302. -o-tab-size: 4;
  303. tab-size: 4;
  304. text-rendering: optimizeLegibility
  305. }
  306. main {
  307. display: block
  308. }
  309. body {
  310. margin: 0;
  311. width: 100%
  312. }
  313. body>footer,
  314. body>header,
  315. body>main {
  316. margin-left: auto;
  317. margin-right: auto;
  318. padding: var(--block-spacing-vertical) 0;
  319. width: 100%
  320. }
  321. .container,
  322. .container-fluid {
  323. margin-left: auto;
  324. margin-right: auto;
  325. padding-left: var(--spacing);
  326. padding-right: var(--spacing);
  327. width: 100%
  328. }
  329. @media (min-width:576px) {
  330. .container {
  331. max-width: 510px;
  332. padding-left: 0;
  333. padding-right: 0
  334. }
  335. }
  336. @media (min-width:768px) {
  337. .container {
  338. max-width: 700px
  339. }
  340. }
  341. @media (min-width:992px) {
  342. .container {
  343. max-width: 920px
  344. }
  345. }
  346. @media (min-width:1200px) {
  347. .container {
  348. max-width: 1130px
  349. }
  350. }
  351. section {
  352. margin-bottom: var(--block-spacing-vertical)
  353. }
  354. b,
  355. strong {
  356. font-weight: bolder
  357. }
  358. address,
  359. blockquote,
  360. dl,
  361. figure,
  362. form,
  363. ol,
  364. p,
  365. pre,
  366. table,
  367. ul {
  368. color: var(--color);
  369. font-size: var(--font-size);
  370. font-style: normal;
  371. font-weight: var(--font-weight);
  372. margin-bottom: var(--typography-spacing-vertical);
  373. margin-top: 0
  374. }
  375. [role=link],
  376. a:not(.file-link) {
  377. --color: var(--primary);
  378. --background-color: transparent;
  379. background-color: var(--background-color);
  380. color: var(--color);
  381. outline: none;
  382. -webkit-text-decoration: var(--text-decoration);
  383. text-decoration: var(--text-decoration)
  384. }
  385. [role=link]:is([aria-current], :hover, :active, :focus):not(.file-link),
  386. a:is([aria-current], :hover, :active, :focus):not(.file-link) {
  387. color: var(--primary-hover);
  388. text-decoration: underline
  389. }
  390. [role=link]:focus:not(.file-link),
  391. a:focus:not(.file-link) {
  392. --background-color: var(--primary-focus)
  393. }
  394. h1,
  395. h2,
  396. h3,
  397. h4,
  398. h5,
  399. h6 {
  400. color: var(--color);
  401. font-family: var(--font-family);
  402. font-size: var(--font-size);
  403. font-weight: var(--font-weight);
  404. margin-bottom: var(--typography-spacing-vertical);
  405. margin-top: 0
  406. }
  407. h1 {
  408. --color: var(--h1-color)
  409. }
  410. h2 {
  411. --color: var(--h2-color)
  412. }
  413. h3 {
  414. --color: var(--h3-color)
  415. }
  416. h4 {
  417. --color: var(--h4-color)
  418. }
  419. h5 {
  420. --color: var(--h5-color)
  421. }
  422. h6 {
  423. --color: var(--h6-color)
  424. }
  425. :where(address, blockquote, dl, figure, form, ol, p, pre, table, ul)~:is(h1, h2, h3, h4, h5, h6) {
  426. margin-top: var(--typography-spacing-vertical)
  427. }
  428. p {
  429. margin-bottom: var(--typography-spacing-vertical)
  430. }
  431. small {
  432. font-size: var(--font-size)
  433. }
  434. :where(dl, ol, ul) {
  435. -webkit-padding-start: var(--spacing);
  436. -webkit-padding-end: 0;
  437. padding-left: var(--spacing);
  438. padding-right: 0;
  439. padding-inline-end: 0;
  440. padding-inline-start: var(--spacing)
  441. }
  442. :where(dl, ol, ul) li {
  443. margin-bottom: calc(var(--typography-spacing-vertical)*.25)
  444. }
  445. :where(dl, ol, ul) :is(dl, ol, ul) {
  446. margin: 0;
  447. margin-top: calc(var(--typography-spacing-vertical)*.25)
  448. }
  449. mark {
  450. background-color: var(--mark-background-color);
  451. color: var(--mark-color);
  452. padding: .125rem .25rem;
  453. vertical-align: baseline
  454. }
  455. ::-moz-selection {
  456. background-color: var(--primary-focus)
  457. }
  458. ::selection {
  459. background-color: var(--primary-focus)
  460. }
  461. :where(audio, canvas, iframe, img, svg, video) {
  462. vertical-align: middle
  463. }
  464. img {
  465. border-style: none;
  466. height: auto;
  467. max-width: 100%
  468. }
  469. :where(svg:not([fill])) {
  470. fill: currentColor
  471. }
  472. svg:not(:root) {
  473. overflow: hidden
  474. }
  475. legend {
  476. color: inherit;
  477. max-width: 100%;
  478. padding: 0;
  479. white-space: normal
  480. }
  481. ::-webkit-inner-spin-button,
  482. ::-webkit-outer-spin-button {
  483. height: auto
  484. }
  485. ::-moz-focus-inner {
  486. border-style: none;
  487. padding: 0
  488. }
  489. :-moz-focusring {
  490. outline: none
  491. }
  492. :-moz-ui-invalid {
  493. box-shadow: none
  494. }
  495. ::-ms-expand {
  496. display: none
  497. }
  498. fieldset {
  499. border: 0;
  500. margin: 0;
  501. margin-bottom: var(--spacing);
  502. padding: 0
  503. }
  504. fieldset legend,
  505. label {
  506. display: block;
  507. font-weight: var(--form-label-font-weight, var(--font-weight));
  508. margin-bottom: calc(var(--spacing)*.25)
  509. }
  510. [aria-controls] {
  511. cursor: pointer
  512. }
  513. [aria-disabled=true],
  514. [disabled] {
  515. cursor: not-allowed
  516. }
  517. [aria-hidden=false][hidden] {
  518. display: initial
  519. }
  520. [aria-hidden=false][hidden]:not(:focus) {
  521. clip: rect(0, 0, 0, 0);
  522. position: absolute
  523. }
  524. [tabindex],
  525. a,
  526. area,
  527. button,
  528. input,
  529. label,
  530. select,
  531. summary,
  532. textarea {
  533. -ms-touch-action: manipulation
  534. }
  535. .tree {
  536. --tree-spacing: 1.5rem;
  537. --radius: 10px;
  538. }
  539. .tree a {
  540. border-bottom: 1px solid transparent;
  541. border-color: var(--secondary);
  542. color: var(--color);
  543. text-decoration: none;
  544. transition: all 0.2s ease;
  545. }
  546. .tree a:hover {
  547. border-color: var(--secondary-hover);
  548. color: var(--h3-color);
  549. }
  550. .tree,
  551. .tree ul,
  552. .tree li {
  553. list-style: none;
  554. list-style-type: none;
  555. }
  556. .tree .folder li {
  557. display: block;
  558. position: relative;
  559. padding-left: calc(2 * var(--tree-spacing) - var(--radius) - 2px);
  560. }
  561. .tree ul {
  562. margin-left: calc(var(--radius) - var(--tree-spacing));
  563. padding-left: 0;
  564. }
  565. .tree summary {
  566. display: block;
  567. cursor: pointer;
  568. }
  569. .tree summary::marker,
  570. .tree summary::-webkit-details-marker {
  571. display: none;
  572. }
  573. .tree summary:focus {
  574. outline: none;
  575. }
  576. .tree summary:focus-visible {
  577. outline: 1px dotted #000;
  578. }
  579. .tree li.file::before {
  580. margin-right: 10px;
  581. vertical-align: middle;
  582. height: 20px;
  583. width: 20px;
  584. content: '';
  585. display: inline-block;
  586. background-image: var(--icon-file);
  587. background-position: top;
  588. background-size: 75% auto;
  589. }
  590. .tree li.folder>details>summary::before {
  591. z-index: 1;
  592. margin-right: 10px;
  593. vertical-align: middle;
  594. height: 20px;
  595. width: 20px;
  596. content: '';
  597. display: inline-block;
  598. background-image: var(--icon-folder);
  599. background-position: top;
  600. background-size: 75% auto;
  601. }
  602. .tree li.folder>details[open]>summary::before {
  603. background-image: var(--icon-folder-open);
  604. }
  605. </style>
  606. </head>
  607. <body>
  608. <main class="container">
  609. <h1>Sukka Ruleset Server</h1>
  610. <p>
  611. 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>
  612. </p>
  613. <p>Last Build: ${new Date().toISOString()}</p>
  614. <br>
  615. <ul class="tree">
  616. ${treeHtml(tree)}
  617. </ul>
  618. </main>
  619. </body>
  620. </html>
  621. `;
  622. }