Add pages for users
This commit is contained in:
parent
5596998511
commit
41012edf9e
|
@ -1,6 +1,7 @@
|
||||||
package pages
|
package pages
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"strconv"
|
||||||
"sync"
|
"sync"
|
||||||
|
|
||||||
"codeberg.org/video-prize-ranch/rimgo/api"
|
"codeberg.org/video-prize-ranch/rimgo/api"
|
||||||
|
@ -14,6 +15,16 @@ func HandleUser(c *fiber.Ctx) error {
|
||||||
c.Set("Cache-Control", "public,max-age=604800")
|
c.Set("Cache-Control", "public,max-age=604800")
|
||||||
c.Set("Content-Security-Policy", "default-src 'none'; media-src 'self'; style-src 'unsafe-inline' 'self'; img-src 'self'; font-src 'self'; block-all-mixed-content")
|
c.Set("Content-Security-Policy", "default-src 'none'; media-src 'self'; style-src 'unsafe-inline' 'self'; img-src 'self'; font-src 'self'; block-all-mixed-content")
|
||||||
|
|
||||||
|
page := "0"
|
||||||
|
if c.Query("page") != "" {
|
||||||
|
page = c.Query("page")
|
||||||
|
}
|
||||||
|
|
||||||
|
pageNumber, err := strconv.Atoi(c.Query("page"))
|
||||||
|
if err != nil {
|
||||||
|
pageNumber = 0
|
||||||
|
}
|
||||||
|
|
||||||
wg := sync.WaitGroup{}
|
wg := sync.WaitGroup{}
|
||||||
wg.Add(2)
|
wg.Add(2)
|
||||||
user, err := types.User{}, error(nil)
|
user, err := types.User{}, error(nil)
|
||||||
|
@ -28,7 +39,7 @@ func HandleUser(c *fiber.Ctx) error {
|
||||||
submissions, err := []types.Submission{}, error(nil)
|
submissions, err := []types.Submission{}, error(nil)
|
||||||
go func() {
|
go func() {
|
||||||
defer wg.Done()
|
defer wg.Done()
|
||||||
submissions, err = api.FetchSubmissions(c.Params("userID"), "newest", "0")
|
submissions, err = api.FetchSubmissions(c.Params("userID"), "newest", page)
|
||||||
}()
|
}()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
|
@ -38,5 +49,8 @@ func HandleUser(c *fiber.Ctx) error {
|
||||||
return c.Render("user", fiber.Map{
|
return c.Render("user", fiber.Map{
|
||||||
"user": user,
|
"user": user,
|
||||||
"submissions": submissions,
|
"submissions": submissions,
|
||||||
|
"page": page,
|
||||||
|
"nextPage": pageNumber + 1,
|
||||||
|
"prevPage": pageNumber - 1,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
|
@ -61,3 +61,9 @@ video:not(:fullscreen) {
|
||||||
.post__meta .material-icons-outlined {
|
.post__meta .material-icons-outlined {
|
||||||
font-size: 1rem;
|
font-size: 1rem;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.pageSelector {
|
||||||
|
display: flex;
|
||||||
|
justify-content: space-between;
|
||||||
|
margin-top: 1em;
|
||||||
|
}
|
|
@ -1,7 +1,7 @@
|
||||||
<a href="{{Link}}">
|
<a href="{{Link}}">
|
||||||
<div class="post">
|
<div class="post">
|
||||||
{{#equal Cover.Type "video"}}
|
{{#equal Cover.Type "video"}}
|
||||||
<video fullscreen controls loop poster="/{{Cover.Id}}.webp" preload="none" width="100%" height="100%">
|
<video controls loop poster="/{{Cover.Id}}.webp" preload="none" width="100%" height="100%">
|
||||||
<source src="{{Cover.Url}}" type="video/mp4" />
|
<source src="{{Cover.Url}}" type="video/mp4" />
|
||||||
</video>
|
</video>
|
||||||
{{/equal}}
|
{{/equal}}
|
||||||
|
|
|
@ -31,6 +31,14 @@
|
||||||
{{> partials/post }}
|
{{> partials/post }}
|
||||||
{{/each}}
|
{{/each}}
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
<div class="pageSelector">
|
||||||
|
{{#equal page "0" }}
|
||||||
|
{{else}}
|
||||||
|
<a href="{{channel.RelUrl}}?page={{prevPage}}">Previous page</a>
|
||||||
|
{{/equal}}
|
||||||
|
<a href="{{channel.RelUrl}}?page={{nextPage}}">Next page</a>
|
||||||
|
</div>
|
||||||
</main>
|
</main>
|
||||||
|
|
||||||
{{> partials/footer }}
|
{{> partials/footer }}
|
||||||
|
|
Loading…
Reference in New Issue