1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283 |
- package main
- import (
- "fmt"
- "log"
- "os"
- "github.com/gin-contrib/multitemplate"
- "github.com/gin-gonic/gin"
- "git.aetherial.dev/aeth/keiji/pkg/env"
- "git.aetherial.dev/aeth/keiji/pkg/routes"
- )
- var WEB_ROOT string
- var DOMAIN_NAME string
- func main() {
- args := os.Args
- err := env.LoadAndVerifyEnv(args[1], env.REQUIRED_VARS)
- if err != nil {
- log.Fatal("Error when loading env file: ", err)
- }
- REDIS_PORT := os.Getenv("REDIS_PORT")
- REDIS_ADDR := os.Getenv("REDIS_ADDR")
- renderer := multitemplate.NewRenderer()
- renderer.AddFromFiles(
- "home",
- fmt.Sprintf("%s/templates/home.html", WEB_ROOT),
- fmt.Sprintf("%s/templates/navigation.html", WEB_ROOT),
- fmt.Sprintf("%s/templates/menu.html", WEB_ROOT),
- fmt.Sprintf("%s/templates/link.html", WEB_ROOT),
- fmt.Sprintf("%s/templates/listing.html", WEB_ROOT),
- )
- renderer.AddFromFiles(
- "blogpost",
- fmt.Sprintf("%s/templates/blogpost.html", WEB_ROOT),
- fmt.Sprintf("%s/templates/navigation.html", WEB_ROOT),
- fmt.Sprintf("%s/templates/menu.html", WEB_ROOT),
- fmt.Sprintf("%s/templates/link.html", WEB_ROOT),
- )
- renderer.AddFromFiles(
- "digital_art",
- fmt.Sprintf("%s/templates/digital_art.html", WEB_ROOT),
- fmt.Sprintf("%s/templates/centered_image.html", WEB_ROOT),
- fmt.Sprintf("%s/templates/navigation.html", WEB_ROOT),
- fmt.Sprintf("%s/templates/menu.html", WEB_ROOT),
- fmt.Sprintf("%s/templates/link.html", WEB_ROOT),
- )
- renderer.AddFromFiles(
- "login",
- fmt.Sprintf("%s/templates/login.html", WEB_ROOT),
- )
- renderer.AddFromFiles(
- "admin",
- fmt.Sprintf("%s/templates/admin.html", WEB_ROOT),
- fmt.Sprintf("%s/templates/menu.html", WEB_ROOT),
- fmt.Sprintf("%s/templates/link.html", WEB_ROOT),
- fmt.Sprintf("%s/templates/navigation.html", WEB_ROOT),
- fmt.Sprintf("%s/templates/listing.html", WEB_ROOT),
- )
- renderer.AddFromFiles(
- "blogpost_editor",
- fmt.Sprintf("%s/templates/blogpost_editor.html", WEB_ROOT),
- fmt.Sprintf("%s/templates/menu.html", WEB_ROOT),
- fmt.Sprintf("%s/templates/link.html", WEB_ROOT),
- fmt.Sprintf("%s/templates/upload_status.html", WEB_ROOT),
- fmt.Sprintf("%s/templates/navigation.html", WEB_ROOT),
- fmt.Sprintf("%s/templates/listing.html", WEB_ROOT),
- )
- renderer.AddFromFiles(
- "upload_status",
- fmt.Sprintf("%s/templates/upload_status.html", WEB_ROOT),
- )
- e := gin.Default()
- e.HTMLRender = renderer
- routes.Register(e, WEB_ROOT, DOMAIN_NAME, REDIS_PORT, REDIS_ADDR)
- e.RunTLS(fmt.Sprintf("%s:%s", os.Getenv("HOST_ADDR"), os.Getenv("HOST_PORT")),
- os.Getenv(env.CHAIN), os.Getenv(env.KEY))
- }
|