build-public.ts 22 KB

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