add more admin panel pages and styling

This commit is contained in:
yequari 2026-01-01 12:02:41 -07:00
parent fc91b3dec7
commit 702c261e2b
11 changed files with 1071 additions and 210 deletions

View File

@ -4,6 +4,7 @@ import (
"errors"
"fmt"
"net/http"
"strconv"
"time"
"git.32bit.cafe/32bitcafe/guestbook/internal/forms"
@ -13,8 +14,28 @@ import (
)
func (app *application) getAdminPanelLanding(w http.ResponseWriter, r *http.Request) {
websites, err := app.websites.GetCount()
if err != nil {
app.serverError(w, r, err)
return
}
users, err := app.users.GetCount()
if err != nil {
app.serverError(w, r, err)
return
}
comments, err := app.guestbookComments.GetCount()
if err != nil {
app.serverError(w, r, err)
return
}
stats := views.AdminStat{
WebsiteCount: websites,
UserCount: users,
CommentCount: comments,
}
data := app.newCommonData(r)
views.AdminPanelLandingView("Admin Panel", data).Render(r.Context(), w)
views.AdminPanelLandingView("Admin Panel", data, stats).Render(r.Context(), w)
}
func (app *application) getAdminPanelAllUsers(w http.ResponseWriter, r *http.Request) {
@ -158,4 +179,70 @@ func (app *application) putAdminPanelUnbanUser(w http.ResponseWriter, r *http.Re
}
func (app *application) getAdminPanelWebsites(w http.ResponseWriter, r *http.Request) {
page := r.URL.Query().Get("page")
count := r.URL.Query().Get("count")
var pageNum int64 = 1
var pageSize int64 = 5
var err error
if page != "" {
pageNum, err = strconv.ParseInt(page, 10, 0)
if err != nil {
app.clientError(w, http.StatusBadRequest)
return
}
}
if count != "" {
pageSize, err = strconv.ParseInt(count, 10, 0)
if err != nil {
app.clientError(w, http.StatusBadRequest)
return
}
}
websites, err := app.websites.GetAllPage(pageNum, pageSize)
if err != nil {
app.serverError(w, r, err)
return
}
total, err := app.websites.GetCount()
if err != nil {
app.serverError(w, r, err)
return
}
commonData := app.newCommonData(r)
views.AdminPanelAllWebsitesView("All websites", commonData, websites, pageNum, total).Render(r.Context(), w)
}
func (app *application) getAdminPanelWebsiteDetails(w http.ResponseWriter, r *http.Request) {
slug := r.PathValue("id")
// page := r.URL.Query().Get("page")
// count := r.URL.Query().Get("count")
// var pageNum int64 = 1
// var pageSize int64 = 5
// var err error
// if page != "" {
// pageNum, err = strconv.ParseInt(page, 10, 0)
// if err != nil {
// app.clientError(w, http.StatusBadRequest)
// return
// }
// }
// if count != "" {
// pageSize, err = strconv.ParseInt(count, 10, 0)
// if err != nil {
// app.clientError(w, http.StatusBadRequest)
// return
// }
// }
website, err := app.websites.Get(slugToShortId(slug))
if err != nil {
app.serverError(w, r, err)
return
}
comments, err := app.guestbookComments.GetAll(website.Guestbook.ID)
if err != nil {
app.serverError(w, r, err)
return
}
commonData := app.newCommonData(r)
views.AdminPanelWebsiteDetailView(fmt.Sprintf("Admin - %s", website.Name), commonData, website, comments).Render(r.Context(), w)
}

View File

@ -67,6 +67,8 @@ func (app *application) routes() http.Handler {
mux.Handle("PUT /admin/users/{id}/edit", adminOnly.ThenFunc(app.putAdminPanelUserMgmtForm))
mux.Handle("PUT /admin/users/{id}/ban", adminOnly.ThenFunc(app.putAdminPanelBanUser))
mux.Handle("PUT /admin/users/{id}/unban", adminOnly.ThenFunc(app.putAdminPanelUnbanUser))
mux.Handle("GET /admin/websites", adminOnly.ThenFunc(app.getAdminPanelWebsites))
mux.Handle("GET /admin/websites/{id}", adminOnly.ThenFunc(app.getAdminPanelWebsiteDetails))
return standard.Then(mux)
}

View File

@ -33,6 +33,7 @@ type GuestbookCommentModel struct {
type GuestbookCommentModelInterface interface {
Insert(shortId uint64, guestbookId, parentId int64, authorName, authorEmail, authorSite, commentText, pageUrl string, isPublished bool) (int64, error)
Get(shortId uint64) (GuestbookComment, error)
GetCount() (int64, error)
GetVisible(guestbookId int64) ([]GuestbookComment, error)
GetVisibleSerialized(guestbookId int64) ([]GuestbookCommentSerialized, error)
GetDeleted(guestbookId int64) ([]GuestbookComment, error)
@ -74,6 +75,20 @@ func (m *GuestbookCommentModel) Get(shortId uint64) (GuestbookComment, error) {
return c, nil
}
func (m *GuestbookCommentModel) GetCount() (int64, error) {
stmt := `SELECT COUNT(*) FROM guestbook_comments WHERE Deleted IS NULL`
row := m.DB.QueryRow(stmt)
var result int64
err := row.Scan(&result)
if err != nil {
return -1, err
}
if err = row.Err(); err != nil {
return -1, err
}
return result, nil
}
func (m *GuestbookCommentModel) GetVisible(guestbookId int64) ([]GuestbookComment, error) {
stmt := `SELECT Id, ShortId, GuestbookId, ParentId, AuthorName, AuthorEmail, AuthorSite,
CommentText, PageUrl, Created, IsPublished

View File

@ -56,6 +56,14 @@ func (m *WebsiteModel) GetAllUser(userId int64) ([]models.Website, error) {
return []models.Website{mockWebsite}, nil
}
func GetCountUser(userId int64) (int64, error) {
return 1, nil
}
func (m *WebsiteModel) GetAllUserPage(userId int64, pageNum int64) ([]models.Website, error) {
return []models.Website{mockWebsite}, nil
}
func (m *WebsiteModel) GetById(id int64) (models.Website, error) {
switch id {
case 1:
@ -69,6 +77,14 @@ func (m *WebsiteModel) GetAll() ([]models.Website, error) {
return []models.Website{mockWebsite}, nil
}
func GetCount() (int64, error) {
return 1, nil
}
func (m *WebsiteModel) GetAllPage(pageNum int64) ([]models.Website, error) {
return []models.Website{mockWebsite}, nil
}
func (m *WebsiteModel) Update(w models.Website) error {
return nil
}

View File

@ -56,6 +56,7 @@ type UserModelInterface interface {
Insert(shortId uint64, username string, email string, password string, settings UserSettings) error
InsertWithoutPassword(shortId uint64, username string, email string, subject string, settings UserSettings) (int64, error)
Get(shortId uint64) (User, error)
GetCount() (int64, error)
GetById(id int64) (User, error)
GetByEmail(email string) (int64, error)
GetBySubject(subject string) (int64, error)
@ -247,6 +248,20 @@ func (m *UserModel) Get(shortId uint64) (User, error) {
return u, nil
}
func (m *UserModel) GetCount() (int64, error) {
stmt := `SELECT COUNT(*) FROM users WHERE Deleted IS NULL`
row := m.DB.QueryRow(stmt)
var result int64
err := row.Scan(&result)
if err != nil {
return -1, err
}
if err = row.Err(); err != nil {
return -1, err
}
return result, nil
}
func (m *UserModel) GetById(id int64) (User, error) {
stmt := `SELECT Id, ShortId, Username, Email, Created, Banned FROM users WHERE Id = ? AND Deleted IS NULL`
tx, err := m.DB.Begin()

View File

@ -95,7 +95,11 @@ type WebsiteModelInterface interface {
Insert(shortId uint64, userId int64, siteName, siteUrl, authorName string) (int64, error)
Get(shortId uint64) (Website, error)
GetAllUser(userId int64) ([]Website, error)
GetCountUser(userId int64) (int64, error)
GetAllUserPage(userId int64, pageNum int64, pageSize int64) ([]Website, error)
GetAll() ([]Website, error)
GetCount() (int64, error)
GetAllPage(pageNum int64, pageSize int64) ([]Website, error)
Update(w Website) error
InitializeSettingsMap() error
UpdateGuestbookSettings(guestbookId int64, settings GuestbookSettings) error
@ -270,6 +274,51 @@ func (m *WebsiteModel) GetAllUser(userId int64) ([]Website, error) {
return websites, nil
}
func (m *WebsiteModel) GetCountUser(userId int64) (int64, error) {
stmt := `SELECT COUNT(*) FROM websites WHERE UserId = ? AND Deleted IS NULL`
row := m.DB.QueryRow(stmt, userId)
var result int64
err := row.Scan(&result)
if err != nil {
return -1, err
}
if err = row.Err(); err != nil {
return -1, err
}
return result, nil
}
func (m *WebsiteModel) GetAllUserPage(userId int64, pageNum int64, pageSize int64) ([]Website, error) {
stmt := `SELECT w.Id, w.ShortId, w.Name, w.SiteUrl, w.AuthorName, w.UserId, w.Created,
g.Id, g.ShortId, g.Created, g.IsActive
FROM websites AS w INNER JOIN guestbooks AS g ON w.Id = g.WebsiteId
WHERE w.UserId = ? AND w.Deleted IS NULL
LIMIT ? OFFSET ?`
rows, err := m.DB.Query(stmt, userId, pageSize, (pageNum-1)*pageSize)
if err != nil {
return nil, err
}
var websites []Website
for rows.Next() {
var w Website
var u string
err := rows.Scan(&w.ID, &w.ShortId, &w.Name, &u, &w.AuthorName, &w.UserId, &w.Created,
&w.Guestbook.ID, &w.Guestbook.ShortId, &w.Guestbook.Created, &w.Guestbook.IsActive)
if err != nil {
return nil, err
}
w.Url, err = url.Parse(u)
if err != nil {
return nil, err
}
websites = append(websites, w)
}
if err = rows.Err(); err != nil {
return nil, err
}
return websites, nil
}
func (m *WebsiteModel) GetAll() ([]Website, error) {
stmt := `SELECT w.Id, w.ShortId, w.Name, w.SiteUrl, w.AuthorName, w.UserId, w.Created,
g.Id, g.ShortId, g.Created, g.IsActive
@ -299,6 +348,50 @@ func (m *WebsiteModel) GetAll() ([]Website, error) {
return websites, nil
}
func (m *WebsiteModel) GetCount() (int64, error) {
stmt := `SELECT COUNT(*) FROM websites WHERE Deleted IS NULL`
row := m.DB.QueryRow(stmt)
var result int64
err := row.Scan(&result)
if err != nil {
return -1, err
}
if err = row.Err(); err != nil {
return -1, err
}
return result, nil
}
func (m *WebsiteModel) GetAllPage(pageNum int64, pageSize int64) ([]Website, error) {
stmt := `SELECT w.Id, w.ShortId, w.Name, w.SiteUrl, w.AuthorName, w.UserId, w.Created,
g.Id, g.ShortId, g.Created, g.IsActive
FROM websites AS w INNER JOIN guestbooks AS g ON w.Id = g.WebsiteId WHERE w.Deleted IS NULL
LIMIT ? OFFSET ?`
rows, err := m.DB.Query(stmt, pageSize, (pageNum-1)*pageSize)
if err != nil {
return nil, err
}
var websites []Website
for rows.Next() {
var w Website
var u string
err := rows.Scan(&w.ID, &w.ShortId, &w.Name, &u, &w.AuthorName, &w.UserId, &w.Created,
&w.Guestbook.ID, &w.Guestbook.ShortId, &w.Guestbook.Created, &w.Guestbook.IsActive)
if err != nil {
return nil, err
}
w.Url, err = url.Parse(u)
if err != nil {
return nil, err
}
websites = append(websites, w)
}
if err = rows.Err(); err != nil {
return nil, err
}
return websites, nil
}
func (m *WebsiteModel) Update(w Website) error {
stmt := `UPDATE websites SET Name = ?, SiteUrl = ?, AuthorName = ? WHERE ID = ?`
r, err := m.DB.Exec(stmt, w.Name, w.Url.String(), w.AuthorName, w.ID)

View File

@ -709,6 +709,54 @@ ul#websites li {
margin-top: var(--space-2xl);
}
/* Admin Panel */
.admin-section {
background-color: var(--color-surface);
padding: var(--space-xl);
border-radius: var(--radius-lg);
border: 1px solid var(--color-border);
margin-bottom: var(--space-xl);
}
.admin-section table {
width: 100%;
}
.admin-section th {
border-bottom: 1px solid var(--color-border);
}
.admin-section td {
padding: var(--space-sm);
text-align: center;
}
.admin-flex {
display: flex;
justify-content: space-between;
gap: var(--space-sm);
}
.admin-info {
flex: 1;
text-align: center;
font-size: x-large;
}
/* Pagination */
.pagination {
width: 100%;
display: flex;
justify-content: center;
}
.pagination-btn {
background-color: var(--color-surface);
padding: var(--space-sm);
border-radius: var(--radius-lg);
border: 1px solid var(--color-border);
margin: var(--space-xs);
}
/* Utilities */
hr {
border: none;

View File

@ -8,6 +8,12 @@ import (
"time"
)
type AdminStat struct {
WebsiteCount int64
UserCount int64
CommentCount int64
}
templ adminBase(title string, data CommonData) {
<!DOCTYPE html>
<html lang="en">
@ -41,20 +47,36 @@ templ adminSidebar() {
<ul role="list">
<li><a href="/admin">Dashboard</a></li>
<li><a href="/admin/users">Users</a></li>
<li><a href="/admin/guestbooks">Guestbooks</a></li>
<li><a href="/admin/websites">Websites</a></li>
</ul>
</section>
</div>
</nav>
}
templ AdminPanelLandingView(title string, data CommonData) {
templ AdminPanelLandingView(title string, data CommonData, stats AdminStat) {
@adminBase(title, data) {
<div id="dashboard">
@adminSidebar()
<div>
<h1>{ title }</h1>
<p>Welcome to the admin panel</p>
<section class="admin-section">
<h1>{ title }</h1>
<p>Welcome to the admin panel</p>
</section>
<section class="admin-flex">
<section class="admin-section admin-info">
<h2>Users</h2>
<p>{ fmt.Sprintf("%d", stats.UserCount) }</p>
</section>
<section class="admin-section admin-info">
<h2>Websites</h2>
<p>{ fmt.Sprintf("%d", stats.WebsiteCount) }</p>
</section>
<section class="admin-section admin-info">
<h2>Comments</h2>
<p>{ fmt.Sprintf("%d", stats.CommentCount) }</p>
</section>
</section>
</div>
</div>
}
@ -65,7 +87,7 @@ templ AdminPanelUsersView(title string, data CommonData, users []models.User) {
<div id="dashboard">
@adminSidebar()
<div>
<section>
<section class="admin-section">
<table>
<th>Username</th>
<th>Joined</th>
@ -180,3 +202,62 @@ templ AdminPanelUserMgmtEditForm(csrfToken string, form forms.AdminUserMgmtForm,
</form>
</div>
}
templ AdminPanelAllWebsitesView(title string, data CommonData, websites []models.Website, pageNum int64, total int64) {
@adminBase(title, data) {
<div id="dashboard">
@adminSidebar()
<div>
<section class="admin-section">
<table>
<th>Site Name</th>
<th>Owner</th>
<th>URL</th>
<th>Created</th>
<th>Guestbook</th>
for _, w := range websites {
<tr>
{{ detailUrl := fmt.Sprintf("/admin/websites/%s", shortIdToSlug(w.ShortId)) }}
<td><a href={ templ.SafeURL(detailUrl) }>{ w.Name }</a></td>
<td>{ w.AuthorName }</td>
<td><a href={ templ.SafeURL(w.Url.String()) }>{ w.Url.String() }</a></td>
<td>{ w.Created.Format(time.RFC1123) }</td>
{{ gbUrl := fmt.Sprintf("/websites/%s/guestbook", shortIdToSlug(w.ShortId)) }}
<td><a href={ templ.SafeURL(gbUrl) }>View</a></td>
</tr>
}
</table>
</section>
@pagination("/admin/websites", pageNum, total, 5)
</div>
</div>
}
}
templ AdminPanelWebsiteDetailView(title string, data CommonData, website models.Website, comments []models.GuestbookComment) {
@adminBase(title, data) {
<div id="dashboard">
@adminSidebar()
<div>
<section class="admin-section">
<table>
<th>Author</th>
<th>Created</th>
<th>Email</th>
<th>Homepage</th>
<th>Comment</th>
for _, c := range comments {
<tr>
<td>{ c.AuthorName }</td>
<td>{ c.Created.Format(time.RFC1123) }</td>
<td>{ c.AuthorEmail }</td>
<td>{ c.AuthorSite }</td>
<td>{ c.CommentText }</td>
</tr>
}
</table>
</section>
</div>
</div>
}
}

File diff suppressed because it is too large Load Diff

View File

@ -3,6 +3,7 @@ package views
import (
"fmt"
"git.32bit.cafe/32bitcafe/guestbook/internal/models"
"math"
"slices"
"strconv"
"strings"
@ -117,3 +118,35 @@ templ base(title string, data CommonData) {
</body>
</html>
}
templ pagination(baseUrl string, currentPage int64, recordsAmount int64, recordsPerPage int64) {
{{ totalPages := int64(math.Ceil(float64(recordsAmount) / float64(recordsPerPage))) }}
<div class="pagination">
<span class="pagination-btn">
if currentPage > 1 {
{{ url := fmt.Sprintf("%s?page=%d", baseUrl, currentPage-1) }}
<a href={ templ.URL(url) }>Prev</a>
} else {
Prev
}
</span>
for i := range totalPages {
<span class="pagination-btn">
{{ url := fmt.Sprintf("%s?page=%d", baseUrl, i+1) }}
if i+1 == currentPage {
{ fmt.Sprintf("%d",i+1) }
} else {
<a href={ templ.URL(url) }>{ fmt.Sprintf("%d",i+1) }</a>
}
</span>
}
<span class="pagination-btn">
if currentPage < totalPages {
{{ url := fmt.Sprintf("%s?page=%d", baseUrl, currentPage+1) }}
<a href={ templ.URL(url) }>Next</a>
} else {
Next
}
</span>
</div>
}

View File

@ -11,6 +11,7 @@ import templruntime "github.com/a-h/templ/runtime"
import (
"fmt"
"git.32bit.cafe/32bitcafe/guestbook/internal/models"
"math"
"slices"
"strconv"
"strings"
@ -117,7 +118,7 @@ func topNav(data CommonData) templ.Component {
var templ_7745c5c3_Var3 string
templ_7745c5c3_Var3, templ_7745c5c3_Err = templ.JoinStringErrs(data.CurrentUser.Username)
if templ_7745c5c3_Err != nil {
return templ.Error{Err: templ_7745c5c3_Err, FileName: `ui/views/common.templ`, Line: 61, Col: 41}
return templ.Error{Err: templ_7745c5c3_Err, FileName: `ui/views/common.templ`, Line: 62, Col: 41}
}
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var3))
if templ_7745c5c3_Err != nil {
@ -146,7 +147,7 @@ func topNav(data CommonData) templ.Component {
var templ_7745c5c3_Var4 string
templ_7745c5c3_Var4, templ_7745c5c3_Err = templ.JoinStringErrs(hxHeaders)
if templ_7745c5c3_Err != nil {
return templ.Error{Err: templ_7745c5c3_Err, FileName: `ui/views/common.templ`, Line: 73, Col: 66}
return templ.Error{Err: templ_7745c5c3_Err, FileName: `ui/views/common.templ`, Line: 74, Col: 66}
}
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var4))
if templ_7745c5c3_Err != nil {
@ -233,7 +234,7 @@ func base(title string, data CommonData) templ.Component {
var templ_7745c5c3_Var7 string
templ_7745c5c3_Var7, templ_7745c5c3_Err = templ.JoinStringErrs(title)
if templ_7745c5c3_Err != nil {
return templ.Error{Err: templ_7745c5c3_Err, FileName: `ui/views/common.templ`, Line: 98, Col: 17}
return templ.Error{Err: templ_7745c5c3_Err, FileName: `ui/views/common.templ`, Line: 99, Col: 17}
}
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var7))
if templ_7745c5c3_Err != nil {
@ -246,7 +247,7 @@ func base(title string, data CommonData) templ.Component {
var templ_7745c5c3_Var8 string
templ_7745c5c3_Var8, templ_7745c5c3_Err = templ.JoinStringErrs(`{"includeIndicatorStyles":false}`)
if templ_7745c5c3_Err != nil {
return templ.Error{Err: templ_7745c5c3_Err, FileName: `ui/views/common.templ`, Line: 101, Col: 72}
return templ.Error{Err: templ_7745c5c3_Err, FileName: `ui/views/common.templ`, Line: 102, Col: 72}
}
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var8))
if templ_7745c5c3_Err != nil {
@ -276,7 +277,7 @@ func base(title string, data CommonData) templ.Component {
var templ_7745c5c3_Var9 string
templ_7745c5c3_Var9, templ_7745c5c3_Err = templ.JoinStringErrs(data.Flash)
if templ_7745c5c3_Err != nil {
return templ.Error{Err: templ_7745c5c3_Err, FileName: `ui/views/common.templ`, Line: 112, Col: 43}
return templ.Error{Err: templ_7745c5c3_Err, FileName: `ui/views/common.templ`, Line: 113, Col: 43}
}
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var9))
if templ_7745c5c3_Err != nil {
@ -307,4 +308,137 @@ func base(title string, data CommonData) templ.Component {
})
}
func pagination(baseUrl string, currentPage int64, recordsAmount int64, recordsPerPage int64) templ.Component {
return templruntime.GeneratedTemplate(func(templ_7745c5c3_Input templruntime.GeneratedComponentInput) (templ_7745c5c3_Err error) {
templ_7745c5c3_W, ctx := templ_7745c5c3_Input.Writer, templ_7745c5c3_Input.Context
if templ_7745c5c3_CtxErr := ctx.Err(); templ_7745c5c3_CtxErr != nil {
return templ_7745c5c3_CtxErr
}
templ_7745c5c3_Buffer, templ_7745c5c3_IsBuffer := templruntime.GetBuffer(templ_7745c5c3_W)
if !templ_7745c5c3_IsBuffer {
defer func() {
templ_7745c5c3_BufErr := templruntime.ReleaseBuffer(templ_7745c5c3_Buffer)
if templ_7745c5c3_Err == nil {
templ_7745c5c3_Err = templ_7745c5c3_BufErr
}
}()
}
ctx = templ.InitializeContext(ctx)
templ_7745c5c3_Var10 := templ.GetChildren(ctx)
if templ_7745c5c3_Var10 == nil {
templ_7745c5c3_Var10 = templ.NopComponent
}
ctx = templ.ClearChildren(ctx)
totalPages := int64(math.Ceil(float64(recordsAmount) / float64(recordsPerPage)))
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 21, "<div class=\"pagination\"><span class=\"pagination-btn\">")
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
if currentPage > 1 {
url := fmt.Sprintf("%s?page=%d", baseUrl, currentPage-1)
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 22, "<a href=\"")
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
var templ_7745c5c3_Var11 templ.SafeURL = templ.URL(url)
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(string(templ_7745c5c3_Var11)))
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 23, "\">Prev</a>")
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
} else {
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 24, "Prev")
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
}
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 25, "</span> ")
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
for i := range totalPages {
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 26, "<span class=\"pagination-btn\">")
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
url := fmt.Sprintf("%s?page=%d", baseUrl, i+1)
if i+1 == currentPage {
var templ_7745c5c3_Var12 string
templ_7745c5c3_Var12, templ_7745c5c3_Err = templ.JoinStringErrs(fmt.Sprintf("%d", i+1))
if templ_7745c5c3_Err != nil {
return templ.Error{Err: templ_7745c5c3_Err, FileName: `ui/views/common.templ`, Line: 137, Col: 28}
}
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var12))
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
} else {
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 27, "<a href=\"")
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
var templ_7745c5c3_Var13 templ.SafeURL = templ.URL(url)
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(string(templ_7745c5c3_Var13)))
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 28, "\">")
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
var templ_7745c5c3_Var14 string
templ_7745c5c3_Var14, templ_7745c5c3_Err = templ.JoinStringErrs(fmt.Sprintf("%d", i+1))
if templ_7745c5c3_Err != nil {
return templ.Error{Err: templ_7745c5c3_Err, FileName: `ui/views/common.templ`, Line: 139, Col: 55}
}
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var14))
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 29, "</a>")
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
}
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 30, "</span> ")
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
}
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 31, "<span class=\"pagination-btn\">")
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
if currentPage < totalPages {
url := fmt.Sprintf("%s?page=%d", baseUrl, currentPage+1)
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 32, "<a href=\"")
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
var templ_7745c5c3_Var15 templ.SafeURL = templ.URL(url)
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(string(templ_7745c5c3_Var15)))
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 33, "\">Next</a>")
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
} else {
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 34, "Next")
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
}
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 35, "</span></div>")
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
return nil
})
}
var _ = templruntime.GeneratedTemplate