openidec

Unnamed repository; edit this file 'description' to name the repository.
Log | Files | Refs | README | LICENSE

commit 53ab6042eee3185f3223651eac6b97e9bc0c677d
parent 535c874b133bae526a8940975feb205137896ff1
Author: Peter Kosyh <p.kosyh@gmail.com>
Date:   Sat,  5 Sep 2020 21:53:33 +0300

compat with go 1.8

Diffstat:
Mii-node/tpl/index.tpl | 10++++------
Mii-node/tpl/topics.tpl | 10++++------
Mii-node/web.go | 3+++
3 files changed, 11 insertions(+), 12 deletions(-)

diff --git a/ii-node/tpl/index.tpl b/ii-node/tpl/index.tpl @@ -1,5 +1,4 @@ {{template "header.tpl" $}} -{{ $odd := false }} <table id="echolist" cellspacing=0 cellpadding=0> <tr class="title"> <th>Echo</th> @@ -7,11 +6,11 @@ <th class="extra">Posts</th> <th>Last</th> </tr> -{{range .Echoes }} -{{ if $odd }} -<tr class="odd"> -{{ else }} +{{range $k, $_ := .Echoes }} +{{ if is_even $k }} <tr class="even"> +{{ else }} +<tr class="odd"> {{ end }} <td class="echo"><a href="/{{.Name}}/">{{.Name}}</a><br> <span class="info">{{ index $.Echolist.Info .Name }}</span> @@ -20,7 +19,6 @@ <td class="count extra">{{.Count}}</td> <td class="info">{{with .Msg}}<span class="subj">{{.Subj}}</span><br><a href="/{{.MsgId}}#{{.MsgId}}">{{.Date | fdate}}</a> by {{.From}}{{end}}</td> </tr> -{{ $odd = not $odd }} {{ end }} </table> diff --git a/ii-node/tpl/topics.tpl b/ii-node/tpl/topics.tpl @@ -1,5 +1,4 @@ {{template "header.tpl" $}} -{{ $odd := false }} {{template "pager.tpl" $}} <table id="topiclist" cellspacing=0 cellpadding=0> <tr class="title"> @@ -7,17 +6,16 @@ <th class="extra">Posts</th> <th>Last post</th> </tr> -{{range .Topics }} -{{ if $odd }} -<tr class="odd"> -{{ else }} +{{range $k, $v := .Topics }} +{{ if is_even $k }} <tr class="even"> +{{ else }} +<tr class="odd"> {{ end }} <td class="topic"><a href="/{{.Head.MsgId}}/1">{{with .Head.Subj}}{{.}}{{else}}No subject{{end}}</a></td> <td class="posts extra">{{.Count}}</td> <td class="info"><a href="/{{.Tail.MsgId}}#{{.Tail.MsgId}}">{{.Tail.Date | fdate}}</a><br>by {{.Tail.From}}</td> </tr> -{{ $odd = not $odd }} {{ end }} </table> {{template "pager.tpl" $}} diff --git a/ii-node/web.go b/ii-node/web.go @@ -543,6 +543,9 @@ func WebInit(www *WWW) { "msg_access": func (m ii.Msg, u ii.User) bool { return msg_access(www, m, u) }, + "is_even": func (i int) bool { + return i % 2 == 0 + }, } www.tpl = template.Must(template.New("main").Funcs(funcMap).ParseGlob("tpl/*.tpl")) }