2023-05-16 12:35:39 +00:00
|
|
|
package views
|
|
|
|
|
|
|
|
import (
|
|
|
|
"github.com/gin-gonic/gin"
|
|
|
|
"net/http"
|
|
|
|
"pixivfe/handler"
|
|
|
|
"strconv"
|
|
|
|
)
|
|
|
|
|
|
|
|
func artwork_page(c *gin.Context) {
|
2023-05-16 12:59:42 +00:00
|
|
|
illust, _ := handler.GetIllustByID(c)
|
|
|
|
related, _ := handler.GetRelatedIllust(c)
|
|
|
|
recent_by_artist, _ := handler.GetMemberIllust(c, strconv.Itoa(illust.Artist.ID))
|
2023-05-16 12:35:39 +00:00
|
|
|
c.HTML(http.StatusOK, "artwork.html", gin.H{
|
|
|
|
"Illust": illust,
|
|
|
|
"Related": related,
|
|
|
|
"Recent": recent_by_artist,
|
|
|
|
})
|
|
|
|
}
|
|
|
|
|
|
|
|
func index_page(c *gin.Context) {
|
2023-05-16 12:59:42 +00:00
|
|
|
recommended, _ := handler.GetRecommendedIllust(c)
|
|
|
|
ranking, _ := handler.GetRankingIllust(c, "day")
|
2023-05-16 12:35:39 +00:00
|
|
|
spotlight := handler.GetSpotlightArticle(c)
|
2023-05-16 12:59:42 +00:00
|
|
|
newest, _ := handler.GetNewestIllust(c)
|
2023-05-16 12:35:39 +00:00
|
|
|
c.HTML(http.StatusOK, "index.html", gin.H{
|
|
|
|
"Recommended": recommended,
|
|
|
|
"Rankings": ranking,
|
|
|
|
"Spotlights": spotlight,
|
|
|
|
"Newest": newest,
|
|
|
|
})
|
|
|
|
}
|
|
|
|
|
2023-05-16 15:07:17 +00:00
|
|
|
func user_page(c *gin.Context) {
|
|
|
|
user, _ := handler.GetUserInfo(c)
|
|
|
|
recent, _ := handler.GetMemberIllust(c, c.Param("id"))
|
|
|
|
c.HTML(http.StatusOK, "user.html", gin.H{"User": user, "Recent": recent})
|
|
|
|
}
|
|
|
|
|
2023-05-16 12:35:39 +00:00
|
|
|
func SetupRoutes(r *gin.Engine) {
|
|
|
|
r.GET("/", index_page)
|
|
|
|
r.GET("artworks/:id", artwork_page)
|
2023-05-16 15:07:17 +00:00
|
|
|
r.GET("user/:id", user_page)
|
2023-05-16 12:35:39 +00:00
|
|
|
}
|