mirror of
https://codeberg.org/VnPower/PixivFE
synced 2024-12-06 19:16:23 +01:00
62 lines
1.2 KiB
Go
62 lines
1.2 KiB
Go
package pages
|
|
|
|
import (
|
|
"strconv"
|
|
"strings"
|
|
|
|
session "codeberg.org/vnpower/pixivfe/v2/core/config"
|
|
core "codeberg.org/vnpower/pixivfe/v2/core/webapi"
|
|
"github.com/gofiber/fiber/v2"
|
|
)
|
|
|
|
func LoginUserPage(c *fiber.Ctx) error {
|
|
token := session.CheckToken(c)
|
|
|
|
if token == "" {
|
|
return c.Redirect("/settings")
|
|
}
|
|
|
|
// The left part of the token is the member ID
|
|
userId := strings.Split(token, "_")
|
|
|
|
c.Redirect("/users/" + userId[0])
|
|
return nil
|
|
}
|
|
|
|
func LoginBookmarkPage(c *fiber.Ctx) error {
|
|
token := session.CheckToken(c)
|
|
if token == "" {
|
|
return c.Redirect("/settings")
|
|
}
|
|
|
|
// The left part of the token is the member ID
|
|
userId := strings.Split(token, "_")
|
|
|
|
c.Redirect("/users/" + userId[0] + "/bookmarks#checkpoint")
|
|
return nil
|
|
}
|
|
|
|
func FollowingWorksPage(c *fiber.Ctx) error {
|
|
if token := session.CheckToken(c); token == "" {
|
|
return c.Redirect("/settings")
|
|
}
|
|
|
|
mode := c.Query("mode", "all")
|
|
page := c.Query("page", "1")
|
|
|
|
pageInt, _ := strconv.Atoi(page)
|
|
|
|
works, err := core.GetNewestFromFollowing(c, mode, page)
|
|
if err != nil {
|
|
return err
|
|
}
|
|
|
|
return c.Render("pages/following", fiber.Map{
|
|
"Title": "Following works",
|
|
"Mode": mode,
|
|
"Artworks": works,
|
|
"CurPage": page,
|
|
"Page": pageInt,
|
|
})
|
|
}
|