func Index(users []*models.User, total int, limit int, offset int) string { var _buffer bytes.Buffer _buffer.WriteString("\n\n<h2 class=\"sub-header\">用户总数:") _buffer.WriteString(gorazor.HTMLEscape(gorazor.Itoa(total))) _buffer.WriteString("</h2>\n<div class=\"table-responsive\">\n <table class=\"table table-striped\">\n <thead>\n <tr>\n <th>名字</th>\n <th>电邮</th>\n <th>编辑</th>\n </tr>\n </thead>\n <tbody>\n ") for _, u := range users { _buffer.WriteString("<tr>\n <td>") _buffer.WriteString(gorazor.HTMLEscape(u.Name)) _buffer.WriteString("</td>\n <td>") _buffer.WriteString(gorazor.HTMLEscape(u.Email)) _buffer.WriteString("</td>\n <td><a href=\"/admin/user/edit?id=") _buffer.WriteString(gorazor.HTMLEscape(u.ID.Hex())) _buffer.WriteString("\">编辑</a></td>\n </tr>") } _buffer.WriteString("\n </tbody>\n </table>\n</div>") js := func() string { var _buffer bytes.Buffer return _buffer.String() } title := func() string { var _buffer bytes.Buffer _buffer.WriteString("用户管理") return _buffer.String() } return layout.Base(_buffer.String(), title(), js()) }
func Index(u *model.User, nav []*model.Navigation, title string) string { var _buffer bytes.Buffer _buffer.WriteString("\n\n<div class=\"content\">\n\t<div class=\"welcome\">\n\t\t<h4>Hello ") _buffer.WriteString(gorazor.HTMLEscape(u.FirstName)) _buffer.WriteString("</h4>\n\t\t\n\t\t<div class=\"raw\">") _buffer.WriteString((u.RawContent)) _buffer.WriteString("</div>\n\t\t<div class=\"enc\">") _buffer.WriteString(gorazor.HTMLEscape(u.EscapedContent)) _buffer.WriteString("</div>\n\t</div>") for i := 1; i <= 5; i++ { if i == 1 { _buffer.WriteString("<p>") _buffer.WriteString(gorazor.HTMLEscape(u.FirstName)) _buffer.WriteString(" has ") _buffer.WriteString(gorazor.HTMLEscape(i)) _buffer.WriteString(" message</p>") } else { _buffer.WriteString("<p>") _buffer.WriteString(gorazor.HTMLEscape(u.FirstName)) _buffer.WriteString(" has ") _buffer.WriteString(gorazor.HTMLEscape(gorazor.Itoa(i))) _buffer.WriteString(" messages</p>") } } _buffer.WriteString("\n</div>") header := func() string { var _buffer bytes.Buffer _buffer.WriteString((helper.Header(title))) return _buffer.String() } footer := func() string { var _buffer bytes.Buffer _buffer.WriteString((helper.Footer())) return _buffer.String() } navigation := func() string { var _buffer bytes.Buffer _buffer.WriteString((helper.Navigation(nav))) return _buffer.String() } return layout.Base(_buffer.String(), header(), footer(), navigation()) }
func Argsbug(totalMessage int, u *User) string { var _buffer bytes.Buffer messages := []string{} _buffer.WriteString("\n\n<p>") _buffer.WriteString(gorazor.HTMLEscape(gorazor.Itoa(args(messages...)))) _buffer.WriteString("</p>") return layout.Args(_buffer.String()) }
func Home(totalMessage int, u *User) string { var _buffer bytes.Buffer _buffer.WriteString((helper.Header())) _buffer.WriteString((helper.Msg(u))) for i := 0; i < 2; i++ { if totalMessage > 0 { if totalMessage == 1 { _buffer.WriteString("<p>") _buffer.WriteString(gorazor.HTMLEscape(u.Name)) _buffer.WriteString(" has 1 message</p>") } else { _buffer.WriteString("<p>") _buffer.WriteString(gorazor.HTMLEscape(u.Name)) _buffer.WriteString(" has ") _buffer.WriteString(gorazor.HTMLEscape(gorazor.Itoa(totalMessage))) _buffer.WriteString(" messages</p>") } } else { _buffer.WriteString("<p>") _buffer.WriteString(gorazor.HTMLEscape(u.Name)) _buffer.WriteString(" has no messages</p>") } } for i := 0; i < 2; i++ { if totalMessage > 0 { if totalMessage == 1 { _buffer.WriteString("<p>") _buffer.WriteString(gorazor.HTMLEscape(u.Name)) _buffer.WriteString(" has 1 message</p>") } else { _buffer.WriteString("<p>") _buffer.WriteString(gorazor.HTMLEscape(u.Name)) _buffer.WriteString(" has ") _buffer.WriteString(gorazor.HTMLEscape(gorazor.Itoa(totalMessage))) _buffer.WriteString(" messages</p>") } } else { _buffer.WriteString("<p>") _buffer.WriteString(gorazor.HTMLEscape(u.Name)) _buffer.WriteString(" has no messages</p>") } } switch totalMessage { case 1: _buffer.WriteString("<p>") _buffer.WriteString(gorazor.HTMLEscape(u.Name)) _buffer.WriteString(" has 1 message</p>") case 2: _buffer.WriteString("<p>") _buffer.WriteString(gorazor.HTMLEscape(u.Name)) _buffer.WriteString(" has 2 messages</p>") default: _buffer.WriteString("<p>") _buffer.WriteString(gorazor.HTMLEscape(u.Name)) _buffer.WriteString(" has no messages</p>") } _buffer.WriteString((helper.Footer())) title := func() string { var _buffer bytes.Buffer _buffer.WriteString("<title>") _buffer.WriteString(gorazor.HTMLEscape(u.Name)) _buffer.WriteString("'s homepage</title>") return _buffer.String() } side := func() string { var _buffer bytes.Buffer return _buffer.String() } return layout.Base(_buffer.String(), title(), side()) }