Skip to content

Commit

Permalink
People pages now show the last 6 items now rather than the first 6
Browse files Browse the repository at this point in the history
Fixes #35
  • Loading branch information
Brookke committed May 22, 2017
1 parent 127e8ff commit bfa01c3
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 7 deletions.
11 changes: 5 additions & 6 deletions utils/template.go
Original file line number Diff line number Diff line change
Expand Up @@ -54,13 +54,12 @@ func RenderTemplate(w http.ResponseWriter, context structs.PageContext, data int
t := template.New("base.tmpl")
t.Funcs(template.FuncMap{
"html": renderHTML,
"limitShowMeta": func(a []myradio.ShowMeta, start int, end int) []myradio.ShowMeta {
if len(a) < end {
return a[start:]
} else if len(a) < start {
return nil
//Takes a splice of show meta and returns the last x elements
"getLastShowMeta": func(a []myradio.ShowMeta, amount int) []myradio.ShowMeta {
if len(a) < amount {
return a
}
return a[start:end]
return a[len(a)-amount:]

},
//Takes a splice of seasons and returns the total number of episodes
Expand Down
2 changes: 1 addition & 1 deletion views/people.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
<h1 class="user-name pt-3">{{.Name}}</h1>
<hr>
<div class="row">
{{range limitShowMeta .ShowCredits 0 6}}
{{range getLastShowMeta .ShowCredits 6}}
<div class="col-4 col-md-2 p-0">
<a href="{{.MicroSiteLink.URL}}" title="View the {{.Title}} webpage.">
<img class="img-fluid" src="https://ury.org.uk{{.Photo}}" alt="{{.Title}} logo." />
Expand Down

0 comments on commit bfa01c3

Please sign in to comment.