build-public.ts 22 KB

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