├── .dockerignore ├── .github ├── dependabot.yml └── workflows │ ├── cd.yml │ └── ci.yml ├── .gitignore ├── .vscode └── launch.json ├── AUTO_REDIRECT_API.md ├── Cargo.lock ├── Cargo.toml ├── Dockerfile ├── LICENSE ├── README.md ├── cfworkers └── ghwsee-indexable-redirect │ ├── .cargo-ok │ ├── .github │ └── workflows │ │ └── ci.yml │ ├── .gitignore │ ├── .prettierrc │ ├── .vscode │ ├── launch.json │ └── settings.json │ ├── LICENSE_APACHE │ ├── LICENSE_MIT │ ├── README.md │ ├── handler.ts │ ├── index.ts │ ├── jest.config.ts │ ├── package-lock.json │ ├── package.json │ ├── src │ ├── handler.ts │ └── index.ts │ ├── test │ └── handler.test.ts │ ├── tsconfig.json │ ├── webpack.config.js │ └── wrangler.toml ├── fly.toml ├── src ├── decommission.rs ├── gh_extensions.rs ├── main.rs ├── retrieval.rs └── scraper.rs ├── templates ├── callToAction.svg ├── favicon.ico ├── front_page.html ├── mirror.html ├── robots.txt ├── robots_ip.txt └── social.png └── test-data ├── _Sidebar.md ├── _Sidebar_pure.md ├── update-wiki-index.sh ├── wiki-homeless-index.html └── wiki-index.html /.dockerignore: -------------------------------------------------------------------------------- 1 | target/ 2 | Dockerfile 3 | fly.toml 4 | .github/ 5 | -------------------------------------------------------------------------------- /.github/dependabot.yml: -------------------------------------------------------------------------------- 1 | version: 2 2 | updates: 3 | 4 | # Maintain dependencies for GitHub Actions 5 | - package-ecosystem: "github-actions" 6 | directory: "/" 7 | schedule: 8 | interval: "daily" 9 | 10 | # Maintain dependencies for Rust Cargo 11 | - package-ecosystem: "cargo" 12 | directory: "/" 13 | schedule: 14 | interval: "daily" 15 | allow: 16 | # Allow both direct and indirect updates for all packages 17 | - dependency-type: "all" 18 | groups: 19 | patch-dependencies: 20 | update-types: 21 | - "patch" 22 | 23 | # Maintain dependencies for Docker 24 | - package-ecosystem: "docker" 25 | directory: "/" 26 | schedule: 27 | interval: "daily" 28 | allow: 29 | # Allow both direct and indirect updates for all packages 30 | - dependency-type: "all" 31 | -------------------------------------------------------------------------------- /.github/workflows/cd.yml: -------------------------------------------------------------------------------- 1 | on: 2 | # Trigger the workflow on push 3 | # but only for the main branch 4 | push: 5 | branches: 6 | - master 7 | 8 | name: Continuous Deployment 9 | 10 | concurrency: 11 | group: "${{ github.ref }}-cd" 12 | cancel-in-progress: true 13 | 14 | jobs: 15 | check-env: 16 | runs-on: ubuntu-latest 17 | outputs: 18 | fly-api-token: ${{ steps.fly-api-token.outputs.defined }} 19 | steps: 20 | - id: fly-api-token 21 | env: 22 | FLY_API_TOKEN: ${{ secrets.FLY_API_TOKEN }} 23 | if: "${{ env.FLY_API_TOKEN != '' }}" 24 | run: echo "defined=true" >> $GITHUB_OUTPUT 25 | 26 | deploy: 27 | needs: [check-env] 28 | if: needs.check-env.outputs.fly-api-token == 'true' 29 | name: Deploy 30 | runs-on: ubuntu-latest 31 | steps: 32 | - uses: actions/checkout@v4 33 | - uses: docker/setup-buildx-action@v3 34 | - uses: docker/build-push-action@v6 35 | with: 36 | context: . 37 | cache-from: type=gha,scope=cached-stage 38 | cache-to: type=gha,scope=cached-stage,mode=max 39 | load: true 40 | tags: app:latest 41 | - uses: superfly/flyctl-actions@1.5 42 | env: 43 | FLY_API_TOKEN: ${{ secrets.FLY_API_TOKEN }} 44 | with: 45 | args: "deploy --local-only -i app:latest" 46 | - name: Cloudflare Cache Purge Action 47 | uses: NathanVaughn/actions-cloudflare-purge@v3.0.0 48 | if: success() 49 | with: 50 | cf_zone: ${{ secrets.CLOUDFLARE_ZONE }} 51 | cf_auth: ${{ secrets.CLOUDFLARE_AUTH_KEY }} 52 | -------------------------------------------------------------------------------- /.github/workflows/ci.yml: -------------------------------------------------------------------------------- 1 | on: [push, pull_request] 2 | 3 | name: Continuous Integration 4 | 5 | concurrency: 6 | group: "${{ github.ref }}-ci" 7 | cancel-in-progress: true 8 | 9 | jobs: 10 | check: 11 | name: Check 12 | runs-on: ubuntu-latest 13 | steps: 14 | - uses: actions/checkout@v4 15 | - uses: actions-rs/toolchain@v1 16 | with: 17 | profile: minimal 18 | toolchain: stable 19 | override: true 20 | - uses: Swatinem/rust-cache@v2 21 | - uses: actions-rs/cargo@v1 22 | with: 23 | command: check 24 | 25 | test: 26 | name: Test Suite 27 | runs-on: ubuntu-latest 28 | steps: 29 | - uses: actions/checkout@v4 30 | - uses: actions-rs/toolchain@v1 31 | with: 32 | profile: minimal 33 | toolchain: stable 34 | override: true 35 | - uses: Swatinem/rust-cache@v2 36 | - uses: actions-rs/cargo@v1 37 | with: 38 | command: test 39 | 40 | fmt: 41 | name: Rustfmt 42 | runs-on: ubuntu-latest 43 | steps: 44 | - uses: actions/checkout@v4 45 | - uses: actions-rs/toolchain@v1 46 | with: 47 | profile: minimal 48 | toolchain: stable 49 | override: true 50 | - run: rustup component add rustfmt 51 | - uses: Swatinem/rust-cache@v2 52 | - uses: actions-rs/cargo@v1 53 | with: 54 | command: fmt 55 | args: --all -- --check 56 | 57 | clippy: 58 | name: Clippy 59 | runs-on: ubuntu-latest 60 | steps: 61 | - uses: actions/checkout@v4 62 | - uses: actions-rs/toolchain@v1 63 | with: 64 | profile: minimal 65 | toolchain: stable 66 | override: true 67 | - run: rustup component add clippy 68 | - uses: Swatinem/rust-cache@v2 69 | - uses: actions-rs/cargo@v1 70 | with: 71 | command: clippy 72 | args: -- -D warnings 73 | 74 | docker: 75 | name: Docker Build 76 | runs-on: ubuntu-latest 77 | steps: 78 | - uses: actions/checkout@v4 79 | - name: Set up Docker Buildx 80 | uses: docker/setup-buildx-action@v3 81 | - name: Build and push 82 | uses: docker/build-push-action@v6 83 | with: 84 | context: . 85 | cache-from: type=gha,scope=cached-stage 86 | cache-to: type=gha,scope=cached-stage,mode=max 87 | load: true 88 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | /target 2 | -------------------------------------------------------------------------------- /.vscode/launch.json: -------------------------------------------------------------------------------- 1 | { 2 | // Use IntelliSense to learn about possible attributes. 3 | // Hover to view descriptions of existing attributes. 4 | // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387 5 | "version": "0.2.0", 6 | "configurations": [ 7 | { 8 | "type": "lldb", 9 | "request": "launch", 10 | "name": "Debug executable 'github-wiki-see'", 11 | "cargo": { 12 | "args": [ 13 | "build", 14 | "--bin=github-wiki-see", 15 | "--package=github-wiki-see" 16 | ], 17 | "filter": { 18 | "name": "github-wiki-see", 19 | "kind": "bin" 20 | } 21 | }, 22 | "args": [], 23 | "cwd": "${workspaceFolder}" 24 | }, 25 | { 26 | "type": "lldb", 27 | "request": "launch", 28 | "name": "Debug unit tests in executable 'github-wiki-see'", 29 | "cargo": { 30 | "args": [ 31 | "test", 32 | "--no-run", 33 | "--bin=github-wiki-see", 34 | "--package=github-wiki-see" 35 | ], 36 | "filter": { 37 | "name": "github-wiki-see", 38 | "kind": "bin" 39 | } 40 | }, 41 | "args": [], 42 | "cwd": "${workspaceFolder}" 43 | } 44 | ] 45 | } -------------------------------------------------------------------------------- /AUTO_REDIRECT_API.md: -------------------------------------------------------------------------------- 1 | # Auto Redirect API 2 | 3 | This is the Javascript/CSS/HTML API to use to automatically redirect when one land on GHWSEE that scripters, extension authors, and power users may want to use. 4 | 5 | Run this on the domain https://github-wiki-see.page and it will automatically redirect to GitHub.com's wiki page when landing from a search page onto an indexable GHWSEE page and won't fire on other pages such as the front page. 6 | 7 | ```javascript 8 | if (document.getElementById('header_button')) 9 | window.location.replace(document.querySelector(".visit_url_original").href); 10 | ``` 11 | 12 | This API will be maintained as the mirror page changes or gets updated. The ID names and class names used in the example above will stay this and will not change for the foreseeable future. 13 | 14 | ## Examples 15 | 16 | Here are some examples of this "API" in use. 17 | 18 | Please contribute if you have other examples of using this API with other setups and ecosystems. 19 | 20 | ### Page Extender.app 21 | 22 | https://github.com/fphilipe/PageExtender.app 23 | 24 | PageExtender is a Safari Extension that injects CSS and JS files into websites, allowing you to customize your favorite websites to your needs. 25 | 26 | Create a file: `github-wiki-see.page.js` 27 | 28 | The file is named so that it only runs on the domain `github-wiki-see.page` and not on any other domain. 29 | 30 | Contents: Use the example Javascript at the top of this document. 31 | 32 | See [@gingerbeardman](https://github.com/gingerbeardman)'s post for the original post but note it uses an older version of the example Javascript which may have back button issues: 33 | 34 | https://github.com/nelsonjchen/github-wiki-see-rs/issues/136#issuecomment-1040821971 35 | 36 | ### Userscript 37 | ```javascript 38 | // ==UserScript== 39 | // @name github-wiki-see-redirect 40 | // @namespace nelsonjchen.github-wiki-see-redirect 41 | // @version 0.2 42 | // @description 43 | // @author nelsonjchen, firepup650 44 | // @match https://github-wiki-see.page/* 45 | // @icon https://www.google.com/s2/favicons?sz=64&domain=github.com 46 | // @grant none 47 | // ==/UserScript== 48 | (function() { 49 | 'use strict'; 50 | if (document.getElementById('header_button')) { 51 | window.location.replace(document.querySelector(".visit_url_original").href); 52 | } 53 | })(); 54 | ``` 55 | -------------------------------------------------------------------------------- /Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "github-wiki-see" 3 | version = "0.2.1" 4 | authors = ["Nelson Chen "] 5 | edition = "2021" 6 | 7 | # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html 8 | 9 | [dependencies] 10 | nipper = "0.1.9" 11 | rocket = "0.5.1" 12 | askama = { version = "0.12.1", features = ["with-rocket", "mime", "mime_guess"] } 13 | askama_rocket = "0.12.0" 14 | reqwest = { version = "0.12", features = ["deflate", "brotli", "gzip"] } 15 | tokio = { version = "1", features = ["full"] } 16 | comrak = "0.28" 17 | regex = "1" 18 | lazy_static = "1.4.0" 19 | percent-encoding = "2.3.1" 20 | scraper = "0.18.1" 21 | quick-xml = "0.31.0" 22 | phf = { version = "0.11", features = ["macros"] } 23 | futures = "0.3.30" 24 | more-asserts = "0.3.1" 25 | git-version = "0.3.9" 26 | 27 | [features] 28 | -------------------------------------------------------------------------------- /Dockerfile: -------------------------------------------------------------------------------- 1 | FROM rust:1.87.0 AS chef 2 | # We only pay the installation cost once, 3 | # it will be cached from the second build onwards 4 | RUN cargo install cargo-chef 5 | WORKDIR app 6 | 7 | FROM chef AS planner 8 | COPY . . 9 | RUN cargo chef prepare --recipe-path recipe.json 10 | 11 | FROM chef AS builder 12 | COPY --from=planner /app/recipe.json recipe.json 13 | # Build dependencies - this is the caching Docker layer! 14 | RUN cargo chef cook --release --recipe-path recipe.json 15 | # Build application 16 | COPY . . 17 | RUN cargo build --release --bin github-wiki-see 18 | 19 | # We do not need the Rust toolchain to run the binary! 20 | FROM gcr.io/distroless/cc-debian12 AS runtime 21 | WORKDIR /app 22 | COPY --from=builder /app/target/release/github-wiki-see /usr/local/bin/github-wiki-see 23 | 24 | ENV ROCKET_ADDRESS=0.0.0.0 25 | 26 | CMD ["/usr/local/bin/github-wiki-see"] 27 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) github-wiki-see-rs contributors 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # GitHub Wiki SEE 2 | 3 | ![GitHub](https://img.shields.io/github/license/nelsonjchen/github-wiki-see-rs) ![GitHub](https://img.shields.io/github/stars/nelsonjchen/github-wiki-see-rs) 4 | 5 | _As seen at https://github-wiki-see.page by search engines and archivers!_ 6 | 7 | GitHub Wiki Search Engine Enablement is a service to allow GitHub Wikis to be indexed by search engines. 8 | 9 | This is a terribly and hastily built service. However, it is usable and MVP! 10 | 11 | This was made in response to https://github.com/github/feedback/discussions/4992, an issue that has been present for 10+ years. 12 | 13 | ## Design 14 | 15 | This is designed as a Rust web proxy application. It is not very Rusty and has lots of hackiness. Cleanup, major overhauls, and straightening are much appreciated! 16 | 17 | It is designed to run as a simple Docker application on a service such as [fly.io][flyio] and/or [Google Cloud Run][gcr]. Uptime and latency are important so that the service appears on search engines and gets a high ranking. 18 | 19 | 301/302/307/308s are intentionally **not** used as to not give search engines the impression that the page is a redirect and to 20 | ignore the content. 21 | Humans should see the "content" as a redirect; the robots should not. 22 | 23 | All links rendered in the tool going outside of GitHub are tagged with `rel="nofollow ugc"` to prevent ranking 24 | manipulation which is probably one the reason wiki content was excluded from indexing. 25 | 26 | A Cloudflare Worker is placed in front to additionally protect against the service accidentally mirroring indexable content 27 | on GitHub. The worker also enriches a "last modified" header date on the proxied content if possible from the original content if the original content isn't indexable to better hint to search engines the freshness of content and better utilize their crawler budget. 28 | 29 | ## Decommissioning 30 | 31 | Please see: 32 | 33 | https://github-wiki-see.page/#decommissioning 34 | 35 | But basically if GitHub lets it be indexed, this service will 308 redirect it. 36 | 37 | [gcr]: https://cloud.google.com/run 38 | [flyio]: https://fly.io 39 | -------------------------------------------------------------------------------- /cfworkers/ghwsee-indexable-redirect/.cargo-ok: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nelsonjchen/github-wiki-see-rs/d2c22b12b5865e67c7c5feef5da0fac9a316a614/cfworkers/ghwsee-indexable-redirect/.cargo-ok -------------------------------------------------------------------------------- /cfworkers/ghwsee-indexable-redirect/.github/workflows/ci.yml: -------------------------------------------------------------------------------- 1 | # This workflow will do a clean installation of node dependencies, cache/restore them, build the source code and run tests across different versions of node 2 | # For more information see: https://help.github.com/actions/language-and-framework-guides/using-nodejs-with-github-actions 3 | 4 | name: CI 5 | 6 | on: 7 | pull_request: 8 | paths-ignore: 9 | - '**.md' 10 | push: 11 | paths-ignore: 12 | - '**.md' 13 | 14 | jobs: 15 | build: 16 | runs-on: ubuntu-latest 17 | 18 | strategy: 19 | matrix: 20 | node-version: [16.x] 21 | # See supported Node.js release schedule at https://nodejs.org/en/about/releases/ 22 | 23 | steps: 24 | - uses: actions/checkout@v2 25 | - name: Use Node.js ${{ matrix.node-version }} 26 | uses: actions/setup-node@v2 27 | with: 28 | node-version: ${{ matrix.node-version }} 29 | cache: 'npm' 30 | - run: npm install 31 | - run: npm run build 32 | - run: npm test 33 | -------------------------------------------------------------------------------- /cfworkers/ghwsee-indexable-redirect/.gitignore: -------------------------------------------------------------------------------- 1 | dist 2 | node_modules 3 | transpiled 4 | /.idea/ 5 | -------------------------------------------------------------------------------- /cfworkers/ghwsee-indexable-redirect/.prettierrc: -------------------------------------------------------------------------------- 1 | { 2 | "singleQuote": true, 3 | "semi": false, 4 | "trailingComma": "all", 5 | "tabWidth": 2, 6 | "printWidth": 80 7 | } 8 | -------------------------------------------------------------------------------- /cfworkers/ghwsee-indexable-redirect/.vscode/launch.json: -------------------------------------------------------------------------------- 1 | { 2 | "configurations": [ 3 | { 4 | "type": "node", 5 | "name": "vscode-jest-tests", 6 | "request": "launch", 7 | "console": "integratedTerminal", 8 | "internalConsoleOptions": "neverOpen", 9 | "disableOptimisticBPs": true, 10 | "cwd": "${workspaceFolder}", 11 | "runtimeExecutable": "npm", 12 | "args": [ 13 | "run", 14 | "test", 15 | "--", 16 | "--runInBand", 17 | "--watchAll=false" 18 | ] 19 | } 20 | ] 21 | } -------------------------------------------------------------------------------- /cfworkers/ghwsee-indexable-redirect/.vscode/settings.json: -------------------------------------------------------------------------------- 1 | { 2 | "jest.jestCommandLine": "npm run test --" 3 | } 4 | -------------------------------------------------------------------------------- /cfworkers/ghwsee-indexable-redirect/LICENSE_APACHE: -------------------------------------------------------------------------------- 1 | Apache License 2 | Version 2.0, January 2004 3 | http://www.apache.org/licenses/ 4 | 5 | TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION 6 | 7 | 1. Definitions. 8 | 9 | "License" shall mean the terms and conditions for use, reproduction, 10 | and distribution as defined by Sections 1 through 9 of this document. 11 | 12 | "Licensor" shall mean the copyright owner or entity authorized by 13 | the copyright owner that is granting the License. 14 | 15 | "Legal Entity" shall mean the union of the acting entity and all 16 | other entities that control, are controlled by, or are under common 17 | control with that entity. For the purposes of this definition, 18 | "control" means (i) the power, direct or indirect, to cause the 19 | direction or management of such entity, whether by contract or 20 | otherwise, or (ii) ownership of fifty percent (50%) or more of the 21 | outstanding shares, or (iii) beneficial ownership of such entity. 22 | 23 | "You" (or "Your") shall mean an individual or Legal Entity 24 | exercising permissions granted by this License. 25 | 26 | "Source" form shall mean the preferred form for making modifications, 27 | including but not limited to software source code, documentation 28 | source, and configuration files. 29 | 30 | "Object" form shall mean any form resulting from mechanical 31 | transformation or translation of a Source form, including but 32 | not limited to compiled object code, generated documentation, 33 | and conversions to other media types. 34 | 35 | "Work" shall mean the work of authorship, whether in Source or 36 | Object form, made available under the License, as indicated by a 37 | copyright notice that is included in or attached to the work 38 | (an example is provided in the Appendix below). 39 | 40 | "Derivative Works" shall mean any work, whether in Source or Object 41 | form, that is based on (or derived from) the Work and for which the 42 | editorial revisions, annotations, elaborations, or other modifications 43 | represent, as a whole, an original work of authorship. For the purposes 44 | of this License, Derivative Works shall not include works that remain 45 | separable from, or merely link (or bind by name) to the interfaces of, 46 | the Work and Derivative Works thereof. 47 | 48 | "Contribution" shall mean any work of authorship, including 49 | the original version of the Work and any modifications or additions 50 | to that Work or Derivative Works thereof, that is intentionally 51 | submitted to Licensor for inclusion in the Work by the copyright owner 52 | or by an individual or Legal Entity authorized to submit on behalf of 53 | the copyright owner. For the purposes of this definition, "submitted" 54 | means any form of electronic, verbal, or written communication sent 55 | to the Licensor or its representatives, including but not limited to 56 | communication on electronic mailing lists, source code control systems, 57 | and issue tracking systems that are managed by, or on behalf of, the 58 | Licensor for the purpose of discussing and improving the Work, but 59 | excluding communication that is conspicuously marked or otherwise 60 | designated in writing by the copyright owner as "Not a Contribution." 61 | 62 | "Contributor" shall mean Licensor and any individual or Legal Entity 63 | on behalf of whom a Contribution has been received by Licensor and 64 | subsequently incorporated within the Work. 65 | 66 | 2. Grant of Copyright License. Subject to the terms and conditions of 67 | this License, each Contributor hereby grants to You a perpetual, 68 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 69 | copyright license to reproduce, prepare Derivative Works of, 70 | publicly display, publicly perform, sublicense, and distribute the 71 | Work and such Derivative Works in Source or Object form. 72 | 73 | 3. Grant of Patent License. Subject to the terms and conditions of 74 | this License, each Contributor hereby grants to You a perpetual, 75 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 76 | (except as stated in this section) patent license to make, have made, 77 | use, offer to sell, sell, import, and otherwise transfer the Work, 78 | where such license applies only to those patent claims licensable 79 | by such Contributor that are necessarily infringed by their 80 | Contribution(s) alone or by combination of their Contribution(s) 81 | with the Work to which such Contribution(s) was submitted. If You 82 | institute patent litigation against any entity (including a 83 | cross-claim or counterclaim in a lawsuit) alleging that the Work 84 | or a Contribution incorporated within the Work constitutes direct 85 | or contributory patent infringement, then any patent licenses 86 | granted to You under this License for that Work shall terminate 87 | as of the date such litigation is filed. 88 | 89 | 4. Redistribution. You may reproduce and distribute copies of the 90 | Work or Derivative Works thereof in any medium, with or without 91 | modifications, and in Source or Object form, provided that You 92 | meet the following conditions: 93 | 94 | (a) You must give any other recipients of the Work or 95 | Derivative Works a copy of this License; and 96 | 97 | (b) You must cause any modified files to carry prominent notices 98 | stating that You changed the files; and 99 | 100 | (c) You must retain, in the Source form of any Derivative Works 101 | that You distribute, all copyright, patent, trademark, and 102 | attribution notices from the Source form of the Work, 103 | excluding those notices that do not pertain to any part of 104 | the Derivative Works; and 105 | 106 | (d) If the Work includes a "NOTICE" text file as part of its 107 | distribution, then any Derivative Works that You distribute must 108 | include a readable copy of the attribution notices contained 109 | within such NOTICE file, excluding those notices that do not 110 | pertain to any part of the Derivative Works, in at least one 111 | of the following places: within a NOTICE text file distributed 112 | as part of the Derivative Works; within the Source form or 113 | documentation, if provided along with the Derivative Works; or, 114 | within a display generated by the Derivative Works, if and 115 | wherever such third-party notices normally appear. The contents 116 | of the NOTICE file are for informational purposes only and 117 | do not modify the License. You may add Your own attribution 118 | notices within Derivative Works that You distribute, alongside 119 | or as an addendum to the NOTICE text from the Work, provided 120 | that such additional attribution notices cannot be construed 121 | as modifying the License. 122 | 123 | You may add Your own copyright statement to Your modifications and 124 | may provide additional or different license terms and conditions 125 | for use, reproduction, or distribution of Your modifications, or 126 | for any such Derivative Works as a whole, provided Your use, 127 | reproduction, and distribution of the Work otherwise complies with 128 | the conditions stated in this License. 129 | 130 | 5. Submission of Contributions. Unless You explicitly state otherwise, 131 | any Contribution intentionally submitted for inclusion in the Work 132 | by You to the Licensor shall be under the terms and conditions of 133 | this License, without any additional terms or conditions. 134 | Notwithstanding the above, nothing herein shall supersede or modify 135 | the terms of any separate license agreement you may have executed 136 | with Licensor regarding such Contributions. 137 | 138 | 6. Trademarks. This License does not grant permission to use the trade 139 | names, trademarks, service marks, or product names of the Licensor, 140 | except as required for reasonable and customary use in describing the 141 | origin of the Work and reproducing the content of the NOTICE file. 142 | 143 | 7. Disclaimer of Warranty. Unless required by applicable law or 144 | agreed to in writing, Licensor provides the Work (and each 145 | Contributor provides its Contributions) on an "AS IS" BASIS, 146 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 147 | implied, including, without limitation, any warranties or conditions 148 | of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A 149 | PARTICULAR PURPOSE. You are solely responsible for determining the 150 | appropriateness of using or redistributing the Work and assume any 151 | risks associated with Your exercise of permissions under this License. 152 | 153 | 8. Limitation of Liability. In no event and under no legal theory, 154 | whether in tort (including negligence), contract, or otherwise, 155 | unless required by applicable law (such as deliberate and grossly 156 | negligent acts) or agreed to in writing, shall any Contributor be 157 | liable to You for damages, including any direct, indirect, special, 158 | incidental, or consequential damages of any character arising as a 159 | result of this License or out of the use or inability to use the 160 | Work (including but not limited to damages for loss of goodwill, 161 | work stoppage, computer failure or malfunction, or any and all 162 | other commercial damages or losses), even if such Contributor 163 | has been advised of the possibility of such damages. 164 | 165 | 9. Accepting Warranty or Additional Liability. While redistributing 166 | the Work or Derivative Works thereof, You may choose to offer, 167 | and charge a fee for, acceptance of support, warranty, indemnity, 168 | or other liability obligations and/or rights consistent with this 169 | License. However, in accepting such obligations, You may act only 170 | on Your own behalf and on Your sole responsibility, not on behalf 171 | of any other Contributor, and only if You agree to indemnify, 172 | defend, and hold each Contributor harmless for any liability 173 | incurred by, or claims asserted against, such Contributor by reason 174 | of your accepting any such warranty or additional liability. 175 | 176 | END OF TERMS AND CONDITIONS 177 | -------------------------------------------------------------------------------- /cfworkers/ghwsee-indexable-redirect/LICENSE_MIT: -------------------------------------------------------------------------------- 1 | Copyright (c) 2020 Cloudflare, Inc. 2 | 3 | Permission is hereby granted, free of charge, to any 4 | person obtaining a copy of this software and associated 5 | documentation files (the "Software"), to deal in the 6 | Software without restriction, including without 7 | limitation the rights to use, copy, modify, merge, 8 | publish, distribute, sublicense, and/or sell copies of 9 | the Software, and to permit persons to whom the Software 10 | is furnished to do so, subject to the following 11 | conditions: 12 | 13 | The above copyright notice and this permission notice 14 | shall be included in all copies or substantial portions 15 | of the Software. 16 | 17 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF 18 | ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED 19 | TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A 20 | PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT 21 | SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY 22 | CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION 23 | OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR 24 | IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 25 | DEALINGS IN THE SOFTWARE. -------------------------------------------------------------------------------- /cfworkers/ghwsee-indexable-redirect/README.md: -------------------------------------------------------------------------------- 1 | # GHWSEE Indexable Redirect 2 | 3 | If the GitHub page this is proxy off of is indexable, redirect immediately. 4 | 5 | -------------------------------------------------------------------------------- /cfworkers/ghwsee-indexable-redirect/handler.ts: -------------------------------------------------------------------------------- 1 | export async function handleRequest(request: Request): Promise { 2 | // Check if the original GitHub URL is indexable. If it is, redirect. 3 | const url = new URL(request.url) 4 | const path = url.pathname 5 | 6 | return await fetch(request) 7 | } 8 | 9 | export function indexable(url: URL): boolean { 10 | 11 | return url.hostname.endsWith('3vngqvvpoq-uc.a.run.app') 12 | } 13 | -------------------------------------------------------------------------------- /cfworkers/ghwsee-indexable-redirect/index.ts: -------------------------------------------------------------------------------- 1 | import { handleRequest } from './handler' 2 | 3 | addEventListener('fetch', (event) => { 4 | event.respondWith(handleRequest(event.request)) 5 | }) 6 | -------------------------------------------------------------------------------- /cfworkers/ghwsee-indexable-redirect/jest.config.ts: -------------------------------------------------------------------------------- 1 | import type { Config } from '@jest/types' 2 | 3 | const config: Config.InitialOptions = { 4 | testEnvironment: "miniflare", 5 | transform: { 6 | '^.+\\.(t|j)sx?$': 'ts-jest', 7 | }, 8 | testRegex: '/test/.*\\.test\\.ts$', 9 | 10 | collectCoverageFrom: ['src/**/*.{ts,js}'], 11 | verbose: true, 12 | } 13 | 14 | export default config 15 | -------------------------------------------------------------------------------- /cfworkers/ghwsee-indexable-redirect/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "worker-typescript-template", 3 | "version": "1.0.0", 4 | "description": "Cloudflare worker TypeScript template", 5 | "main": "dist/worker.js", 6 | "scripts": { 7 | "build": "webpack", 8 | "format": "prettier --write '*.{json,js}' 'src/**/*.{js,ts}' 'test/**/*.{js,ts}'", 9 | "lint": "eslint --max-warnings=0 src && prettier --check '*.{json,js}' 'src/**/*.{js,ts}' 'test/**/*.{js,ts}'", 10 | "test": "jest" 11 | }, 12 | "author": "author", 13 | "license": "MIT OR Apache-2.0", 14 | "eslintConfig": { 15 | "root": true, 16 | "extends": [ 17 | "typescript", 18 | "prettier" 19 | ] 20 | }, 21 | "devDependencies": { 22 | "@cloudflare/workers-types": "^3.0.0", 23 | "@types/jest": "^27.0.23", 24 | "@types/node": "^17.0.21", 25 | "@typescript-eslint/eslint-plugin": "^4.16.1", 26 | "@typescript-eslint/parser": "^4.16.1", 27 | "eslint": "^7.21.0", 28 | "eslint-config-prettier": "^8.1.0", 29 | "eslint-config-typescript": "^3.0.0", 30 | "jest": "^27.5.1", 31 | "jest-environment-miniflare": "^2.3.0", 32 | "prettier": "^2.3.0", 33 | "ts-jest": "^27.0.1", 34 | "ts-loader": "^9.2.2", 35 | "ts-node": "^10.6.0", 36 | "typescript": "^4.3.2", 37 | "webpack": "^5.70.0", 38 | "webpack-cli": "^4.7.0", 39 | "wrangler": "^2.0.6" 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /cfworkers/ghwsee-indexable-redirect/src/handler.ts: -------------------------------------------------------------------------------- 1 | interface OriginalInfo { 2 | indexable: boolean 3 | last_modified?: Date 4 | moved_to?: string 5 | } 6 | 7 | class ModifiedDateAppender implements HTMLRewriterElementContentHandlers { 8 | date: Date 9 | 10 | constructor(date: Date) { 11 | this.date = date 12 | } 13 | 14 | element(element: Element) { 15 | element.append(`

📅 Last Modified: ${this.date.toUTCString()}

`, { 16 | html: true, 17 | }) 18 | } 19 | } 20 | 21 | export async function handleRequest(request: Request): Promise { 22 | const githubUrl = new URL( 23 | request.url.replace('github-wiki-see.page/m', 'github.com'), 24 | ) 25 | 26 | const ghwseeResponse = fetch(request, { 27 | cf: { 28 | cacheEverything: true, 29 | cacheTtl: 7200, 30 | }, 31 | }) 32 | 33 | const pathComponents = githubUrl.pathname.split('/') 34 | 35 | // Don't redirect wiki_index path. Index that, even for indexable wikis. 36 | if (pathComponents.length > 3 && pathComponents[2] === 'wiki_index') { 37 | return await ghwseeResponse 38 | } 39 | 40 | console.log(request.headers.get('user-agent')) 41 | 42 | let lastModifiedDate: Date | undefined = undefined 43 | 44 | try { 45 | const info = await originalInfo(githubUrl) 46 | if (info.moved_to) { 47 | console.log('Repo Moved Redirect: ' + githubUrl.href) 48 | 49 | const redirectUrl = 50 | 'https://github-wiki-see.page/m' + new URL(info.moved_to).pathname 51 | 52 | return new Response('', { 53 | status: 308, 54 | headers: { 55 | location: redirectUrl, 56 | }, 57 | }) 58 | } 59 | if (info.indexable) { 60 | console.log('Indexable Redirect: ' + githubUrl.href) 61 | return new Response(null, { 62 | status: 308, 63 | statusText: 'Permanent Redirect', 64 | headers: { 65 | Location: githubUrl.toString(), 66 | }, 67 | }) 68 | } 69 | lastModifiedDate = info.last_modified 70 | } catch (e) { 71 | console.error(e) 72 | } 73 | 74 | console.log('No Redirect: ' + githubUrl.href) 75 | 76 | const response = await ghwseeResponse 77 | if (response.status === 308 && !request.url.endsWith('/wiki/Home')) { 78 | console.warn('Redirected Unindexable: ' + response.headers.get('Location')) 79 | } 80 | 81 | let maybeDatedResponse = new Response(response.body, { 82 | status: response.status, 83 | statusText: response.statusText, 84 | headers: response.headers, 85 | }) 86 | 87 | if (lastModifiedDate) { 88 | maybeDatedResponse.headers.set( 89 | 'last-modified', 90 | lastModifiedDate.toUTCString(), 91 | ) 92 | maybeDatedResponse = new HTMLRewriter() 93 | .on('#header_info', new ModifiedDateAppender(lastModifiedDate)) 94 | .transform(maybeDatedResponse) 95 | } else { 96 | // Don't claim a last modified date if it wasn't found on the original page. 97 | maybeDatedResponse.headers.delete('last-modified') 98 | } 99 | 100 | return maybeDatedResponse 101 | } 102 | 103 | export async function originalInfo(url: URL): Promise { 104 | const response = await fetch(url.toString(), { 105 | redirect: 'follow', 106 | cf: { 107 | cacheEverything: true, 108 | cacheTtl: 86400, 109 | }, 110 | }) 111 | 112 | if (response.status != 200 || response.headers.has('x-robots-tag')) { 113 | // Check if Moved Repo 114 | if (response.redirected) { 115 | // If the account and repository parts of the url are different from the original url, then it's a moved repo. 116 | const originalAccountRepo = /\.com(\/.*\/.*\/)/.exec(url.toString()) 117 | const redirectedAccountRepo = /\.com(\/.*\/.*\/)/.exec(response.url) 118 | if ( 119 | originalAccountRepo && 120 | redirectedAccountRepo && 121 | originalAccountRepo[1] !== redirectedAccountRepo[1] 122 | ) { 123 | return { 124 | indexable: false, 125 | moved_to: response.url, 126 | } 127 | } 128 | } 129 | 130 | // Scan the response body for a date of last change 131 | const body = await response.text() 132 | 133 | // { 4 | event.respondWith(handleRequest(event.request)) 5 | }) 6 | -------------------------------------------------------------------------------- /cfworkers/ghwsee-indexable-redirect/test/handler.test.ts: -------------------------------------------------------------------------------- 1 | import { handleRequest, originalInfo } from '../src/handler' 2 | 3 | describe('handle', () => { 4 | test('can determine if a URL is indexable', async () => { 5 | const url = new URL('https://github.com/PixarAnimationStudios/USD/wiki') 6 | expect((await originalInfo(url)).indexable).toBeTruthy() 7 | }) 8 | 9 | test('redirects an indexable wiki', async () => { 10 | const request_url = `https://github-wiki-see.page/m/PixarAnimationStudios/USD/wiki` 11 | console.debug(request_url) 12 | const result = await handleRequest( 13 | new Request(request_url, { method: 'GET' }), 14 | ) 15 | 16 | expect(result.status).toEqual(308) 17 | expect(result.headers.get('location')).toEqual( 18 | 'https://github.com/PixarAnimationStudios/USD/wiki', 19 | ) 20 | expect(result.headers.has('Last-Modified')).toBeFalsy() 21 | }) 22 | 23 | test('can determine if a URL is not indexable', async () => { 24 | const url = new URL('https://github.com/commaai/openpilot/wiki') 25 | expect(await (await originalInfo(url)).indexable).toBeFalsy() 26 | }) 27 | 28 | test('does not redirect an indexable wiki', async () => { 29 | const request_url = `https://github-wiki-see.page/m/commaai/openpilot/wiki` 30 | console.debug(request_url) 31 | const result = await handleRequest( 32 | new Request(request_url, { method: 'GET' }), 33 | ) 34 | 35 | expect(result.status).toEqual(200) 36 | expect(result.headers.has('Last-Modified')).toBeTruthy() 37 | }) 38 | 39 | test('does not try to redirect wiki_index on an indexable wiki', async () => { 40 | const request_url = `https://github-wiki-see.page/m/PixarAnimationStudios/USD/wiki_index` 41 | console.debug(request_url) 42 | const result = await handleRequest( 43 | new Request(request_url, { method: 'GET' }), 44 | ) 45 | 46 | expect(result.status).toEqual(200) 47 | // The index is synthesized and there is no last modified to claim. 48 | expect(result.headers.has('Last-Modified')).toBeFalsy() 49 | }) 50 | 51 | test('does not try to redirect wiki_index on an unindexable wiki', async () => { 52 | const request_url = `https://github-wiki-see.page/m/commaai/openpilot/wiki_index` 53 | console.debug(request_url) 54 | const result = await handleRequest( 55 | new Request(request_url, { method: 'GET' }), 56 | ) 57 | 58 | expect(result.status).toEqual(200) 59 | // The index is synthesized and there is no last modified to claim. 60 | expect(result.headers.has('Last-Modified')).toBeFalsy() 61 | 62 | const bodyText = await result.text() 63 | 64 | console.debug(bodyText) 65 | expect(bodyText.includes('Modified Date')).toBeFalsy() 66 | }) 67 | 68 | test('extracts a date from a non-indexable original page', async () => { 69 | const url = new URL( 70 | 'https://github.com/nelsonjchen/wiki-public-test/wiki/last-modified-test', 71 | ) 72 | const info = await originalInfo(url) 73 | expect(info.indexable).toBeFalsy() 74 | expect(info.last_modified).toBeInstanceOf(Date) 75 | if (info.last_modified) { 76 | expect(info.last_modified).toStrictEqual( 77 | new Date('2022-04-24T17:07:11.000Z'), 78 | ) 79 | } 80 | }) 81 | 82 | test('synthesizes a correct last modified', async () => { 83 | // This page is never edited so this date won't change. 84 | const request_url = 85 | 'https://github-wiki-see.page/m/nelsonjchen/wiki-public-test/wiki/last-modified-test' 86 | const result = await handleRequest( 87 | new Request(request_url, { method: 'GET' }), 88 | ) 89 | 90 | expect(result.status).toEqual(200) 91 | expect(result.headers.get('Last-Modified')).toEqual( 92 | 'Sun, 24 Apr 2022 17:07:11 GMT', 93 | ) 94 | 95 | const bodyText = await result.text() 96 | 97 | expect( 98 | bodyText.includes('Last Modified: Sun, 24 Apr 2022 17:07:11 GMT'), 99 | ).toBeTruthy() 100 | }) 101 | 102 | test('redirects an unindexable wiki that was moved', async () => { 103 | const request_url = `https://github-wiki-see.page/m/lorenwest/node-config/wiki` 104 | console.debug(request_url) 105 | const result = await handleRequest( 106 | new Request(request_url, { method: 'GET' }), 107 | ) 108 | 109 | expect(result.status).toEqual(308) 110 | expect(result.headers.get('location')).toEqual( 111 | 'https://github-wiki-see.page/m/node-config/node-config/wiki', 112 | ) 113 | 114 | }) 115 | }) 116 | -------------------------------------------------------------------------------- /cfworkers/ghwsee-indexable-redirect/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "compilerOptions": { 3 | "outDir": "./dist", 4 | "module": "esnext", 5 | "target": "esnext", 6 | "lib": ["esnext"], 7 | "alwaysStrict": true, 8 | "strict": true, 9 | "preserveConstEnums": true, 10 | "moduleResolution": "node", 11 | "sourceMap": true, 12 | "esModuleInterop": true, 13 | "types": ["@cloudflare/workers-types", "@types/jest", "@types/node"], 14 | "allowJs": true 15 | }, 16 | "include": ["src"], 17 | "exclude": ["node_modules", "dist", "test"] 18 | } 19 | -------------------------------------------------------------------------------- /cfworkers/ghwsee-indexable-redirect/webpack.config.js: -------------------------------------------------------------------------------- 1 | const path = require('path') 2 | 3 | module.exports = { 4 | entry: './src/index.ts', 5 | output: { 6 | filename: 'worker.js', 7 | path: path.join(__dirname, 'dist'), 8 | }, 9 | devtool: 'cheap-module-source-map', 10 | mode: 'development', 11 | resolve: { 12 | extensions: ['.ts', '.tsx', '.js'], 13 | }, 14 | module: { 15 | rules: [ 16 | { 17 | test: /\.tsx?$/, 18 | loader: 'ts-loader', 19 | options: { 20 | allowTsInNodeModules: true, 21 | // transpileOnly is useful to skip typescript checks occasionally: 22 | // transpileOnly: true, 23 | }, 24 | }, 25 | ], 26 | }, 27 | } 28 | -------------------------------------------------------------------------------- /cfworkers/ghwsee-indexable-redirect/wrangler.toml: -------------------------------------------------------------------------------- 1 | name = "ghwsee-indexable-redirect" 2 | account_id = "c455dc5b9661861484370320794ab63c" 3 | workers_dev = true 4 | compatibility_date = "2022-02-27" 5 | main = "dist/worker.js" 6 | 7 | [build] 8 | command = "npm install && npm run build" 9 | -------------------------------------------------------------------------------- /fly.toml: -------------------------------------------------------------------------------- 1 | # fly.toml app configuration file generated for github-wiki-see on 2023-07-01T09:49:30-07:00 2 | # 3 | # See https://fly.io/docs/reference/configuration/ for information about how to use this file. 4 | # 5 | 6 | app = "github-wiki-see" 7 | primary_region = "sea" 8 | kill_signal = "SIGINT" 9 | kill_timeout = "5s" 10 | 11 | [experimental] 12 | auto_rollback = true 13 | 14 | [[services]] 15 | protocol = "tcp" 16 | internal_port = 8000 17 | auto_stop_machines = true 18 | auto_start_machines = true 19 | min_machines_running = 1 20 | processes = ["app"] 21 | 22 | [[services.ports]] 23 | port = 80 24 | handlers = ["http"] 25 | 26 | [[services.ports]] 27 | port = 443 28 | handlers = ["tls", "http"] 29 | [services.concurrency] 30 | type = "requests" 31 | hard_limit = 30 32 | soft_limit = 1 33 | 34 | [[services.tcp_checks]] 35 | interval = "15s" 36 | timeout = "2s" 37 | grace_period = "1s" 38 | restart_limit = 6 39 | 40 | [[services.http_checks]] 41 | interval = "15s" 42 | timeout = "10s" 43 | grace_period = "5s" 44 | restart_limit = 4 45 | method = "get" 46 | path = "/m/nelsonjchen/github-wiki-test/wiki" 47 | protocol = "http" 48 | -------------------------------------------------------------------------------- /src/gh_extensions.rs: -------------------------------------------------------------------------------- 1 | use lazy_static::lazy_static; 2 | use regex::{Captures, Regex}; 3 | 4 | // Apparently the wiki part of GitHub can also take mediawiki syntax! 5 | // https://docs.github.com/en/communities/documenting-your-project-with-wikis/editing-wiki-content 6 | // Transform them to pure markdown 7 | // Transform images first, then links 8 | pub fn github_wiki_markdown_to_pure_markdown<'b>( 9 | md: &'b str, 10 | account: &'b str, 11 | repo: &'b str, 12 | ) -> String { 13 | lazy_static! { 14 | static ref IMG_RE: Regex = Regex::new( 15 | "\\[\\[(?P.*\\.(?i)(jpg|jpeg|png|gif))\\|(alt=)?(?P.*?)\\]\\]" 16 | ) 17 | .unwrap(); 18 | static ref IMG_REPO_BLOB: Regex = 19 | Regex::new(r"(?P
!\[.*\]\(https://github.com/.+/.+)/blob/(?P.*)").unwrap();
 20 |         static ref LINK_RE: Regex =
 21 |             Regex::new("\\[\\[((?P.*?)\\| *)?(?P.*?)\\]\\]").unwrap();
 22 |     }
 23 |     // Disregard alt for now.
 24 |     let processed_img_md = IMG_RE.replace_all(
 25 |         md,
 26 |         format!("![$link_text](https://raw.githubusercontent.com/wiki/{account}/{repo}$image_url)"),
 27 |     );
 28 | 
 29 |     let processed_blob_md = IMG_REPO_BLOB.replace_all(&processed_img_md, "$pre/raw/$suf");
 30 | 
 31 |     LINK_RE
 32 |         .replace_all(&processed_blob_md, |caps: &Captures<'_>| {
 33 |             let page_name = match caps.name("page_name") {
 34 |                 Some(page_name) => page_name.as_str(),
 35 |                 None => "",
 36 |             };
 37 | 
 38 |             let link_text = match caps.name("link_text") {
 39 |                 Some(link_text) => link_text.as_str(),
 40 |                 None => page_name,
 41 |             };
 42 | 
 43 |             if page_name.starts_with("http://") || page_name.starts_with("https://") {
 44 |                 return format!("[{link_text}]({page_name})");
 45 |             }
 46 | 
 47 |             let page_name_link = page_name.replace(' ', "-");
 48 | 
 49 |             format!("[{link_text}](/{account}/{repo}/wiki/{page_name_link})")
 50 |         })
 51 |         .to_string()
 52 | }
 53 | 
 54 | #[cfg(test)]
 55 | mod tests {
 56 |     use super::*;
 57 | 
 58 |     #[test]
 59 |     fn image_links() {
 60 |         let md = r#"[[/images/TimonHiWhite.jpg|Timon (Global), Tima (Swedish)]]"#;
 61 |         let result = github_wiki_markdown_to_pure_markdown(
 62 |             md,
 63 |             "Erithano",
 64 |             "Timon-Your-FAQ-bot-for-Microsoft-Teams",
 65 |         );
 66 |         assert_eq!(
 67 |             result,
 68 |             "![Timon (Global), Tima (Swedish)](https://raw.githubusercontent.com/wiki/Erithano/Timon-Your-FAQ-bot-for-Microsoft-Teams/images/TimonHiWhite.jpg)"
 69 |         );
 70 |     }
 71 | 
 72 |     #[test]
 73 |     fn image_links_repo() {
 74 |         let md = r#"![](https://github.com/Navid200/xDrip/blob/master/Documentation/images/Releases.png)"#;
 75 |         let result = github_wiki_markdown_to_pure_markdown(md, "Navid200", "xDrip");
 76 |         assert_eq!(
 77 |             result,
 78 |             "![](https://github.com/Navid200/xDrip/raw/master/Documentation/images/Releases.png)"
 79 |         );
 80 |     }
 81 | 
 82 |     #[test]
 83 |     fn media_wiki_page_links() {
 84 |         let md = r#"[[Meeting with James 30th March]]"#;
 85 |         let result = github_wiki_markdown_to_pure_markdown(md, "hamstar", "Braincase");
 86 |         assert_eq!(
 87 |             result,
 88 |             "[Meeting with James 30th March](/hamstar/Braincase/wiki/Meeting-with-James-30th-March)"
 89 |         );
 90 |     }
 91 | 
 92 |     #[test]
 93 |     fn media_wiki_external_links() {
 94 |         // https://github.com/vyvvvip/html5-boilerplate/wiki/sites
 95 |         let md = r#"[[10, The TV Series|http://www.10-la-serie.ch/]]"#;
 96 |         let result = github_wiki_markdown_to_pure_markdown(md, "hamstar", "Braincase");
 97 |         assert_eq!(result, "[10, The TV Series](http://www.10-la-serie.ch/)");
 98 |     }
 99 | 
100 |     #[test]
101 |     fn sidebar_links() {
102 |         let md = include_str!("../test-data/_Sidebar.md");
103 |         let result = github_wiki_markdown_to_pure_markdown(
104 |             md,
105 |             "Erithano",
106 |             "Timon-Your-FAQ-bot-for-Microsoft-Teams",
107 |         );
108 |         assert_eq!(result, include_str!("../test-data/_Sidebar_pure.md"));
109 |     }
110 | }
111 | 


--------------------------------------------------------------------------------
/src/main.rs:
--------------------------------------------------------------------------------
  1 | #[macro_use]
  2 | extern crate rocket;
  3 | 
  4 | use std::time::Duration;
  5 | 
  6 | use reqwest::Client;
  7 | use retrieval::{retrieve_wiki_sitemap_index, Content};
  8 | use rocket::futures::TryFutureExt;
  9 | use rocket::http::{ContentType, Method, Status};
 10 | 
 11 | use rocket::response::{content, status};
 12 | use rocket::response::{Redirect, Responder};
 13 | use rocket::route::{Handler, Outcome};
 14 | use rocket::{Route, State};
 15 | 
 16 | use crate::scraper::process_html;
 17 | use askama::Template;
 18 | 
 19 | use crate::gh_extensions::github_wiki_markdown_to_pure_markdown;
 20 | use crate::scraper::process_markdown;
 21 | 
 22 | mod decommission;
 23 | mod gh_extensions;
 24 | mod retrieval;
 25 | mod scraper;
 26 | 
 27 | #[derive(Template)]
 28 | #[template(path = "front_page.html")]
 29 | struct FrontPageTemplate {}
 30 | 
 31 | #[get("/")]
 32 | fn front() -> FrontPageTemplate {
 33 |     FrontPageTemplate {}
 34 | }
 35 | 
 36 | #[get("/favicon.ico")]
 37 | fn favicon() -> (Status, (ContentType, &'static [u8])) {
 38 |     (
 39 |         Status::Ok,
 40 |         (
 41 |             ContentType::Icon,
 42 |             include_bytes!("../templates/favicon.ico"),
 43 |         ),
 44 |     )
 45 | }
 46 | 
 47 | #[get("/social.png")]
 48 | fn social_png() -> (Status, (ContentType, &'static [u8])) {
 49 |     (
 50 |         Status::Ok,
 51 |         (ContentType::PNG, include_bytes!("../templates/social.png")),
 52 |     )
 53 | }
 54 | 
 55 | #[get("/callToAction.svg")]
 56 | fn call_to_action_svg() -> (Status, (ContentType, &'static [u8])) {
 57 |     (
 58 |         Status::Ok,
 59 |         (
 60 |             ContentType::SVG,
 61 |             include_bytes!("../templates/callToAction.svg"),
 62 |         ),
 63 |     )
 64 | }
 65 | 
 66 | #[get("/robots.txt")]
 67 | fn robots_txt(host: &rocket::http::uri::Host<'_>) -> (Status, (ContentType, &'static [u8])) {
 68 |     // Check if the host is an IP address, if so, don't allow crawling
 69 |     let a = host.domain().as_str();
 70 |     // Need to check if the host is an IP address
 71 |     if a.parse::().is_ok() {
 72 |         return (
 73 |             Status::Ok,
 74 |             (
 75 |                 ContentType::Plain,
 76 |                 include_bytes!("../templates/robots_ip.txt"),
 77 |             ),
 78 |         );
 79 |     }
 80 |     (
 81 |         Status::Ok,
 82 |         (
 83 |             ContentType::Plain,
 84 |             include_bytes!("../templates/robots.txt"),
 85 |         ),
 86 |     )
 87 | }
 88 | 
 89 | #[get("/sitemap.xml")]
 90 | fn sitemap_xml() -> Redirect {
 91 |     Redirect::permanent(uri!(
 92 |         "https://nelsonjchen.github.io/github-wiki-see-rs-sitemaps/sitemap_index.xml"
 93 |     ))
 94 | }
 95 | 
 96 | #[get("/base_sitemap.xml")]
 97 | fn base_sitemap_xml() -> Redirect {
 98 |     Redirect::permanent(uri!(
 99 |         "https://nelsonjchen.github.io/github-wiki-see-rs-sitemaps/base_sitemap.xml"
100 |     ))
101 | }
102 | 
103 | #[get("/generated_sitemap.xml")]
104 | fn generated_sitemap_xml() -> Redirect {
105 |     Redirect::permanent(uri!(
106 |         "https://nelsonjchen.github.io/github-wiki-see-rs-sitemaps/generated_sitemap.xml"
107 |     ))
108 | }
109 | 
110 | #[get("/seed_sitemaps/")]
111 | fn seed_sitemaps(id: &str) -> Redirect {
112 |     Redirect::permanent(format!(
113 |         "https://nelsonjchen.github.io/github-wiki-see-rs-sitemaps/seed_sitemaps/{id}"
114 |     ))
115 | }
116 | 
117 | #[derive(Clone)]
118 | struct RemoveSlashes;
119 | 
120 | #[rocket::async_trait]
121 | impl Handler for RemoveSlashes {
122 |     async fn handle<'r>(
123 |         &self,
124 |         req: &'r rocket::Request<'_>,
125 |         data: rocket::Data<'r>,
126 |     ) -> Outcome<'r> {
127 |         if req.uri().path().ends_with('/') && req.uri().path().to_string().chars().count() > 1 {
128 |             let mut uri = req.uri().path().to_string();
129 |             uri.pop();
130 |             Outcome::from(req, Redirect::permanent(uri))
131 |         } else {
132 |             Outcome::forward(data, Status::PermanentRedirect)
133 |         }
134 |     }
135 | }
136 | impl From for Vec {
137 |     fn from(rs: RemoveSlashes) -> Vec {
138 |         vec![Route::new(Method::Get, "/", rs)]
139 |     }
140 | }
141 | 
142 | #[get("/debug_sitemaps///sitemap.xml")]
143 | async fn wiki_debug_sitemaps(
144 |     account: &str,
145 |     repository: &str,
146 |     client: &State,
147 | ) -> Result, status::Custom> {
148 |     let content = retrieve_wiki_sitemap_index(account, repository, client)
149 |         .await
150 |         .map_err(|op| status::Custom(Status::InternalServerError, format!("Error: {op:?}")))?;
151 | 
152 |     Ok(content::RawXml(content))
153 | }
154 | 
155 | #[derive(Template)]
156 | #[template(path = "mirror.html")]
157 | struct MirrorTemplate {
158 |     original_title: String,
159 |     original_url: String,
160 |     mirrored_content: String,
161 |     index_url: String,
162 | }
163 | 
164 | #[allow(clippy::large_enum_variant)]
165 | #[derive(Responder)]
166 | enum MirrorError {
167 |     // DocumentNotFound(NotFound),
168 |     InternalError(status::Custom),
169 |     GiveUpSendToGitHub(Redirect),
170 | }
171 | 
172 | #[get("///wiki")]
173 | async fn mirror_home<'a>(
174 |     account: &'a str,
175 |     repository: &'a str,
176 |     client: &State,
177 | ) -> Result {
178 |     mirror_page(account, repository, "Home", client).await
179 | }
180 | 
181 | // Copied from percent_encoding crate but modified for what GitHub is OK with.
182 | pub const NON_ALPHANUMERIC_GH: &percent_encoding::AsciiSet = &percent_encoding::CONTROLS
183 |     .add(b' ')
184 |     .add(b'!')
185 |     .add(b'"')
186 |     .add(b'#')
187 |     .add(b'$')
188 |     .add(b'%')
189 |     .add(b'&')
190 |     // .add(b'\'') // OK to exist in URL
191 |     .add(b'(')
192 |     .add(b')')
193 |     .add(b'*')
194 |     .add(b'+')
195 |     .add(b',')
196 |     // .add(b'-') // OK to exist in URL
197 |     // .add(b'.') // OK to exist in URL
198 |     .add(b'/')
199 |     // .add(b':') // OK to exist in URL
200 |     .add(b';')
201 |     .add(b'<')
202 |     .add(b'=')
203 |     .add(b'>')
204 |     .add(b'?')
205 |     .add(b'@')
206 |     .add(b'[')
207 |     .add(b'\\')
208 |     .add(b']')
209 |     .add(b'^')
210 |     // .add(b'_') // OK to exist in URL
211 |     .add(b'`')
212 |     .add(b'{')
213 |     .add(b'|')
214 |     .add(b'}')
215 |     .add(b'~');
216 | 
217 | #[get("///wiki/Home", rank = 1)]
218 | async fn mirror_page_redirect_home<'a>(account: &'a str, repository: &'a str) -> Redirect {
219 |     Redirect::permanent(format!("/m/{account}/{repository}/wiki"))
220 | }
221 | 
222 | #[get("///wiki/", rank = 2)]
223 | async fn mirror_page<'a>(
224 |     account: &'a str,
225 |     repository: &'a str,
226 |     page: &'a str,
227 |     client: &State,
228 | ) -> Result {
229 |     use retrieval::retrieve_source_file;
230 |     use retrieval::ContentError;
231 |     use MirrorError::*;
232 | 
233 |     // Have original URL to forward to if there is an error.
234 |     let original_url = format!("https://github.com/{account}/{repository}/wiki/{page}",);
235 | 
236 |     // Rocket's Redirect / GitHub itself doesn't like unencoded URLs.
237 |     let original_url_encoded = format!(
238 |         "https://github.com/{}/{}/wiki/{}",
239 |         account,
240 |         repository,
241 |         percent_encoding::utf8_percent_encode(page, NON_ALPHANUMERIC_GH),
242 |     );
243 | 
244 |     let page_title = format!(
245 |         "{} - {}/{} GitHub Wiki",
246 |         page.replace('-', " "),
247 |         account,
248 |         repository
249 |     );
250 | 
251 |     // Grab main content from GitHub
252 |     // Consider it "fatal" if this doesn't exist/errors and forward to GitHub or return an error.
253 |     let content = retrieve_source_file(account, repository, page, client)
254 |         .map_err(|e| match e {
255 |             ContentError::NotFound => {
256 |                 GiveUpSendToGitHub(Redirect::to(original_url_encoded.clone()))
257 |             }
258 |             ContentError::TooMayRequests => {
259 |                 GiveUpSendToGitHub(Redirect::temporary(original_url_encoded.clone()))
260 |             }
261 |             ContentError::Decommissioned => {
262 |                 GiveUpSendToGitHub(Redirect::permanent(original_url_encoded.clone()))
263 |             }
264 |             ContentError::OtherError(e) => InternalError(status::Custom(
265 |                 Status::InternalServerError,
266 |                 MirrorTemplate {
267 |                     original_title: page_title.clone(),
268 |                     original_url: original_url.clone(),
269 |                     mirrored_content: format!("500 Internal Server Error - {e}"),
270 |                     index_url: format!("/m/{account}/{repository}/wiki_index"),
271 |                 },
272 |             )),
273 |         })
274 |         .await?;
275 | 
276 |     let original_html = content_to_html(content, account, repository, page);
277 | 
278 |     // The content exists. Now try to get the sidebar.
279 |     //
280 |     // Disabled for load reasons
281 |     //
282 |     // let sidebar_content = retrieve_source_file(account, repository, "_Sidebar", client)
283 |     //     .await
284 |     //     .ok();
285 |     let sidebar_content = None;
286 | 
287 |     let sidebar_html =
288 |         sidebar_content.map(|content| content_to_html(content, account, repository, page));
289 | 
290 |     // Append the sidebar if it exists
291 |     let mirrored_content = if let Some(sidebar_html) = sidebar_html {
292 |         format!(
293 |             "{original_html}\n
294 |             

Sidebar

295 | \n{sidebar_html}", 296 | ) 297 | } else { 298 | original_html 299 | }; 300 | 301 | Ok(MirrorTemplate { 302 | original_title: page_title.clone(), 303 | original_url: original_url_encoded.clone(), 304 | mirrored_content, 305 | index_url: format!("/m/{account}/{repository}/wiki_index"), 306 | }) 307 | } 308 | 309 | #[get("///wiki_index")] 310 | async fn mirror_page_index<'a>( 311 | account: &'a str, 312 | repository: &'a str, 313 | client: &State, 314 | ) -> Result { 315 | use retrieval::retrieve_wiki_index; 316 | use retrieval::ContentError; 317 | use MirrorError::*; 318 | 319 | // Have original URL to forward to if there is an error. 320 | let original_url = format!("https://github.com/{account}/{repository}/wiki/Home"); 321 | 322 | let page_title = format!("Page Index - {account}/{repository} GitHub Wiki"); 323 | 324 | // Grab main content from GitHub 325 | // Consider it "fatal" if this doesn't exist/errors and forward to GitHub or return an error. 326 | let content = retrieve_wiki_index(account, repository, client) 327 | .map_err(|e| match e { 328 | // Retreive wiki index never returns decomissioned 329 | ContentError::NotFound => GiveUpSendToGitHub(Redirect::to(original_url.clone())), 330 | ContentError::TooMayRequests => { 331 | GiveUpSendToGitHub(Redirect::temporary(original_url.clone())) 332 | } 333 | // Not used, but could be if index is decommisioned 334 | ContentError::Decommissioned => { 335 | GiveUpSendToGitHub(Redirect::permanent(original_url.clone())) 336 | } 337 | ContentError::OtherError(e) => InternalError(status::Custom( 338 | Status::InternalServerError, 339 | MirrorTemplate { 340 | original_title: page_title.clone(), 341 | original_url: original_url.clone(), 342 | mirrored_content: format!("500 Internal Server Error - {e}"), 343 | index_url: format!("/m/{account}/{repository}/wiki_index"), 344 | }, 345 | )), 346 | }) 347 | .await?; 348 | 349 | let original_html = content_to_html(content, account, repository, "Home"); 350 | 351 | Ok(MirrorTemplate { 352 | original_title: page_title.clone(), 353 | original_url: original_url.clone(), 354 | mirrored_content: original_html, 355 | index_url: format!("/m/{account}/{repository}/wiki_index"), 356 | }) 357 | } 358 | 359 | fn content_to_html(content: Content, account: &str, repository: &str, page: &str) -> String { 360 | match content { 361 | Content::AsciiDoc(ascii_doc) => { 362 | let md = format!( 363 | "🚨 **github-wiki-see.page does not render asciidoc. Source for crawling below. Please visit the Original URL!** 🚨\n 364 | ```asciidoc\n 365 | {ascii_doc}\n 366 | ```\n" 367 | ); 368 | process_markdown(&md, account, repository, page == "Home") 369 | } 370 | Content::Creole(cr) => { 371 | let md = format!( 372 | "🚨 **github-wiki-see.page does not render Creole. Source for crawling below. Please visit the Original URL!** 🚨\n 373 | ```creole\n 374 | {cr}\n 375 | ```\n" 376 | ); 377 | process_markdown(&md, account, repository, page == "Home") 378 | } 379 | Content::Markdown(md) => { 380 | // Markdown can have mediawiki links in them apparently 381 | let pure_markdown = github_wiki_markdown_to_pure_markdown(&md, account, repository); 382 | process_markdown(&pure_markdown, account, repository, page == "Home") 383 | } 384 | Content::Mediawiki(mw) => { 385 | let md = format!( 386 | "🚨 **github-wiki-see.page does not render Mediawiki. Source for crawling below. Please visit the Original URL!** 🚨\n 387 | ```creole\n 388 | {mw}\n 389 | ```\n" 390 | ); 391 | process_markdown(&md, account, repository, page == "Home") 392 | } 393 | Content::Orgmode(og) => { 394 | let md = format!( 395 | "🚨 **github-wiki-see.page does not render Org-Mode. Source for crawling below. Please visit the Original URL!** 🚨\n 396 | ```org\n 397 | {og}\n 398 | ```\n" 399 | ); 400 | process_markdown(&md, account, repository, page == "Home") 401 | } 402 | Content::Pod(p) => { 403 | let md = format!( 404 | "🚨 **github-wiki-see.page does not render Pod. Source for crawling below. Please visit the Original URL!** 🚨\n 405 | ```pod\n 406 | {p}\n 407 | ```\n" 408 | ); 409 | process_markdown(&md, account, repository, page == "Home") 410 | } 411 | Content::Rdoc(rd) => { 412 | let md = format!( 413 | "🚨 **github-wiki-see.page does not render Rdoc. Source for crawling below. Please visit the Original URL!** 🚨\n 414 | ```rdoc\n 415 | {rd}\n 416 | ```\n" 417 | ); 418 | process_markdown(&md, account, repository, page == "Home") 419 | } 420 | Content::Textile(tt) => { 421 | let md = format!( 422 | "🚨 **github-wiki-see.page does not render Textile. Source for crawling below. Please visit the Original URL!** 🚨\n 423 | ```textile\n 424 | {tt}\n 425 | ```\n" 426 | ); 427 | process_markdown(&md, account, repository, page == "Home") 428 | } 429 | Content::ReStructuredText(rst) => { 430 | let md = format!( 431 | "🚨 **github-wiki-see.page does not render ReStructuredText. Source for crawling below. Please visit the Original URL!** 🚨\n 432 | ```rst\n 433 | {rst}\n 434 | ```\n" 435 | ); 436 | process_markdown(&md, account, repository, page == "Home") 437 | } 438 | Content::FallbackHtml(html) => { 439 | let annotated_html = format!("{html}
⚠️ **GitHub.com Fallback** ⚠️
"); 440 | process_html(&annotated_html, account, repository, page == "Home") 441 | } 442 | } 443 | } 444 | 445 | #[catch(404)] 446 | fn not_found() -> &'static str { 447 | "404 Not Found - Links on this service may not work! CONTENT IS FOR CRAWLERS ONLY. Go back and visit the original page on GitHub for working links." 448 | } 449 | 450 | static APP_USER_AGENT: &str = concat!(env!("CARGO_PKG_NAME"), "/", env!("CARGO_PKG_VERSION"),); 451 | 452 | #[get("/versionz")] 453 | fn versionz() -> String { 454 | format!("{}, {}", APP_USER_AGENT, git_version::git_version!()) 455 | } 456 | 457 | #[launch] 458 | fn rocket() -> _ { 459 | // Mount front Page 460 | 461 | let mut mirror_routes = routes![ 462 | mirror_home, 463 | mirror_page_redirect_home, 464 | mirror_page, 465 | mirror_page_index 466 | ]; 467 | // Strip off trailing slashes on this route 468 | mirror_routes.push(Route::ranked( 469 | -20, 470 | Method::Get, 471 | "///wiki/", 472 | RemoveSlashes, 473 | )); 474 | 475 | // Mount Mirror 476 | rocket::build() 477 | .register("/", catchers![not_found]) 478 | .mount("/m", mirror_routes) 479 | .mount( 480 | "/", 481 | routes![ 482 | front, 483 | favicon, 484 | call_to_action_svg, 485 | social_png, 486 | robots_txt, 487 | sitemap_xml, 488 | base_sitemap_xml, 489 | generated_sitemap_xml, 490 | seed_sitemaps, 491 | wiki_debug_sitemaps, 492 | versionz, 493 | ], 494 | ) 495 | .manage( 496 | Client::builder() 497 | .user_agent(APP_USER_AGENT) 498 | .timeout(Duration::from_secs(10)) 499 | .connect_timeout(Duration::from_secs(3)) 500 | .redirect(reqwest::redirect::Policy::none()) 501 | .build() 502 | .expect("Could not build client"), 503 | ) 504 | } 505 | -------------------------------------------------------------------------------- /src/retrieval.rs: -------------------------------------------------------------------------------- 1 | use futures::future::TryFutureExt; 2 | use futures::FutureExt; 3 | use quick_xml::events::BytesText; 4 | use reqwest::{Client, StatusCode}; 5 | use scraper::{Html, Selector}; 6 | use std::future::Future; 7 | 8 | use crate::decommission::DECOMMISSION_LIST; 9 | use crate::scraper::process_html_index; 10 | 11 | #[allow(dead_code)] 12 | #[derive(Debug)] 13 | pub enum Content { 14 | AsciiDoc(String), 15 | Creole(String), 16 | Markdown(String), 17 | Mediawiki(String), 18 | Orgmode(String), 19 | Pod(String), 20 | Rdoc(String), 21 | Textile(String), 22 | ReStructuredText(String), 23 | FallbackHtml(String), 24 | } 25 | 26 | #[derive(Debug, PartialEq, Eq)] 27 | pub enum ContentError { 28 | NotFound, 29 | TooMayRequests, 30 | Decommissioned, 31 | OtherError(String), 32 | } 33 | 34 | const FALLBACK_HOST: &str = "https://gh-mirror-gucl6ahvva-uc.a.run.app"; 35 | 36 | pub async fn retrieve_source_file<'a>( 37 | account: &'a str, 38 | repository: &'a str, 39 | page: &'a str, 40 | client: &'a Client, 41 | ) -> Result { 42 | // Skip decommissioned wikis 43 | if DECOMMISSION_LIST.contains(format!("{account}/{repository}").as_str()) { 44 | return Err(ContentError::Decommissioned); 45 | } 46 | 47 | retrieve_source_file_extension(account, repository, page, client, &Content::Markdown, "md") 48 | // Is there something that vaguely looks like HTML? Fallback to HTML if seen 49 | .map(|result| match &result { 50 | Ok(Content::Markdown(md)) => { 51 | use lazy_static::lazy_static; 52 | use regex::Regex; 53 | 54 | lazy_static! { 55 | static ref RE: Regex = Regex::new("<.{3,10}>").unwrap(); 56 | } 57 | 58 | if RE.is_match(md) { 59 | return Err(ContentError::OtherError( 60 | "Markdown contains HTML".to_string(), 61 | )); 62 | } 63 | result 64 | } 65 | _ => result, 66 | }) 67 | .or_else(|_| async { 68 | retrieve_fallback_html(account, repository, page, client, "https://github.com").await 69 | }) 70 | .or_else(|err| async { 71 | if err == ContentError::TooMayRequests { 72 | retrieve_fallback_html(account, repository, page, client, FALLBACK_HOST).await 73 | } else { 74 | Err(err) 75 | } 76 | }) 77 | .await 78 | } 79 | 80 | async fn retrieve_github_com_html<'a>( 81 | account: &str, 82 | repository: &str, 83 | page: &str, 84 | client: &'a Client, 85 | domain: &'a str, 86 | ) -> Result { 87 | // Home is special 88 | let raw_github_url = if page == "Home" { 89 | format!("{domain}/{account}/{repository}/wiki") 90 | } else { 91 | format!("{domain}/{account}/{repository}/wiki/{page}") 92 | }; 93 | 94 | let resp_attempt = client.get(raw_github_url).send().await; 95 | 96 | let resp = resp_attempt.map_err(|e| ContentError::OtherError(e.to_string()))?; 97 | 98 | if resp.status() == StatusCode::NOT_FOUND { 99 | return Err(ContentError::NotFound); 100 | } 101 | 102 | // GitHub does this for unlogged in pages. 103 | if resp.status() == StatusCode::FOUND { 104 | return Err(ContentError::NotFound); 105 | } 106 | if resp.status() == StatusCode::MOVED_PERMANENTLY { 107 | return Err(ContentError::NotFound); 108 | } 109 | 110 | if resp.status() == StatusCode::TOO_MANY_REQUESTS { 111 | return Err(ContentError::TooMayRequests); 112 | } 113 | if !resp.status().is_success() { 114 | return Err(ContentError::OtherError(format!( 115 | "Remote: {}", 116 | resp.status() 117 | ))); 118 | } 119 | 120 | resp.text() 121 | .await 122 | .map_err(|e| ContentError::OtherError(e.to_string())) 123 | } 124 | 125 | async fn retrieve_fallback_html<'a>( 126 | account: &'a str, 127 | repository: &'a str, 128 | page: &'a str, 129 | client: &'a Client, 130 | domain: &'a str, 131 | ) -> Result { 132 | let html = retrieve_github_com_html(account, repository, page, client, domain).await?; 133 | 134 | let document = Html::parse_document(&html); 135 | document 136 | .select(&Selector::parse("#wiki-body").unwrap()) 137 | .next() 138 | .map(|e| e.inner_html()) 139 | .map(Content::FallbackHtml) 140 | .ok_or(ContentError::NotFound) 141 | } 142 | 143 | // https://github-wiki-see.page/m/nelsonjchen/github-wiki-test/wiki/Fallback 144 | fn retrieve_source_file_extension<'a, T: Fn(String) -> Content>( 145 | account: &'a str, 146 | repository: &'a str, 147 | page: &'a str, 148 | client: &'a Client, 149 | enum_constructor: T, 150 | extension: &'a str, 151 | ) -> impl Future> { 152 | let page_encoded = 153 | percent_encoding::utf8_percent_encode(page, percent_encoding::NON_ALPHANUMERIC); 154 | let raw_github_assets_url = format!( 155 | "https://raw.githubusercontent.com/wiki/{account}/{repository}/{page_encoded}.{extension}" 156 | ); 157 | 158 | client 159 | .get(raw_github_assets_url) 160 | .send() 161 | .map_err(|e| ContentError::OtherError(e.to_string())) 162 | .and_then(|r| async { 163 | if r.status() == StatusCode::NOT_FOUND { 164 | return Err(ContentError::NotFound); 165 | } 166 | if !r.status().is_success() { 167 | return Err(ContentError::OtherError(format!("Remote: {}", r.status()))); 168 | } 169 | Ok(r) 170 | }) 171 | .map_ok(|r| { 172 | r.text() 173 | .map_err(|e| ContentError::OtherError(e.to_string())) 174 | }) 175 | .and_then(|t| t) 176 | .map_ok(enum_constructor) 177 | } 178 | 179 | pub async fn retrieve_wiki_index<'a>( 180 | account: &'a str, 181 | repository: &'a str, 182 | client: &'a Client, 183 | ) -> Result { 184 | let html = retrieve_github_com_html(account, repository, "", client, "https://github.com") 185 | .or_else(|err| async { 186 | if err == ContentError::TooMayRequests { 187 | retrieve_github_com_html(account, repository, "", client, FALLBACK_HOST).await 188 | } else { 189 | Err(err) 190 | } 191 | }) 192 | .await?; 193 | let wiki_page_urls = process_html_index(&html); 194 | let content = Content::Markdown(format!( 195 | "{} page(s) in this GitHub Wiki: 196 | 197 | {} 198 | ", 199 | wiki_page_urls.len(), 200 | wiki_page_urls 201 | .into_iter() 202 | .map(|(url, text)| format!("* [{text}]({url})")) 203 | .collect::>() 204 | .join("\n"), 205 | )); 206 | Ok(content) 207 | } 208 | 209 | pub async fn retrieve_wiki_sitemap_index<'a>( 210 | account: &'a str, 211 | repository: &'a str, 212 | client: &'a Client, 213 | ) -> Result { 214 | let html = retrieve_github_com_html(account, repository, "", client, "https://github.com") 215 | .or_else(|err| async { 216 | if err == ContentError::TooMayRequests { 217 | retrieve_github_com_html(account, repository, "", client, FALLBACK_HOST).await 218 | } else { 219 | Err(err) 220 | } 221 | }) 222 | .await?; 223 | let mut wiki_page_urls = process_html_index(&html); 224 | 225 | // Add the synthetic index page 226 | wiki_page_urls.push(( 227 | format!("/{account}/{repository}/wiki_index"), 228 | "Wiki Index".to_string(), 229 | )); 230 | 231 | use quick_xml::events::{BytesEnd, BytesStart, Event}; 232 | 233 | use quick_xml::Writer; 234 | use std::io::Cursor; 235 | 236 | let mut writer = Writer::new(Cursor::new(Vec::new())); 237 | 238 | let mut urlset_el = BytesStart::new("urlset"); 239 | urlset_el.push_attribute(("xmlns", "http://www.sitemaps.org/schemas/sitemap/0.9")); 240 | urlset_el.push_attribute(("xmlns:xsi", "http://www.w3.org/2001/XMLSchema-instance")); 241 | urlset_el.push_attribute(("xsi:schemaLocation", "http://www.sitemaps.org/schemas/sitemap/0.9 http://www.sitemaps.org/schemas/sitemap/0.9/sitemap.xsd")); 242 | 243 | writer 244 | .write_event(Event::Start(urlset_el)) 245 | .map_err(|o| ContentError::OtherError(o.to_string()))?; 246 | 247 | for (url, _) in wiki_page_urls { 248 | let url_el = BytesStart::new("url"); 249 | writer 250 | .write_event(Event::Start(url_el)) 251 | .map_err(|o| ContentError::OtherError(o.to_string()))?; 252 | 253 | let loc_el = BytesStart::new("loc"); 254 | writer 255 | .write_event(Event::Start(loc_el)) 256 | .map_err(|o| ContentError::OtherError(o.to_string()))?; 257 | 258 | writer 259 | .write_event(Event::Text(BytesText::new(&format!( 260 | "https://github-wiki-see.page/m{url}" 261 | )))) 262 | .map_err(|o| ContentError::OtherError(o.to_string()))?; 263 | 264 | writer 265 | .write_event(Event::End(BytesEnd::new("loc"))) 266 | .map_err(|o| ContentError::OtherError(o.to_string()))?; 267 | 268 | writer 269 | .write_event(Event::End(BytesEnd::new("url"))) 270 | .map_err(|o| ContentError::OtherError(o.to_string()))?; 271 | } 272 | 273 | writer 274 | .write_event(Event::End(BytesEnd::new("urlset"))) 275 | .map_err(|op| ContentError::OtherError(op.to_string()))?; 276 | 277 | use std::str; 278 | let written = &writer.into_inner().into_inner(); 279 | let xml_str = str::from_utf8(written).map_err(|op| ContentError::OtherError(op.to_string()))?; 280 | Ok(xml_str.to_string()) 281 | } 282 | 283 | #[cfg(test)] 284 | mod tests { 285 | use super::*; 286 | 287 | #[tokio::test] 288 | async fn basic() { 289 | let client = Client::new(); 290 | 291 | let future = retrieve_source_file_extension( 292 | "nelsonjchen", 293 | "github-wiki-test", 294 | "Home", 295 | &client, 296 | &Content::Markdown, 297 | "md", 298 | ); 299 | let content = future.await; 300 | 301 | println!("{content:?}"); 302 | assert!(content.is_ok()); 303 | } 304 | 305 | #[tokio::test] 306 | async fn encoded() { 307 | let client = Client::new(); 308 | 309 | let future = retrieve_source_file_extension( 310 | "naver", 311 | "billboard.js", 312 | "How-to-bundle-for-legacy-browsers?", 313 | &client, 314 | &Content::Markdown, 315 | "md", 316 | ); 317 | let content = future.await; 318 | 319 | println!("{content:?}"); 320 | assert!(content.is_ok()); 321 | } 322 | 323 | #[tokio::test] 324 | async fn html_in_markdown() { 325 | let client = Client::new(); 326 | 327 | let future = retrieve_source_file("wlsdn2316", "1-tetris-", "Functions", &client); 328 | let content = future.await; 329 | 330 | assert!(content.is_ok()); 331 | // Fallback must be used for HTML in Markdown documents 332 | assert!(matches!(content, Ok(Content::FallbackHtml(_)))); 333 | } 334 | 335 | #[tokio::test] 336 | async fn fallback_encoded() { 337 | let client = Client::new(); 338 | 339 | let future = retrieve_github_com_html( 340 | "naver", 341 | "billboard.js", 342 | "How-to-bundle-for-legacy-browsers?", 343 | &client, 344 | "https://github.com", 345 | ); 346 | let content = future.await; 347 | 348 | println!("{content:?}"); 349 | assert!(content.is_ok()); 350 | } 351 | 352 | #[tokio::test] 353 | async fn fallback_soapy() { 354 | let client = Client::new(); 355 | 356 | let future = retrieve_github_com_html( 357 | "pothosware", 358 | "SoapySDR", 359 | "Home", 360 | &client, 361 | "https://github.com", 362 | ); 363 | let content = future.await; 364 | 365 | println!("{content:?}"); 366 | assert!(content.is_ok()); 367 | } 368 | 369 | #[tokio::test] 370 | async fn page_list() { 371 | let client = Client::new(); 372 | let future = retrieve_wiki_index("nelsonjchen", "github-wiki-test", &client); 373 | let content = future.await; 374 | 375 | println!("{content:?}"); 376 | assert!(content.is_ok()); 377 | } 378 | 379 | #[tokio::test] 380 | async fn wiki_sitemap_index() { 381 | let client = Client::new(); 382 | let future = retrieve_wiki_sitemap_index("nelsonjchen", "github-wiki-test", &client); 383 | let content = future.await; 384 | 385 | println!("{content:?}"); 386 | assert!(content.is_ok()); 387 | } 388 | } 389 | -------------------------------------------------------------------------------- /src/scraper.rs: -------------------------------------------------------------------------------- 1 | use core::str; 2 | 3 | use comrak::{markdown_to_html, ComrakOptions}; 4 | use nipper::Document; 5 | 6 | pub fn process_markdown( 7 | original_markdown: &str, 8 | account: &str, 9 | repository: &str, 10 | homepage_prepend: bool, 11 | ) -> String { 12 | let mut options = ComrakOptions::default(); 13 | options.extension.strikethrough = true; 14 | options.extension.tagfilter = true; 15 | options.extension.table = true; 16 | options.extension.autolink = true; 17 | options.extension.tasklist = true; 18 | options.extension.header_ids = Some("".to_string()); 19 | options.render.github_pre_lang = true; 20 | 21 | let original_html = markdown_to_html(original_markdown, &options); 22 | process_html(&original_html, account, repository, homepage_prepend) 23 | } 24 | 25 | pub fn process_html( 26 | original_html: &str, 27 | account: &str, 28 | repository: &str, 29 | homepage_prepend: bool, 30 | ) -> String { 31 | let document = Document::from(original_html); 32 | document.select("a").iter().for_each(|mut thing| { 33 | if let Some(href) = thing.attr("href") { 34 | let string_href = String::from(href); 35 | if !string_href.starts_with("http://") 36 | && !string_href.starts_with("https://") 37 | && !string_href.starts_with("//") 38 | { 39 | if string_href.starts_with('/') { 40 | let new_string_href = "/m".to_owned() + &string_href; 41 | thing.set_attr("href", &new_string_href); 42 | } else { 43 | // Prepend wiki if homepage and if the href doesn't start with wiki 44 | if homepage_prepend && !string_href.starts_with("wiki/") { 45 | let new_string_href = "wiki/".to_owned() + &string_href; 46 | thing.set_attr("href", &new_string_href); 47 | } 48 | } 49 | } else { 50 | thing.set_attr("rel", "nofollow ugc"); 51 | } 52 | } 53 | }); 54 | document.select("img").iter().for_each(|mut thing| { 55 | if let Some(href) = thing.attr("src") { 56 | let string_href = String::from(href); 57 | if !string_href.starts_with("http://") 58 | && !string_href.starts_with("https://") 59 | && !string_href.starts_with("//") 60 | { 61 | if !string_href.starts_with("wiki") { 62 | let new_string_href = 63 | format!("https://github.com/{account}/{repository}/wiki/") + &string_href; 64 | thing.set_attr("src", &new_string_href); 65 | } else { 66 | let new_string_href = 67 | format!("https://github.com/{account}/{repository}/") + &string_href; 68 | thing.set_attr("src", &new_string_href); 69 | } 70 | } 71 | if string_href.starts_with('/') { 72 | let new_string_href = "https://github.com".to_owned() + &string_href; 73 | thing.set_attr("src", &new_string_href); 74 | } 75 | } 76 | }); 77 | 78 | String::from(document.html()) 79 | } 80 | 81 | pub fn process_html_index(original_html: &str) -> Vec<(String, String)> { 82 | let document = Document::from(original_html); 83 | document 84 | .select("#wiki-pages-box a, .flex-auto.min-width-0.col-12.col-md-8 a") 85 | .iter() 86 | .filter_map(|element| { 87 | element 88 | .attr("href") 89 | .map(|attr_value| (String::from(attr_value), String::from(element.text()))) 90 | }) 91 | .collect() 92 | } 93 | 94 | #[cfg(test)] 95 | mod tests { 96 | use super::*; 97 | 98 | #[test] 99 | fn something() { 100 | let html = r#"
101 | One 102 | Two 103 | Three 104 |
"#; 105 | 106 | let document = Document::from(html); 107 | let a = document.select("a:nth-child(3)"); 108 | let text: &str = &a.text(); 109 | assert_eq!(text, "Three"); 110 | } 111 | 112 | #[test] 113 | fn github_html() { 114 | let html = include_str!("../test-data/wiki-index.html"); 115 | 116 | let document = Document::from(html); 117 | let a = document.select("#wiki-wrapper"); 118 | let text: &str = &a.html(); 119 | assert_ne!(text.len(), 0); 120 | } 121 | 122 | #[test] 123 | fn transform_non_relative_urls_to_nofollow_ugc_https() { 124 | let html = ""; 125 | 126 | assert_eq!( 127 | process_html(html, "some_account", "some_repo", false), 128 | "" 129 | ); 130 | } 131 | 132 | #[test] 133 | fn transform_non_relative_urls_to_nofollow_ugc_agnostic() { 134 | let html = ""; 135 | 136 | assert_eq!( 137 | process_html(html, "some_account", "some_repo", false), 138 | "" 139 | ); 140 | } 141 | 142 | #[test] 143 | fn transform_non_relative_urls_to_nofollow_ugc_http() { 144 | let html = ""; 145 | 146 | assert_eq!( 147 | process_html(html, "some_account", "some_repo", false), 148 | "" 149 | ); 150 | } 151 | 152 | #[test] 153 | fn transform_img_src_to_github_root() { 154 | let html = ""; 155 | 156 | assert_eq!( 157 | process_html(html, "some_account", "some_repo", false), 158 | "" 159 | ); 160 | } 161 | 162 | #[test] 163 | fn transform_img_src_to_github_root_relative() { 164 | // https://github.com/ant-media/Ant-Media-Server/wiki 165 | let html = 166 | ""; 167 | 168 | assert_eq!( 169 | process_html(html, "some_account", "some_repo", false), 170 | "" 171 | ); 172 | } 173 | 174 | #[test] 175 | fn transform_img_src_to_github_root_non_relative() { 176 | let html = ""; 177 | 178 | assert_eq!( 179 | process_html(html, "some_account", "some_repo", false), 180 | "" 181 | ); 182 | } 183 | 184 | #[test] 185 | fn transform_img_src_to_github_root_non_relative_2() { 186 | // https://github.com/zanonmark/Google-4-TbSync/wiki/How-to-generate-your-own-Google-API-Console-project-credentials 187 | let html = ""; 188 | 189 | assert_eq!( 190 | process_html(html, "some_account", "some_repo", false), 191 | "" 192 | ); 193 | } 194 | 195 | #[test] 196 | fn get_page_list() { 197 | let html = include_str!("../test-data/wiki-index.html"); 198 | 199 | let pages = process_html_index(html); 200 | assert!(pages.len() > 3); 201 | let page_1 = pages.first().unwrap(); 202 | assert!(page_1.0.contains("nelsonjchen")); 203 | assert!(page_1.0.contains("wiki")); 204 | } 205 | 206 | #[test] 207 | fn get_page_list_homeless() { 208 | let html = include_str!("../test-data/wiki-homeless-index.html"); 209 | 210 | let pages = process_html_index(html); 211 | more_asserts::assert_ge!(pages.len(), 3); 212 | assert!(pages.first().unwrap().0.contains("Homeless")); 213 | assert!(pages.get(1).unwrap().0.contains("Ooze")); 214 | assert!(pages.get(2).unwrap().0.contains("Porkchops")); 215 | } 216 | } 217 | -------------------------------------------------------------------------------- /templates/callToAction.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 16 | 36 | 38 | 42 | Please view the original page on GitHub.com 67 | 68 | 69 | -------------------------------------------------------------------------------- /templates/favicon.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nelsonjchen/github-wiki-see-rs/d2c22b12b5865e67c7c5feef5da0fac9a316a614/templates/favicon.ico -------------------------------------------------------------------------------- /templates/front_page.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | About GitHub Wiki SEE - 400,000+ Wikis, now indexable. 5 | 15 | 16 | 18 | 19 | 20 | 21 | 23 | 24 | 25 | 26 | 27 |

GitHub Wiki SEE

28 |

🔎 400,000+ GitHub Wikis, now indexable by your favorite search engine. 29 |

30 |

31 | GitHub Wiki Search Engine Enablement (GHWSEE) allows non-indexed GitHub Wikis to be indexed by search 32 | engines. The robots.txt and HTTP headers on 34 | this site do not prevent indexing of wiki content and GitHub Wiki content proxied from GitHub and served from 35 | this service can be crawled and indexed by major search engines. 36 |

37 |

The situation so far:

38 |
    39 |
  • 40 | GitHub prevents indexing of repository wiki 41 | content through HTTP headers. 43 | The blocking greatly reduces the effectiveness of content of pages on affected Wikis if they cannot be 44 | searched on search engines such as Google or DuckDuckGo. 45 |
  • 46 |
  • GitHub has officially documented that they only index certain GitHub Wikis. According to GitHub's documentation, 48 | "Search engines will only index wikis with 500 or more stars that you configure to prevent public editing." 49 | This provides clarity on the exact criteria being used, which was previously unclear.
  • 50 |
  • About 51 | 3,300 GitHub.com Wikis met an older criteria requiring ~1000+ and can be found on search engines 52 | such as Google / DuckDuckGo according to a survey in February 2022.
  • 53 |
  • About 54 | 4,700 repositories have 798 stars and above and can't be directly indexed by search engines from the 55 | same survey with the older criteria in February 2022. These repositories do not appear to have the "Editing 56 | Restricted to Repository Collaborators" option turned on. You would likely recognize some of these 57 | repositories no matter where your expertise may lie. Many of these projects have large amounts of content in 58 | their Wikis and are very active.
  • 59 |
  • There are still about 400,000+ GitHub.com Wikis that are below 500 stars and/or publically editable. These 60 | can't be directly indexed by search engines as well.
  • 61 |
  • GHWSEE is helping GitHub Wikis that aren't indexable be indexable in search engines and is continually 62 | decommissioning itself for GitHub Wikis that are directly indexable.
  • 63 |
64 |

GHWSEE proxies the rendered contents of the pages and has a link with a large button at the top to visit the 65 | page on GitHub for everyday usage and a link at the bottom explaining what GHWSEE is. The content of this 66 | service is not meant to be read directly by users and is intended for crawlers. GHWSEE is designed to behave 67 | like those StackOverflow content mirroring sites that rank high with "stolen" content from StackOverflow but 68 | with far less ad-farming. Unlike its inspiration, GHWSEE has no ads and tries to make it obvious, quick, and 69 | easy for users to get to the content they want directly on GitHub.com short of an automatic redirect that may 70 | make search engines not crawl or index the content.

71 |

Another purpose of GHWSEE is to bring awareness to the issue of GitHub Wikis purposefully not being indexed 72 | since 2012. Many are caught 73 | off-guard and have produced massive libraries of information that they are unaware of being generally invisible 74 | to the internet. Likewise, many searching for information in these libraries are not aware that the information 75 | is invisible to them if it was in a GitHub Wiki. Up until 76 | April 2021 (9 years since 2012), GitHub did not document this limitation; the only way you knew was by 77 | previously looking at robots.txt. A warning is still not present in GitHub's UI itself about this 78 | limitation. By showing up in real-world search results, it is hoped that greater awareness to this issue can be 79 | made amongst affected communities and projects.

80 |

If you are a GitHub Wiki maintainer, you may want to consider GitHub Pages backed by a public repository for 81 | your community's content as a more crawlable, stable, blessed, and probably higher search ranking alternative. 82 | This 84 | alternative is also mentioned in GitHub Docs about GitHub Wikis. Consider adding an "Edit on GitHub" link to the 86 | content on GitHub Pages to have an experience closer to wikis, easily permit editing, and to encourage 87 | contributions. This is the official solution which can be burdensome and you are welcome to continue using GHWSEE. 89 |

90 |
    91 |
  • A great example of an organization taking the moving to GitHub Pages route would be the libGDX cross-platform Java game development framework project. The 93 | project has migrated their Wiki to their website. The pages are very faithful to the original GitHub Wiki page design including the aforementioned "Edit on GitHub" link. 95 | You can see the Jekyll/GitHub Pages implementation backing this in their repository. There is also a pull request on that repository that can 98 | be used as a reference as well.
  • 99 |
  • It is also possible to target a "Editing Restricted to Repository Collaborators" GitHub Wiki itself as well 100 | from the GitHub repository and deploy to it with GitHub Actions and have it be indexed if the repo has a 101 | high star count (500+). These Wikis are likely to be whitelisted by GitHub for direct indexing (please test 102 | first). An example of this can be seen on the Go 103 | for VSCode repository.
  • 104 |
  • Some organizations or projects such as ShellCheck mirror their content themselves 106 | and choose to keep their Wikis editable. NOTE: GHWSEE cannot automatically disengage itself for wikis backed 107 | by this setup as it is technically impossible to automatically detect. Please create an issue if your project or 109 | any other project still permits editing but mirrors their content themselves and a blacklist entry can be added. 111 |
  • 112 |
  • If you or your organization does any of this, please reach out to me to try to expedite search engines to 113 | remove GHWSEE's entries from search engine results for the migrated wiki. Please also make sure to produce 114 | the necessary sitemaps and monitor your own wiki's content indexing progress and ranking via tools such as 115 | Google Search Console or Bing Webmaster Tools (Bing is also a DuckDuckGo source).
  • 116 |
117 |

If you are interested in providing feedback to GitHub or seeing what GitHub staff has said about their blocking 118 | of Wiki content from appearing in search engines, participate in the discussion here: https://github.com/github/feedback/discussions/4992. 120 | Let us hope that GitHub can find a solution to unblock GitHub Wiki content in harmony with their SEO concerns, 121 | and GHWSEE can be decommissioned. Already, Wikis that are known to be directly 122 | indexable are skipped by GHWSEE as part of the partial decommissioning.

123 |

For anti-abuse reasons, all links rendered in the service that are going out of GitHub are tagged with 124 | rel="nofollow ugc" 125 | as to not affect search engine rankings or to promote mass vandalism of GitHub Wikis. This is in addition to 126 | rel="nofollow" in the original content.

127 |

Usage

128 |
    129 |
  • Wiki Reader: Use your favorite search engine! Every query you run searches a corpus that has GHWSEE 130 | in it. That is the intended interface to the content "on" this service and to get a link to the original 131 | GitHub content. Do not read or use the content on this site as it may have rendered with errors and is only 132 | meant for robots. Go directly to the original page on GitHub with the link or button.
  • 133 | 140 |
  • Wiki Editor whose Wiki does not meet the native indexing criterias: If you are a GitHub Wiki contributor, 141 | simply edit your content periodically and the sitemap generator will eventually 143 | pick it up and notify search engines. Because this just isn't GitHub.com, don't expect a high ranking as 144 | your content will probably be on page 2, 3, or worse. That is still much better than the previous 145 | alternative of not being in the search results at all! Note that it may take quite some time and luck for 146 | content to be picked up or detected by search engine crawlers and there is no guarantee it will be picked up 147 | or detected.
  • 148 | 160 |
161 |

Examples

162 |

These are just examples and testing wikis.

163 | 172 |

Project, README, Source, Issues, and other information

173 | https://github.com/nelsonjchen/github-wiki-see-rs 174 |

So far, about $300 have been spent on experiments, queries, and so on with this service during its initial 175 | ramp-up. The good news is that the cost to currently host the service is very low. In lieu of any compensation, 176 | please consider donating money recurringly or one-time to the Internet Archive 177 | and/or your time to Archive Team projects.

178 |

Decommissioning

179 |

This service will be completely decommissioned to redirect old links once the block is lifted or GitHub produces 180 | some other solution to index all useful GitHub Wikis in harmony with their SEO concerns.

181 |

People shouldn't have linked to this site but maybe the warnings weren't big and red enough. Flashing yellow was very unpopular. 183 | Regardless, let us not contribute to link rot.

184 |

Ongoing Continuous Partial Decommissioning

185 |

As of January 2022, GitHub does appear to be letting some Wikis be indexed according to some non-public 186 | criteria. These small sample of Wikis allow native indexing by not having a x-robots-tag: none HTTP 187 | header. A Cloudflare Worker is implemented in front of the proxied URLs to check GitHub and automatically 188 | redirect if the backing page is detected to allow indexing if something doesn't get added to that list on time. 189 | By automatically redirecting, it is hoped that GHWSEE's entries for that GitHub wiki falls off the search engine 190 | index and that GHWSEE's ranking may be conferred directly on GitHub's ranking.

191 |

Some projects have chosen to mirror their own wiki's content onto their own site as well. These cannot be 192 | automatically detected, but may be manually added to the decommission list.

193 |

The small sample of links below help test the partial decommissioning functionality.

194 | 201 |
202 |

This project is not affiliated with GitHub in any way, if it wasn't obvious from the substandard CSS and code. 203 | This project is only made and run by nelsonjchen, GitHub User 204 | #5653.

205 | 206 | 207 | 208 | -------------------------------------------------------------------------------- /templates/mirror.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | {{ original_title }} 5 | 188 | 189 | 190 | 191 | 192 | 193 | 194 | 195 | 196 | 197 | 198 |
199 | 211 | 214 |
215 |

{{ original_title }}

216 |
{{ mirrored_content|safe }}
217 |
218 | 221 |
222 | 223 | 224 | 225 | -------------------------------------------------------------------------------- /templates/robots.txt: -------------------------------------------------------------------------------- 1 | # Workaround inadverdent indexing of /cgi-bin/ stuff 2 | User-agent: * 3 | Disallow: /cgi-bin/ 4 | 5 | # Crawl it all otherwise. 🟢 6 | 7 | Sitemap: https://github-wiki-see.page/sitemap.xml 8 | -------------------------------------------------------------------------------- /templates/robots_ip.txt: -------------------------------------------------------------------------------- 1 | # Block all indexing as you are accessing by IP address 2 | 3 | User-agent: * 4 | Disallow: / -------------------------------------------------------------------------------- /templates/social.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/nelsonjchen/github-wiki-see-rs/d2c22b12b5865e67c7c5feef5da0fac9a316a614/templates/social.png -------------------------------------------------------------------------------- /test-data/_Sidebar.md: -------------------------------------------------------------------------------- 1 | ## Table of Contents 2 | ### Getting started 3 | * [[Home| Home]] 4 | * [[About Timon | About]] 5 | * [[Prerequisites | Prerequisites]] 6 | * [[Deployment Guide | Deployment-Guide]] 7 | * [[Frequently Asked Questions | Frequently-Asked-Questions]] 8 | 9 | 10 | ### Deployment Appendix 11 | * [[Update Timon's knowledge|Timon's-Knowledge]] 12 | * [[How to edit, create and design answers|How-to-edit,-create-and-design-answers]] 13 | * [[Change default behavior when not understanding the user's intent|Change-Timon's-default-behavior-when-not-understanding-the-user's-intent]] 14 | * [[PVA Bonus Tips|PVA-Bonus-Tips]] 15 | * [[Known Issues|Known-Issues]] 16 | -------------------------------------------------------------------------------- /test-data/_Sidebar_pure.md: -------------------------------------------------------------------------------- 1 | ## Table of Contents 2 | ### Getting started 3 | * [Home](/Erithano/Timon-Your-FAQ-bot-for-Microsoft-Teams/wiki/Home) 4 | * [About Timon ](/Erithano/Timon-Your-FAQ-bot-for-Microsoft-Teams/wiki/About) 5 | * [Prerequisites ](/Erithano/Timon-Your-FAQ-bot-for-Microsoft-Teams/wiki/Prerequisites) 6 | * [Deployment Guide ](/Erithano/Timon-Your-FAQ-bot-for-Microsoft-Teams/wiki/Deployment-Guide) 7 | * [Frequently Asked Questions ](/Erithano/Timon-Your-FAQ-bot-for-Microsoft-Teams/wiki/Frequently-Asked-Questions) 8 | 9 | 10 | ### Deployment Appendix 11 | * [Update Timon's knowledge](/Erithano/Timon-Your-FAQ-bot-for-Microsoft-Teams/wiki/Timon's-Knowledge) 12 | * [How to edit, create and design answers](/Erithano/Timon-Your-FAQ-bot-for-Microsoft-Teams/wiki/How-to-edit,-create-and-design-answers) 13 | * [Change default behavior when not understanding the user's intent](/Erithano/Timon-Your-FAQ-bot-for-Microsoft-Teams/wiki/Change-Timon's-default-behavior-when-not-understanding-the-user's-intent) 14 | * [PVA Bonus Tips](/Erithano/Timon-Your-FAQ-bot-for-Microsoft-Teams/wiki/PVA-Bonus-Tips) 15 | * [Known Issues](/Erithano/Timon-Your-FAQ-bot-for-Microsoft-Teams/wiki/Known-Issues) 16 | -------------------------------------------------------------------------------- /test-data/update-wiki-index.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | curl "https://github.com/nelsonjchen/github-wiki-test/wiki" > wiki-index.html 4 | curl "https://github.com/nelsonjchen/github-wiki-test-homeless/wiki" > wiki-homeless-index.html 5 | -------------------------------------------------------------------------------- /test-data/wiki-homeless-index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | Pages · nelsonjchen/github-wiki-test-homeless Wiki · GitHub 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | 77 | 78 | 79 | 80 | 81 | 82 | 83 | 84 | 85 | 86 | 87 | 88 | 89 | 90 | 91 | 92 | 93 | 94 | 95 | 96 | 97 | 98 | 99 | 100 | 101 | 102 | 103 | 104 | 105 | 106 | 107 | 108 | 109 | 110 | 111 | 112 | 113 | 114 | 115 | 116 | 117 | 118 | 119 | 120 | 121 | 122 | 123 | 124 | 125 | 126 | 127 | 128 | 129 | 130 | 131 | 132 | 133 | 134 | 135 | 136 | 137 | 138 | 139 | 140 | 141 | 142 | 143 | 144 | 145 | 146 | 147 | 148 | 149 | 150 | 151 | 152 | 153 | 154 | 155 | 156 | 157 | 158 | 159 | 160 | 161 | 162 | 163 | 164 | 165 | 166 | 167 | 168 |
169 | 170 | 171 | 172 |
173 | Skip to content 174 | 175 | 176 | 177 | 178 | 179 | 180 | 181 | 182 | 183 | 184 | 775 | 776 |
777 | 778 |
779 | 780 | 781 | 782 | 783 | 784 | 785 | 786 |
787 | 788 | 789 | 790 | 791 | 792 | 809 |
810 | 811 | 812 | 813 | 814 | 815 | 816 | 817 | 818 | 819 | 820 |
826 |
827 |
828 | 829 | 830 | 831 | 832 | 833 | 834 | 835 | 836 | 837 | 838 | 839 |
840 | 841 |
842 | 843 |
844 | 845 |
846 | 849 | 850 | 854 | / 855 | 856 | github-wiki-test-homeless 857 | 858 | 859 | Public 860 |
861 | 862 | 863 |
864 | 865 | 900 | 901 |
902 | 903 |
904 |
905 | 906 | 907 | 1051 | 1052 |
1053 | 1054 | 1055 | 1056 | 1057 | 1058 | 1059 |
1060 | 1061 | 1062 | 1063 | 1064 | 1065 |
1066 |
1067 |
1068 | New page 1069 | 1070 |
1071 |

Pages

1072 |
1073 | 1074 |
1075 |
1076 |
1077 |
    1078 |
  • 1079 |
    1080 |
    1083 |
    1084 | 1085 |
    Last updated Oct 25, 2021
    1086 |
    1087 |
    1088 |
  • 1089 |
  • 1090 |
    1091 |
    1094 |
    1095 | 1096 |
    Last updated Mar 9, 2023
    1097 |
    1098 |
    1099 |
  • 1100 |
  • 1101 |
    1102 |
    1105 |
    1106 | 1107 |
    Last updated Mar 9, 2023
    1108 |
    1109 |
    1110 |
  • 1111 |
1112 |
1113 |
1114 |
1115 |
1116 | 1117 | 1118 |
1119 | 1120 |
1121 | 1122 | 1123 | 1124 |
1125 |
1126 | 1127 |
1128 | 1129 | 1167 | 1168 | 1169 | 1170 | 1171 | 1182 | 1183 | 1191 | 1204 | 1205 | 1209 | 1210 | 1222 | 1223 | 1224 | 1225 | 1226 |
1227 | 1228 |
1229 | 1230 | 1231 | 1232 | --------------------------------------------------------------------------------