37 lines
662 B
Go
37 lines
662 B
Go
|
package main
|
||
|
|
||
|
import (
|
||
|
"github.com/gin-gonic/gin"
|
||
|
"strings"
|
||
|
)
|
||
|
|
||
|
func (conf *config) template(c *gin.Context) {
|
||
|
page := c.Param("page")
|
||
|
code := 200
|
||
|
if !strings.Contains("create index privacy terms", page) {
|
||
|
page = "404"
|
||
|
code = 404
|
||
|
}
|
||
|
if page == "" {
|
||
|
page = "index"
|
||
|
}
|
||
|
c.HTML(code, page+".html", gin.H{
|
||
|
"repoURL": conf.RepoURL,
|
||
|
"demoBotURL": conf.DemoBotURL,
|
||
|
"privacyURL": conf.PrivacyURL,
|
||
|
"termsURL": conf.TermsURL,
|
||
|
})
|
||
|
}
|
||
|
|
||
|
func (conf *config) serveFrontend(r *gin.Engine) {
|
||
|
|
||
|
r.LoadHTMLGlob("frontend/templates/*")
|
||
|
|
||
|
r.GET("/", conf.template)
|
||
|
r.GET("/:page", conf.template)
|
||
|
|
||
|
res := r.Group("/res")
|
||
|
res.Static("/", "./frontend/res")
|
||
|
|
||
|
}
|