proper-website-2/src/main.go

101 lines
2.7 KiB
Go
Raw Normal View History

2022-03-01 14:36:04 +01:00
package main
import (
2022-03-24 15:55:18 +01:00
"compress/gzip"
2022-03-01 14:36:04 +01:00
"log"
"net/http"
2022-05-27 20:35:53 +02:00
"os"
2022-03-01 14:36:04 +01:00
2022-03-24 14:31:02 +01:00
"github.com/gorilla/handlers"
2022-03-01 14:36:04 +01:00
"github.com/maxence-charriere/go-app/v9/pkg/app"
)
2022-03-12 15:52:13 +01:00
//type application struct {
// client *mongo.Client
// database *mongo.Database
// collection *mongo.Collection
//}
2022-03-01 14:36:04 +01:00
func main() {
2022-03-15 12:48:47 +01:00
homepage := NewHomepage()
aboutpage := NewAboutPage()
galaxiespage := NewGalaxiesPage()
2022-03-18 22:45:29 +01:00
undertalePage := NewUndertalePage()
2022-04-19 22:30:47 +02:00
musicPage := NewMusicPage()
2022-03-01 15:50:53 +01:00
app.Route("/", homepage)
2022-03-01 17:07:33 +01:00
app.Route("/about", aboutpage)
app.Route("/galaxies", galaxiespage)
2022-03-18 22:45:29 +01:00
app.Route("/undertale", undertalePage)
2022-03-25 13:51:25 +01:00
app.Route("/blog", NewBlogPage())
2022-04-19 22:30:47 +02:00
app.Route("/music", musicPage)
2022-03-01 14:36:04 +01:00
2022-03-15 12:48:47 +01:00
app.Handle(getHTML, handleGetHTML)
2022-03-01 15:50:53 +01:00
// This is executed on the client side only.
// It handles client side stuff
// It exits immediately on the server side
2022-03-01 14:36:04 +01:00
app.RunWhenOnBrowser()
2022-03-13 15:27:47 +01:00
icon := &app.Icon{
Default: "/web/static/images/icon-small.png",
Large: "/web/static/images/icon.png",
}
2022-03-12 15:52:13 +01:00
handler := &app.Handler{
2022-03-13 15:27:47 +01:00
Name: "Internetica Galactica",
Icon: *icon,
BackgroundColor: "#362730",
ThemeColor: "#362730",
LoadingLabel: "Internetica Galactica",
Title: "Internetica Galactica",
Description: "A 1990's style PWA!",
Author: "Quenten",
Keywords: []string{
"Based website",
"Cool website",
"PWA",
"Programming",
"Go", "Golang",
"Webassembly", "WASM",
"DutchEllie", "Quenten",
},
2022-03-01 15:50:53 +01:00
Styles: []string{
"/web/static/style.css",
2022-03-01 19:45:23 +01:00
"/web/static/adreena.css",
2022-03-01 15:50:53 +01:00
"/web/static/anisha.css",
2022-03-01 19:45:23 +01:00
"/web/static/havakana.css",
2022-03-15 16:42:26 +01:00
"/web/static/form.css",
2022-03-01 15:50:53 +01:00
},
2022-03-16 13:13:14 +01:00
CacheableResources: []string{
// Images
"/web/static/images/email3.gif",
"/web/static/images/rin-len1.webp",
"/web/static/images/background_star.gif",
"/web/static/images/kanata-1.gif",
"/web/static/images/rin-1.gif",
"/web/static/images/rin-2.gif",
2022-04-18 13:51:17 +02:00
"/web/static/images/gnu-head-sm.png",
2022-03-16 13:13:14 +01:00
// Pages
"/web/blocks/pages/about.html",
"/web/blocks/pages/intro.html",
"/web/blocks/snippets/bannerpanel.html",
// Music
"https://music-website.s3.nl-ams.scw.cloud/Tokusya-Seizon%20Wonder-la-der%21%21.mp3",
2022-04-20 18:07:52 +02:00
"https://music-website.s3.nl-ams.scw.cloud/kegarenaki-barajuuji.mp3",
2022-04-25 14:29:37 +02:00
"https://music-website.s3.nl-ams.scw.cloud/error-towa.mp3",
2022-05-14 22:24:14 +02:00
"https://music-website.s3.nl-ams.scw.cloud/diamond-city-lights-lazulight.opus",
"https://music-website.s3.nl-ams.scw.cloud/tsunami-finana.opus",
2022-03-16 13:13:14 +01:00
},
2022-03-12 15:52:13 +01:00
}
app.GenerateStaticWebsite("./staticsite", handler)
2022-03-24 15:55:18 +01:00
compressed := handlers.CompressHandlerLevel(handler, gzip.BestSpeed)
2022-03-24 14:31:02 +01:00
http.Handle("/", compressed)
2022-05-27 20:35:53 +02:00
if os.Getenv("GEN_STATIC_SITE") == "true" {
return
}
2022-03-01 14:36:04 +01:00
if err := http.ListenAndServe(":8000", nil); err != nil {
log.Fatal(err)
}
}