Changed theme, added search, added pagination

This commit is contained in:
2022-11-27 09:27:49 +01:00
parent 7ab57f2ea0
commit bea96468d5
19 changed files with 370 additions and 137 deletions
+16 -3
View File
@@ -6,9 +6,10 @@ import (
"net/http"
"path/filepath"
"strings"
"text/template"
"time"
"github.com/diaid83/pokemongotemplates/internal/infrastructure"
"github.com/dadobos/pokemongotemplates/internal/infrastructure"
"github.com/gin-gonic/gin"
)
@@ -22,6 +23,13 @@ type ApplicationServer struct {
State ApplicationState
}
var templateFunctionMap = template.FuncMap{
"GetCurrentYear": infrastructure.GetCurrentYear,
"GetPrevPagePokemons": infrastructure.GetPrevPagePokemons,
"GetNextPagePokemons": infrastructure.GetNextPagePokemons,
}
func (s *ApplicationServer) registerHandlers() {
var files []string
@@ -36,9 +44,14 @@ func (s *ApplicationServer) registerHandlers() {
if err != nil {
panic(err.Error())
}
s.State.Handler.SetFuncMap(templateFunctionMap)
s.State.Handler.LoadHTMLFiles(files...)
s.State.Handler.GET("/", s.pokemonPageHandler())
s.State.Handler.GET("/custom", s.customPokemonPageHandler())
s.State.Handler.GET("/", s.pageHandler())
s.State.Handler.GET("/pagination", s.paginationPageHandler())
s.State.Handler.GET("/form/send-pagination", s.slugSendPaginationRequestHandler())
}
func NewApplicationServer(userOptions *ApplicationState) *ApplicationServer {