build-public.ts 21 KB

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