mirror of
https://codeberg.org/VnPower/PixivFE
synced 2024-12-06 19:16:23 +01:00
pixivision landing page attempt
This commit is contained in:
@@ -0,0 +1,35 @@
|
||||
{{- 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 }}
|
||||
@@ -21,8 +21,22 @@
|
||||
{{- 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" }}
|
||||
|
||||
@@ -5,41 +5,8 @@
|
||||
|
||||
<div class="col-12">
|
||||
<div class="row row-cols-1 row-cols-md-2 row-cols-lg-3 g-4">
|
||||
{{- 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 }}
|
||||
<!-- Main content -->
|
||||
{{- include "fragments/pixivisionArticles" .Data }}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
+22
-4
@@ -29,14 +29,19 @@ type LandingArtworks struct {
|
||||
Newest []ArtworkBrief
|
||||
Rankings []ArtworkBrief
|
||||
Users []ArtworkBrief
|
||||
Pixivision []Pixivision
|
||||
// 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
|
||||
RecommendByTags []RecommendedTags
|
||||
}
|
||||
|
||||
func GetLanding(r *http.Request, mode string) (*LandingArtworks, error) {
|
||||
var pages struct {
|
||||
Pixivision []Pixivision `json:"pixivision"`
|
||||
Follow []int `json:"follow"`
|
||||
// NOTE: commented out for the reason above
|
||||
// Pixivision []Pixivision `json:"pixivision"`
|
||||
Follow []int `json:"follow"`
|
||||
Recommended struct {
|
||||
IDs []string `json:"ids"`
|
||||
} `json:"recommend"`
|
||||
@@ -95,7 +100,20 @@ func GetLanding(r *http.Request, mode string) (*LandingArtworks, error) {
|
||||
}
|
||||
|
||||
// Parse everything
|
||||
landing.Pixivision = pages.Pixivision
|
||||
// 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.Following = make([]ArtworkBrief, len(pages.Follow))
|
||||
for _, i := range pages.Follow {
|
||||
|
||||
Reference in New Issue
Block a user