From c7193e583ddac654014e7b71862596bd585670d3 Mon Sep 17 00:00:00 2001 From: perennial Date: Thu, 10 Oct 2024 17:19:41 +1100 Subject: [PATCH] Revert "pixivision landing page attempt" This reverts commit 15dd300aa60fe5535cfee7e9a152516f6a8e3d73. --- .../fragments/pixivisionArticles.jet.html | 35 ------------------ assets/views/index.jet.html | 14 ------- assets/views/pixivisionIndex.jet.html | 37 ++++++++++++++++++- core/index.go | 26 ++----------- 4 files changed, 39 insertions(+), 73 deletions(-) delete mode 100644 assets/views/fragments/pixivisionArticles.jet.html diff --git a/assets/views/fragments/pixivisionArticles.jet.html b/assets/views/fragments/pixivisionArticles.jet.html deleted file mode 100644 index fa31b56..0000000 --- a/assets/views/fragments/pixivisionArticles.jet.html +++ /dev/null @@ -1,35 +0,0 @@ -{{- range _, article := . }} -
-
- -
- {{article.Title}} -
-
-
- -

- - {{article.Title}} - -

- -
- -
- {{- range _, tag := article.Tags }} - - #{{ tag.Name }} - - {{- end }} -
- - -

- {{parseTimeCustomFormat(article.Date, "2006-01-02")}} -

-
-
-
-
-{{- end }} diff --git a/assets/views/index.jet.html b/assets/views/index.jet.html index f6d9114..c391022 100644 --- a/assets/views/index.jet.html +++ b/assets/views/index.jet.html @@ -21,22 +21,8 @@ {{- include "fragments/ranking-tn" .NoTokenData.Contents }} - -
-

Articles from pixivision

-
- {{- include "fragments/pixivisionArticles" .Data.Pixivision }} -
-
{{- else }} -
-

Articles from pixivision

-
- {{- include "fragments/pixivisionArticles" .Data.Pixivision }} -
-
-
{{- Mode := isset(Queries.mode) ? Queries.mode : "all" }} diff --git a/assets/views/pixivisionIndex.jet.html b/assets/views/pixivisionIndex.jet.html index 8916252..1d535fd 100644 --- a/assets/views/pixivisionIndex.jet.html +++ b/assets/views/pixivisionIndex.jet.html @@ -5,8 +5,41 @@
- - {{- include "fragments/pixivisionArticles" .Data }} + {{- range _, article := .Data }} +
+
+ +
+ {{article.Title}} +
+
+
+ +

+ + {{article.Title}} + +

+ +
+ +
+ {{- range _, tag := article.Tags }} + + #{{ tag.Name }} + + {{- end }} +
+ + +

+ {{parseTimeCustomFormat(article.Date, "2006-01-02")}} +

+
+
+
+
+ {{- end }}
diff --git a/core/index.go b/core/index.go index f3ff470..db96586 100644 --- a/core/index.go +++ b/core/index.go @@ -29,19 +29,14 @@ type LandingArtworks struct { Newest []ArtworkBrief Rankings []ArtworkBrief Users []ArtworkBrief - // NOTE: a Pixivision field *does* exist in the GetLandingURL response, but it is incomplete, - // containing only the id, title, thumbnailUrl, and url fields - // As such, we need to retrieve the full-fat Pixivision field by calling PixivisionGetHomepage - // Pixivision []Pixivision - Pixivision []PixivisionArticle + Pixivision []Pixivision RecommendByTags []RecommendedTags } func GetLanding(r *http.Request, mode string) (*LandingArtworks, error) { var pages struct { - // NOTE: commented out for the reason above - // Pixivision []Pixivision `json:"pixivision"` - Follow []int `json:"follow"` + Pixivision []Pixivision `json:"pixivision"` + Follow []int `json:"follow"` Recommended struct { IDs []string `json:"ids"` } `json:"recommend"` @@ -100,20 +95,7 @@ func GetLanding(r *http.Request, mode string) (*LandingArtworks, error) { } // Parse everything - // Fetch full pixivision data - pixivisionArticles, err := PixivisionGetHomepage(r, "1") // Fetch the first page - if err != nil { - return &landing, err - } - - // Apply ProxyImageUrl to each Thumbnail - for i := range pixivisionArticles { - pixivisionArticles[i].Thumbnail = session.ProxyImageUrl(r, pixivisionArticles[i].Thumbnail) - } - - // Assign the fetched pixivision articles to the landing struct - landing.Pixivision = pixivisionArticles - fmt.Println("Pixivision JSON:", gjson.Get(pagesStr, "pixivision")) + landing.Pixivision = pages.Pixivision landing.Following = make([]ArtworkBrief, len(pages.Follow)) for _, i := range pages.Follow {