package router import ( "html/template" "log" "math" "net/url" "strconv" "github.com/nicksnyder/go-i18n/i18n" "github.com/ewhal/nyaa/templates" ) var FuncMap = template.FuncMap{ "min": math.Min, "genRoute": func(name string, params ...string) string { url, err := Router.Get(name).URL(params...) if err == nil { return url.String() } return "error" }, "genRouteWithQuery": func(name string, currentUrl *url.URL, params ...string) template.HTML { url, err := Router.Get(name).URL(params...) if err == nil { return template.HTML(url.String()+ "?" + currentUrl.RawQuery) } return "error" }, "genNav": func(nav Navigation, currentUrl *url.URL, pagesSelectable int) template.HTML { maxPages := math.Ceil(float64(nav.TotalItem) / float64(nav.MaxItemPerPage)) var ret = "" if nav.CurrentPage-1 > 0 { url, _ := Router.Get(nav.Route).URL("page", "1") ret = ret + "