Revert "pixivision landing page attempt"

This reverts commit 15dd300aa60fe5535cfee7e9a152516f6a8e3d73.
This commit is contained in:
perennial
2024-10-10 17:19:41 +11:00
parent 80aaa72bf5
commit c7193e583d
4 changed files with 39 additions and 73 deletions
@@ -1,35 +0,0 @@
{{- range _, article := . }}
<div class="col">
<div class="custom-card bg-charcoal-surface1 thumbnail-hover-dark">
<a href="/pixivision/a/{{article.ID}}">
<div class="thumbnail-wrapper rounded-top-5 overflow-hidden">
<img src="{{article.Thumbnail}}" class="card-img-top rounded-top-5" alt="{{article.Title}}" />
</div>
</a>
<div class="custom-card-body">
<!-- Title -->
<h4 class="lh-lg">
<a href="/pixivision/a/{{article.ID}}" class="text-body text-decoration-none">
{{article.Title}}
</a>
</h4>
<!-- NOTE: would not have figured out the following classes without referring to the actual pixivision web site -->
<div class="d-flex align-content-between align-items-baseline">
<!-- Tags -->
<div>
{{- range _, tag := article.Tags }}
<span class="badge fw-normal me-2 mb-2 p-0">
<a href="/pixivision/t/{{tag.ID}}" class="text-decoration-none">#{{ tag.Name }}</a>
</span>
{{- end }}
</div>
<!-- Publication Date -->
<!-- NOTE: d-inline-flex required for the child elements to not wrap weirdly when there are a lot of tags -->
<p class="d-inline-flex text-body-secondary small mb-0 ms-auto">
<i class="bi bi-calendar me-2"></i>{{parseTimeCustomFormat(article.Date, "2006-01-02")}}
</p>
</div>
</div>
</div>
</div>
{{- end }}
-14
View File
@@ -21,22 +21,8 @@
{{- include "fragments/ranking-tn" .NoTokenData.Contents }}
</div>
</div>
<div class="col-12">
<h2>Articles from pixivision</h2>
<div class="row row-cols-1 row-cols-md-2 row-cols-lg-3 g-4">
{{- include "fragments/pixivisionArticles" .Data.Pixivision }}
</div>
</div>
{{- else }}
<div class="col-12">
<h2>Articles from pixivision</h2>
<div class="row row-cols-1 row-cols-md-2 row-cols-lg-3 g-4">
{{- include "fragments/pixivisionArticles" .Data.Pixivision }}
</div>
</div>
<div class="col-12">
<div class="d-flex flex-column flex-md-row align-items-center justify-content-center justify-content-md-end mx-auto">
{{- Mode := isset(Queries.mode) ? Queries.mode : "all" }}
+35 -2
View File
@@ -5,8 +5,41 @@
<div class="col-12">
<div class="row row-cols-1 row-cols-md-2 row-cols-lg-3 g-4">
<!-- Main content -->
{{- include "fragments/pixivisionArticles" .Data }}
{{- range _, article := .Data }}
<div class="col">
<div class="custom-card bg-charcoal-surface1 thumbnail-hover-dark">
<a href="/pixivision/a/{{article.ID}}">
<div class="thumbnail-wrapper rounded-top-5 overflow-hidden">
<img src="{{article.Thumbnail}}" class="card-img-top rounded-top-5" alt="{{article.Title}}" />
</div>
</a>
<div class="custom-card-body">
<!-- Title -->
<h4 class="lh-lg">
<a href="/pixivision/a/{{article.ID}}" class="text-body text-decoration-none">
{{article.Title}}
</a>
</h4>
<!-- NOTE: would not have figured out the following classes without referring to the actual pixivision web site -->
<div class="d-flex align-content-between align-items-baseline">
<!-- Tags -->
<div>
{{- range _, tag := article.Tags }}
<span class="badge fw-normal me-2 mb-2 p-0">
<a href="/pixivision/t/{{tag.ID}}" class="text-decoration-none">#{{ tag.Name }}</a>
</span>
{{- end }}
</div>
<!-- Publication Date -->
<!-- NOTE: d-inline-flex required for the child elements to not wrap weirdly when there are a lot of tags -->
<p class="d-inline-flex text-body-secondary small mb-0 ms-auto">
<i class="bi bi-calendar me-2"></i>{{parseTimeCustomFormat(article.Date, "2006-01-02")}}
</p>
</div>
</div>
</div>
</div>
{{- end }}
</div>
</div>
</div>
+4 -22
View File
@@ -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 {