Skip to content

Latest commit

 

History

History
195 lines (143 loc) · 7.48 KB

README.md

File metadata and controls

195 lines (143 loc) · 7.48 KB

GMod Wiki Mirror

This project scrapes and mirrors the GMod Wiki.

It also includes a number of enhancments over the original.

You may use the public site, or even host your own for super fast offline access!

Features

  • 🕶️ Custom Darkmode (Thanks @Be1zebub/@Phoenixf129!)
    • Alternatively, this mirror plays nicely with DarkReader!
  • 🚢 Self-hosting with Docker
  • 🏎️ Performance enhancements
    • Significant performance improvements for CSS styling
    • Reduced the total stylesheet size by nearly 90%
    • Noticeable improvements to "Page-to-page" navigation speed
    • Vastly improved navigation performance on Firefox
  • 🧠 Optimized memory usage
    • Caches page content in browser cache rather than Javascript memory
  • 🔎 Fast searching
    • Both basic and full-site searching are implemented
    • Search results are not paginated
  • 🖼️ Optimized images
    • Image size reduced by > 40% with only a small loss in quality
  • ☁️ Hosted entirely on The Cloud
    • Very reliable! Should almost never go down
  • 🤖 Automatic content updates
  • 🛠️ UI bug fixes
  • ?format=json support
  • ~pagelist support (json format only)
  • /gmod/ redirect support
    • This means you can safely redirect all gmod links from wiki.facepunch.com to gmodwiki.com
  • "Copy markdown link" button (Thanks TankNut!)
  • Keyboard navigation/highlighting support for the sidebar
  • All external links open in a new tab

Limitations

Current limitations:

  • No Editing (will not implement)
  • No change history (probably won't implement)
  • All images are mirrored into the .webp format, which has somewhat limited browser support
  • The main page script.js is self-hosted and modified (for performance), meaning any useful updates will need to be manually backported

Self-Hosting

A docker image is provided to support self-hosting use cases.

The image is about 160mb, making it reasonably portable and quick to download 👍

Running the Docker image

First, be sure you have Docker installed.

With docker run

Run the wiki in the background:

docker run --name gmodwiki -p 127.0.0.1:4321:4321 --rm -d ghcr.io/cfc-servers/gmodwiki:latest

Then visit http://localhost:4321 in your browser.

Stopping the background container:

docker stop --time 1 gmodwiki

Useful if you want to leave the site running at all times

👆 Instructions

Download the docker-compose.yml file from this repository and put it somewhere on your machine.

Then, simply docker compose up (or docker-compose up for older docker engines).


You can easily configure the Host and Port when using docker compose.

First, create a .env file in the same directory as the docker-compose.yml, in the format of:

GMODWIKI_HOST=127.0.0.1
GMODWIKI_PORT=4321

Then you can change the Host or Port in that file, and then run docker compose up again.

If you want to expose the wiki instance to the world (not recommended without a reverse proxy like Nginx, and especially not without Cloudflare):

  • Set GMODWIKI_HOST=0.0.0.0
  • Forward your chosen port (4321 by default) in your router/firewall
  • Visit your public IP in your browser: http://<your IP>:<your port>

Hosting your own public instance

If you want to run another global instance for redundancy / host your own version

👆 Instructions

This mirror is made to run on Cloudflare. Deploying is really easy, simply clone the project and run:

npm i;
npm run build;
npm run pages:deploy;

Follow the auth/setup prompts from wrangler.

Then:

  • Visit your Cloudflare dashboard
  • Select "Workers and Pages" from the sidebar
  • Click on your gmodwiki instance
  • Verify that it deployed correctly and that you can visit the latest .pages.dev site listed on the page

If you have your own domain:

  • Go to the "Custom Domains" tab and click "Set up a custom domain" to connect your own domain

Now, set up the redirect rules:

Navigate to Cache Rules:

image

?format=json redirect

⚠️ Be sure to replace gmodwiki.com with your domain!

image

/gmod/ redirect

⚠️ This needs to be the second rule in the rules list!

image

Now, wait about 30 seconds, and then try:

  • Visiting: https://<YOUR DOMAIN>/Player_Animations?format=json and verify that you're redirected to: https://<YOUR DOMAIN>/content/Player_Animations.json
  • Visiting: https://<YOUR DOMAIN>/gmod/Player_Animations and verify that you're redirected to: https://<YOUR DOMAIN>/Player_Animations

Then, you'll need to set up your caching rules:

image

Search Caching Rule (needs to be first in the rule list): image image

Primary Caching Rule:

  • Edge Cache: 3 days
  • Brower Cache: 1 day

⚠️ Be sure to replace gmodwiki.com with your domain!

image image image

Dev

👆 Instructions/Details

Development should be fairly simple:

npm i;
npm run build;
npm run astrobuild;
npm run preview;

Some dev notes:

  • The first npm run build will take awhile as it scrapes the main website
  • Those building on windows may need to run the following command to fix issues with sharp
npm install --force @img/sharp-win32-x64
  • Once built:
    • All downloaded page content will be cached into ./build/cache/
    • All downloaded static content will be cached to ./public/
    • You can remove either of these directories if you need to re-parse the remote content again
  • By default, npm run astrobuild will build the site for self hosting, not cloud hosting. If you need to test the cloud environment, you can run export BUILD_ENV=production before running the build/preview commands