Skip to content

Commit

Permalink
Moving over item counter formatter to compton
Browse files Browse the repository at this point in the history
  • Loading branch information
boggydigital committed Oct 28, 2024
1 parent 680dcd8 commit 2bb6ac4
Show file tree
Hide file tree
Showing 9 changed files with 27 additions and 47 deletions.
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ require (
github.com/boggydigital/atomus v0.1.9
github.com/boggydigital/backups v0.1.3
github.com/boggydigital/clo v1.0.4
github.com/boggydigital/compton v0.1.96
github.com/boggydigital/compton v0.1.97
github.com/boggydigital/coost v0.3.9
github.com/boggydigital/dolo v0.2.18
github.com/boggydigital/issa v0.1.12
Expand Down
2 changes: 2 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@ github.com/boggydigital/compton v0.1.95 h1:0TP++8sGf5qe9mBrDIEdhdHhSJ+dJxWtBp0t2
github.com/boggydigital/compton v0.1.95/go.mod h1:dj/yZ2cCfts6+heUS60Favateu+gNTIsoxfX6yNZWLg=
github.com/boggydigital/compton v0.1.96 h1:Rg7GvZrDFgsm0htDof/MNCXexkzW/BrLfG0DPsBAaQc=
github.com/boggydigital/compton v0.1.96/go.mod h1:dj/yZ2cCfts6+heUS60Favateu+gNTIsoxfX6yNZWLg=
github.com/boggydigital/compton v0.1.97 h1:xRe+lOILJtmav9a+njNtkBqBQsefnwa2VUV5AnBuwAg=
github.com/boggydigital/compton v0.1.97/go.mod h1:dj/yZ2cCfts6+heUS60Favateu+gNTIsoxfX6yNZWLg=
github.com/boggydigital/coost v0.3.9 h1:lMfR5PyexBDR4xDOQp0zWZWUk/Dqlrx7gw7i7XdsC4c=
github.com/boggydigital/coost v0.3.9/go.mod h1:w7ChGaah1DKsBIXb9ANdILg2pe2Jp7JkNpnK2R6rBec=
github.com/boggydigital/dolo v0.2.18 h1:aN/Bq55e0/9VgmVTNw0ru3aoS6lpZJI59ho5YQlFbDE=
Expand Down
7 changes: 7 additions & 0 deletions rest/compton_data/count_templates.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
package compton_data

const (
SingleItemTemplate = "1 item"
ManyItemsSinglePageTemplate = "{total} items"
ManyItemsManyPagesTemplate = "{from}-{to} out of {total} items"
)
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import (
"github.com/boggydigital/compton/consts/input_types"
)

func ShowMoreButton(r compton.Registrar, title, href string) compton.Element {
func Button(r compton.Registrar, title, href string) compton.Element {

showAllLink := compton.A(href)

Expand Down
37 changes: 0 additions & 37 deletions rest/compton_fragments/items_count.go

This file was deleted.

10 changes: 7 additions & 3 deletions rest/compton_pages/search.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,12 @@ func Search(query map[string][]string, ids []string, from, to int, rdx kevlar.Re

if len(query) > 0 {

itemsCount := compton_fragments.ItemsCount(p, from, to, len(ids))
filterSearchDetails.AppendSummary(itemsCount)
cf := compton.NewCountFormatter(
compton_data.SingleItemTemplate,
compton_data.ManyItemsSinglePageTemplate,
compton_data.ManyItemsManyPagesTemplate)

filterSearchDetails.AppendSummary(cf.TitleElement(p, from, to, len(ids)))
}

searchQuery := compton.Query(p, query,
Expand Down Expand Up @@ -69,7 +73,7 @@ func Search(query map[string][]string, ids []string, from, to int, rdx kevlar.Re

href := "/search?" + enq

pageStack.Append(compton_fragments.ShowMoreButton(p, "Next page", href))
pageStack.Append(compton_fragments.Button(p, "Next page", href))
}

/* Standard app footer */
Expand Down
2 changes: 1 addition & 1 deletion rest/compton_pages/steam_news.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ func SteamNews(id string, san *steam_integration.AppNews, all bool) compton.Page
title = "Show only community announcements"
href = "/steam-news?id=" + id
}
pageStack.Append(compton_fragments.ShowMoreButton(s, title, href))
pageStack.Append(compton_fragments.Button(s, title, href))
}

newsItems := communityAnnouncements
Expand Down
10 changes: 7 additions & 3 deletions rest/compton_pages/updates.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ func Updates(sections []string,

var showAll compton.Element
if hasMoreItems(sections, updates, updateTotals) {
showAll = compton_fragments.ShowMoreButton(p, "Show all", "?show-all=true")
showAll = compton_fragments.Button(p, "Show all", "?show-all=true")
pageStack.Append(showAll)
}

Expand All @@ -65,8 +65,12 @@ func Updates(sections []string,
DetailsMarginBlockEnd(size.Unset).
SummaryRowGap(size.XXSmall)

itemsCount := compton_fragments.ItemsCount(p, 0, len(ids), updateTotals[section])
sectionDetailsToggle.AppendSummary(itemsCount)
cf := compton.NewCountFormatter(
compton_data.SingleItemTemplate,
compton_data.ManyItemsSinglePageTemplate,
compton_data.ManyItemsManyPagesTemplate)

sectionDetailsToggle.AppendSummary(cf.TitleElement(p, 0, len(ids), updateTotals[section]))

sectionDetailsToggle.SetId(sectionTitle)
pageStack.Append(sectionDetailsToggle)
Expand Down
2 changes: 1 addition & 1 deletion rest/get_search.go
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ func GetSearch(w http.ResponseWriter, r *http.Request) {

var err error
found := rdx.Match(q)
ids, err = rdx.Sort(found, desc, sort, vangogh_local_data.TitleProperty)
ids, err = rdx.Sort(found, desc, sort, vangogh_local_data.TitleProperty, vangogh_local_data.ProductTypeProperty)
if err != nil {
http.Error(w, nod.Error(err).Error(), http.StatusInternalServerError)
return
Expand Down

0 comments on commit 2bb6ac4

Please sign in to comment.