package pages import ( "fmt" c "git.ekzyis.com/ekzyis/delphi.market/server/router/context" "git.ekzyis.com/ekzyis/delphi.market/server/router/pages/components" "git.ekzyis.com/ekzyis/delphi.market/types" "github.com/dustin/go-humanize" "time" ) templ Index(markets []types.Market) { @components.Head() @components.Nav()
@components.Figlet("random", "delphi")
A prediction market using the lightning network
if ctx.Value(c.ReqPathContextKey).(string) == "/" {
for _, m := range markets { { m.Question }
{ m.User.Name } / { humanize.Time(m.CreatedAt) } / { humanize.Time(m.EndDate) }
{ fmt.Sprintf("%.2f%%", m.Pyes * 100) }
{ fmt.Sprintf("%s", humanizeRound(m.Volume)) }
}
} else {
optional
}
@components.Modal(nil) @components.Footer() } func minDate() string { return time.Now().Add(24 * time.Hour).Format("2006-01-02") } func humanizeRound(f float64) string { if f > 1_000_000 { return fmt.Sprintf("%.2fm", f/1_000_000) } else if f > 1_000 { return fmt.Sprintf("%.2fk", f/1_000) } else { return fmt.Sprintf("%.2f", f) } } func colorize(f float64) string { if f > 0.5 { return "text-success" } else { return "text-error" } } func tabStyle(path string, tab string) string { class := "!no-underline" if path == tab { class += " font-bold border-b-none" } return class }