2023-05-13 03:34:31 +00:00
|
|
|
package main
|
|
|
|
|
|
|
|
import (
|
2023-05-13 12:25:32 +00:00
|
|
|
"html/template"
|
2023-05-18 13:18:44 +00:00
|
|
|
"pixivfe/configs"
|
2023-05-16 12:35:39 +00:00
|
|
|
"pixivfe/views"
|
2023-05-13 03:34:31 +00:00
|
|
|
|
|
|
|
"github.com/gin-gonic/gin"
|
|
|
|
)
|
|
|
|
|
2023-05-16 12:35:39 +00:00
|
|
|
func setupRouter() *gin.Engine {
|
2023-05-13 10:03:13 +00:00
|
|
|
server := gin.Default()
|
2023-05-16 12:35:39 +00:00
|
|
|
|
2023-05-13 12:25:32 +00:00
|
|
|
server.SetFuncMap(template.FuncMap{
|
2023-05-16 12:35:39 +00:00
|
|
|
"inc": func(n int) int {
|
2023-05-19 05:15:27 +00:00
|
|
|
// For rankings to increment a number by 1
|
2023-05-16 12:35:39 +00:00
|
|
|
return n + 1
|
|
|
|
},
|
2023-05-19 05:15:27 +00:00
|
|
|
|
|
|
|
"isEmpty": func(s string) bool {
|
|
|
|
return len(s) < 1
|
|
|
|
},
|
2023-05-13 12:25:32 +00:00
|
|
|
})
|
2023-05-16 12:35:39 +00:00
|
|
|
|
|
|
|
// Static files
|
2023-05-14 12:30:03 +00:00
|
|
|
server.StaticFile("/favicon.ico", "./template/favicon.ico")
|
2023-05-13 10:03:13 +00:00
|
|
|
server.Static("css/", "./template/css")
|
2023-05-16 12:35:39 +00:00
|
|
|
|
|
|
|
// HTML templates, automatically loaded
|
2023-05-13 10:03:13 +00:00
|
|
|
server.LoadHTMLGlob("template/*.html")
|
|
|
|
|
2023-05-16 12:35:39 +00:00
|
|
|
// Routes/Views
|
|
|
|
views.SetupRoutes(server)
|
|
|
|
|
|
|
|
return server
|
|
|
|
}
|
|
|
|
|
|
|
|
func main() {
|
2023-05-18 13:18:44 +00:00
|
|
|
configs.Configs.ReadConfig()
|
|
|
|
|
2023-05-16 12:35:39 +00:00
|
|
|
r := setupRouter()
|
|
|
|
|
|
|
|
r.Run(":8080")
|
2023-05-13 03:34:31 +00:00
|
|
|
}
|