gosora/template_topic.go
Azareal 9075798128 Alerts are now rendered via a client side transpiled template rather than being hard-coded.
Tweaked some bits to make them more 32-bit friendly for GopherJS, but this might not be necessary now.
Added notice.html
Added an alerts package to fix the import cycles, more things may be moved here soon.
Saved a few lines of accumulator code in a few stores.
Moved the AccountEditCriticalSubmit, AccountEditAvatar, AccountEditAvatarSubmit, AccountEditUsername, and AccountEditUsernameSubmit routes into the routes package.
Added a QueryRow method to AccSelectBuilder.
Tweaked the indentation in the generated templates.
Simplified the template render in the AccountEditUsernameSubmit route into a redirect back to the previous page.

Run the update script / patcher to replace the route names in the viewchunks table.
2018-05-14 18:56:56 +10:00

591 lines
16 KiB
Go

// +build !no_templategen
// Code generated by Gosora. More below:
/* This file was automatically generated by the software. Please don't edit it as your changes may be overwritten at any moment. */
package main
import "strconv"
import "io"
import "./common"
var topic_tmpl_phrase_id int
// nolint
func init() {
common.Template_topic_handle = Template_topic
common.Ctemplates = append(common.Ctemplates,"topic")
common.TmplPtrMap["topic"] = &common.Template_topic_handle
common.TmplPtrMap["o_topic"] = Template_topic
topic_tmpl_phrase_id = common.RegisterTmplPhraseNames([]string{
"menu_hamburger_tooltip",
"paginator_prev_page_aria",
"paginator_less_than",
"paginator_next_page_aria",
"paginator_greater_than",
"topic_opening_post_aria",
"status_closed_tooltip",
"topic_status_closed_aria",
"topic_title_input_aria",
"topic_update_button",
"topic_poll_aria",
"topic_poll_vote",
"topic_poll_results",
"topic_poll_cancel",
"topic_opening_post_aria",
"topic_post_controls_aria",
"topic_unlike_tooltip",
"topic_unlike_aria",
"topic_like_tooltip",
"topic_like_aria",
"topic_edit_tooltip",
"topic_edit_aria",
"topic_delete_tooltip",
"topic_delete_aria",
"topic_unlock_tooltip",
"topic_unlock_aria",
"topic_lock_tooltip",
"topic_lock_aria",
"topic_unpin_tooltip",
"topic_unpin_aria",
"topic_pin_tooltip",
"topic_pin_aria",
"topic_ip_tooltip",
"topic_flag_tooltip",
"topic_flag_aria",
"topic_like_count_aria",
"topic_like_count_tooltip",
"topic_level_aria",
"topic_level_tooltip",
"topic_current_page_aria",
"topic_post_like_tooltip",
"topic_post_like_aria",
"topic_post_unlike_tooltip",
"topic_post_unlike_aria",
"topic_post_edit_tooltip",
"topic_post_edit_aria",
"topic_post_delete_tooltip",
"topic_post_delete_aria",
"topic_post_ip_tooltip",
"topic_post_flag_tooltip",
"topic_post_flag_aria",
"topic_post_like_count_tooltip",
"topic_post_level_aria",
"topic_post_level_tooltip",
"topic_reply_aria",
"topic_reply_content",
"topic_reply_add_poll_option",
"topic_reply_button",
"topic_reply_add_poll_button",
"topic_reply_add_file_button",
"footer_powered_by",
"footer_made_with_love",
"footer_theme_selector_aria",
})
}
// nolint
func Template_topic(tmpl_topic_vars common.TopicPage, w io.Writer) error {
var phrases = common.GetTmplPhrasesBytes(topic_tmpl_phrase_id)
w.Write(header_frags[0])
w.Write([]byte(tmpl_topic_vars.Title))
w.Write(header_frags[1])
w.Write([]byte(tmpl_topic_vars.Header.Site.Name))
w.Write(header_frags[2])
w.Write([]byte(tmpl_topic_vars.Header.Theme.Name))
w.Write(header_frags[3])
if len(tmpl_topic_vars.Header.Stylesheets) != 0 {
for _, item := range tmpl_topic_vars.Header.Stylesheets {
w.Write(header_frags[4])
w.Write([]byte(item))
w.Write(header_frags[5])
}
}
w.Write(header_frags[6])
if len(tmpl_topic_vars.Header.Scripts) != 0 {
for _, item := range tmpl_topic_vars.Header.Scripts {
w.Write(header_frags[7])
w.Write([]byte(item))
w.Write(header_frags[8])
}
}
w.Write(header_frags[9])
w.Write([]byte(tmpl_topic_vars.CurrentUser.Session))
w.Write(header_frags[10])
w.Write([]byte(tmpl_topic_vars.Header.Site.URL))
w.Write(header_frags[11])
if tmpl_topic_vars.Header.MetaDesc != "" {
w.Write(header_frags[12])
w.Write([]byte(tmpl_topic_vars.Header.MetaDesc))
w.Write(header_frags[13])
}
w.Write(header_frags[14])
if !tmpl_topic_vars.CurrentUser.IsSuperMod {
w.Write(header_frags[15])
}
w.Write(header_frags[16])
w.Write([]byte(common.BuildWidget("leftOfNav",tmpl_topic_vars.Header)))
w.Write(header_frags[17])
w.Write([]byte(tmpl_topic_vars.Header.Site.ShortName))
w.Write(header_frags[18])
w.Write([]byte(common.BuildWidget("topMenu",tmpl_topic_vars.Header)))
w.Write(header_frags[19])
w.Write(phrases[0])
w.Write(header_frags[20])
w.Write([]byte(common.BuildWidget("rightOfNav",tmpl_topic_vars.Header)))
w.Write(header_frags[21])
if tmpl_topic_vars.Header.Widgets.RightSidebar != "" {
w.Write(header_frags[22])
}
w.Write(header_frags[23])
if len(tmpl_topic_vars.Header.NoticeList) != 0 {
for _, item := range tmpl_topic_vars.Header.NoticeList {
w.Write(notice_frags[0])
w.Write([]byte(item))
w.Write(notice_frags[1])
}
}
w.Write(header_frags[24])
w.Write(topic_frags[0])
w.Write([]byte(strconv.Itoa(tmpl_topic_vars.Topic.ID)))
w.Write(topic_frags[1])
w.Write([]byte(tmpl_topic_vars.CurrentUser.Session))
w.Write(topic_frags[2])
if tmpl_topic_vars.Page > 1 {
w.Write(topic_frags[3])
w.Write([]byte(strconv.Itoa(tmpl_topic_vars.Topic.ID)))
w.Write(topic_frags[4])
w.Write([]byte(strconv.Itoa(tmpl_topic_vars.Page - 1)))
w.Write(topic_frags[5])
w.Write(phrases[1])
w.Write(topic_frags[6])
w.Write([]byte(strconv.Itoa(tmpl_topic_vars.Topic.ID)))
w.Write(topic_frags[7])
w.Write([]byte(strconv.Itoa(tmpl_topic_vars.Page - 1)))
w.Write(topic_frags[8])
w.Write(phrases[2])
w.Write(topic_frags[9])
}
if tmpl_topic_vars.LastPage != tmpl_topic_vars.Page {
w.Write(topic_frags[10])
w.Write([]byte(strconv.Itoa(tmpl_topic_vars.Topic.ID)))
w.Write(topic_frags[11])
w.Write([]byte(strconv.Itoa(tmpl_topic_vars.Page + 1)))
w.Write(topic_frags[12])
w.Write(phrases[3])
w.Write(topic_frags[13])
w.Write([]byte(strconv.Itoa(tmpl_topic_vars.Topic.ID)))
w.Write(topic_frags[14])
w.Write([]byte(strconv.Itoa(tmpl_topic_vars.Page + 1)))
w.Write(topic_frags[15])
w.Write(phrases[4])
w.Write(topic_frags[16])
}
w.Write(topic_frags[17])
w.Write(topic_frags[18])
w.Write(phrases[5])
w.Write(topic_frags[19])
if tmpl_topic_vars.Topic.Sticky {
w.Write(topic_frags[20])
} else {
if tmpl_topic_vars.Topic.IsClosed {
w.Write(topic_frags[21])
}
}
w.Write(topic_frags[22])
w.Write([]byte(tmpl_topic_vars.Topic.Title))
w.Write(topic_frags[23])
w.Write([]byte(tmpl_topic_vars.Topic.Title))
w.Write(topic_frags[24])
if tmpl_topic_vars.Topic.IsClosed {
w.Write(topic_frags[25])
w.Write(phrases[6])
w.Write(topic_frags[26])
w.Write(phrases[7])
w.Write(topic_frags[27])
}
if tmpl_topic_vars.CurrentUser.Perms.EditTopic {
w.Write(topic_frags[28])
w.Write([]byte(tmpl_topic_vars.Topic.Title))
w.Write(topic_frags[29])
w.Write(phrases[8])
w.Write(topic_frags[30])
w.Write(phrases[9])
w.Write(topic_frags[31])
}
w.Write(topic_frags[32])
if tmpl_topic_vars.Poll.ID > 0 {
w.Write(topic_frags[33])
w.Write(phrases[10])
w.Write(topic_frags[34])
w.Write([]byte(tmpl_topic_vars.Topic.ClassName))
w.Write(topic_frags[35])
w.Write([]byte(tmpl_topic_vars.Topic.Avatar))
w.Write(topic_frags[36])
w.Write([]byte(tmpl_topic_vars.Header.Theme.Name))
w.Write(topic_frags[37])
if tmpl_topic_vars.Topic.ContentLines <= 5 {
w.Write(topic_frags[38])
}
w.Write(topic_frags[39])
if len(tmpl_topic_vars.Poll.QuickOptions) != 0 {
for _, item := range tmpl_topic_vars.Poll.QuickOptions {
w.Write(topic_frags[40])
w.Write([]byte(strconv.Itoa(tmpl_topic_vars.Poll.ID)))
w.Write(topic_frags[41])
w.Write([]byte(strconv.Itoa(item.ID)))
w.Write(topic_frags[42])
w.Write([]byte(strconv.Itoa(item.ID)))
w.Write(topic_frags[43])
w.Write([]byte(strconv.Itoa(item.ID)))
w.Write(topic_frags[44])
w.Write([]byte(strconv.Itoa(item.ID)))
w.Write(topic_frags[45])
w.Write([]byte(item.Value))
w.Write(topic_frags[46])
}
}
w.Write(topic_frags[47])
w.Write([]byte(strconv.Itoa(tmpl_topic_vars.Poll.ID)))
w.Write(topic_frags[48])
w.Write(phrases[11])
w.Write(topic_frags[49])
w.Write([]byte(strconv.Itoa(tmpl_topic_vars.Poll.ID)))
w.Write(topic_frags[50])
w.Write(phrases[12])
w.Write(topic_frags[51])
w.Write(phrases[13])
w.Write(topic_frags[52])
w.Write([]byte(strconv.Itoa(tmpl_topic_vars.Poll.ID)))
w.Write(topic_frags[53])
}
w.Write(topic_frags[54])
w.Write(topic_frags[55])
w.Write(phrases[14])
w.Write(topic_frags[56])
w.Write([]byte(tmpl_topic_vars.Topic.ClassName))
w.Write(topic_frags[57])
w.Write([]byte(tmpl_topic_vars.Topic.Avatar))
w.Write(topic_frags[58])
w.Write([]byte(tmpl_topic_vars.Header.Theme.Name))
w.Write(topic_frags[59])
if tmpl_topic_vars.Topic.ContentLines <= 5 {
w.Write(topic_frags[60])
}
w.Write(topic_frags[61])
w.Write([]byte(tmpl_topic_vars.Topic.ContentHTML))
w.Write(topic_frags[62])
w.Write([]byte(tmpl_topic_vars.Topic.Content))
w.Write(topic_frags[63])
if tmpl_topic_vars.Topic.LikeCount > 0 {
w.Write(topic_frags[64])
}
w.Write(topic_frags[65])
w.Write(phrases[15])
w.Write(topic_frags[66])
w.Write([]byte(tmpl_topic_vars.Topic.UserLink))
w.Write(topic_frags[67])
w.Write([]byte(tmpl_topic_vars.Topic.CreatedByName))
w.Write(topic_frags[68])
if tmpl_topic_vars.CurrentUser.Perms.LikeItem {
w.Write(topic_frags[69])
w.Write([]byte(strconv.Itoa(tmpl_topic_vars.Topic.ID)))
w.Write(topic_frags[70])
w.Write([]byte(tmpl_topic_vars.CurrentUser.Session))
w.Write(topic_frags[71])
if tmpl_topic_vars.Topic.Liked {
w.Write(topic_frags[72])
w.Write(phrases[16])
w.Write(topic_frags[73])
w.Write(phrases[17])
w.Write(topic_frags[74])
} else {
w.Write(topic_frags[75])
w.Write(phrases[18])
w.Write(topic_frags[76])
w.Write(phrases[19])
w.Write(topic_frags[77])
}
w.Write(topic_frags[78])
if tmpl_topic_vars.Topic.Liked {
w.Write(topic_frags[79])
} else {
w.Write(topic_frags[80])
}
w.Write(topic_frags[81])
}
if tmpl_topic_vars.CurrentUser.Perms.EditTopic {
w.Write(topic_frags[82])
w.Write([]byte(strconv.Itoa(tmpl_topic_vars.Topic.ID)))
w.Write(topic_frags[83])
w.Write(phrases[20])
w.Write(topic_frags[84])
w.Write(phrases[21])
w.Write(topic_frags[85])
}
if tmpl_topic_vars.CurrentUser.Perms.DeleteTopic {
w.Write(topic_frags[86])
w.Write([]byte(strconv.Itoa(tmpl_topic_vars.Topic.ID)))
w.Write(topic_frags[87])
w.Write([]byte(tmpl_topic_vars.CurrentUser.Session))
w.Write(topic_frags[88])
w.Write(phrases[22])
w.Write(topic_frags[89])
w.Write(phrases[23])
w.Write(topic_frags[90])
}
if tmpl_topic_vars.CurrentUser.Perms.CloseTopic {
if tmpl_topic_vars.Topic.IsClosed {
w.Write(topic_frags[91])
w.Write([]byte(strconv.Itoa(tmpl_topic_vars.Topic.ID)))
w.Write(topic_frags[92])
w.Write([]byte(tmpl_topic_vars.CurrentUser.Session))
w.Write(topic_frags[93])
w.Write(phrases[24])
w.Write(topic_frags[94])
w.Write(phrases[25])
w.Write(topic_frags[95])
} else {
w.Write(topic_frags[96])
w.Write([]byte(strconv.Itoa(tmpl_topic_vars.Topic.ID)))
w.Write(topic_frags[97])
w.Write([]byte(tmpl_topic_vars.CurrentUser.Session))
w.Write(topic_frags[98])
w.Write(phrases[26])
w.Write(topic_frags[99])
w.Write(phrases[27])
w.Write(topic_frags[100])
}
}
if tmpl_topic_vars.CurrentUser.Perms.PinTopic {
if tmpl_topic_vars.Topic.Sticky {
w.Write(topic_frags[101])
w.Write([]byte(strconv.Itoa(tmpl_topic_vars.Topic.ID)))
w.Write(topic_frags[102])
w.Write([]byte(tmpl_topic_vars.CurrentUser.Session))
w.Write(topic_frags[103])
w.Write(phrases[28])
w.Write(topic_frags[104])
w.Write(phrases[29])
w.Write(topic_frags[105])
} else {
w.Write(topic_frags[106])
w.Write([]byte(strconv.Itoa(tmpl_topic_vars.Topic.ID)))
w.Write(topic_frags[107])
w.Write([]byte(tmpl_topic_vars.CurrentUser.Session))
w.Write(topic_frags[108])
w.Write(phrases[30])
w.Write(topic_frags[109])
w.Write(phrases[31])
w.Write(topic_frags[110])
}
}
if tmpl_topic_vars.CurrentUser.Perms.ViewIPs {
w.Write(topic_frags[111])
w.Write([]byte(tmpl_topic_vars.Topic.IPAddress))
w.Write(topic_frags[112])
w.Write(phrases[32])
w.Write(topic_frags[113])
w.Write([]byte(tmpl_topic_vars.Topic.IPAddress))
w.Write(topic_frags[114])
}
w.Write(topic_frags[115])
w.Write([]byte(strconv.Itoa(tmpl_topic_vars.Topic.ID)))
w.Write(topic_frags[116])
w.Write([]byte(tmpl_topic_vars.CurrentUser.Session))
w.Write(topic_frags[117])
w.Write(phrases[33])
w.Write(topic_frags[118])
w.Write(phrases[34])
w.Write(topic_frags[119])
w.Write(phrases[35])
w.Write(topic_frags[120])
w.Write([]byte(strconv.Itoa(tmpl_topic_vars.Topic.LikeCount)))
w.Write(topic_frags[121])
w.Write(phrases[36])
w.Write(topic_frags[122])
if tmpl_topic_vars.Topic.Tag != "" {
w.Write(topic_frags[123])
w.Write([]byte(tmpl_topic_vars.Topic.Tag))
w.Write(topic_frags[124])
} else {
w.Write(topic_frags[125])
w.Write(phrases[37])
w.Write(topic_frags[126])
w.Write([]byte(strconv.Itoa(tmpl_topic_vars.Topic.Level)))
w.Write(topic_frags[127])
w.Write(phrases[38])
w.Write(topic_frags[128])
}
w.Write(topic_frags[129])
w.Write(phrases[39])
w.Write(topic_frags[130])
if len(tmpl_topic_vars.ItemList) != 0 {
for _, item := range tmpl_topic_vars.ItemList {
if item.ActionType != "" {
w.Write(topic_frags[131])
w.Write([]byte(item.ActionIcon))
w.Write(topic_frags[132])
w.Write([]byte(item.ActionType))
w.Write(topic_frags[133])
} else {
w.Write(topic_frags[134])
w.Write(topic_frags[135])
w.Write([]byte(item.ClassName))
w.Write(topic_frags[136])
w.Write([]byte(item.Avatar))
w.Write(topic_frags[137])
w.Write([]byte(tmpl_topic_vars.Header.Theme.Name))
w.Write(topic_frags[138])
if item.ContentLines <= 5 {
w.Write(topic_frags[139])
}
w.Write(topic_frags[140])
w.Write(topic_frags[141])
w.Write([]byte(item.ContentHtml))
w.Write(topic_frags[142])
if item.LikeCount > 0 {
w.Write(topic_frags[143])
}
w.Write(topic_frags[144])
w.Write([]byte(item.UserLink))
w.Write(topic_frags[145])
w.Write([]byte(item.CreatedByName))
w.Write(topic_frags[146])
if tmpl_topic_vars.CurrentUser.Perms.LikeItem {
if item.Liked {
w.Write(topic_frags[147])
w.Write([]byte(strconv.Itoa(item.ID)))
w.Write(topic_frags[148])
w.Write([]byte(tmpl_topic_vars.CurrentUser.Session))
w.Write(topic_frags[149])
w.Write(phrases[40])
w.Write(topic_frags[150])
w.Write(phrases[41])
w.Write(topic_frags[151])
} else {
w.Write(topic_frags[152])
w.Write([]byte(strconv.Itoa(item.ID)))
w.Write(topic_frags[153])
w.Write([]byte(tmpl_topic_vars.CurrentUser.Session))
w.Write(topic_frags[154])
w.Write(phrases[42])
w.Write(topic_frags[155])
w.Write(phrases[43])
w.Write(topic_frags[156])
}
}
if tmpl_topic_vars.CurrentUser.Perms.EditReply {
w.Write(topic_frags[157])
w.Write([]byte(strconv.Itoa(item.ID)))
w.Write(topic_frags[158])
w.Write([]byte(tmpl_topic_vars.CurrentUser.Session))
w.Write(topic_frags[159])
w.Write(phrases[44])
w.Write(topic_frags[160])
w.Write(phrases[45])
w.Write(topic_frags[161])
}
if tmpl_topic_vars.CurrentUser.Perms.DeleteReply {
w.Write(topic_frags[162])
w.Write([]byte(strconv.Itoa(item.ID)))
w.Write(topic_frags[163])
w.Write([]byte(tmpl_topic_vars.CurrentUser.Session))
w.Write(topic_frags[164])
w.Write(phrases[46])
w.Write(topic_frags[165])
w.Write(phrases[47])
w.Write(topic_frags[166])
}
if tmpl_topic_vars.CurrentUser.Perms.ViewIPs {
w.Write(topic_frags[167])
w.Write([]byte(item.IPAddress))
w.Write(topic_frags[168])
w.Write(phrases[48])
w.Write(topic_frags[169])
w.Write([]byte(item.IPAddress))
w.Write(topic_frags[170])
}
w.Write(topic_frags[171])
w.Write([]byte(strconv.Itoa(item.ID)))
w.Write(topic_frags[172])
w.Write([]byte(tmpl_topic_vars.CurrentUser.Session))
w.Write(topic_frags[173])
w.Write(phrases[49])
w.Write(topic_frags[174])
w.Write(phrases[50])
w.Write(topic_frags[175])
w.Write([]byte(strconv.Itoa(item.LikeCount)))
w.Write(topic_frags[176])
w.Write(phrases[51])
w.Write(topic_frags[177])
if item.Tag != "" {
w.Write(topic_frags[178])
w.Write([]byte(item.Tag))
w.Write(topic_frags[179])
} else {
w.Write(topic_frags[180])
w.Write(phrases[52])
w.Write(topic_frags[181])
w.Write([]byte(strconv.Itoa(item.Level)))
w.Write(topic_frags[182])
w.Write(phrases[53])
w.Write(topic_frags[183])
}
w.Write(topic_frags[184])
}
}
}
w.Write(topic_frags[185])
if tmpl_topic_vars.CurrentUser.Perms.CreateReply {
w.Write(topic_frags[186])
w.Write(phrases[54])
w.Write(topic_frags[187])
w.Write([]byte(tmpl_topic_vars.CurrentUser.Session))
w.Write(topic_frags[188])
w.Write([]byte(strconv.Itoa(tmpl_topic_vars.Topic.ID)))
w.Write(topic_frags[189])
w.Write(phrases[55])
w.Write(topic_frags[190])
w.Write(phrases[56])
w.Write(topic_frags[191])
w.Write(phrases[57])
w.Write(topic_frags[192])
w.Write(phrases[58])
w.Write(topic_frags[193])
if tmpl_topic_vars.CurrentUser.Perms.UploadFiles {
w.Write(topic_frags[194])
w.Write(phrases[59])
w.Write(topic_frags[195])
}
w.Write(topic_frags[196])
}
w.Write(topic_frags[197])
w.Write(footer_frags[0])
w.Write([]byte(common.BuildWidget("footer",tmpl_topic_vars.Header)))
w.Write(footer_frags[1])
w.Write(phrases[60])
w.Write(footer_frags[2])
w.Write(phrases[61])
w.Write(footer_frags[3])
w.Write(phrases[62])
w.Write(footer_frags[4])
if len(tmpl_topic_vars.Header.Themes) != 0 {
for _, item := range tmpl_topic_vars.Header.Themes {
if !item.HideFromThemes {
w.Write(footer_frags[5])
w.Write([]byte(item.Name))
w.Write(footer_frags[6])
if tmpl_topic_vars.Header.Theme.Name == item.Name {
w.Write(footer_frags[7])
}
w.Write(footer_frags[8])
w.Write([]byte(item.FriendlyName))
w.Write(footer_frags[9])
}
}
}
w.Write(footer_frags[10])
w.Write([]byte(common.BuildWidget("rightSidebar",tmpl_topic_vars.Header)))
w.Write(footer_frags[11])
return nil
}