Browse Source

Migrating from custom Pug setup to Hugo

master
Mobius K 10 months ago
parent
commit
33733219e9
  1. 8
      README.md
  2. BIN
      assets/apple-touch-icon.png
  3. 24
      assets/index.scss
  4. 17
      assets/manifest.json
  5. 8
      config/_default/config.yaml
  6. 2
      config/primary/config.yaml
  7. 2
      config/secondary/config.yaml
  8. 10
      content/404.html
  9. 11
      content/500.html
  10. 13
      content/_index.html
  11. 4
      html/routes/404.pug
  12. 5
      html/routes/500.pug
  13. 4
      html/routes/index.pug
  14. 4
      html/routes/offline.pug
  15. 7
      html/templates/error.pug
  16. 37
      html/templates/layout.pug
  17. 51
      layouts/_default/baseof.html
  18. 3
      layouts/_default/single.html
  19. 3
      layouts/index.html
  20. 19
      scripts/index.ts
  21. 42
      scripts/service-worker.ts
  22. 0
      static/favicon.ico
  23. 0
      static/icon.png

8
README.md

@ -1,10 +1,14 @@
# MobiCraft
Community Minecraft server web site
Community Minecraft server web site.
## Sub-module layout
This project is a sub-module of a parent repository that contains dependency resolution files like NPM's `package.json` and Go's `go.mod`, some build tasks in a `Makefile`, and potentially necessary shared code among many other projects.
This project is a sub-module of a parent repository that contains some shared sources:
- Dependency resolution files like NPM's `package.json` and Go's `go.mod`
- Build tasks in a `Makefile`
- Various code and other scripts
It adds some complexity but helps me maintain several similar projects more efficiently.
To setup the necessary structure:
```bash

BIN
assets/apple-touch-icon.png

Before

Width: 192  |  Height: 192  |  Size: 15 KiB

24
styles/index.scss → assets/index.scss

@ -1,30 +1,34 @@
// Content wrapper
html {
background-color: black;
overflow: hidden;
}
body, html {
// Temporary styles until Dynmap plugin works
background-color: black;
box-sizing: border-box;
color: white;
height: 100%;
margin: 0;
min-height: 100%;
min-width: 100%;
padding: 0;
& .center {
font-family: Monospaced, monospace;
font-weight: bold;
margin: 50px auto;
max-width: 400px;
padding: 20px;
text-align: center;
}
box-sizing: border-box;
margin: 0;
padding: 0;
min-width: 100%;
min-height: 100%;
height: 100%;
}
// Fonts
.attribution, .center {
font-family: Monospaced, monospace;
font-weight: bold;
}
// DynMap plugin

17
assets/manifest.json

@ -1,17 +0,0 @@
{
"background_color": "#000000",
"display": "standalone",
"icons": [
{
"sizes": "512x512",
"src": "icon.png",
"type": "image/png",
"purpose": "any maskable"
}
],
"name": "MobiCraft",
"scope": "/",
"short_name": "MobiCraft",
"start_url": "/index.html",
"theme_color": "#8ECDD3"
}

8
config/_default/config.yaml

@ -0,0 +1,8 @@
# Where to read files from (relative to parent mono-repo)
assetDir: mobicraft/assets
contentDir: mobicraft/content
dataDir: mobicraft/data
layoutDir: mobicraft/layouts
staticDir:
- shared/static
- mobicraft/static

2
config/primary/config.yaml

@ -0,0 +1,2 @@
# Hostname root
baseURL: "https://minecraft.mobiusk.com/"

2
config/secondary/config.yaml

@ -0,0 +1,2 @@
# Hostname root
baseURL: "https://qa-minecraft.mobiusk.com/"

10
content/404.html

@ -0,0 +1,10 @@
---
title: Content not found
url: 404.html
---
<div class="error">
<a href="/">&lArr; Return to home page</a>
<br>
The file you are looking for doesn't exist here
</div>

11
content/500.html

@ -0,0 +1,11 @@
---
title: Error
url: 500.html
---
<div class="error">
<a href="/">&lArr; Return to home page</a>
<br>
Something went wrong with this website.
An alert has likely been sent to me, but an email is the fastest way to get bugs fixed and is greatly appreciated.
</div>

13
content/_index.html

@ -0,0 +1,13 @@
---
title: Map
---
<main class="center">
<p>
This server will be dormant until the community wants to restart it.
<br>
Thanks for everything!
</p>
</main>
<!-- Previous map link: <iframe src="https://minecraft.mobiusk.com/map"></iframe> -->

4
html/routes/404.pug

@ -1,4 +0,0 @@
extends /mobicraft/html/templates/error
block message
| The file you are looking for doesn't exist here

5
html/routes/500.pug

@ -1,5 +0,0 @@
extends /mobicraft/html/templates/error
block message
| Something went wrong with this website.
| An alert has likely been sent to me, but an email is the fastest way to get bugs fixed and is greatly appreciated.

4
html/routes/index.pug

@ -1,4 +0,0 @@
extends /mobicraft/html/templates/layout
block content
iframe(src="https://minecraft.mobiusk.com/map")

4
html/routes/offline.pug

@ -1,4 +0,0 @@
extends /mobicraft/html/templates/error
block message
| Please check your Internet connection, your request could not be completed.

7
html/templates/error.pug

@ -1,7 +0,0 @@
extends layout
block content
.error
a(href="/") &lArr; Return to home page
br
block message

37
html/templates/layout.pug

@ -1,37 +0,0 @@
doctype html
html(lang="en")
head
meta(charset="utf-8")
meta(name="description" content="Community Minecraft server map")
meta(name="theme-color" content="#8ECDD3")
meta(name="viewport" content="width=device-width, initial-scale=1")
title MobiCraft
link(rel="icon shortcut" href="/favicon.ico")
link(rel="apple-touch-icon" href="/apple-touch-icon.png")
link(rel="stylesheet" href="/mobicraft.css")
link(rel="manifest" href="/manifest.json" crossorigin="use-credentials")
if release
script(src="/sentry.js" defer)
script(src="/mobicraft.js" defer)
body
block content
aside.attribution
img(src="/icon.png" alt="Logo")
p
| Logo by
|
a(href="https://eluish.wixsite.com/portfolio") Eluish
p
| Server support
|
a(href="https://paypal.me/mobiusk") appreciated

51
layouts/_default/baseof.html

@ -0,0 +1,51 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="description" content="Community Minecraft server map">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>
MobiCraft
{{ with .Params.Title }} - {{ . }} {{ end }}
</title>
<link rel="shortcut icon" href="/favicon.ico">
<!-- Parse styles -->
{{ $scss := resources.Get "index.scss" }}
{{ $style := $scss | toCSS $.Site.Params.scss }}
<!-- Fingerprint assets -->
{{ if $.Site.Params.fingerprint.enabled }}
{{ $style = $style | fingerprint $.Site.Params.fingerprint.algorithm }}
{{ end }}
<!-- Link assets -->
<link rel="stylesheet" href="{{ $style.RelPermalink }}">
</head>
<body>
{{ block "main" . }}{{ end }}
<aside class="attribution">
<img alt="Logo" src="/icon.png">
<p>
Logo by
<a href="https://pixelle.cc">Elle</a>
</p>
</aside>
</body>
</html>

3
layouts/_default/single.html

@ -0,0 +1,3 @@
{{ define "main" }}
{{ .Content }}
{{ end }}

3
layouts/index.html

@ -0,0 +1,3 @@
{{ define "main" }}
{{ .Content }}
{{ end }}

19
scripts/index.ts

@ -1,19 +0,0 @@
import { release } from "shared/config/build.dev";
import { ErrorMonitor } from "shared/scripts/error-monitor";
if (release) {
// Start the error watcher
new ErrorMonitor(
"mobicraft",
"https://c5f560addbb54259813114527ad60479@o127434.ingest.sentry.io/5178461"
);
// Load our service worker to enable PWA functionality
if ("serviceWorker" in navigator) {
window.addEventListener("load", () => {
navigator.serviceWorker.register("/service-worker.js").then();
});
}
}

42
scripts/service-worker.ts

@ -1,42 +0,0 @@
import { ServiceWorkerCache } from "shared/scripts/service-worker-cache";
/* eslint-disable @typescript-eslint/ban-ts-comment */
// Cache manipulator
const cache: ServiceWorkerCache = new ServiceWorkerCache("replaceAtBuildWithDate");
// @ts-ignore Install the service worker and cache any files for offline use
self.addEventListener("install", (event: InstallEvent) => event.waitUntil(
cache.initialize([
"/404.html",
"/favicon.ico",
"/icon.png",
"/index.html",
"/manifest.json",
"/offline.html",
"/mobicraft.css",
"/mobicraft.js",
"/robots.txt",
"/sentry.js"
]).then(() =>
// @ts-ignore New service workers require a tab close and re-open to activate without this
self.skipWaiting()
)
));
// @ts-ignore Activate the service worker and remove previous caches
self.addEventListener("activate", (event: ExtendableEvent) => event.waitUntil(
cache.deletePreviousCaching().then(() =>
// @ts-ignore New service workers can immediately take control over current service workers
self.clients.claim()
)
));
// @ts-ignore Response priority: Cache > Network > Offline message
self.addEventListener("fetch", (event: FetchEvent) => event.respondWith(
cache.fetchOrFallback(
event.request,
() => fetch(event.request),
() => cache.match("/offline.html")
)
));

0
assets/favicon.ico → static/favicon.ico

0
assets/icon.png → static/icon.png

Before

Width: 512  |  Height: 512  |  Size: 19 KiB

After

Width: 512  |  Height: 512  |  Size: 19 KiB

Loading…
Cancel
Save