Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Increase player count to 20, preserve get variables #17

Merged
merged 1 commit into from
Apr 27, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 18 additions & 1 deletion pkg/site/site.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,8 @@ import (
const VERSION = "2020-04-22.01"

var (
nonWordRe = regexp.MustCompile(`\W`)
nonWordRe = regexp.MustCompile(`\W`)
MaxPlayers = 20
)

// Config is how external users interact with this package.
Expand Down Expand Up @@ -99,6 +100,7 @@ type Page struct {
Player int
Players int
PlayerChoices []string
PlayerNums []int
Mode int
Index int
EmbedURL string
Expand All @@ -113,6 +115,8 @@ type Page struct {
CollectionResult *triage.CollectionResult
Stats *triage.CollectionResult
StatsID string

GetVars string
}

// is this request an HTTP refresh?
Expand Down Expand Up @@ -158,6 +162,11 @@ func (h *Handlers) Collection() http.HandlerFunc {
playerChoices = append(playerChoices, fmt.Sprintf("Player %d", i+1))
}

playerNums := []int{}
for i := 0; i < MaxPlayers; i++ {
playerNums = append(playerNums, i+1)
}

klog.Infof("GET %s (%q): %v", r.URL.Path, id, r.Header)
s, err := h.party.LookupCollection(id)
if err != nil {
Expand Down Expand Up @@ -239,6 +248,12 @@ func (h *Handlers) Collection() http.HandlerFunc {
}
}
}

getVars := ""
if players > 0 {
getVars = fmt.Sprintf("?player=%d&players=%d", player, players)
}

p := &Page{
ID: s.ID,
Version: VERSION,
Expand All @@ -252,13 +267,15 @@ func (h *Handlers) Collection() http.HandlerFunc {
TotalShown: len(uniqueFiltered),
Types: "Issues",
PlayerChoices: playerChoices,
PlayerNums: playerNums,
Player: player,
Players: players,
Mode: mode,
Index: index,
EmbedURL: embedURL,
Warning: warning,
UniqueItems: uniqueFiltered,
GetVars: getVars,
}

for _, s := range sts {
Expand Down
8 changes: 4 additions & 4 deletions site/base.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -25,16 +25,16 @@
<div class="navbar-start">
{{ range .Collections }}
{{ if not .Hidden }}
<a class="navbar-item {{ if eq $.ID .ID }}is-active{{ else }}is-inactive{{ end }}" href="/s/{{ .ID }}">{{ .Name }}</a>
<a class="navbar-item {{ if eq $.ID .ID }}is-active{{ else }}is-inactive{{ end }}" href="/s/{{ .ID }}{{ $.GetVars }}">{{ .Name }}</a>
{{ end }}
{{ end }}
</div>
<div class="navbar-end">
<div class="buttons">
{{ if .Stats }}
<a class="button is-white" title="Total PRs" href="/s/{{ .StatsID }}">{{ .Stats.TotalPullRequests }} PRs</a>
<a class="button is-white" title="Total Issues" href="/s/{{ .StatsID }}">{{ .Stats.TotalIssues }} issues</a>
<a class="button is-white" title="Average time latest response took on each issue" href="/s/{{ .StatsID }}">{{ .Stats.AvgDelay | toDays }} response</a>
<a class="button is-white" title="Total PRs" href="/s/{{ .StatsID }}{{ $.GetVars }}">{{ .Stats.TotalPullRequests }} PRs</a>
<a class="button is-white" title="Total Issues" href="/s/{{ .StatsID }}{{ $.GetVars }}">{{ .Stats.TotalIssues }} issues</a>
<a class="button is-white" title="Average time latest response took on each issue" href="/s/{{ .StatsID }}{{ $.GetVars }}">{{ .Stats.AvgDelay | toDays }} response</a>
{{ end }}
</div>
</div>
Expand Down
9 changes: 3 additions & 6 deletions site/collection.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -40,12 +40,9 @@
of
{{ end }}
<select onchange="this.form.submit();" name="players">
<option value="1" {{ if eq .Players 1}}selected{{ end }}>Solo</option>
<option value="2" {{ if eq .Players 2}}selected{{ end }}>2 Players</option>
<option value="3" {{ if eq .Players 3}}selected{{ end }}>3 Players</option>
<option value="4" {{ if eq .Players 4}}selected{{ end }}>4 Players</option>
<option value="5" {{ if eq .Players 5}}selected{{ end }}>5 Players</option>
<option value="6" {{ if eq .Players 6}}selected{{ end }}>6 Players</option>
{{ range $i, $val := .PlayerNums }}
<option value="{{ $val }}" {{ if eq $.Players $val}}selected{{ end }}>{{ if eq $val 1}}Solo{{ else }}{{ $val }} Players{{ end }}</option>
{{ end }}
</select>
</form>
</div>
Expand Down