{"id":13646964,"url":"https://github.com/tuna/mirror-web","last_synced_at":"2026-01-01T07:30:25.354Z","repository":{"id":12357411,"uuid":"15004696","full_name":"tuna/mirror-web","owner":"tuna","description":"Source code of the web interface of https://mirrors.tuna.tsinghua.edu.cn/ ","archived":false,"fork":false,"pushed_at":"2025-02-11T15:11:25.000Z","size":14893,"stargazers_count":786,"open_issues_count":7,"forks_count":305,"subscribers_count":43,"default_branch":"master","last_synced_at":"2025-02-11T16:25:00.014Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"HTML","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"gpl-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/tuna.png","metadata":{"files":{"readme":"README.md","changelog":"news.html","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2013-12-07T11:39:53.000Z","updated_at":"2025-02-11T15:11:31.000Z","dependencies_parsed_at":"2023-02-18T08:00:47.923Z","dependency_job_id":"62ea3d9d-e8ad-43dd-8fb2-81997e4dfea1","html_url":"https://github.com/tuna/mirror-web","commit_stats":null,"previous_names":[],"tags_count":3,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tuna%2Fmirror-web","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tuna%2Fmirror-web/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tuna%2Fmirror-web/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tuna%2Fmirror-web/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/tuna","download_url":"https://codeload.github.com/tuna/mirror-web/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":239727054,"owners_count":19687098,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-08-02T01:03:16.911Z","updated_at":"2026-01-01T07:30:20.001Z","avatar_url":"https://github.com/tuna.png","language":"HTML","funding_links":[],"categories":["JavaScript","HTML","CSS (5)"],"sub_categories":[],"readme":"# TUNA 镜像站主页\n\n注意：如果使用本项目搭建开源镜像站，**必须**：\n\n* 移除所有与清华大学和 TUNA 相关的内容，包括且不限于站名、logo 和各种文档中出现的所有相关文本和图形；\n* 在网站首页恰当标注项目来源（`tuna/mirror-web`）；\n* 遵循 GPLv2 协议开放修改后的源代码；\n\n## 配置修改\n\n除具体页面内容外，可修改的配置还包括：\n\n* `_config.yml`：Jekyll 配置文件，包括站点名称、描述、链接等；请不要轻易改动构建配置。\n* `_data/options.yml`：Jekyll 数据文件，主要包括各个镜像的简要描述和部分特殊镜像的配置。请仿照已有的配置进行修改。\n* `geninfo/genisolist.ini`：生成直接下载链接的配置文件。具体内容修改请提交到 [mirrorz-org/genisolist](https://github.com/mirrorz-org/genisolist)。\n\n## 编译方式\n\n本站使用 Jekyll 编写，并使用了 Vue、TypeScript、Vite 等前端框架开发。\n\n由于本站部分文档使用 submodule 方式嵌入仓库，clone 后构建前请运行 `git submodule update --init`。\n\n### 本地开发\n\n为正常运行，一些动态数据文件需要从镜像站下载：\n\n```bash\nwget https://mirrors.tuna.tsinghua.edu.cn/static/tunasync.json -O static/tunasync.json\nmkdir -p static/status\nwget https://mirrors.tuna.tsinghua.edu.cn/static/status/isoinfo.json -O static/status/isoinfo.json\n```\n\n编译前，先安装 Ruby (\u003e= 3.0) 和 Node.js (\u003e= 18)，然后执行：\n\n```bash\nbundle install --deployment\nnpm install\nbundle exec jekyll build # 编译到 `_site/` 目录，或者\nbundle exec jekyll serve --livereload # 实时预览\n```\n\n在编译时可选的环境变量：\n\n* `JEKYLL_ENV=production`：编译生产版本（启用代码压缩），可能需要较长时间。\n* `VISUALIZER=true`：生成 Rollup 编译体积分析文件到 `_stats.html`。\n\n### Docker 部署\n\n仓库中的 `Dockerfile.build` 也可用于编译，推荐在生产环境部署时使用。\n\n可用以下命令构建（如依赖无变化，镜像无需重复构建）：\n\n```bash\ndocker build -t tunathu/mirror-web -f Dockerfile.build .\ndocker pull tunathu/mirror-web # 或者直接拉取\n```\n\n构建时，仅需将本地目录挂载到容器中：\n\n```bash\ndocker run --rm -v /path/to/mirror-web:/data tunathu/mirror-web\n```\n\n即可在 `/path/to/mirror-web/_site` 中得到编译结果。\n\n### 编译流程\n\n本项目使用 Jekyll 作为唯一入口完成全部的构建流程。其具体流程是：\n\n1. Jekyll 读取 `_config.yml` 和全部需要渲染的页面，并读取 `_data` 中的数据文件；\n2. Jekyll 调用 vite 的 Jekyll 插件，将所有的前端代码编译到 `_site/assets` 目录：\n  1. 插件将需要传递给 vite 的数据编码为 JSON，并写入临时文件；\n  2. 插件执行 vite 命令，根据 `_vite.config.mjs` 中的配置编译前端代码；\n     1. `_vite.config.mjs` 读取临时文件，向 vite 流程中注册虚拟导入文件；\n     2. vite 中注册的 `vite-plugin-ruby` 插件导入其配置文件；\n     3. vite 加载 `_src/entrypoints` 中的代码，并生成依赖树；\n     4. vite 中注册的 `vite-plugin-legacy` 插件增加一份输出版本，并增加 legacy 标志；\n     5. vite 完成各代码的编译：\n        - 对于 Vue 组件，调用 Vue 的 SFC 编译器完成编译；\n          - 对于其中模板（`\u003ctemplate\u003e`）使用 Liquid 语法的组件，调用 Liquid 编译器完成编译；\n        - 对于 TypeScript 文件，调用 TypeScript 编译器完成编译；\n     6. vite 完成代码各输出版本的后处理：\n        - 对于 legacy 标志的输出版本，`vite-plugin-legacy` 使用 babel 转译，并记录所需的 polyfill；\n        - 对于正常的输出版本，正常编译；\n     7. vite 产生编译结果：\n        1. `vite-plugin-legacy` 新建一个 vite 流水线，并将所需的 polyfill 作为入口，并将编译结果插入到 legacy 版本的输出中；\n        2. 对上述 `vite-plugin-legacy` 产生的 polyfill 代码，再次使用 babel 转译；\n        3. 新建一个 vite 流水线，并将 `_src/entrypoints-njs` 中的代码作为入口，编译结果插入到正常版本的输出中；\n           - 其中，使用 babel 转译生成的 njs 代码，确保其可以在 NGINX 的 njs 模块中运行；\n        4. `vite-plugin-ruby` 对所有输出的文件，生成一个 manifest 文件，用于 Jekyll 插件读取；\n     8. vite 输出编译结果到 `.jekyll-cache/vite-dist` 下；\n  3. 插件将 vite 的输出文件注册到 Jekyll 的静态文件列表中；\n  4. 插件读入 vite 产生的 manifest 文件，备用；\n3. Jekyll 完成所有的页面渲染：\n   - 对于静态文件，直接拷贝到 `_site` 目录；\n   - 对于需要渲染的 html 文件，使用 Liquid 渲染引擎渲染；\n     - 其中，需要调用 Jekyll 的 vite 插件注册的 Liquid 指令，生成前端代码的引用，后者根据已经加载的 manifest 文件，生成正确的引用指令。\n\n### `fancy-index` 部署\n\n本项目使用 NGINX 的 `fancy-index` 模块美化镜像站的文件列表展示。具体配置方法如下：\n\n1. 确保 nginx 安装了 `ngx_http_fancyindex_module` 和 `ngx_http_js_module`，并确保后者的版本不低于 0.7.9；\n2. 在 `nginx.conf` 对应的 `server` 配置块中添加如下配置：\n\n   ```nginx\n   js_path /path/to/build_output/static/njs;\n\n   # 以下设定不能修改，以便与 mirror-web 的前端代码配合\n   fancyindex_time_format \"%d %b %Y %H:%M:%S +0000\";\n   fancyindex_show_path on;\n   fancyindex_header /fancy-index/before;\n   fancyindex_footer /fancy-index/after;\n\n   # 以下设定为推荐设置，fancyindex 的其它设定亦可按需修改\n   fancyindex_exact_size off;\n   fancyindex_name_length 256;\n\n   location /fancy-index {\n     internal;\n     root /path/to/build_output;\n     subrequest_output_buffer_size 100k;\n     js_import fancyIndexRender from fancy_index.njs;\n\n     location = /fancy-index/before {\n       js_content fancyIndexRender.fancyIndexBeforeRender;\n     }\n     location = /fancy-index/after {\n       js_content fancyIndexRender.fancyIndexAfterRender;\n     }\n   }\n   ```\n\n3. 然后在需要开启目录浏览的 `location` 配置块中添加：\n\n   ```nginx\n   fancyindex on;\n   ```\n\n### `genisolist` 部署\n\n本项目使用 [`mirrorz-org/genisolist`](https://github.com/mirrorz-org/genisolist) 生成供前端渲染的 JSON 文件，请查看该项目的文档进行部署和修改。\n\n如果增加了新的配置，不要忘记在 `geninfo/genisolist.ini` 中增加新的 `!include` 指令。\n\n## 贡献文档\n\n目前文档分为两部分维护，一部分是通用文档（`help/_posts/mirrorz-help-ng-transpiled` 目录），从 [mirrorz-org/mirrorz-docs](https://github.com/mirrorz-org/mirrorz-docs) 生成，在 TUNA 本地化维护在 [tuna/mirrorz-help-ng](https://github.com/tuna/mirrorz-help-ng) ，最终以 submodule 方式引入本仓库。如果您的改动是镜像站通用的，可以向前者贡献内容；如果是 TUNA 特有的，可以向后者 PR 。\n\n另一部分维护在本仓库内（`help/_posts/` 目录），需要向本仓库进行 PR 。`mirror-web` 会逐渐迁移到使用通用文档。\n\n### 基本步骤\n\n1. Fork 本项目并 clone\n2. 创建分支 `git checkout -b foo-doc`\n3. 在 `help/_post` 中建立文档文件，文件名格式为 `年-月-日-名称.md`\n4. 用 Markdown 语法编写文档\n5. 提交并推送代码\n6. 发送 Pull Request\n\n### 写作规范\n\n1. 对于相对不知名的镜像项目，首先用一两句话介绍该项目\n2. 写明使用方法, 使用 Github Flavored Markdown 格式\n3. 中英文字符间应留一个空格\n\n### 特殊用法\n\n#### 表单选择\n\n该功能实现在 mirrorz-org/mirrorz-help 中，需要让相应文档迁移到使用通用文档以该功能。\n\n即将推出（TODO）：快速配置、拷贝命令、线路选择……\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftuna%2Fmirror-web","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ftuna%2Fmirror-web","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftuna%2Fmirror-web/lists"}