37 lines
808 B
Text
37 lines
808 B
Text
|
package tpl
|
|||
|
|
|||
|
import (
|
|||
|
"sh.org.ru/pkg/model"
|
|||
|
"strconv"
|
|||
|
)
|
|||
|
|
|||
|
templ Admin(quotes []model.Quote, count int) {
|
|||
|
@Layout(HeaderParams{}) {
|
|||
|
for _, q := range quotes {
|
|||
|
@QuoteAdmin(&q)
|
|||
|
}
|
|||
|
Всего { strconv.Itoa(count) } цитат.
|
|||
|
}
|
|||
|
}
|
|||
|
|
|||
|
templ QuoteAdmin(quote *model.Quote) {
|
|||
|
<article>
|
|||
|
<header>#{ strconv.Itoa(int(quote.ID)) }</header>
|
|||
|
@templ.Raw(quote.Text())
|
|||
|
<footer>
|
|||
|
<form method="post" action="/admin/action">
|
|||
|
<input type="hidden" name="id" value={ strconv.Itoa(int(quote.ID)) }/>
|
|||
|
<div role="group">
|
|||
|
<input class="primary" type="submit" name="action" value="approve"/>
|
|||
|
<input class="secondary" type="submit" name="action" value="decline"/>
|
|||
|
</div>
|
|||
|
</form>
|
|||
|
</footer>
|
|||
|
</article>
|
|||
|
}
|
|||
|
|
|||
|
type AdminForm struct {
|
|||
|
ID int `form:"id"`
|
|||
|
Action string `form:"action"`
|
|||
|
}
|