mirror of
https://codeberg.org/VnPower/PixivFE
synced 2024-12-06 19:16:23 +01:00
move files around
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
package doc
|
||||
package config
|
||||
|
||||
const BuiltinProxyUrl = "/proxy/i.pximg.net" // built-in proxy route
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
// For development, set in addition `PIXIVFE_DEV=true`.
|
||||
// How to get PIXIVFE_TOKEN is described in How-to-get-the-pixiv-token.md.
|
||||
|
||||
package doc
|
||||
package config
|
||||
|
||||
import (
|
||||
"log"
|
||||
@@ -1,6 +1,6 @@
|
||||
// Global (Server-Wide) Settings
|
||||
|
||||
package core
|
||||
package config
|
||||
|
||||
import (
|
||||
"errors"
|
||||
@@ -10,8 +10,6 @@ import (
|
||||
"strconv"
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
"codeberg.org/vnpower/pixivfe/v2/doc"
|
||||
)
|
||||
|
||||
var GlobalServerConfig ServerConfig
|
||||
@@ -41,9 +39,9 @@ type ServerConfig struct {
|
||||
func (s *ServerConfig) InitializeConfig() error {
|
||||
s.setVersion()
|
||||
|
||||
doc.CollectAllEnv()
|
||||
CollectAllEnv()
|
||||
|
||||
token, hasToken := doc.LookupEnv("PIXIVFE_TOKEN")
|
||||
token, hasToken := LookupEnv("PIXIVFE_TOKEN")
|
||||
if !hasToken {
|
||||
log.Fatalln("PIXIVFE_TOKEN is required, but was not set.")
|
||||
return errors.New("PIXIVFE_TOKEN is required, but was not set.\n")
|
||||
@@ -51,8 +49,8 @@ func (s *ServerConfig) InitializeConfig() error {
|
||||
// TODO Maybe add some testing?
|
||||
s.Token = strings.Split(token, ",")
|
||||
|
||||
port, hasPort := doc.LookupEnv("PIXIVFE_PORT")
|
||||
socket, hasSocket := doc.LookupEnv("PIXIVFE_UNIXSOCKET")
|
||||
port, hasPort := LookupEnv("PIXIVFE_PORT")
|
||||
socket, hasSocket := LookupEnv("PIXIVFE_UNIXSOCKET")
|
||||
if !hasPort && !hasSocket {
|
||||
log.Fatalln("Either PIXIVFE_PORT or PIXIVFE_UNIXSOCKET has to be set.")
|
||||
return errors.New("Either PIXIVFE_PORT or PIXIVFE_UNIXSOCKET has to be set.")
|
||||
@@ -60,20 +58,20 @@ func (s *ServerConfig) InitializeConfig() error {
|
||||
s.Port = port
|
||||
s.UnixSocket = socket
|
||||
|
||||
_, hasDev := doc.LookupEnv("PIXIVFE_DEV")
|
||||
_, hasDev := LookupEnv("PIXIVFE_DEV")
|
||||
s.InDevelopment = hasDev
|
||||
|
||||
s.Host = doc.GetEnv("PIXIVFE_HOST")
|
||||
s.Host = GetEnv("PIXIVFE_HOST")
|
||||
|
||||
s.UserAgent = doc.GetEnv("PIXIVFE_USERAGENT")
|
||||
s.UserAgent = GetEnv("PIXIVFE_USERAGENT")
|
||||
|
||||
s.AcceptLanguage = doc.GetEnv("PIXIVFE_ACCEPTLANGUAGE")
|
||||
s.AcceptLanguage = GetEnv("PIXIVFE_ACCEPTLANGUAGE")
|
||||
|
||||
s.SetRequestLimit(doc.GetEnv("PIXIVFE_REQUESTLIMIT"))
|
||||
s.SetRequestLimit(GetEnv("PIXIVFE_REQUESTLIMIT"))
|
||||
|
||||
s.SetProxyServer(doc.GetEnv("PIXIVFE_IMAGEPROXY"))
|
||||
s.SetProxyServer(GetEnv("PIXIVFE_IMAGEPROXY"))
|
||||
|
||||
doc.AnnounceAllEnv()
|
||||
AnnounceAllEnv()
|
||||
|
||||
s.setStartingTime()
|
||||
|
||||
@@ -13,13 +13,13 @@ import (
|
||||
"syscall"
|
||||
"time"
|
||||
|
||||
config "codeberg.org/vnpower/pixivfe/v2/core/config"
|
||||
core_http "codeberg.org/vnpower/pixivfe/v2/core/http"
|
||||
session "codeberg.org/vnpower/pixivfe/v2/core/session"
|
||||
config "codeberg.org/vnpower/pixivfe/v2/config"
|
||||
core_http "codeberg.org/vnpower/pixivfe/v2/pixiv"
|
||||
session "codeberg.org/vnpower/pixivfe/v2/session"
|
||||
|
||||
"codeberg.org/vnpower/pixivfe/v2/core/kmutex"
|
||||
"codeberg.org/vnpower/pixivfe/v2/pages"
|
||||
"codeberg.org/vnpower/pixivfe/v2/serve"
|
||||
pages "codeberg.org/vnpower/pixivfe/v2/routes"
|
||||
serve "codeberg.org/vnpower/pixivfe/v2/utils"
|
||||
"codeberg.org/vnpower/pixivfe/v2/utils/kmutex"
|
||||
"github.com/goccy/go-json"
|
||||
"github.com/gofiber/fiber/v2"
|
||||
"github.com/gofiber/fiber/v2/middleware/cache"
|
||||
|
||||
@@ -1,16 +0,0 @@
|
||||
package pages
|
||||
|
||||
import (
|
||||
"codeberg.org/vnpower/pixivfe/v2/core/config"
|
||||
"github.com/gofiber/fiber/v2"
|
||||
)
|
||||
|
||||
func AboutPage(c *fiber.Ctx) error {
|
||||
info := fiber.Map{
|
||||
"Time": core.GlobalServerConfig.StartingTime,
|
||||
"Version": core.GlobalServerConfig.Version,
|
||||
"ImageProxy": core.GlobalServerConfig.ProxyServer.String(),
|
||||
"AcceptLanguage": core.GlobalServerConfig.AcceptLanguage,
|
||||
}
|
||||
return c.Render("about", info)
|
||||
}
|
||||
@@ -1 +0,0 @@
|
||||
package pages
|
||||
@@ -1,11 +0,0 @@
|
||||
package pages
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
|
||||
"github.com/gofiber/fiber/v2"
|
||||
)
|
||||
|
||||
func PreloadImage(c *fiber.Ctx, url string) {
|
||||
c.Response().Header.Add("Link", fmt.Sprintf("<%s>; rel=preload; as=image", url))
|
||||
}
|
||||
@@ -1,4 +1,4 @@
|
||||
package core
|
||||
package pixiv
|
||||
|
||||
import (
|
||||
"errors"
|
||||
@@ -9,8 +9,7 @@ import (
|
||||
"sync"
|
||||
"time"
|
||||
|
||||
http "codeberg.org/vnpower/pixivfe/v2/core/http"
|
||||
session "codeberg.org/vnpower/pixivfe/v2/core/session"
|
||||
session "codeberg.org/vnpower/pixivfe/v2/session"
|
||||
"github.com/goccy/go-json"
|
||||
"github.com/gofiber/fiber/v2"
|
||||
)
|
||||
@@ -135,9 +134,9 @@ type Illust struct {
|
||||
func GetUserBasicInformation(c *fiber.Ctx, id string) (UserBrief, error) {
|
||||
var user UserBrief
|
||||
|
||||
URL := http.GetUserInformationURL(id)
|
||||
URL := GetUserInformationURL(id)
|
||||
|
||||
response, err := http.UnwrapWebAPIRequest(c.Context(), URL, "")
|
||||
response, err := UnwrapWebAPIRequest(c.Context(), URL, "")
|
||||
if err != nil {
|
||||
return user, err
|
||||
}
|
||||
@@ -155,9 +154,9 @@ func GetArtworkImages(c *fiber.Ctx, id string) ([]Image, error) {
|
||||
var resp []ImageResponse
|
||||
var images []Image
|
||||
|
||||
URL := http.GetArtworkImagesURL(id)
|
||||
URL := GetArtworkImagesURL(id)
|
||||
|
||||
response, err := http.UnwrapWebAPIRequest(c.Context(), URL, "")
|
||||
response, err := UnwrapWebAPIRequest(c.Context(), URL, "")
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@@ -194,9 +193,9 @@ func GetArtworkComments(c *fiber.Ctx, id string) ([]Comment, error) {
|
||||
Comments []Comment `json:"comments"`
|
||||
}
|
||||
|
||||
URL := http.GetArtworkCommentsURL(id)
|
||||
URL := GetArtworkCommentsURL(id)
|
||||
|
||||
response, err := http.UnwrapWebAPIRequest(c.Context(), URL, "")
|
||||
response, err := UnwrapWebAPIRequest(c.Context(), URL, "")
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@@ -216,9 +215,9 @@ func GetRelatedArtworks(c *fiber.Ctx, id string) ([]ArtworkBrief, error) {
|
||||
}
|
||||
|
||||
// TODO: keep the hard-coded limit?
|
||||
URL := http.GetArtworkRelatedURL(id, 96)
|
||||
URL := GetArtworkRelatedURL(id, 96)
|
||||
|
||||
response, err := http.UnwrapWebAPIRequest(c.Context(), URL, "")
|
||||
response, err := UnwrapWebAPIRequest(c.Context(), URL, "")
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@@ -234,10 +233,10 @@ func GetRelatedArtworks(c *fiber.Ctx, id string) ([]ArtworkBrief, error) {
|
||||
}
|
||||
|
||||
func GetArtworkByID(c *fiber.Ctx, id string, full bool) (*Illust, error) {
|
||||
URL := http.GetArtworkInformationURL(id)
|
||||
URL := GetArtworkInformationURL(id)
|
||||
|
||||
token := session.GetPixivToken(c)
|
||||
response, err := http.UnwrapWebAPIRequest(c.Context(), URL, token)
|
||||
response, err := UnwrapWebAPIRequest(c.Context(), URL, token)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@@ -1,10 +1,9 @@
|
||||
package core
|
||||
package pixiv
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
|
||||
session "codeberg.org/vnpower/pixivfe/v2/core/session"
|
||||
http "codeberg.org/vnpower/pixivfe/v2/core/http"
|
||||
session "codeberg.org/vnpower/pixivfe/v2/session"
|
||||
"github.com/goccy/go-json"
|
||||
"github.com/gofiber/fiber/v2"
|
||||
"github.com/tidwall/gjson"
|
||||
@@ -13,11 +12,11 @@ import (
|
||||
func GetDiscoveryArtwork(c *fiber.Ctx, mode string) ([]ArtworkBrief, error) {
|
||||
token := session.GetPixivToken(c)
|
||||
|
||||
URL := http.GetDiscoveryURL(mode, 100)
|
||||
URL := GetDiscoveryURL(mode, 100)
|
||||
|
||||
var artworks []ArtworkBrief
|
||||
|
||||
resp, err := http.UnwrapWebAPIRequest(c.Context(), URL, token)
|
||||
resp, err := UnwrapWebAPIRequest(c.Context(), URL, token)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@@ -38,11 +37,11 @@ func GetDiscoveryArtwork(c *fiber.Ctx, mode string) ([]ArtworkBrief, error) {
|
||||
func GetDiscoveryNovels(c *fiber.Ctx, mode string) ([]NovelBrief, error) {
|
||||
token := session.GetPixivToken(c)
|
||||
|
||||
URL := http.GetDiscoveryNovelURL(mode, 100)
|
||||
URL := GetDiscoveryNovelURL(mode, 100)
|
||||
|
||||
var novels []NovelBrief
|
||||
|
||||
resp, err := http.UnwrapWebAPIRequest(c.Context(), URL, token)
|
||||
resp, err := UnwrapWebAPIRequest(c.Context(), URL, token)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@@ -1,4 +1,4 @@
|
||||
package core
|
||||
package pixiv
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
@@ -1,10 +1,9 @@
|
||||
package core
|
||||
package pixiv
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
|
||||
session "codeberg.org/vnpower/pixivfe/v2/core/session"
|
||||
http "codeberg.org/vnpower/pixivfe/v2/core/http"
|
||||
session "codeberg.org/vnpower/pixivfe/v2/session"
|
||||
"github.com/goccy/go-json"
|
||||
"github.com/gofiber/fiber/v2"
|
||||
"github.com/tidwall/gjson"
|
||||
@@ -43,16 +42,16 @@ func GetLanding(c *fiber.Ctx, mode string) (*LandingArtworks, error) {
|
||||
// UserRecommended []any `json:"recommendUser"`
|
||||
// Commission []any `json:"completeRequestIds"`
|
||||
RecommendedByTags []struct {
|
||||
Name string `json:"tag"`
|
||||
IDs []string `json:"ids"`
|
||||
Name string `json:"tag"`
|
||||
IDs []string `json:"ids"`
|
||||
} `json:"recommendByTag"`
|
||||
}
|
||||
|
||||
URL := http.GetLandingURL(mode)
|
||||
URL := GetLandingURL(mode)
|
||||
|
||||
var landing LandingArtworks
|
||||
|
||||
resp, err := http.UnwrapWebAPIRequest(c.Context(), URL, "")
|
||||
resp, err := UnwrapWebAPIRequest(c.Context(), URL, "")
|
||||
|
||||
if err != nil {
|
||||
return &landing, err
|
||||
@@ -1,22 +1,21 @@
|
||||
package core
|
||||
package pixiv
|
||||
|
||||
import (
|
||||
session "codeberg.org/vnpower/pixivfe/v2/core/session"
|
||||
http "codeberg.org/vnpower/pixivfe/v2/core/http"
|
||||
session "codeberg.org/vnpower/pixivfe/v2/session"
|
||||
"github.com/goccy/go-json"
|
||||
"github.com/gofiber/fiber/v2"
|
||||
)
|
||||
|
||||
func GetNewestArtworks(c *fiber.Ctx, worktype string, r18 string) ([]ArtworkBrief, error) {
|
||||
token := session.GetPixivToken(c)
|
||||
URL := http.GetNewestArtworksURL(worktype, r18, "0")
|
||||
URL := GetNewestArtworksURL(worktype, r18, "0")
|
||||
|
||||
var body struct {
|
||||
Artworks []ArtworkBrief `json:"illusts"`
|
||||
// LastId string
|
||||
}
|
||||
|
||||
resp, err := http.UnwrapWebAPIRequest(c.Context(), URL, token)
|
||||
resp, err := UnwrapWebAPIRequest(c.Context(), URL, token)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@@ -1,12 +1,11 @@
|
||||
package core
|
||||
package pixiv
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"regexp"
|
||||
"time"
|
||||
|
||||
http "codeberg.org/vnpower/pixivfe/v2/core/http"
|
||||
session "codeberg.org/vnpower/pixivfe/v2/core/session"
|
||||
session "codeberg.org/vnpower/pixivfe/v2/session"
|
||||
"github.com/goccy/go-json"
|
||||
"github.com/gofiber/fiber/v2"
|
||||
)
|
||||
@@ -93,9 +92,9 @@ type NovelBrief struct {
|
||||
func GetNovelByID(c *fiber.Ctx, id string) (Novel, error) {
|
||||
var novel Novel
|
||||
|
||||
URL := http.GetNovelURL(id)
|
||||
URL := GetNovelURL(id)
|
||||
|
||||
response, err := http.UnwrapWebAPIRequest(c.Context(), URL, "")
|
||||
response, err := UnwrapWebAPIRequest(c.Context(), URL, "")
|
||||
if err != nil {
|
||||
return novel, err
|
||||
}
|
||||
@@ -114,8 +113,8 @@ func GetNovelByID(c *fiber.Ctx, id string) (Novel, error) {
|
||||
novel.Content = r.ReplaceAllStringFunc(novel.Content, func(s string) string {
|
||||
illustid := d.FindString(s)
|
||||
|
||||
URL := http.GetInsertIllustURL(novel.ID, illustid)
|
||||
response, err := http.UnwrapWebAPIRequest(c.Context(), URL, "")
|
||||
URL := GetInsertIllustURL(novel.ID, illustid)
|
||||
response, err := UnwrapWebAPIRequest(c.Context(), URL, "")
|
||||
if err != nil {
|
||||
return "Cannot insert illust" + illustid
|
||||
}
|
||||
@@ -135,9 +134,9 @@ func GetNovelRelated(c *fiber.Ctx, id string) ([]NovelBrief, error) {
|
||||
}
|
||||
|
||||
// hard-coded value, may change
|
||||
URL := http.GetNovelRelatedURL(id, 50)
|
||||
URL := GetNovelRelatedURL(id, 50)
|
||||
|
||||
response, err := http.UnwrapWebAPIRequest(c.Context(), URL, "")
|
||||
response, err := UnwrapWebAPIRequest(c.Context(), URL, "")
|
||||
if err != nil {
|
||||
return novels.List, err
|
||||
}
|
||||
@@ -1,15 +1,15 @@
|
||||
package core
|
||||
package pixiv
|
||||
|
||||
import (
|
||||
session "codeberg.org/vnpower/pixivfe/v2/core/session"
|
||||
http "codeberg.org/vnpower/pixivfe/v2/core/http"
|
||||
session "codeberg.org/vnpower/pixivfe/v2/session"
|
||||
|
||||
"github.com/goccy/go-json"
|
||||
"github.com/gofiber/fiber/v2"
|
||||
)
|
||||
|
||||
func GetNewestFromFollowing(c *fiber.Ctx, mode, page string) ([]ArtworkBrief, error) {
|
||||
token := session.GetPixivToken(c)
|
||||
URL := http.GetNewestFromFollowingURL(mode, page)
|
||||
URL := GetNewestFromFollowingURL(mode, page)
|
||||
|
||||
var body struct {
|
||||
Thumbnails json.RawMessage `json:"thumbnails"`
|
||||
@@ -19,7 +19,7 @@ func GetNewestFromFollowing(c *fiber.Ctx, mode, page string) ([]ArtworkBrief, er
|
||||
Artworks []ArtworkBrief `json:"illust"`
|
||||
}
|
||||
|
||||
resp, err := http.UnwrapWebAPIRequest(c.Context(), URL, token)
|
||||
resp, err := UnwrapWebAPIRequest(c.Context(), URL, token)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@@ -1,11 +1,11 @@
|
||||
package core
|
||||
package pixiv
|
||||
|
||||
import (
|
||||
"errors"
|
||||
"strings"
|
||||
|
||||
session "codeberg.org/vnpower/pixivfe/v2/core/session"
|
||||
http "codeberg.org/vnpower/pixivfe/v2/core/http"
|
||||
session "codeberg.org/vnpower/pixivfe/v2/session"
|
||||
|
||||
"github.com/goccy/go-json"
|
||||
"github.com/gofiber/fiber/v2"
|
||||
)
|
||||
@@ -14,13 +14,13 @@ type Ranking struct {
|
||||
Contents []struct {
|
||||
Title string `json:"title"`
|
||||
Image string `json:"url"`
|
||||
Pages int `json:"illust_page_count,string"`
|
||||
Pages int `json:"illust_page_count,string"`
|
||||
ArtistName string `json:"user_name"`
|
||||
ArtistAvatar string `json:"profile_img"`
|
||||
ID int `json:"illust_id"`
|
||||
ArtistID int `json:"user_id"`
|
||||
Rank int `json:"rank"`
|
||||
IllustType int `json:"illust_type,string"`
|
||||
IllustType int `json:"illust_type,string"`
|
||||
} `json:"contents"`
|
||||
|
||||
Mode string `json:"mode"`
|
||||
@@ -35,11 +35,11 @@ type Ranking struct {
|
||||
}
|
||||
|
||||
func GetRanking(c *fiber.Ctx, mode, content, date, page string) (Ranking, error) {
|
||||
URL := http.GetRankingURL(mode, content, date, page)
|
||||
URL := GetRankingURL(mode, content, date, page)
|
||||
|
||||
var ranking Ranking
|
||||
|
||||
resp := http.WebAPIRequest(c.Context(), URL, "")
|
||||
resp := WebAPIRequest(c.Context(), URL, "")
|
||||
if !resp.Ok {
|
||||
return ranking, errors.New(resp.Message)
|
||||
}
|
||||
@@ -1,4 +1,4 @@
|
||||
package core
|
||||
package pixiv
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
@@ -6,8 +6,7 @@ import (
|
||||
"net/http"
|
||||
"time"
|
||||
|
||||
session "codeberg.org/vnpower/pixivfe/v2/core/session"
|
||||
url "codeberg.org/vnpower/pixivfe/v2/core/http"
|
||||
session "codeberg.org/vnpower/pixivfe/v2/session"
|
||||
"github.com/gofiber/fiber/v2"
|
||||
"golang.org/x/net/html"
|
||||
)
|
||||
@@ -37,7 +36,7 @@ func get_weekday(n time.Weekday) int {
|
||||
// is it a bug or a feature?
|
||||
func GetRankingCalendar(c *fiber.Ctx, mode string, year, month int) (template.HTML, error) {
|
||||
token := session.GetPixivToken(c)
|
||||
URL := url.GetRankingCalendarURL(mode, year, month)
|
||||
URL := GetRankingCalendarURL(mode, year, month)
|
||||
|
||||
req, err := http.NewRequest("GET", URL, nil)
|
||||
if err != nil {
|
||||
@@ -1,4 +1,4 @@
|
||||
package core
|
||||
package pixiv
|
||||
|
||||
import (
|
||||
"context"
|
||||
@@ -11,7 +11,7 @@ import (
|
||||
"path"
|
||||
"time"
|
||||
|
||||
config "codeberg.org/vnpower/pixivfe/v2/core/config"
|
||||
config "codeberg.org/vnpower/pixivfe/v2/config"
|
||||
"github.com/tidwall/gjson"
|
||||
)
|
||||
|
||||
@@ -1,10 +1,9 @@
|
||||
package core
|
||||
package pixiv
|
||||
|
||||
import (
|
||||
"strings"
|
||||
|
||||
http "codeberg.org/vnpower/pixivfe/v2/core/http"
|
||||
session "codeberg.org/vnpower/pixivfe/v2/core/session"
|
||||
session "codeberg.org/vnpower/pixivfe/v2/session"
|
||||
"github.com/goccy/go-json"
|
||||
"github.com/gofiber/fiber/v2"
|
||||
)
|
||||
@@ -75,9 +74,9 @@ func (s SearchPageSettings) ReturnMap() map[string]string {
|
||||
func GetTagData(c *fiber.Ctx, name string) (TagDetail, error) {
|
||||
var tag TagDetail
|
||||
|
||||
URL := http.GetTagDetailURL(name)
|
||||
URL := GetTagDetailURL(name)
|
||||
|
||||
response, err := http.UnwrapWebAPIRequest(c.Context(), URL, "")
|
||||
response, err := UnwrapWebAPIRequest(c.Context(), URL, "")
|
||||
if err != nil {
|
||||
return tag, err
|
||||
}
|
||||
@@ -93,9 +92,9 @@ func GetTagData(c *fiber.Ctx, name string) (TagDetail, error) {
|
||||
}
|
||||
|
||||
func GetSearch(c *fiber.Ctx, settings SearchPageSettings) (*SearchResult, error) {
|
||||
URL := http.GetSearchArtworksURL(settings.ReturnMap())
|
||||
URL := GetSearchArtworksURL(settings.ReturnMap())
|
||||
|
||||
response, err := http.UnwrapWebAPIRequest(c.Context(), URL, "")
|
||||
response, err := UnwrapWebAPIRequest(c.Context(), URL, "")
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@@ -1,4 +1,4 @@
|
||||
package core
|
||||
package pixiv
|
||||
|
||||
import (
|
||||
"errors"
|
||||
@@ -7,8 +7,7 @@ import (
|
||||
"math"
|
||||
"sort"
|
||||
|
||||
http "codeberg.org/vnpower/pixivfe/v2/core/http"
|
||||
session "codeberg.org/vnpower/pixivfe/v2/core/session"
|
||||
session "codeberg.org/vnpower/pixivfe/v2/session"
|
||||
"github.com/goccy/go-json"
|
||||
"github.com/gofiber/fiber/v2"
|
||||
)
|
||||
@@ -79,12 +78,12 @@ func GetFrequentTags(c *fiber.Ctx, ids string, category UserArtCategory) ([]Freq
|
||||
var URL string
|
||||
|
||||
if category != "novels" {
|
||||
URL = http.GetFrequentArtworkTagsURL(ids)
|
||||
URL = GetFrequentArtworkTagsURL(ids)
|
||||
} else {
|
||||
URL = http.GetFrequentNovelTagsURL(ids)
|
||||
URL = GetFrequentNovelTagsURL(ids)
|
||||
}
|
||||
|
||||
response, err := http.UnwrapWebAPIRequest(c.Context(), URL, "")
|
||||
response, err := UnwrapWebAPIRequest(c.Context(), URL, "")
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@@ -100,9 +99,9 @@ func GetFrequentTags(c *fiber.Ctx, ids string, category UserArtCategory) ([]Freq
|
||||
func GetUserArtworks(c *fiber.Ctx, id, ids string) ([]ArtworkBrief, error) {
|
||||
var works []ArtworkBrief
|
||||
|
||||
URL := http.GetUserFullArtworkURL(id, ids)
|
||||
URL := GetUserFullArtworkURL(id, ids)
|
||||
|
||||
resp, err := http.UnwrapWebAPIRequest(c.Context(), URL, "")
|
||||
resp, err := UnwrapWebAPIRequest(c.Context(), URL, "")
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@@ -135,9 +134,9 @@ func GetUserNovels(c *fiber.Ctx, id, ids string) ([]NovelBrief, error) {
|
||||
// VnPower: we can merge this function into GetUserArtworks, but I want to make things simple for now
|
||||
var works []NovelBrief
|
||||
|
||||
URL := http.GetUserFullNovelURL(id, ids)
|
||||
URL := GetUserFullNovelURL(id, ids)
|
||||
|
||||
resp, err := http.UnwrapWebAPIRequest(c.Context(), URL, "")
|
||||
resp, err := UnwrapWebAPIRequest(c.Context(), URL, "")
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@@ -167,9 +166,9 @@ func GetUserNovels(c *fiber.Ctx, id, ids string) ([]NovelBrief, error) {
|
||||
}
|
||||
|
||||
func GetUserArtworksID(c *fiber.Ctx, id string, category UserArtCategory, page int) (string, int, error) {
|
||||
URL := http.GetUserArtworksURL(id)
|
||||
URL := GetUserArtworksURL(id)
|
||||
|
||||
resp, err := http.UnwrapWebAPIRequest(c.Context(), URL, "")
|
||||
resp, err := UnwrapWebAPIRequest(c.Context(), URL, "")
|
||||
if err != nil {
|
||||
return "", -1, err
|
||||
}
|
||||
@@ -254,9 +253,9 @@ func GetUserArtwork(c *fiber.Ctx, id string, category UserArtCategory, page int,
|
||||
|
||||
token := session.GetPixivToken(c)
|
||||
|
||||
URL := http.GetUserInformationURL(id)
|
||||
URL := GetUserInformationURL(id)
|
||||
|
||||
resp, err := http.UnwrapWebAPIRequest(c.Context(), URL, token)
|
||||
resp, err := UnwrapWebAPIRequest(c.Context(), URL, token)
|
||||
if err != nil {
|
||||
return user, err
|
||||
}
|
||||
@@ -358,9 +357,9 @@ func GetUserArtwork(c *fiber.Ctx, id string, category UserArtCategory, page int,
|
||||
func GetUserBookmarks(c *fiber.Ctx, id, mode string, page int) ([]ArtworkBrief, int, error) {
|
||||
page--
|
||||
|
||||
URL := http.GetUserBookmarksURL(id, mode, page)
|
||||
URL := GetUserBookmarksURL(id, mode, page)
|
||||
|
||||
resp, err := http.UnwrapWebAPIRequest(c.Context(), URL, "")
|
||||
resp, err := UnwrapWebAPIRequest(c.Context(), URL, "")
|
||||
if err != nil {
|
||||
return nil, -1, err
|
||||
}
|
||||
@@ -0,0 +1,16 @@
|
||||
package pages
|
||||
|
||||
import (
|
||||
"codeberg.org/vnpower/pixivfe/v2/config"
|
||||
"github.com/gofiber/fiber/v2"
|
||||
)
|
||||
|
||||
func AboutPage(c *fiber.Ctx) error {
|
||||
info := fiber.Map{
|
||||
"Time": config.GlobalServerConfig.StartingTime,
|
||||
"Version": config.GlobalServerConfig.Version,
|
||||
"ImageProxy": config.GlobalServerConfig.ProxyServer.String(),
|
||||
"AcceptLanguage": config.GlobalServerConfig.AcceptLanguage,
|
||||
}
|
||||
return c.Render("about", info)
|
||||
}
|
||||
@@ -7,7 +7,7 @@ import (
|
||||
"io"
|
||||
"net/http"
|
||||
|
||||
session "codeberg.org/vnpower/pixivfe/v2/core/session"
|
||||
session "codeberg.org/vnpower/pixivfe/v2/session"
|
||||
"github.com/gofiber/fiber/v2"
|
||||
"github.com/tidwall/gjson"
|
||||
)
|
||||
@@ -6,7 +6,7 @@ import (
|
||||
"strings"
|
||||
"sync"
|
||||
|
||||
core "codeberg.org/vnpower/pixivfe/v2/core/webapi"
|
||||
core "codeberg.org/vnpower/pixivfe/v2/pixiv"
|
||||
"github.com/gofiber/fiber/v2"
|
||||
)
|
||||
|
||||
@@ -4,7 +4,7 @@ import (
|
||||
"fmt"
|
||||
"strconv"
|
||||
|
||||
core "codeberg.org/vnpower/pixivfe/v2/core/webapi"
|
||||
core "codeberg.org/vnpower/pixivfe/v2/pixiv"
|
||||
"github.com/gofiber/fiber/v2"
|
||||
)
|
||||
|
||||
@@ -38,3 +38,7 @@ func ArtworkPage(c *fiber.Ctx) error {
|
||||
"MetaAuthorID": illust.UserID,
|
||||
})
|
||||
}
|
||||
|
||||
func PreloadImage(c *fiber.Ctx, url string) {
|
||||
c.Response().Header.Add("Link", fmt.Sprintf("<%s>; rel=preload; as=image", url))
|
||||
}
|
||||
@@ -1,8 +1,8 @@
|
||||
package pages
|
||||
|
||||
import (
|
||||
site "codeberg.org/vnpower/pixivfe/v2/core/http"
|
||||
core "codeberg.org/vnpower/pixivfe/v2/core/webapi"
|
||||
core "codeberg.org/vnpower/pixivfe/v2/pixiv"
|
||||
"codeberg.org/vnpower/pixivfe/v2/utils"
|
||||
"github.com/gofiber/fiber/v2"
|
||||
)
|
||||
|
||||
@@ -14,7 +14,7 @@ func DiscoveryPage(c *fiber.Ctx) error {
|
||||
return err
|
||||
}
|
||||
|
||||
urlc := site.NewURLConstruct("discovery", map[string]string{"mode": mode})
|
||||
urlc := utils.NewURLConstruct("discovery", map[string]string{"mode": mode})
|
||||
|
||||
return c.Render("discovery", fiber.Map{
|
||||
"Artworks": works,
|
||||
@@ -1,8 +1,8 @@
|
||||
package pages
|
||||
|
||||
import (
|
||||
session "codeberg.org/vnpower/pixivfe/v2/core/session"
|
||||
core "codeberg.org/vnpower/pixivfe/v2/core/webapi"
|
||||
core "codeberg.org/vnpower/pixivfe/v2/pixiv"
|
||||
session "codeberg.org/vnpower/pixivfe/v2/session"
|
||||
"github.com/gofiber/fiber/v2"
|
||||
)
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
package pages
|
||||
|
||||
import (
|
||||
core "codeberg.org/vnpower/pixivfe/v2/core/webapi"
|
||||
core "codeberg.org/vnpower/pixivfe/v2/pixiv"
|
||||
"github.com/gofiber/fiber/v2"
|
||||
)
|
||||
|
||||
@@ -5,8 +5,8 @@ import (
|
||||
"strconv"
|
||||
"strings"
|
||||
|
||||
session "codeberg.org/vnpower/pixivfe/v2/core/session"
|
||||
core "codeberg.org/vnpower/pixivfe/v2/core/webapi"
|
||||
core "codeberg.org/vnpower/pixivfe/v2/pixiv"
|
||||
session "codeberg.org/vnpower/pixivfe/v2/session"
|
||||
"github.com/gofiber/fiber/v2"
|
||||
)
|
||||
|
||||
@@ -5,8 +5,8 @@ import (
|
||||
"strconv"
|
||||
"strings"
|
||||
|
||||
session "codeberg.org/vnpower/pixivfe/v2/core/session"
|
||||
core "codeberg.org/vnpower/pixivfe/v2/core/webapi"
|
||||
core "codeberg.org/vnpower/pixivfe/v2/pixiv"
|
||||
session "codeberg.org/vnpower/pixivfe/v2/session"
|
||||
"github.com/gofiber/fiber/v2"
|
||||
)
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
package pages
|
||||
|
||||
import (
|
||||
"github.com/gofiber/fiber/v2"
|
||||
"codeberg.org/vnpower/pixivision"
|
||||
"github.com/gofiber/fiber/v2"
|
||||
)
|
||||
|
||||
func PixivisionHomePage(c *fiber.Ctx) error {
|
||||
@@ -3,7 +3,7 @@ package pages
|
||||
import (
|
||||
"strconv"
|
||||
|
||||
core "codeberg.org/vnpower/pixivfe/v2/core/webapi"
|
||||
core "codeberg.org/vnpower/pixivfe/v2/pixiv"
|
||||
"github.com/gofiber/fiber/v2"
|
||||
)
|
||||
|
||||
@@ -5,7 +5,7 @@ import (
|
||||
"strconv"
|
||||
"time"
|
||||
|
||||
core "codeberg.org/vnpower/pixivfe/v2/core/webapi"
|
||||
core "codeberg.org/vnpower/pixivfe/v2/pixiv"
|
||||
"github.com/gofiber/fiber/v2"
|
||||
)
|
||||
|
||||
@@ -0,0 +1 @@
|
||||
package pages
|
||||
@@ -9,9 +9,9 @@ import (
|
||||
"slices"
|
||||
"strings"
|
||||
|
||||
httpc "codeberg.org/vnpower/pixivfe/v2/core/http"
|
||||
session "codeberg.org/vnpower/pixivfe/v2/core/session"
|
||||
"codeberg.org/vnpower/pixivfe/v2/doc"
|
||||
"codeberg.org/vnpower/pixivfe/v2/config"
|
||||
httpc "codeberg.org/vnpower/pixivfe/v2/pixiv"
|
||||
"codeberg.org/vnpower/pixivfe/v2/session"
|
||||
"github.com/gofiber/fiber/v2"
|
||||
)
|
||||
|
||||
@@ -163,7 +163,7 @@ func resetAll(c *fiber.Ctx) error {
|
||||
|
||||
func SettingsPage(c *fiber.Ctx) error {
|
||||
return c.Render("settings", fiber.Map{
|
||||
"ProxyList": doc.BuiltinProxyList,
|
||||
"ProxyList": config.BuiltinProxyList,
|
||||
})
|
||||
}
|
||||
|
||||
@@ -5,8 +5,8 @@ import (
|
||||
"net/url"
|
||||
"strconv"
|
||||
|
||||
site "codeberg.org/vnpower/pixivfe/v2/core/http"
|
||||
core "codeberg.org/vnpower/pixivfe/v2/core/webapi"
|
||||
core "codeberg.org/vnpower/pixivfe/v2/pixiv"
|
||||
"codeberg.org/vnpower/pixivfe/v2/utils"
|
||||
"github.com/gofiber/fiber/v2"
|
||||
)
|
||||
|
||||
@@ -50,7 +50,7 @@ func TagPage(c *fiber.Ctx) error {
|
||||
return err
|
||||
}
|
||||
|
||||
urlc := site.NewURLConstruct("tags", queries.ReturnMap())
|
||||
urlc := utils.NewURLConstruct("tags", queries.ReturnMap())
|
||||
|
||||
return c.Render("tag", fiber.Map{"Title": "Results for " + name, "Tag": tag, "Data": result, "QueriesC": urlc, "TrueTag": param, "Page": pageInt})
|
||||
}
|
||||
@@ -5,15 +5,15 @@ import (
|
||||
"strconv"
|
||||
"time"
|
||||
|
||||
core "codeberg.org/vnpower/pixivfe/v2/core/webapi"
|
||||
core "codeberg.org/vnpower/pixivfe/v2/pixiv"
|
||||
"github.com/gofiber/fiber/v2"
|
||||
)
|
||||
|
||||
type userPageData struct {
|
||||
user core.User
|
||||
category core.UserArtCategory
|
||||
pageLimit int
|
||||
page int
|
||||
user core.User
|
||||
category core.UserArtCategory
|
||||
pageLimit int
|
||||
page int
|
||||
}
|
||||
|
||||
func fetchData(c *fiber.Ctx, getTags bool) (userPageData, error) {
|
||||
@@ -1,11 +1,11 @@
|
||||
package core
|
||||
package session
|
||||
|
||||
import (
|
||||
"log"
|
||||
"net/url"
|
||||
"strings"
|
||||
|
||||
config "codeberg.org/vnpower/pixivfe/v2/core/config"
|
||||
config "codeberg.org/vnpower/pixivfe/v2/config"
|
||||
"github.com/gofiber/fiber/v2"
|
||||
)
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
// User Settings (Using Browser Cookies)
|
||||
|
||||
package core
|
||||
package session
|
||||
|
||||
import (
|
||||
"time"
|
||||
+1
-1
@@ -1 +1 @@
|
||||
package tests
|
||||
package tests
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
package core
|
||||
package utils
|
||||
|
||||
type URLConstructor struct {
|
||||
Path string
|
||||
@@ -1,4 +1,4 @@
|
||||
package serve
|
||||
package utils
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
@@ -1,4 +1,4 @@
|
||||
package serve
|
||||
package utils
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
@@ -10,8 +10,7 @@ import (
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
site "codeberg.org/vnpower/pixivfe/v2/core/http"
|
||||
core "codeberg.org/vnpower/pixivfe/v2/core/webapi"
|
||||
core "codeberg.org/vnpower/pixivfe/v2/pixiv"
|
||||
)
|
||||
|
||||
func GetRandomColor() string {
|
||||
@@ -310,7 +309,7 @@ func GetTemplateFunctions() template.FuncMap {
|
||||
"floor": func(i float64) int {
|
||||
return int(math.Floor(i))
|
||||
},
|
||||
"URLC": func(obj site.URLConstructor, name string) string {
|
||||
"URLC": func(obj URLConstructor, name string) string {
|
||||
url := fmt.Sprintf("/%s", obj.Path)
|
||||
first := true
|
||||
exists := false
|
||||
Reference in New Issue
Block a user