From a5f5f4af7e0c8eb136ed323b4dca39713add67e1 Mon Sep 17 00:00:00 2001 From: Azareal Date: Wed, 6 Jun 2018 10:21:22 +1000 Subject: [PATCH] Added the Page Manager for faster and easier custom page creation. Added the PageStore. Renamed account_own_edit.html to account_own_edit_password.html Renamed custom-page.html to custom_page.html Renamed the pre_render_custom_page hook to pre_render_tmpl_page. Added a new pre_render_custom_page hook, not to be confused with the previous one. Renamed the pre_render_account_own_edit_critical hook to pre_render_account_own_edit_password. Moved the report forum ID into a constant. Renamed todaysReportCount to topicsTopicCountByForum and made it more generic. Renamed panel-menu.html to panel_menu.html Renamed panel-inner-menu.html to panel_inner_menu.html Removed an irrelevant editable_parent in a no results row. Fixed the profile page loading the wrong profile.css Fixed a bug where the last poster avatar would break on the forum page. Added the AddNotice method to *Header. Greatly simplified many of the page struct definitions. Added the ErrorPage page struct and refactored the error pages to use it. Added the BasePanelPage page struct and refactored the panel page structs to use it. Tweaked the DefaultHeader function to set the user on the spot rather than after the fact. Simplified AccountEditAvatarSubmit into a redirect. Add the addElement closure in the control panel dashboard to reduce the amount of complexity. Tweaked LogWarning to better handle nils. Added the account_username phrase. Added the account_avatar phrase. Added the account_email phrase. Added the panel_pages phrase. Added the panel_pages_edit phrase. Added the panel_page_created phrase. Added the panel_page_updated phrase. Added the panel_page_deleted phrase. Added the account_menu_security phrase. Added the panel_menu_pages phrase. Added the panel_pages_head phrase. Added the panel_pages_edit_button_aria phrase. Added the panel_pages_delete_button_aria phrase. Added the panel_pages_no_pages phrase. Added the panel_pages_create_head phrase. Added the panel_pages_create_name phrase. Added the panel_pages_create_name_placeholder phrase. Added the panel_pages_create_title phrase. Added the panel_pages_create_title_placeholder phrase. Added the panel_pages_create_body_placeholder phrase. Added the panel_pages_create_submit_button phrase. Added the panel_pages_edit_head phrase. Added the panel_pages_name phrase. Added the panel_pages_title phrase. Added the panel_pages_edit_update_button phrase. Began work on two-factor authentication. Made more progress with the Nox Theme. --- common/auth.go | 10 + common/errors.go | 37 +- common/extend.go | 3 +- common/forum_store.go | 2 +- common/gauth/authenticator.go | 65 ++ common/page_store.go | 175 ++++++ common/pages.go | 228 +++---- common/report_store.go | 12 +- common/routes_common.go | 5 +- common/template_init.go | 13 +- common/theme.go | 18 + common/theme_list.go | 24 + docs/custom_pages.md | 7 + extend/guilds/lib/guilds.go | 3 +- gen_mssql.go | 2 +- gen_mysql.go | 2 +- gen_pgsql.go | 2 +- gen_router.go | 588 ++++++++++-------- langs/english.json | 29 +- main.go | 4 + misc_test.go | 7 +- mssql.go | 5 +- mysql.go | 5 +- panel_routes.go | 95 +-- query_gen/lib/mssql.go | 2 +- query_gen/lib/mysql.go | 2 +- query_gen/lib/pgsql.go | 2 +- query_gen/tables.go | 20 + router_gen/routes.go | 6 + routes/account.go | 55 +- routes/misc.go | 29 +- routes/panel/analytics.go | 117 ++-- routes/panel/backups.go | 9 +- routes/panel/debug.go | 5 +- routes/panel/forums.go | 30 +- routes/panel/logs.go | 15 +- routes/panel/pages.go | 156 +++++ routes/panel/settings.go | 5 +- routes/profile.go | 2 +- routes/reports.go | 1 + ...it.html => account_own_edit_password.html} | 0 templates/custom-page.html | 8 - templates/custom_page.html | 10 + templates/error.html | 2 +- templates/forum.html | 12 +- templates/panel-forum-edit-perms.html | 2 +- templates/panel-forum-edit.html | 2 +- templates/panel-group-edit-perms.html | 2 +- templates/panel-group-edit.html | 2 +- templates/panel-user-edit.html | 2 +- templates/panel_adminlogs.html | 2 +- templates/panel_analytics_agent_views.html | 2 +- templates/panel_analytics_agents.html | 2 +- templates/panel_analytics_forum_views.html | 2 +- templates/panel_analytics_forums.html | 2 +- templates/panel_analytics_lang_views.html | 2 +- templates/panel_analytics_langs.html | 2 +- templates/panel_analytics_posts.html | 2 +- templates/panel_analytics_referrer_views.html | 2 +- templates/panel_analytics_referrers.html | 2 +- templates/panel_analytics_route_views.html | 2 +- templates/panel_analytics_routes.html | 2 +- templates/panel_analytics_system_views.html | 2 +- templates/panel_analytics_systems.html | 2 +- templates/panel_analytics_topics.html | 2 +- templates/panel_analytics_views.html | 2 +- templates/panel_backups.html | 2 +- templates/panel_dashboard.html | 2 +- templates/panel_debug.html | 2 +- templates/panel_forums.html | 2 +- templates/panel_groups.html | 2 +- ...-inner-menu.html => panel_inner_menu.html} | 5 +- .../{panel-menu.html => panel_menu.html} | 2 +- templates/panel_modlogs.html | 2 +- templates/panel_pages.html | 49 ++ templates/panel_pages_edit.html | 31 + templates/panel_plugins.html | 2 +- templates/panel_reglogs.html | 2 +- templates/panel_setting.html | 2 +- templates/panel_settings.html | 2 +- templates/panel_themes.html | 2 +- templates/panel_themes_menus.html | 2 +- templates/panel_themes_menus_item_edit.html | 2 +- templates/panel_themes_menus_items.html | 2 +- templates/panel_users.html | 2 +- templates/panel_word_filters.html | 4 +- themes/cosora/public/panel.css | 5 +- themes/nox/public/main.css | 24 +- themes/nox/public/panel.css | 40 ++ themes/nox/public/profile.css | 7 + 90 files changed, 1406 insertions(+), 662 deletions(-) create mode 100644 common/gauth/authenticator.go create mode 100644 common/page_store.go create mode 100644 docs/custom_pages.md create mode 100644 routes/panel/pages.go rename templates/{account_own_edit.html => account_own_edit_password.html} (100%) delete mode 100644 templates/custom-page.html create mode 100644 templates/custom_page.html rename templates/{panel-inner-menu.html => panel_inner_menu.html} (93%) rename templates/{panel-menu.html => panel_menu.html} (58%) create mode 100644 templates/panel_pages.html create mode 100644 templates/panel_pages_edit.html create mode 100644 themes/nox/public/panel.css diff --git a/common/auth.go b/common/auth.go index c70be49a..7349d83f 100644 --- a/common/auth.go +++ b/common/auth.go @@ -14,6 +14,7 @@ import ( "strings" "../query_gen/lib" + "./gauth" //"golang.org/x/crypto/argon2" "golang.org/x/crypto/bcrypt" ) @@ -272,3 +273,12 @@ func Argon2GeneratePassword(password string) (hash string, salt string, err erro return fmt.Sprintf("argon2$%d%d%d%d%s%s", argon2Time, argon2Memory, argon2Threads, argon2KeyLen, salt, hash), string(sbytes), nil } */ + +// TODO: Not sure if these work, test them with Google Authenticator +func GenerateGAuthSecret() (string, error) { + return GenerateSafeString(24) +} +func VerifyGAuthToken(secret string, token string) (bool, error) { + trueToken, err := gauth.GetTOTPToken(secret) + return trueToken == token, err +} diff --git a/common/errors.go b/common/errors.go index bdc85ce8..e5801e35 100644 --- a/common/errors.go +++ b/common/errors.go @@ -72,18 +72,30 @@ func LogError(err error) { } func LogWarning(err error) { + var errmsg string + if err == nil { + errmsg = "Unknown error" + } else { + errmsg = err.Error() + } stack := debug.Stack() - log.Print(err.Error()+"\n", string(stack)) + log.Print(errmsg+"\n", string(stack)) errorBufferMutex.Lock() defer errorBufferMutex.Unlock() errorBuffer = append(errorBuffer, ErrorItem{err, stack}) } +func errorHeader(w http.ResponseWriter, user User, title string) *Header { + header := DefaultHeader(w, user) + header.Title = title + return header +} + // TODO: Dump the request? // InternalError is the main function for handling internal errors, while simultaneously printing out a page for the end-user to let them know that *something* has gone wrong // ? - Add a user parameter? func InternalError(err error, w http.ResponseWriter, r *http.Request) RouteError { - pi := Page{"Internal Server Error", GuestUser, DefaultHeader(w), tList, "A problem has occurred in the system."} + pi := ErrorPage{errorHeader(w, GuestUser, "Internal Server Error"), "A problem has occurred in the system."} handleErrorTemplate(w, r, pi) LogError(err) return HandledRouteError() @@ -129,7 +141,7 @@ func SilentInternalErrorXML(err error, w http.ResponseWriter, r *http.Request) R func PreError(errmsg string, w http.ResponseWriter, r *http.Request) RouteError { w.WriteHeader(500) - pi := Page{"Error", GuestUser, DefaultHeader(w), tList, errmsg} + pi := ErrorPage{errorHeader(w, GuestUser, "Error"), errmsg} handleErrorTemplate(w, r, pi) return HandledRouteError() } @@ -148,9 +160,10 @@ func PreErrorJSQ(errmsg string, w http.ResponseWriter, r *http.Request, isJs boo } // LocalError is an error shown to the end-user when something goes wrong and it's not the software's fault +// TODO: Pass header in for this and similar errors instead of having to pass in both user and w? Would also allow for more stateful things, although this could be a problem func LocalError(errmsg string, w http.ResponseWriter, r *http.Request, user User) RouteError { w.WriteHeader(500) - pi := Page{"Local Error", user, DefaultHeader(w), tList, errmsg} + pi := ErrorPage{errorHeader(w, user, "Local Error"), errmsg} handleErrorTemplate(w, r, pi) return HandledRouteError() } @@ -172,7 +185,7 @@ func LocalErrorJS(errmsg string, w http.ResponseWriter, r *http.Request) RouteEr // NoPermissions is an error shown to the end-user when they try to access an area which they aren't authorised to access func NoPermissions(w http.ResponseWriter, r *http.Request, user User) RouteError { w.WriteHeader(403) - pi := Page{"Local Error", user, DefaultHeader(w), tList, "You don't have permission to do that."} + pi := ErrorPage{errorHeader(w, user, "Local Error"), "You don't have permission to do that."} handleErrorTemplate(w, r, pi) return HandledRouteError() } @@ -193,7 +206,7 @@ func NoPermissionsJS(w http.ResponseWriter, r *http.Request, user User) RouteErr // ? - Is this actually used? Should it be used? A ban in Gosora should be more of a permission revocation to stop them posting rather than something which spits up an error page, right? func Banned(w http.ResponseWriter, r *http.Request, user User) RouteError { w.WriteHeader(403) - pi := Page{"Banned", user, DefaultHeader(w), tList, "You have been banned from this site."} + pi := ErrorPage{errorHeader(w, user, "Banned"), "You have been banned from this site."} handleErrorTemplate(w, r, pi) return HandledRouteError() } @@ -225,7 +238,7 @@ func LoginRequiredJSQ(w http.ResponseWriter, r *http.Request, user User, isJs bo // LoginRequired is an error shown to the end-user when they try to access an area which requires them to login func LoginRequired(w http.ResponseWriter, r *http.Request, user User) RouteError { w.WriteHeader(401) - pi := Page{"Local Error", user, DefaultHeader(w), tList, "You need to login to do that."} + pi := ErrorPage{errorHeader(w, user, "Local Error"), "You need to login to do that."} handleErrorTemplate(w, r, pi) return HandledRouteError() } @@ -241,7 +254,7 @@ func LoginRequiredJS(w http.ResponseWriter, r *http.Request, user User) RouteErr // ? - Should we add JS and JSQ versions of this? func SecurityError(w http.ResponseWriter, r *http.Request, user User) RouteError { w.WriteHeader(403) - pi := Page{"Security Error", user, DefaultHeader(w), tList, "There was a security issue with your request."} + pi := ErrorPage{errorHeader(w, user, "Security Error"), "There was a security issue with your request."} if RunPreRenderHook("pre_render_security_error", w, r, &user, &pi) { return nil } @@ -262,10 +275,10 @@ func NotFound(w http.ResponseWriter, r *http.Request, header *Header) RouteError // CustomError lets us make custom error types which aren't covered by the generic functions above func CustomError(errmsg string, errcode int, errtitle string, w http.ResponseWriter, r *http.Request, header *Header, user User) RouteError { if header == nil { - header = DefaultHeader(w) + header = DefaultHeader(w, user) } w.WriteHeader(errcode) - pi := Page{errtitle, user, header, tList, errmsg} + pi := ErrorPage{header, errmsg} handleErrorTemplate(w, r, pi) return HandledRouteError() } @@ -274,7 +287,7 @@ func CustomError(errmsg string, errcode int, errtitle string, w http.ResponseWri func CustomErrorJSQ(errmsg string, errcode int, errtitle string, w http.ResponseWriter, r *http.Request, header *Header, user User, isJs bool) RouteError { if !isJs { if header == nil { - header = DefaultHeader(w) + header = DefaultHeader(w, user) } return CustomError(errmsg, errcode, errtitle, w, r, header, user) } @@ -288,7 +301,7 @@ func CustomErrorJS(errmsg string, errcode int, w http.ResponseWriter, r *http.Re return HandledRouteError() } -func handleErrorTemplate(w http.ResponseWriter, r *http.Request, pi Page) { +func handleErrorTemplate(w http.ResponseWriter, r *http.Request, pi ErrorPage) { // TODO: What to do about this hook? if RunPreRenderHook("pre_render_error", w, r, &pi.Header.CurrentUser, &pi) { return diff --git a/common/extend.go b/common/extend.go index d9ba9c1a..deacfbe9 100644 --- a/common/extend.go +++ b/common/extend.go @@ -89,10 +89,11 @@ var PreRenderHooks = map[string][]func(http.ResponseWriter, *http.Request, *User "pre_render_view_topic": nil, "pre_render_profile": nil, "pre_render_custom_page": nil, + "pre_render_tmpl_page": nil, "pre_render_overview": nil, "pre_render_create_topic": nil, - "pre_render_account_own_edit_critical": nil, + "pre_render_account_own_edit_password": nil, "pre_render_account_own_edit_avatar": nil, "pre_render_account_own_edit_username": nil, "pre_render_account_own_edit_email": nil, diff --git a/common/forum_store.go b/common/forum_store.go index 0d428374..2905545c 100644 --- a/common/forum_store.go +++ b/common/forum_store.go @@ -278,7 +278,7 @@ func (mfs *MemoryForumStore) CacheDelete(id int) { // TODO: Add a hook to allow plugin_guilds to detect when one of it's forums has just been deleted? func (mfs *MemoryForumStore) Delete(id int) error { - if id == 1 { + if id == ReportForumID { return errors.New("You cannot delete the Reports forum") } _, err := mfs.delete.Exec(id) diff --git a/common/gauth/authenticator.go b/common/gauth/authenticator.go new file mode 100644 index 00000000..97460ee5 --- /dev/null +++ b/common/gauth/authenticator.go @@ -0,0 +1,65 @@ +// Google Authenticator 2FA +// Borrowed from https://github.com/tilaklodha/google-authenticator, as we can't import it as a library as it's in package main +package gauth + +import ( + "bytes" + "crypto/hmac" + "crypto/sha1" + "encoding/base32" + "encoding/binary" + "strconv" + "strings" + "time" +) + +// Append extra 0s if the length of otp is less than 6 +// If otp is "1234", it will return it as "001234" +func prefix0(otp string) string { + if len(otp) == 6 { + return otp + } + for i := (6 - len(otp)); i > 0; i-- { + otp = "0" + otp + } + return otp +} + +func GetHOTPToken(secret string, interval int64) (string, error) { + // Converts secret to base32 Encoding. Base32 encoding desires a 32-character subset of the twenty-six letters A–Z and ten digits 0–9 + key, err := base32.StdEncoding.DecodeString(strings.ToUpper(secret)) + if err != nil { + return "", err + } + bs := make([]byte, 8) + binary.BigEndian.PutUint64(bs, uint64(interval)) + + // Signing the value using HMAC-SHA1 Algorithm + hash := hmac.New(sha1.New, key) + hash.Write(bs) + h := hash.Sum(nil) + + // We're going to use a subset of the generated hash. + // Using the last nibble (half-byte) to choose the index to start from. + // This number is always appropriate as it's maximum decimal 15, the hash will have the maximum index 19 (20 bytes of SHA1) and we need 4 bytes. + o := (h[19] & 15) + + var header uint32 + // Get 32 bit chunk from hash starting at the o + r := bytes.NewReader(h[o : o+4]) + err = binary.Read(r, binary.BigEndian, &header) + if err != nil { + return "", err + } + + // Ignore most significant bits as per RFC 4226. + // Takes division from one million to generate a remainder less than < 7 digits + h12 := (int(header) & 0x7fffffff) % 1000000 + return prefix0(strconv.Itoa(int(h12))), nil +} + +func GetTOTPToken(secret string) (string, error) { + // The TOTP token is just a HOTP token seeded with every 30 seconds. + interval := time.Now().Unix() / 30 + return GetHOTPToken(secret, interval) +} diff --git a/common/page_store.go b/common/page_store.go new file mode 100644 index 00000000..2b6da7ce --- /dev/null +++ b/common/page_store.go @@ -0,0 +1,175 @@ +package common + +import ( + "database/sql" + "strconv" + "strings" + + "../query_gen/lib" +) + +type CustomPageStmts struct { + update *sql.Stmt + create *sql.Stmt +} + +var customPageStmts CustomPageStmts + +func init() { + DbInits.Add(func(acc *qgen.Accumulator) error { + customPageStmts = CustomPageStmts{ + update: acc.Update("pages").Set("name = ?, title = ?, body = ?, allowedGroups = ?, menuID = ?").Where("pid = ?").Prepare(), + create: acc.Insert("pages").Columns("name, title, body, allowedGroups, menuID").Fields("?,?,?,?,?").Prepare(), + } + return acc.FirstError() + }) +} + +type CustomPage struct { + ID int + Name string // TODO: Let admins put pages in "virtual subdirectories" + Title string + Body string + AllowedGroups []int + MenuID int +} + +func BlankCustomPage() *CustomPage { + return new(CustomPage) +} + +func (page *CustomPage) AddAllowedGroup(gid int) { + page.AllowedGroups = append(page.AllowedGroups, gid) +} + +func (page *CustomPage) getRawAllowedGroups() (rawAllowedGroups string) { + for _, group := range page.AllowedGroups { + rawAllowedGroups += strconv.Itoa(group) + "," + } + if len(rawAllowedGroups) > 0 { + rawAllowedGroups = rawAllowedGroups[:len(rawAllowedGroups)-1] + } + return rawAllowedGroups +} + +func (page *CustomPage) Commit() error { + _, err := customPageStmts.update.Exec(page.Name, page.Title, page.Body, page.getRawAllowedGroups(), page.MenuID, page.ID) + Pages.Reload(page.ID) + return err +} + +func (page *CustomPage) Create() (int, error) { + res, err := customPageStmts.create.Exec(page.Name, page.Title, page.Body, page.getRawAllowedGroups(), page.MenuID) + if err != nil { + return 0, err + } + + pid64, err := res.LastInsertId() + return int(pid64), err +} + +var Pages PageStore + +// Holds the custom pages, but doesn't include the template pages in /pages/ which are a lot more flexible yet harder to use and which are too risky security-wise to make editable in the Control Panel +type PageStore interface { + GlobalCount() (pageCount int) + Get(id int) (*CustomPage, error) + GetByName(name string) (*CustomPage, error) + GetOffset(offset int, perPage int) (pages []*CustomPage, err error) + Reload(id int) error + Delete(id int) error +} + +// TODO: Add a cache to this to save on the queries +type DefaultPageStore struct { + get *sql.Stmt + getByName *sql.Stmt + getOffset *sql.Stmt + count *sql.Stmt + delete *sql.Stmt +} + +func NewDefaultPageStore(acc *qgen.Accumulator) (*DefaultPageStore, error) { + return &DefaultPageStore{ + get: acc.Select("pages").Columns("name, title, body, allowedGroups, menuID").Where("pid = ?").Prepare(), + getByName: acc.Select("pages").Columns("pid, name, title, body, allowedGroups, menuID").Where("name = ?").Prepare(), + getOffset: acc.Select("pages").Columns("pid, name, title, body, allowedGroups, menuID").Orderby("pid DESC").Limit("?,?").Prepare(), + count: acc.Count("pages").Prepare(), + delete: acc.Delete("pages").Where("pid = ?").Prepare(), + }, acc.FirstError() +} + +func (store *DefaultPageStore) GlobalCount() (pageCount int) { + err := store.count.QueryRow().Scan(&pageCount) + if err != nil { + LogError(err) + } + return pageCount +} + +func (store *DefaultPageStore) parseAllowedGroups(raw string, page *CustomPage) error { + if raw == "" { + return nil + } + for _, sgroup := range strings.Split(raw, ",") { + group, err := strconv.Atoi(sgroup) + if err != nil { + return err + } + page.AddAllowedGroup(group) + } + return nil +} + +func (store *DefaultPageStore) Get(id int) (*CustomPage, error) { + page := &CustomPage{ID: id} + rawAllowedGroups := "" + err := store.get.QueryRow(id).Scan(&page.Name, &page.Title, &page.Body, &rawAllowedGroups, &page.MenuID) + if err != nil { + return nil, err + } + return page, store.parseAllowedGroups(rawAllowedGroups, page) +} + +func (store *DefaultPageStore) GetByName(name string) (*CustomPage, error) { + page := BlankCustomPage() + rawAllowedGroups := "" + err := store.getByName.QueryRow(name).Scan(&page.ID, &page.Name, &page.Title, &page.Body, &rawAllowedGroups, &page.MenuID) + if err != nil { + return nil, err + } + return page, store.parseAllowedGroups(rawAllowedGroups, page) +} + +func (store *DefaultPageStore) GetOffset(offset int, perPage int) (pages []*CustomPage, err error) { + rows, err := store.getOffset.Query(offset, perPage) + if err != nil { + return pages, err + } + defer rows.Close() + + for rows.Next() { + page := &CustomPage{ID: 0} + rawAllowedGroups := "" + err := rows.Scan(&page.ID, &page.Name, &page.Title, &page.Body, &rawAllowedGroups, &page.MenuID) + if err != nil { + return pages, err + } + err = store.parseAllowedGroups(rawAllowedGroups, page) + if err != nil { + return pages, err + } + pages = append(pages, page) + } + return pages, rows.Err() +} + +// Always returns nil as there's currently no cache +func (store *DefaultPageStore) Reload(id int) error { + return nil +} + +func (store *DefaultPageStore) Delete(id int) error { + _, err := store.delete.Exec(id) + return err +} diff --git a/common/pages.go b/common/pages.go index 63f1f4d8..837784a1 100644 --- a/common/pages.go +++ b/common/pages.go @@ -21,8 +21,7 @@ type Header struct { Themes map[string]*Theme // TODO: Use a slice containing every theme instead of the main map for speed? Theme *Theme //TemplateName string // TODO: Use this to move template calls to the router rather than duplicating them over and over and over? - // TODO: Use a pointer here - CurrentUser User // TODO: Deprecate CurrentUser on the page structs + CurrentUser User // TODO: Deprecate CurrentUser on the page structs and use a pointer here Zone string MetaDesc string Writer http.ResponseWriter @@ -41,6 +40,10 @@ func (header *Header) AddSheet(name string) { header.Stylesheets = append(header.Stylesheets, name) } +func (header *Header) AddNotice(name string) { + header.NoticeList = append(header.NoticeList, GetNoticePhrase(name)) +} + // TODO: Add this to routes which don't use templates. E.g. Json APIs. type HeaderLite struct { Site *site @@ -61,11 +64,18 @@ type ExtData struct { } type Page struct { - Title string - CurrentUser User - Header *Header - ItemList []interface{} - Something interface{} + *Header + ItemList []interface{} + Something interface{} +} + +type SimplePage struct { + *Header +} + +type ErrorPage struct { + *Header + Message string } type Paginator struct { @@ -74,6 +84,11 @@ type Paginator struct { LastPage int } +type CustomPagePage struct { + *Header + Page *CustomPage +} + type TopicPage struct { *Header ItemList []ReplyUser @@ -131,20 +146,24 @@ type PanelStats struct { Users int Groups int Forums int + Pages int Settings int WordFilters int Themes int Reports int } +type BasePanelPage struct { + *Header + Stats PanelStats + Zone string + ReportForumID int +} + type PanelPage struct { - Title string - CurrentUser User - Header *Header - Stats PanelStats - Zone string - ItemList []interface{} - Something interface{} + *BasePanelPage + ItemList []interface{} + Something interface{} } type GridElement struct { @@ -158,9 +177,7 @@ type GridElement struct { } type PanelDashboardPage struct { - *Header - Stats PanelStats - Zone string + *BasePanelPage GridItems []GridElement } @@ -170,13 +187,22 @@ type PanelSetting struct { } type PanelSettingPage struct { - *Header - Stats PanelStats - Zone string + *BasePanelPage ItemList []OptionLabel Setting *PanelSetting } +type PanelCustomPagesPage struct { + *BasePanelPage + ItemList []*CustomPage + Paginator +} + +type PanelCustomPageEditPage struct { + *BasePanelPage + Page *CustomPage +} + type PanelTimeGraph struct { Series []int64 // The counts on the left Labels []int64 // unixtimes for the bottom, gets converted into 1:00, 2:00, etc. with JS @@ -188,11 +214,7 @@ type PanelAnalyticsItem struct { } type PanelAnalyticsPage struct { - Title string - CurrentUser User - Header *Header - Stats PanelStats - Zone string + *BasePanelPage PrimaryGraph PanelTimeGraph ViewItems []PanelAnalyticsItem TimeRange string @@ -204,13 +226,9 @@ type PanelAnalyticsRoutesItem struct { } type PanelAnalyticsRoutesPage struct { - Title string - CurrentUser User - Header *Header - Stats PanelStats - Zone string - ItemList []PanelAnalyticsRoutesItem - TimeRange string + *BasePanelPage + ItemList []PanelAnalyticsRoutesItem + TimeRange string } type PanelAnalyticsAgentsItem struct { @@ -220,21 +238,13 @@ type PanelAnalyticsAgentsItem struct { } type PanelAnalyticsAgentsPage struct { - Title string - CurrentUser User - Header *Header - Stats PanelStats - Zone string - ItemList []PanelAnalyticsAgentsItem - TimeRange string + *BasePanelPage + ItemList []PanelAnalyticsAgentsItem + TimeRange string } type PanelAnalyticsRoutePage struct { - Title string - CurrentUser User - Header *Header - Stats PanelStats - Zone string + *BasePanelPage Route string PrimaryGraph PanelTimeGraph ViewItems []PanelAnalyticsItem @@ -242,11 +252,7 @@ type PanelAnalyticsRoutePage struct { } type PanelAnalyticsAgentPage struct { - Title string - CurrentUser User - Header *Header - Stats PanelStats - Zone string + *BasePanelPage Agent string FriendlyAgent string PrimaryGraph PanelTimeGraph @@ -254,9 +260,7 @@ type PanelAnalyticsAgentPage struct { } type PanelThemesPage struct { - *Header - Stats PanelStats - Zone string + *BasePanelPage PrimaryThemes []*Theme VariantThemes []*Theme } @@ -268,51 +272,35 @@ type PanelMenuListItem struct { } type PanelMenuListPage struct { - *Header - Stats PanelStats - Zone string + *BasePanelPage ItemList []PanelMenuListItem } type PanelMenuPage struct { - *Header - Stats PanelStats - Zone string + *BasePanelPage MenuID int ItemList []MenuItem } type PanelMenuItemPage struct { - *Header - Stats PanelStats - Zone string - Item MenuItem + *BasePanelPage + Item MenuItem } type PanelUserPage struct { - *Header - Stats PanelStats - Zone string + *BasePanelPage ItemList []*User Paginator } type PanelGroupPage struct { - Title string - CurrentUser User - Header *Header - Stats PanelStats - Zone string - ItemList []GroupAdmin + *BasePanelPage + ItemList []GroupAdmin Paginator } type PanelEditGroupPage struct { - Title string - CurrentUser User - Header *Header - Stats PanelStats - Zone string + *BasePanelPage ID int Name string Tag string @@ -326,17 +314,13 @@ type GroupForumPermPreset struct { } type PanelEditForumPage struct { - Title string - CurrentUser User - Header *Header - Stats PanelStats - Zone string - ID int - Name string - Desc string - Active bool - Preset string - Groups []GroupForumPermPreset + *BasePanelPage + ID int + Name string + Desc string + Active bool + Preset string + Groups []GroupForumPermPreset } type NameLangToggle struct { @@ -346,26 +330,18 @@ type NameLangToggle struct { } type PanelEditForumGroupPage struct { - Title string - CurrentUser User - Header *Header - Stats PanelStats - Zone string - ForumID int - GroupID int - Name string - Desc string - Active bool - Preset string - Perms []NameLangToggle + *BasePanelPage + ForumID int + GroupID int + Name string + Desc string + Active bool + Preset string + Perms []NameLangToggle } type PanelEditGroupPermsPage struct { - Title string - CurrentUser User - Header *Header - Stats PanelStats - Zone string + *BasePanelPage ID int Name string LocalPerms []NameLangToggle @@ -381,12 +357,8 @@ type BackupItem struct { } type PanelBackupPage struct { - Title string - CurrentUser User - Header *Header - Stats PanelStats - Zone string - Backups []BackupItem + *BasePanelPage + Backups []BackupItem } type PageLogItem struct { @@ -396,12 +368,8 @@ type PageLogItem struct { } type PanelLogsPage struct { - Title string - CurrentUser User - Header *Header - Stats PanelStats - Zone string - Logs []PageLogItem + *BasePanelPage + Logs []PageLogItem Paginator } @@ -411,26 +379,18 @@ type PageRegLogItem struct { } type PanelRegLogsPage struct { - Title string - CurrentUser User - Header *Header - Stats PanelStats - Zone string - Logs []PageRegLogItem + *BasePanelPage + Logs []PageRegLogItem Paginator } type PanelDebugPage struct { - Title string - CurrentUser User - Header *Header - Stats PanelStats - Zone string - GoVersion string - DBVersion string - Uptime string - OpenConns int - DBAdapter string + *BasePanelPage + GoVersion string + DBVersion string + Uptime string + OpenConns int + DBAdapter string } type PageSimple struct { @@ -444,6 +404,6 @@ type AreYouSure struct { } // TODO: Write a test for this -func DefaultHeader(w http.ResponseWriter) *Header { - return &Header{Site: Site, Theme: Themes[fallbackTheme], CurrentUser: GuestUser, Writer: w} +func DefaultHeader(w http.ResponseWriter, user User) *Header { + return &Header{Site: Site, Theme: Themes[fallbackTheme], CurrentUser: user, Writer: w} } diff --git a/common/report_store.go b/common/report_store.go index 1e478d2f..ac7f2539 100644 --- a/common/report_store.go +++ b/common/report_store.go @@ -8,6 +8,10 @@ import ( "../query_gen/lib" ) +// TODO: Make the default report forum ID configurable +// TODO: Make sure this constant is used everywhere for the report forum ID +const ReportForumID = 1 + var Reports ReportStore var ErrAlreadyReported = errors.New("This item has already been reported") @@ -23,8 +27,8 @@ type DefaultReportStore struct { func NewDefaultReportStore(acc *qgen.Accumulator) (*DefaultReportStore, error) { return &DefaultReportStore{ - create: acc.Insert("topics").Columns("title, content, parsed_content, ipaddress, createdAt, lastReplyAt, createdBy, lastReplyBy, data, parentID, css_class").Fields("?,?,?,?,UTC_TIMESTAMP(),UTC_TIMESTAMP(),?,?,?,1,'report'").Prepare(), - exists: acc.Count("topics").Where("data = ? AND data != '' AND parentID = 1").Prepare(), + create: acc.Insert("topics").Columns("title, content, parsed_content, ipaddress, createdAt, lastReplyAt, createdBy, lastReplyBy, data, parentID, css_class").Fields("?,?,?,?,UTC_TIMESTAMP(),UTC_TIMESTAMP(),?,?,?,?,'report'").Prepare(), + exists: acc.Count("topics").Where("data = ? AND data != '' AND parentID = ?").Prepare(), }, acc.FirstError() } @@ -39,7 +43,7 @@ func (store *DefaultReportStore) Create(title string, content string, user *User return 0, ErrAlreadyReported } - res, err := store.create.Exec(title, content, ParseMessage(content, 0, ""), user.LastIP, user.ID, user.ID, itemType+"_"+strconv.Itoa(itemID)) + res, err := store.create.Exec(title, content, ParseMessage(content, 0, ""), user.LastIP, user.ID, user.ID, itemType+"_"+strconv.Itoa(itemID), ReportForumID) if err != nil { return 0, err } @@ -49,5 +53,5 @@ func (store *DefaultReportStore) Create(title string, content string, user *User return 0, err } - return int(lastID), Forums.AddTopic(int(lastID), user.ID, 1) + return int(lastID), Forums.AddTopic(int(lastID), user.ID, ReportForumID) } diff --git a/common/routes_common.go b/common/routes_common.go index eb456e4d..79264882 100644 --- a/common/routes_common.go +++ b/common/routes_common.go @@ -138,14 +138,17 @@ func panelUserCheck(w http.ResponseWriter, r *http.Request, user *User) (header } } + // TODO: GDPR. Add a global control panel notice warning the admins of staff members who don't have 2FA enabled stats.Users = Users.GlobalCount() stats.Groups = Groups.GlobalCount() - stats.Forums = Forums.GlobalCount() // TODO: Stop it from showing the blanked forums + stats.Forums = Forums.GlobalCount() // TODO: Stop it from showing the blanked forums, do we still have those? I think we removed that + stats.Pages = Pages.GlobalCount() stats.Settings = len(header.Settings) stats.WordFilters = len(WordFilterBox.Load().(WordFilterMap)) stats.Themes = len(Themes) stats.Reports = 0 // TODO: Do the report count. Only show open threads? + // TODO: Remove this as it might be counter-productive pusher, ok := w.(http.Pusher) if ok { pusher.Push("/static/"+theme.Name+"/main.css", nil) diff --git a/common/template_init.go b/common/template_init.go index a233a1a0..4be5a234 100644 --- a/common/template_init.go +++ b/common/template_init.go @@ -105,7 +105,7 @@ var Template_register_handle = func(pi Page, w io.Writer) error { } // nolint -var Template_error_handle = func(pi Page, w io.Writer) error { +var Template_error_handle = func(pi ErrorPage, w io.Writer) error { mapping, ok := Themes[DefaultThemeBox.Load().(string)].TemplatesMap["error"] if !ok { mapping = "error" @@ -229,20 +229,23 @@ func CompileTemplates() error { return err } - loginPage := Page{"Login Page", user, header, tList, nil} + header.Title = "Login Page" + loginPage := Page{header, tList, nil} loginTmpl, err := c.Compile("login.html", "templates/", "common.Page", loginPage, varList) if err != nil { return err } - registerPage := Page{"Registration Page", user, header, tList, "nananana"} + header.Title = "Registration Page" + registerPage := Page{header, tList, "nananana"} registerTmpl, err := c.Compile("register.html", "templates/", "common.Page", registerPage, varList) if err != nil { return err } - errorPage := Page{"Error", user, header, tList, "A problem has occurred in the system."} - errorTmpl, err := c.Compile("error.html", "templates/", "common.Page", errorPage, varList) + header.Title = "Error" + errorPage := ErrorPage{header, "A problem has occurred in the system."} + errorTmpl, err := c.Compile("error.html", "templates/", "common.ErrorPage", errorPage, varList) if err != nil { return err } diff --git a/common/theme.go b/common/theme.go index 6d3f662d..ff146d6c 100644 --- a/common/theme.go +++ b/common/theme.go @@ -140,6 +140,15 @@ func (theme *Theme) MapTemplates() { } switch dTmplPtr := destTmplPtr.(type) { + case *func(CustomPagePage, io.Writer) error: + switch sTmplPtr := sourceTmplPtr.(type) { + case *func(CustomPagePage, io.Writer) error: + //overridenTemplates[themeTmpl.Name] = d_tmpl_ptr + overridenTemplates[themeTmpl.Name] = true + *dTmplPtr = *sTmplPtr + default: + LogError(errors.New("The source and destination templates are incompatible")) + } case *func(TopicPage, io.Writer) error: switch sTmplPtr := sourceTmplPtr.(type) { case *func(TopicPage, io.Writer) error: @@ -203,6 +212,15 @@ func (theme *Theme) MapTemplates() { default: LogError(errors.New("The source and destination templates are incompatible")) } + case *func(ErrorPage, io.Writer) error: + switch sTmplPtr := sourceTmplPtr.(type) { + case *func(ErrorPage, io.Writer) error: + //overridenTemplates[themeTmpl.Name] = d_tmpl_ptr + overridenTemplates[themeTmpl.Name] = true + *dTmplPtr = *sTmplPtr + default: + LogError(errors.New("The source and destination templates are incompatible")) + } case *func(Page, io.Writer) error: switch sTmplPtr := sourceTmplPtr.(type) { case *func(Page, io.Writer) error: diff --git a/common/theme_list.go b/common/theme_list.go index 067c7d33..adfaf6f1 100644 --- a/common/theme_list.go +++ b/common/theme_list.go @@ -194,6 +194,13 @@ func ResetTemplateOverrides() { // Not really a pointer, more of a function handle, an artifact from one of the earlier versions of themes.go switch oPtr := originPointer.(type) { + case func(CustomPagePage, io.Writer) error: + switch dPtr := destTmplPtr.(type) { + case *func(CustomPagePage, io.Writer) error: + *dPtr = oPtr + default: + LogError(errors.New("The source and destination templates are incompatible")) + } case func(TopicPage, io.Writer) error: switch dPtr := destTmplPtr.(type) { case *func(TopicPage, io.Writer) error: @@ -243,6 +250,13 @@ func ResetTemplateOverrides() { default: LogError(errors.New("The source and destination templates are incompatible")) } + case func(ErrorPage, io.Writer) error: + switch dPtr := destTmplPtr.(type) { + case *func(ErrorPage, io.Writer) error: + *dPtr = oPtr + default: + LogError(errors.New("The source and destination templates are incompatible")) + } case func(Page, io.Writer) error: switch dPtr := destTmplPtr.(type) { case *func(Page, io.Writer) error: @@ -266,6 +280,9 @@ func ResetTemplateOverrides() { func RunThemeTemplate(theme string, template string, pi interface{}, w io.Writer) error { var getTmpl = GetThemeTemplate(theme, template) switch tmplO := getTmpl.(type) { + case *func(CustomPagePage, io.Writer) error: + var tmpl = *tmplO + return tmpl(pi.(CustomPagePage), w) case *func(TopicPage, io.Writer) error: var tmpl = *tmplO return tmpl(pi.(TopicPage), w) @@ -287,9 +304,14 @@ func RunThemeTemplate(theme string, template string, pi interface{}, w io.Writer case *func(IPSearchPage, io.Writer) error: var tmpl = *tmplO return tmpl(pi.(IPSearchPage), w) + case *func(ErrorPage, io.Writer) error: + var tmpl = *tmplO + return tmpl(pi.(ErrorPage), w) case *func(Page, io.Writer) error: var tmpl = *tmplO return tmpl(pi.(Page), w) + case func(CustomPagePage, io.Writer) error: + return tmplO(pi.(CustomPagePage), w) case func(TopicPage, io.Writer) error: return tmplO(pi.(TopicPage), w) case func(TopicListPage, io.Writer) error: @@ -304,6 +326,8 @@ func RunThemeTemplate(theme string, template string, pi interface{}, w io.Writer return tmplO(pi.(CreateTopicPage), w) case func(IPSearchPage, io.Writer) error: return tmplO(pi.(IPSearchPage), w) + case func(ErrorPage, io.Writer) error: + return tmplO(pi.(ErrorPage), w) case func(Page, io.Writer) error: return tmplO(pi.(Page), w) case string: diff --git a/docs/custom_pages.md b/docs/custom_pages.md new file mode 100644 index 00000000..897a7a6f --- /dev/null +++ b/docs/custom_pages.md @@ -0,0 +1,7 @@ +# Custom Pages + +There are two ways to create custom pages in Gosora, one which requires a lot more technical knowledge than the other. The first is to create the page via the Page Manager in the Control Panel where you'll be able to type whatever you want visible on the page into a little form. + +The second is to create a template file in /pages/ which will be loaded by Gosora and parsed like any template will. You will require knowledge of HTML, and possibly even Go Templates for this option, but it's a lot more flexible than the first option. + +More to come. \ No newline at end of file diff --git a/extend/guilds/lib/guilds.go b/extend/guilds/lib/guilds.go index 487becb3..9c285286 100644 --- a/extend/guilds/lib/guilds.go +++ b/extend/guilds/lib/guilds.go @@ -232,13 +232,14 @@ func RouteCreateGuild(w http.ResponseWriter, r *http.Request, user common.User) if ferr != nil { return ferr } + header.Title = "Create Guild" // TODO: Add an approval queue mode for group creation if !user.Loggedin || !user.PluginPerms["CreateGuild"] { return common.NoPermissions(w, r, user) } CommonAreaWidgets(header) - pi := common.Page{"Create Guild", user, header, tList, nil} + pi := common.Page{header, tList, nil} err := common.Templates.ExecuteTemplate(w, "guilds_create_guild.html", pi) if err != nil { return common.InternalError(err, w, r) diff --git a/gen_mssql.go b/gen_mssql.go index 76a2c386..69b9db90 100644 --- a/gen_mssql.go +++ b/gen_mssql.go @@ -35,7 +35,7 @@ type Stmts struct { getActivityCountByWatcher *sql.Stmt todaysPostCount *sql.Stmt todaysTopicCount *sql.Stmt - todaysReportCount *sql.Stmt + todaysTopicCountByForum *sql.Stmt todaysNewUserCount *sql.Stmt Mocks bool diff --git a/gen_mysql.go b/gen_mysql.go index 79fdf503..89a230fe 100644 --- a/gen_mysql.go +++ b/gen_mysql.go @@ -37,7 +37,7 @@ type Stmts struct { getActivityCountByWatcher *sql.Stmt todaysPostCount *sql.Stmt todaysTopicCount *sql.Stmt - todaysReportCount *sql.Stmt + todaysTopicCountByForum *sql.Stmt todaysNewUserCount *sql.Stmt Mocks bool diff --git a/gen_pgsql.go b/gen_pgsql.go index 84a4f641..114840cd 100644 --- a/gen_pgsql.go +++ b/gen_pgsql.go @@ -28,7 +28,7 @@ type Stmts struct { getActivityCountByWatcher *sql.Stmt todaysPostCount *sql.Stmt todaysTopicCount *sql.Stmt - todaysReportCount *sql.Stmt + todaysTopicCountByForum *sql.Stmt todaysNewUserCount *sql.Stmt Mocks bool diff --git a/gen_router.go b/gen_router.go index ee6e858a..441e96b0 100644 --- a/gen_router.go +++ b/gen_router.go @@ -48,6 +48,11 @@ var RouteMap = map[string]interface{}{ "routePanelWordFiltersEdit": routePanelWordFiltersEdit, "routePanelWordFiltersEditSubmit": routePanelWordFiltersEditSubmit, "routePanelWordFiltersDeleteSubmit": routePanelWordFiltersDeleteSubmit, + "panel.Pages": panel.Pages, + "panel.PagesCreateSubmit": panel.PagesCreateSubmit, + "panel.PagesEdit": panel.PagesEdit, + "panel.PagesEditSubmit": panel.PagesEditSubmit, + "panel.PagesDeleteSubmit": panel.PagesDeleteSubmit, "routePanelThemes": routePanelThemes, "routePanelThemesSetDefault": routePanelThemesSetDefault, "routePanelThemesMenus": routePanelThemesMenus, @@ -165,91 +170,96 @@ var routeMapEnum = map[string]int{ "routePanelWordFiltersEdit": 25, "routePanelWordFiltersEditSubmit": 26, "routePanelWordFiltersDeleteSubmit": 27, - "routePanelThemes": 28, - "routePanelThemesSetDefault": 29, - "routePanelThemesMenus": 30, - "routePanelThemesMenusEdit": 31, - "routePanelThemesMenuItemEdit": 32, - "routePanelThemesMenuItemEditSubmit": 33, - "routePanelThemesMenuItemCreateSubmit": 34, - "routePanelThemesMenuItemDeleteSubmit": 35, - "routePanelThemesMenuItemOrderSubmit": 36, - "routePanelPlugins": 37, - "routePanelPluginsActivate": 38, - "routePanelPluginsDeactivate": 39, - "routePanelPluginsInstall": 40, - "routePanelUsers": 41, - "routePanelUsersEdit": 42, - "routePanelUsersEditSubmit": 43, - "panel.AnalyticsViews": 44, - "panel.AnalyticsRoutes": 45, - "panel.AnalyticsAgents": 46, - "panel.AnalyticsSystems": 47, - "panel.AnalyticsLanguages": 48, - "panel.AnalyticsReferrers": 49, - "panel.AnalyticsRouteViews": 50, - "panel.AnalyticsAgentViews": 51, - "panel.AnalyticsForumViews": 52, - "panel.AnalyticsSystemViews": 53, - "panel.AnalyticsLanguageViews": 54, - "panel.AnalyticsReferrerViews": 55, - "panel.AnalyticsPosts": 56, - "panel.AnalyticsTopics": 57, - "panel.AnalyticsForums": 58, - "routePanelGroups": 59, - "routePanelGroupsEdit": 60, - "routePanelGroupsEditPerms": 61, - "routePanelGroupsEditSubmit": 62, - "routePanelGroupsEditPermsSubmit": 63, - "routePanelGroupsCreateSubmit": 64, - "panel.Backups": 65, - "panel.LogsRegs": 66, - "panel.LogsMod": 67, - "panel.Debug": 68, - "routePanelDashboard": 69, - "routes.AccountEditCritical": 70, - "routes.AccountEditCriticalSubmit": 71, - "routes.AccountEditAvatar": 72, - "routes.AccountEditAvatarSubmit": 73, - "routes.AccountEditUsername": 74, - "routes.AccountEditUsernameSubmit": 75, - "routes.AccountEditEmail": 76, - "routes.AccountEditEmailTokenSubmit": 77, - "routes.ViewProfile": 78, - "routes.BanUserSubmit": 79, - "routes.UnbanUser": 80, - "routes.ActivateUser": 81, - "routes.IPSearch": 82, - "routes.CreateTopicSubmit": 83, - "routes.EditTopicSubmit": 84, - "routes.DeleteTopicSubmit": 85, - "routes.StickTopicSubmit": 86, - "routes.UnstickTopicSubmit": 87, - "routes.LockTopicSubmit": 88, - "routes.UnlockTopicSubmit": 89, - "routes.MoveTopicSubmit": 90, - "routes.LikeTopicSubmit": 91, - "routes.ViewTopic": 92, - "routes.CreateReplySubmit": 93, - "routes.ReplyEditSubmit": 94, - "routes.ReplyDeleteSubmit": 95, - "routes.ReplyLikeSubmit": 96, - "routes.ProfileReplyCreateSubmit": 97, - "routes.ProfileReplyEditSubmit": 98, - "routes.ProfileReplyDeleteSubmit": 99, - "routes.PollVote": 100, - "routes.PollResults": 101, - "routes.AccountLogin": 102, - "routes.AccountRegister": 103, - "routes.AccountLogout": 104, - "routes.AccountLoginSubmit": 105, - "routes.AccountRegisterSubmit": 106, - "routes.DynamicRoute": 107, - "routes.UploadedFile": 108, - "routes.StaticFile": 109, - "routes.RobotsTxt": 110, - "routes.SitemapXml": 111, - "routes.BadRoute": 112, + "panel.Pages": 28, + "panel.PagesCreateSubmit": 29, + "panel.PagesEdit": 30, + "panel.PagesEditSubmit": 31, + "panel.PagesDeleteSubmit": 32, + "routePanelThemes": 33, + "routePanelThemesSetDefault": 34, + "routePanelThemesMenus": 35, + "routePanelThemesMenusEdit": 36, + "routePanelThemesMenuItemEdit": 37, + "routePanelThemesMenuItemEditSubmit": 38, + "routePanelThemesMenuItemCreateSubmit": 39, + "routePanelThemesMenuItemDeleteSubmit": 40, + "routePanelThemesMenuItemOrderSubmit": 41, + "routePanelPlugins": 42, + "routePanelPluginsActivate": 43, + "routePanelPluginsDeactivate": 44, + "routePanelPluginsInstall": 45, + "routePanelUsers": 46, + "routePanelUsersEdit": 47, + "routePanelUsersEditSubmit": 48, + "panel.AnalyticsViews": 49, + "panel.AnalyticsRoutes": 50, + "panel.AnalyticsAgents": 51, + "panel.AnalyticsSystems": 52, + "panel.AnalyticsLanguages": 53, + "panel.AnalyticsReferrers": 54, + "panel.AnalyticsRouteViews": 55, + "panel.AnalyticsAgentViews": 56, + "panel.AnalyticsForumViews": 57, + "panel.AnalyticsSystemViews": 58, + "panel.AnalyticsLanguageViews": 59, + "panel.AnalyticsReferrerViews": 60, + "panel.AnalyticsPosts": 61, + "panel.AnalyticsTopics": 62, + "panel.AnalyticsForums": 63, + "routePanelGroups": 64, + "routePanelGroupsEdit": 65, + "routePanelGroupsEditPerms": 66, + "routePanelGroupsEditSubmit": 67, + "routePanelGroupsEditPermsSubmit": 68, + "routePanelGroupsCreateSubmit": 69, + "panel.Backups": 70, + "panel.LogsRegs": 71, + "panel.LogsMod": 72, + "panel.Debug": 73, + "routePanelDashboard": 74, + "routes.AccountEditCritical": 75, + "routes.AccountEditCriticalSubmit": 76, + "routes.AccountEditAvatar": 77, + "routes.AccountEditAvatarSubmit": 78, + "routes.AccountEditUsername": 79, + "routes.AccountEditUsernameSubmit": 80, + "routes.AccountEditEmail": 81, + "routes.AccountEditEmailTokenSubmit": 82, + "routes.ViewProfile": 83, + "routes.BanUserSubmit": 84, + "routes.UnbanUser": 85, + "routes.ActivateUser": 86, + "routes.IPSearch": 87, + "routes.CreateTopicSubmit": 88, + "routes.EditTopicSubmit": 89, + "routes.DeleteTopicSubmit": 90, + "routes.StickTopicSubmit": 91, + "routes.UnstickTopicSubmit": 92, + "routes.LockTopicSubmit": 93, + "routes.UnlockTopicSubmit": 94, + "routes.MoveTopicSubmit": 95, + "routes.LikeTopicSubmit": 96, + "routes.ViewTopic": 97, + "routes.CreateReplySubmit": 98, + "routes.ReplyEditSubmit": 99, + "routes.ReplyDeleteSubmit": 100, + "routes.ReplyLikeSubmit": 101, + "routes.ProfileReplyCreateSubmit": 102, + "routes.ProfileReplyEditSubmit": 103, + "routes.ProfileReplyDeleteSubmit": 104, + "routes.PollVote": 105, + "routes.PollResults": 106, + "routes.AccountLogin": 107, + "routes.AccountRegister": 108, + "routes.AccountLogout": 109, + "routes.AccountLoginSubmit": 110, + "routes.AccountRegisterSubmit": 111, + "routes.DynamicRoute": 112, + "routes.UploadedFile": 113, + "routes.StaticFile": 114, + "routes.RobotsTxt": 115, + "routes.SitemapXml": 116, + "routes.BadRoute": 117, } var reverseRouteMapEnum = map[int]string{ 0: "routeAPI", @@ -280,91 +290,96 @@ var reverseRouteMapEnum = map[int]string{ 25: "routePanelWordFiltersEdit", 26: "routePanelWordFiltersEditSubmit", 27: "routePanelWordFiltersDeleteSubmit", - 28: "routePanelThemes", - 29: "routePanelThemesSetDefault", - 30: "routePanelThemesMenus", - 31: "routePanelThemesMenusEdit", - 32: "routePanelThemesMenuItemEdit", - 33: "routePanelThemesMenuItemEditSubmit", - 34: "routePanelThemesMenuItemCreateSubmit", - 35: "routePanelThemesMenuItemDeleteSubmit", - 36: "routePanelThemesMenuItemOrderSubmit", - 37: "routePanelPlugins", - 38: "routePanelPluginsActivate", - 39: "routePanelPluginsDeactivate", - 40: "routePanelPluginsInstall", - 41: "routePanelUsers", - 42: "routePanelUsersEdit", - 43: "routePanelUsersEditSubmit", - 44: "panel.AnalyticsViews", - 45: "panel.AnalyticsRoutes", - 46: "panel.AnalyticsAgents", - 47: "panel.AnalyticsSystems", - 48: "panel.AnalyticsLanguages", - 49: "panel.AnalyticsReferrers", - 50: "panel.AnalyticsRouteViews", - 51: "panel.AnalyticsAgentViews", - 52: "panel.AnalyticsForumViews", - 53: "panel.AnalyticsSystemViews", - 54: "panel.AnalyticsLanguageViews", - 55: "panel.AnalyticsReferrerViews", - 56: "panel.AnalyticsPosts", - 57: "panel.AnalyticsTopics", - 58: "panel.AnalyticsForums", - 59: "routePanelGroups", - 60: "routePanelGroupsEdit", - 61: "routePanelGroupsEditPerms", - 62: "routePanelGroupsEditSubmit", - 63: "routePanelGroupsEditPermsSubmit", - 64: "routePanelGroupsCreateSubmit", - 65: "panel.Backups", - 66: "panel.LogsRegs", - 67: "panel.LogsMod", - 68: "panel.Debug", - 69: "routePanelDashboard", - 70: "routes.AccountEditCritical", - 71: "routes.AccountEditCriticalSubmit", - 72: "routes.AccountEditAvatar", - 73: "routes.AccountEditAvatarSubmit", - 74: "routes.AccountEditUsername", - 75: "routes.AccountEditUsernameSubmit", - 76: "routes.AccountEditEmail", - 77: "routes.AccountEditEmailTokenSubmit", - 78: "routes.ViewProfile", - 79: "routes.BanUserSubmit", - 80: "routes.UnbanUser", - 81: "routes.ActivateUser", - 82: "routes.IPSearch", - 83: "routes.CreateTopicSubmit", - 84: "routes.EditTopicSubmit", - 85: "routes.DeleteTopicSubmit", - 86: "routes.StickTopicSubmit", - 87: "routes.UnstickTopicSubmit", - 88: "routes.LockTopicSubmit", - 89: "routes.UnlockTopicSubmit", - 90: "routes.MoveTopicSubmit", - 91: "routes.LikeTopicSubmit", - 92: "routes.ViewTopic", - 93: "routes.CreateReplySubmit", - 94: "routes.ReplyEditSubmit", - 95: "routes.ReplyDeleteSubmit", - 96: "routes.ReplyLikeSubmit", - 97: "routes.ProfileReplyCreateSubmit", - 98: "routes.ProfileReplyEditSubmit", - 99: "routes.ProfileReplyDeleteSubmit", - 100: "routes.PollVote", - 101: "routes.PollResults", - 102: "routes.AccountLogin", - 103: "routes.AccountRegister", - 104: "routes.AccountLogout", - 105: "routes.AccountLoginSubmit", - 106: "routes.AccountRegisterSubmit", - 107: "routes.DynamicRoute", - 108: "routes.UploadedFile", - 109: "routes.StaticFile", - 110: "routes.RobotsTxt", - 111: "routes.SitemapXml", - 112: "routes.BadRoute", + 28: "panel.Pages", + 29: "panel.PagesCreateSubmit", + 30: "panel.PagesEdit", + 31: "panel.PagesEditSubmit", + 32: "panel.PagesDeleteSubmit", + 33: "routePanelThemes", + 34: "routePanelThemesSetDefault", + 35: "routePanelThemesMenus", + 36: "routePanelThemesMenusEdit", + 37: "routePanelThemesMenuItemEdit", + 38: "routePanelThemesMenuItemEditSubmit", + 39: "routePanelThemesMenuItemCreateSubmit", + 40: "routePanelThemesMenuItemDeleteSubmit", + 41: "routePanelThemesMenuItemOrderSubmit", + 42: "routePanelPlugins", + 43: "routePanelPluginsActivate", + 44: "routePanelPluginsDeactivate", + 45: "routePanelPluginsInstall", + 46: "routePanelUsers", + 47: "routePanelUsersEdit", + 48: "routePanelUsersEditSubmit", + 49: "panel.AnalyticsViews", + 50: "panel.AnalyticsRoutes", + 51: "panel.AnalyticsAgents", + 52: "panel.AnalyticsSystems", + 53: "panel.AnalyticsLanguages", + 54: "panel.AnalyticsReferrers", + 55: "panel.AnalyticsRouteViews", + 56: "panel.AnalyticsAgentViews", + 57: "panel.AnalyticsForumViews", + 58: "panel.AnalyticsSystemViews", + 59: "panel.AnalyticsLanguageViews", + 60: "panel.AnalyticsReferrerViews", + 61: "panel.AnalyticsPosts", + 62: "panel.AnalyticsTopics", + 63: "panel.AnalyticsForums", + 64: "routePanelGroups", + 65: "routePanelGroupsEdit", + 66: "routePanelGroupsEditPerms", + 67: "routePanelGroupsEditSubmit", + 68: "routePanelGroupsEditPermsSubmit", + 69: "routePanelGroupsCreateSubmit", + 70: "panel.Backups", + 71: "panel.LogsRegs", + 72: "panel.LogsMod", + 73: "panel.Debug", + 74: "routePanelDashboard", + 75: "routes.AccountEditCritical", + 76: "routes.AccountEditCriticalSubmit", + 77: "routes.AccountEditAvatar", + 78: "routes.AccountEditAvatarSubmit", + 79: "routes.AccountEditUsername", + 80: "routes.AccountEditUsernameSubmit", + 81: "routes.AccountEditEmail", + 82: "routes.AccountEditEmailTokenSubmit", + 83: "routes.ViewProfile", + 84: "routes.BanUserSubmit", + 85: "routes.UnbanUser", + 86: "routes.ActivateUser", + 87: "routes.IPSearch", + 88: "routes.CreateTopicSubmit", + 89: "routes.EditTopicSubmit", + 90: "routes.DeleteTopicSubmit", + 91: "routes.StickTopicSubmit", + 92: "routes.UnstickTopicSubmit", + 93: "routes.LockTopicSubmit", + 94: "routes.UnlockTopicSubmit", + 95: "routes.MoveTopicSubmit", + 96: "routes.LikeTopicSubmit", + 97: "routes.ViewTopic", + 98: "routes.CreateReplySubmit", + 99: "routes.ReplyEditSubmit", + 100: "routes.ReplyDeleteSubmit", + 101: "routes.ReplyLikeSubmit", + 102: "routes.ProfileReplyCreateSubmit", + 103: "routes.ProfileReplyEditSubmit", + 104: "routes.ProfileReplyDeleteSubmit", + 105: "routes.PollVote", + 106: "routes.PollResults", + 107: "routes.AccountLogin", + 108: "routes.AccountRegister", + 109: "routes.AccountLogout", + 110: "routes.AccountLoginSubmit", + 111: "routes.AccountRegisterSubmit", + 112: "routes.DynamicRoute", + 113: "routes.UploadedFile", + 114: "routes.StaticFile", + 115: "routes.RobotsTxt", + 116: "routes.SitemapXml", + 117: "routes.BadRoute", } var osMapEnum = map[string]int{ "unknown": 0, @@ -655,7 +670,7 @@ func (router *GenRouter) ServeHTTP(w http.ResponseWriter, req *http.Request) { counters.GlobalViewCounter.Bump() if prefix == "/static" { - counters.RouteViewCounter.Bump(109) + counters.RouteViewCounter.Bump(114) req.URL.Path += extraData routes.StaticFile(w, req) return @@ -1046,8 +1061,71 @@ func (router *GenRouter) ServeHTTP(w http.ResponseWriter, req *http.Request) { counters.RouteViewCounter.Bump(27) err = routePanelWordFiltersDeleteSubmit(w,req,user,extraData) - case "/panel/themes/": + case "/panel/pages/": + err = common.AdminOnly(w,req,user) + if err != nil { + router.handleError(err,w,req,user) + return + } + counters.RouteViewCounter.Bump(28) + err = panel.Pages(w,req,user) + case "/panel/pages/create/submit/": + err = common.NoSessionMismatch(w,req,user) + if err != nil { + router.handleError(err,w,req,user) + return + } + + err = common.AdminOnly(w,req,user) + if err != nil { + router.handleError(err,w,req,user) + return + } + + counters.RouteViewCounter.Bump(29) + err = panel.PagesCreateSubmit(w,req,user) + case "/panel/pages/edit/": + err = common.AdminOnly(w,req,user) + if err != nil { + router.handleError(err,w,req,user) + return + } + + counters.RouteViewCounter.Bump(30) + err = panel.PagesEdit(w,req,user,extraData) + case "/panel/pages/edit/submit/": + err = common.NoSessionMismatch(w,req,user) + if err != nil { + router.handleError(err,w,req,user) + return + } + + err = common.AdminOnly(w,req,user) + if err != nil { + router.handleError(err,w,req,user) + return + } + + counters.RouteViewCounter.Bump(31) + err = panel.PagesEditSubmit(w,req,user,extraData) + case "/panel/pages/delete/submit/": + err = common.NoSessionMismatch(w,req,user) + if err != nil { + router.handleError(err,w,req,user) + return + } + + err = common.AdminOnly(w,req,user) + if err != nil { + router.handleError(err,w,req,user) + return + } + + counters.RouteViewCounter.Bump(32) + err = panel.PagesDeleteSubmit(w,req,user,extraData) + case "/panel/themes/": + counters.RouteViewCounter.Bump(33) err = routePanelThemes(w,req,user) case "/panel/themes/default/": err = common.NoSessionMismatch(w,req,user) @@ -1056,16 +1134,16 @@ func (router *GenRouter) ServeHTTP(w http.ResponseWriter, req *http.Request) { return } - counters.RouteViewCounter.Bump(29) + counters.RouteViewCounter.Bump(34) err = routePanelThemesSetDefault(w,req,user,extraData) case "/panel/themes/menus/": - counters.RouteViewCounter.Bump(30) + counters.RouteViewCounter.Bump(35) err = routePanelThemesMenus(w,req,user) case "/panel/themes/menus/edit/": - counters.RouteViewCounter.Bump(31) + counters.RouteViewCounter.Bump(36) err = routePanelThemesMenusEdit(w,req,user,extraData) case "/panel/themes/menus/item/edit/": - counters.RouteViewCounter.Bump(32) + counters.RouteViewCounter.Bump(37) err = routePanelThemesMenuItemEdit(w,req,user,extraData) case "/panel/themes/menus/item/edit/submit/": err = common.NoSessionMismatch(w,req,user) @@ -1074,7 +1152,7 @@ func (router *GenRouter) ServeHTTP(w http.ResponseWriter, req *http.Request) { return } - counters.RouteViewCounter.Bump(33) + counters.RouteViewCounter.Bump(38) err = routePanelThemesMenuItemEditSubmit(w,req,user,extraData) case "/panel/themes/menus/item/create/submit/": err = common.NoSessionMismatch(w,req,user) @@ -1083,7 +1161,7 @@ func (router *GenRouter) ServeHTTP(w http.ResponseWriter, req *http.Request) { return } - counters.RouteViewCounter.Bump(34) + counters.RouteViewCounter.Bump(39) err = routePanelThemesMenuItemCreateSubmit(w,req,user) case "/panel/themes/menus/item/delete/submit/": err = common.NoSessionMismatch(w,req,user) @@ -1092,7 +1170,7 @@ func (router *GenRouter) ServeHTTP(w http.ResponseWriter, req *http.Request) { return } - counters.RouteViewCounter.Bump(35) + counters.RouteViewCounter.Bump(40) err = routePanelThemesMenuItemDeleteSubmit(w,req,user,extraData) case "/panel/themes/menus/item/order/edit/submit/": err = common.NoSessionMismatch(w,req,user) @@ -1101,10 +1179,10 @@ func (router *GenRouter) ServeHTTP(w http.ResponseWriter, req *http.Request) { return } - counters.RouteViewCounter.Bump(36) + counters.RouteViewCounter.Bump(41) err = routePanelThemesMenuItemOrderSubmit(w,req,user,extraData) case "/panel/plugins/": - counters.RouteViewCounter.Bump(37) + counters.RouteViewCounter.Bump(42) err = routePanelPlugins(w,req,user) case "/panel/plugins/activate/": err = common.NoSessionMismatch(w,req,user) @@ -1113,7 +1191,7 @@ func (router *GenRouter) ServeHTTP(w http.ResponseWriter, req *http.Request) { return } - counters.RouteViewCounter.Bump(38) + counters.RouteViewCounter.Bump(43) err = routePanelPluginsActivate(w,req,user,extraData) case "/panel/plugins/deactivate/": err = common.NoSessionMismatch(w,req,user) @@ -1122,7 +1200,7 @@ func (router *GenRouter) ServeHTTP(w http.ResponseWriter, req *http.Request) { return } - counters.RouteViewCounter.Bump(39) + counters.RouteViewCounter.Bump(44) err = routePanelPluginsDeactivate(w,req,user,extraData) case "/panel/plugins/install/": err = common.NoSessionMismatch(w,req,user) @@ -1131,13 +1209,13 @@ func (router *GenRouter) ServeHTTP(w http.ResponseWriter, req *http.Request) { return } - counters.RouteViewCounter.Bump(40) + counters.RouteViewCounter.Bump(45) err = routePanelPluginsInstall(w,req,user,extraData) case "/panel/users/": - counters.RouteViewCounter.Bump(41) + counters.RouteViewCounter.Bump(46) err = routePanelUsers(w,req,user) case "/panel/users/edit/": - counters.RouteViewCounter.Bump(42) + counters.RouteViewCounter.Bump(47) err = routePanelUsersEdit(w,req,user,extraData) case "/panel/users/edit/submit/": err = common.NoSessionMismatch(w,req,user) @@ -1146,7 +1224,7 @@ func (router *GenRouter) ServeHTTP(w http.ResponseWriter, req *http.Request) { return } - counters.RouteViewCounter.Bump(43) + counters.RouteViewCounter.Bump(48) err = routePanelUsersEditSubmit(w,req,user,extraData) case "/panel/analytics/views/": err = common.ParseForm(w,req,user) @@ -1155,7 +1233,7 @@ func (router *GenRouter) ServeHTTP(w http.ResponseWriter, req *http.Request) { return } - counters.RouteViewCounter.Bump(44) + counters.RouteViewCounter.Bump(49) err = panel.AnalyticsViews(w,req,user) case "/panel/analytics/routes/": err = common.ParseForm(w,req,user) @@ -1164,7 +1242,7 @@ func (router *GenRouter) ServeHTTP(w http.ResponseWriter, req *http.Request) { return } - counters.RouteViewCounter.Bump(45) + counters.RouteViewCounter.Bump(50) err = panel.AnalyticsRoutes(w,req,user) case "/panel/analytics/agents/": err = common.ParseForm(w,req,user) @@ -1173,7 +1251,7 @@ func (router *GenRouter) ServeHTTP(w http.ResponseWriter, req *http.Request) { return } - counters.RouteViewCounter.Bump(46) + counters.RouteViewCounter.Bump(51) err = panel.AnalyticsAgents(w,req,user) case "/panel/analytics/systems/": err = common.ParseForm(w,req,user) @@ -1182,7 +1260,7 @@ func (router *GenRouter) ServeHTTP(w http.ResponseWriter, req *http.Request) { return } - counters.RouteViewCounter.Bump(47) + counters.RouteViewCounter.Bump(52) err = panel.AnalyticsSystems(w,req,user) case "/panel/analytics/langs/": err = common.ParseForm(w,req,user) @@ -1191,7 +1269,7 @@ func (router *GenRouter) ServeHTTP(w http.ResponseWriter, req *http.Request) { return } - counters.RouteViewCounter.Bump(48) + counters.RouteViewCounter.Bump(53) err = panel.AnalyticsLanguages(w,req,user) case "/panel/analytics/referrers/": err = common.ParseForm(w,req,user) @@ -1200,25 +1278,25 @@ func (router *GenRouter) ServeHTTP(w http.ResponseWriter, req *http.Request) { return } - counters.RouteViewCounter.Bump(49) + counters.RouteViewCounter.Bump(54) err = panel.AnalyticsReferrers(w,req,user) case "/panel/analytics/route/": - counters.RouteViewCounter.Bump(50) + counters.RouteViewCounter.Bump(55) err = panel.AnalyticsRouteViews(w,req,user,extraData) case "/panel/analytics/agent/": - counters.RouteViewCounter.Bump(51) + counters.RouteViewCounter.Bump(56) err = panel.AnalyticsAgentViews(w,req,user,extraData) case "/panel/analytics/forum/": - counters.RouteViewCounter.Bump(52) + counters.RouteViewCounter.Bump(57) err = panel.AnalyticsForumViews(w,req,user,extraData) case "/panel/analytics/system/": - counters.RouteViewCounter.Bump(53) + counters.RouteViewCounter.Bump(58) err = panel.AnalyticsSystemViews(w,req,user,extraData) case "/panel/analytics/lang/": - counters.RouteViewCounter.Bump(54) + counters.RouteViewCounter.Bump(59) err = panel.AnalyticsLanguageViews(w,req,user,extraData) case "/panel/analytics/referrer/": - counters.RouteViewCounter.Bump(55) + counters.RouteViewCounter.Bump(60) err = panel.AnalyticsReferrerViews(w,req,user,extraData) case "/panel/analytics/posts/": err = common.ParseForm(w,req,user) @@ -1227,7 +1305,7 @@ func (router *GenRouter) ServeHTTP(w http.ResponseWriter, req *http.Request) { return } - counters.RouteViewCounter.Bump(56) + counters.RouteViewCounter.Bump(61) err = panel.AnalyticsPosts(w,req,user) case "/panel/analytics/topics/": err = common.ParseForm(w,req,user) @@ -1236,7 +1314,7 @@ func (router *GenRouter) ServeHTTP(w http.ResponseWriter, req *http.Request) { return } - counters.RouteViewCounter.Bump(57) + counters.RouteViewCounter.Bump(62) err = panel.AnalyticsTopics(w,req,user) case "/panel/analytics/forums/": err = common.ParseForm(w,req,user) @@ -1245,16 +1323,16 @@ func (router *GenRouter) ServeHTTP(w http.ResponseWriter, req *http.Request) { return } - counters.RouteViewCounter.Bump(58) + counters.RouteViewCounter.Bump(63) err = panel.AnalyticsForums(w,req,user) case "/panel/groups/": - counters.RouteViewCounter.Bump(59) + counters.RouteViewCounter.Bump(64) err = routePanelGroups(w,req,user) case "/panel/groups/edit/": - counters.RouteViewCounter.Bump(60) + counters.RouteViewCounter.Bump(65) err = routePanelGroupsEdit(w,req,user,extraData) case "/panel/groups/edit/perms/": - counters.RouteViewCounter.Bump(61) + counters.RouteViewCounter.Bump(66) err = routePanelGroupsEditPerms(w,req,user,extraData) case "/panel/groups/edit/submit/": err = common.NoSessionMismatch(w,req,user) @@ -1263,7 +1341,7 @@ func (router *GenRouter) ServeHTTP(w http.ResponseWriter, req *http.Request) { return } - counters.RouteViewCounter.Bump(62) + counters.RouteViewCounter.Bump(67) err = routePanelGroupsEditSubmit(w,req,user,extraData) case "/panel/groups/edit/perms/submit/": err = common.NoSessionMismatch(w,req,user) @@ -1272,7 +1350,7 @@ func (router *GenRouter) ServeHTTP(w http.ResponseWriter, req *http.Request) { return } - counters.RouteViewCounter.Bump(63) + counters.RouteViewCounter.Bump(68) err = routePanelGroupsEditPermsSubmit(w,req,user,extraData) case "/panel/groups/create/": err = common.NoSessionMismatch(w,req,user) @@ -1281,7 +1359,7 @@ func (router *GenRouter) ServeHTTP(w http.ResponseWriter, req *http.Request) { return } - counters.RouteViewCounter.Bump(64) + counters.RouteViewCounter.Bump(69) err = routePanelGroupsCreateSubmit(w,req,user) case "/panel/backups/": err = common.SuperAdminOnly(w,req,user) @@ -1290,13 +1368,13 @@ func (router *GenRouter) ServeHTTP(w http.ResponseWriter, req *http.Request) { return } - counters.RouteViewCounter.Bump(65) + counters.RouteViewCounter.Bump(70) err = panel.Backups(w,req,user,extraData) case "/panel/logs/regs/": - counters.RouteViewCounter.Bump(66) + counters.RouteViewCounter.Bump(71) err = panel.LogsRegs(w,req,user) case "/panel/logs/mod/": - counters.RouteViewCounter.Bump(67) + counters.RouteViewCounter.Bump(72) err = panel.LogsMod(w,req,user) case "/panel/debug/": err = common.AdminOnly(w,req,user) @@ -1305,10 +1383,10 @@ func (router *GenRouter) ServeHTTP(w http.ResponseWriter, req *http.Request) { return } - counters.RouteViewCounter.Bump(68) + counters.RouteViewCounter.Bump(73) err = panel.Debug(w,req,user) default: - counters.RouteViewCounter.Bump(69) + counters.RouteViewCounter.Bump(74) err = routePanelDashboard(w,req,user) } if err != nil { @@ -1323,7 +1401,7 @@ func (router *GenRouter) ServeHTTP(w http.ResponseWriter, req *http.Request) { return } - counters.RouteViewCounter.Bump(70) + counters.RouteViewCounter.Bump(75) err = routes.AccountEditCritical(w,req,user) case "/user/edit/critical/submit/": err = common.NoSessionMismatch(w,req,user) @@ -1338,7 +1416,7 @@ func (router *GenRouter) ServeHTTP(w http.ResponseWriter, req *http.Request) { return } - counters.RouteViewCounter.Bump(71) + counters.RouteViewCounter.Bump(76) err = routes.AccountEditCriticalSubmit(w,req,user) case "/user/edit/avatar/": err = common.MemberOnly(w,req,user) @@ -1347,7 +1425,7 @@ func (router *GenRouter) ServeHTTP(w http.ResponseWriter, req *http.Request) { return } - counters.RouteViewCounter.Bump(72) + counters.RouteViewCounter.Bump(77) err = routes.AccountEditAvatar(w,req,user) case "/user/edit/avatar/submit/": err = common.MemberOnly(w,req,user) @@ -1367,7 +1445,7 @@ func (router *GenRouter) ServeHTTP(w http.ResponseWriter, req *http.Request) { return } - counters.RouteViewCounter.Bump(73) + counters.RouteViewCounter.Bump(78) err = routes.AccountEditAvatarSubmit(w,req,user) case "/user/edit/username/": err = common.MemberOnly(w,req,user) @@ -1376,7 +1454,7 @@ func (router *GenRouter) ServeHTTP(w http.ResponseWriter, req *http.Request) { return } - counters.RouteViewCounter.Bump(74) + counters.RouteViewCounter.Bump(79) err = routes.AccountEditUsername(w,req,user) case "/user/edit/username/submit/": err = common.NoSessionMismatch(w,req,user) @@ -1391,7 +1469,7 @@ func (router *GenRouter) ServeHTTP(w http.ResponseWriter, req *http.Request) { return } - counters.RouteViewCounter.Bump(75) + counters.RouteViewCounter.Bump(80) err = routes.AccountEditUsernameSubmit(w,req,user) case "/user/edit/email/": err = common.MemberOnly(w,req,user) @@ -1400,7 +1478,7 @@ func (router *GenRouter) ServeHTTP(w http.ResponseWriter, req *http.Request) { return } - counters.RouteViewCounter.Bump(76) + counters.RouteViewCounter.Bump(81) err = routes.AccountEditEmail(w,req,user) case "/user/edit/token/": err = common.NoSessionMismatch(w,req,user) @@ -1415,11 +1493,11 @@ func (router *GenRouter) ServeHTTP(w http.ResponseWriter, req *http.Request) { return } - counters.RouteViewCounter.Bump(77) + counters.RouteViewCounter.Bump(82) err = routes.AccountEditEmailTokenSubmit(w,req,user,extraData) default: req.URL.Path += extraData - counters.RouteViewCounter.Bump(78) + counters.RouteViewCounter.Bump(83) err = routes.ViewProfile(w,req,user) } if err != nil { @@ -1440,7 +1518,7 @@ func (router *GenRouter) ServeHTTP(w http.ResponseWriter, req *http.Request) { return } - counters.RouteViewCounter.Bump(79) + counters.RouteViewCounter.Bump(84) err = routes.BanUserSubmit(w,req,user,extraData) case "/users/unban/": err = common.NoSessionMismatch(w,req,user) @@ -1455,7 +1533,7 @@ func (router *GenRouter) ServeHTTP(w http.ResponseWriter, req *http.Request) { return } - counters.RouteViewCounter.Bump(80) + counters.RouteViewCounter.Bump(85) err = routes.UnbanUser(w,req,user,extraData) case "/users/activate/": err = common.NoSessionMismatch(w,req,user) @@ -1470,7 +1548,7 @@ func (router *GenRouter) ServeHTTP(w http.ResponseWriter, req *http.Request) { return } - counters.RouteViewCounter.Bump(81) + counters.RouteViewCounter.Bump(86) err = routes.ActivateUser(w,req,user,extraData) case "/users/ips/": err = common.MemberOnly(w,req,user) @@ -1479,7 +1557,7 @@ func (router *GenRouter) ServeHTTP(w http.ResponseWriter, req *http.Request) { return } - counters.RouteViewCounter.Bump(82) + counters.RouteViewCounter.Bump(87) err = routes.IPSearch(w,req,user) } if err != nil { @@ -1505,7 +1583,7 @@ func (router *GenRouter) ServeHTTP(w http.ResponseWriter, req *http.Request) { return } - counters.RouteViewCounter.Bump(83) + counters.RouteViewCounter.Bump(88) err = routes.CreateTopicSubmit(w,req,user) case "/topic/edit/submit/": err = common.NoSessionMismatch(w,req,user) @@ -1520,7 +1598,7 @@ func (router *GenRouter) ServeHTTP(w http.ResponseWriter, req *http.Request) { return } - counters.RouteViewCounter.Bump(84) + counters.RouteViewCounter.Bump(89) err = routes.EditTopicSubmit(w,req,user,extraData) case "/topic/delete/submit/": err = common.NoSessionMismatch(w,req,user) @@ -1536,7 +1614,7 @@ func (router *GenRouter) ServeHTTP(w http.ResponseWriter, req *http.Request) { } req.URL.Path += extraData - counters.RouteViewCounter.Bump(85) + counters.RouteViewCounter.Bump(90) err = routes.DeleteTopicSubmit(w,req,user) case "/topic/stick/submit/": err = common.NoSessionMismatch(w,req,user) @@ -1551,7 +1629,7 @@ func (router *GenRouter) ServeHTTP(w http.ResponseWriter, req *http.Request) { return } - counters.RouteViewCounter.Bump(86) + counters.RouteViewCounter.Bump(91) err = routes.StickTopicSubmit(w,req,user,extraData) case "/topic/unstick/submit/": err = common.NoSessionMismatch(w,req,user) @@ -1566,7 +1644,7 @@ func (router *GenRouter) ServeHTTP(w http.ResponseWriter, req *http.Request) { return } - counters.RouteViewCounter.Bump(87) + counters.RouteViewCounter.Bump(92) err = routes.UnstickTopicSubmit(w,req,user,extraData) case "/topic/lock/submit/": err = common.NoSessionMismatch(w,req,user) @@ -1582,7 +1660,7 @@ func (router *GenRouter) ServeHTTP(w http.ResponseWriter, req *http.Request) { } req.URL.Path += extraData - counters.RouteViewCounter.Bump(88) + counters.RouteViewCounter.Bump(93) err = routes.LockTopicSubmit(w,req,user) case "/topic/unlock/submit/": err = common.NoSessionMismatch(w,req,user) @@ -1597,7 +1675,7 @@ func (router *GenRouter) ServeHTTP(w http.ResponseWriter, req *http.Request) { return } - counters.RouteViewCounter.Bump(89) + counters.RouteViewCounter.Bump(94) err = routes.UnlockTopicSubmit(w,req,user,extraData) case "/topic/move/submit/": err = common.NoSessionMismatch(w,req,user) @@ -1612,7 +1690,7 @@ func (router *GenRouter) ServeHTTP(w http.ResponseWriter, req *http.Request) { return } - counters.RouteViewCounter.Bump(90) + counters.RouteViewCounter.Bump(95) err = routes.MoveTopicSubmit(w,req,user,extraData) case "/topic/like/submit/": err = common.NoSessionMismatch(w,req,user) @@ -1633,10 +1711,10 @@ func (router *GenRouter) ServeHTTP(w http.ResponseWriter, req *http.Request) { return } - counters.RouteViewCounter.Bump(91) + counters.RouteViewCounter.Bump(96) err = routes.LikeTopicSubmit(w,req,user,extraData) default: - counters.RouteViewCounter.Bump(92) + counters.RouteViewCounter.Bump(97) err = routes.ViewTopic(w,req,user, extraData) } if err != nil { @@ -1662,7 +1740,7 @@ func (router *GenRouter) ServeHTTP(w http.ResponseWriter, req *http.Request) { return } - counters.RouteViewCounter.Bump(93) + counters.RouteViewCounter.Bump(98) err = routes.CreateReplySubmit(w,req,user) case "/reply/edit/submit/": err = common.NoSessionMismatch(w,req,user) @@ -1677,7 +1755,7 @@ func (router *GenRouter) ServeHTTP(w http.ResponseWriter, req *http.Request) { return } - counters.RouteViewCounter.Bump(94) + counters.RouteViewCounter.Bump(99) err = routes.ReplyEditSubmit(w,req,user,extraData) case "/reply/delete/submit/": err = common.NoSessionMismatch(w,req,user) @@ -1692,7 +1770,7 @@ func (router *GenRouter) ServeHTTP(w http.ResponseWriter, req *http.Request) { return } - counters.RouteViewCounter.Bump(95) + counters.RouteViewCounter.Bump(100) err = routes.ReplyDeleteSubmit(w,req,user,extraData) case "/reply/like/submit/": err = common.NoSessionMismatch(w,req,user) @@ -1713,7 +1791,7 @@ func (router *GenRouter) ServeHTTP(w http.ResponseWriter, req *http.Request) { return } - counters.RouteViewCounter.Bump(96) + counters.RouteViewCounter.Bump(101) err = routes.ReplyLikeSubmit(w,req,user,extraData) } if err != nil { @@ -1734,7 +1812,7 @@ func (router *GenRouter) ServeHTTP(w http.ResponseWriter, req *http.Request) { return } - counters.RouteViewCounter.Bump(97) + counters.RouteViewCounter.Bump(102) err = routes.ProfileReplyCreateSubmit(w,req,user) case "/profile/reply/edit/submit/": err = common.NoSessionMismatch(w,req,user) @@ -1749,7 +1827,7 @@ func (router *GenRouter) ServeHTTP(w http.ResponseWriter, req *http.Request) { return } - counters.RouteViewCounter.Bump(98) + counters.RouteViewCounter.Bump(103) err = routes.ProfileReplyEditSubmit(w,req,user,extraData) case "/profile/reply/delete/submit/": err = common.NoSessionMismatch(w,req,user) @@ -1764,7 +1842,7 @@ func (router *GenRouter) ServeHTTP(w http.ResponseWriter, req *http.Request) { return } - counters.RouteViewCounter.Bump(99) + counters.RouteViewCounter.Bump(104) err = routes.ProfileReplyDeleteSubmit(w,req,user,extraData) } if err != nil { @@ -1785,10 +1863,10 @@ func (router *GenRouter) ServeHTTP(w http.ResponseWriter, req *http.Request) { return } - counters.RouteViewCounter.Bump(100) + counters.RouteViewCounter.Bump(105) err = routes.PollVote(w,req,user,extraData) case "/poll/results/": - counters.RouteViewCounter.Bump(101) + counters.RouteViewCounter.Bump(106) err = routes.PollResults(w,req,user,extraData) } if err != nil { @@ -1797,10 +1875,10 @@ func (router *GenRouter) ServeHTTP(w http.ResponseWriter, req *http.Request) { case "/accounts": switch(req.URL.Path) { case "/accounts/login/": - counters.RouteViewCounter.Bump(102) + counters.RouteViewCounter.Bump(107) err = routes.AccountLogin(w,req,user) case "/accounts/create/": - counters.RouteViewCounter.Bump(103) + counters.RouteViewCounter.Bump(108) err = routes.AccountRegister(w,req,user) case "/accounts/logout/": err = common.NoSessionMismatch(w,req,user) @@ -1815,7 +1893,7 @@ func (router *GenRouter) ServeHTTP(w http.ResponseWriter, req *http.Request) { return } - counters.RouteViewCounter.Bump(104) + counters.RouteViewCounter.Bump(109) err = routes.AccountLogout(w,req,user) case "/accounts/login/submit/": err = common.ParseForm(w,req,user) @@ -1824,7 +1902,7 @@ func (router *GenRouter) ServeHTTP(w http.ResponseWriter, req *http.Request) { return } - counters.RouteViewCounter.Bump(105) + counters.RouteViewCounter.Bump(110) err = routes.AccountLoginSubmit(w,req,user) case "/accounts/create/submit/": err = common.ParseForm(w,req,user) @@ -1833,7 +1911,7 @@ func (router *GenRouter) ServeHTTP(w http.ResponseWriter, req *http.Request) { return } - counters.RouteViewCounter.Bump(106) + counters.RouteViewCounter.Bump(111) err = routes.AccountRegisterSubmit(w,req,user) } if err != nil { @@ -1850,7 +1928,7 @@ func (router *GenRouter) ServeHTTP(w http.ResponseWriter, req *http.Request) { common.NotFound(w,req,nil) return } - counters.RouteViewCounter.Bump(108) + counters.RouteViewCounter.Bump(113) req.URL.Path += extraData // TODO: Find a way to propagate errors up from this? router.UploadHandler(w,req) // TODO: Count these views @@ -1859,14 +1937,14 @@ func (router *GenRouter) ServeHTTP(w http.ResponseWriter, req *http.Request) { // TODO: Add support for favicons and robots.txt files switch(extraData) { case "robots.txt": - counters.RouteViewCounter.Bump(110) + counters.RouteViewCounter.Bump(115) err = routes.RobotsTxt(w,req) if err != nil { router.handleError(err,w,req,user) } return /*case "sitemap.xml": - counters.RouteViewCounter.Bump(111) + counters.RouteViewCounter.Bump(116) err = routes.SitemapXml(w,req) if err != nil { router.handleError(err,w,req,user) @@ -1895,7 +1973,7 @@ func (router *GenRouter) ServeHTTP(w http.ResponseWriter, req *http.Request) { router.RUnlock() if ok { - counters.RouteViewCounter.Bump(107) // TODO: Be more specific about *which* dynamic route it is + counters.RouteViewCounter.Bump(112) // TODO: Be more specific about *which* dynamic route it is req.URL.Path += extraData err = handle(w,req,user) if err != nil { @@ -1910,7 +1988,7 @@ func (router *GenRouter) ServeHTTP(w http.ResponseWriter, req *http.Request) { } else { router.DumpRequest(req,"Bad Route") } - counters.RouteViewCounter.Bump(112) + counters.RouteViewCounter.Bump(117) common.NotFound(w,req,nil) } } diff --git a/langs/english.json b/langs/english.json index 37dd32b3..4313c88b 100644 --- a/langs/english.json +++ b/langs/english.json @@ -81,6 +81,9 @@ "login":"Login", "register":"Registration", "ip_search":"IP Search", + "account_username":"Edit Username", + "account_avatar":"Edit Avatar", + "account_email":"Email Manager", "panel_dashboard":"Control Panel Dashboard", "panel_forums":"Forum Manager", @@ -91,6 +94,8 @@ "panel_edit_setting":"Edit Setting", "panel_word_filters":"Word Filter Manager", "panel_edit_word_filter":"Edit Word Filter", + "panel_pages":"Page Manager", + "panel_pages_edit":"Page Editor", "panel_plugins":"Plugin Manager", "panel_users":"User Manager", "panel_edit_user":"User Editor", @@ -248,7 +253,10 @@ "panel_forum_deleted":"The forum was successfully deleted", "panel_forum_updated":"The forum was successfully updated", "panel_forum_perms_updated":"The forum permissions were successfully updated", - "panel_user_updated":"The user was successfully updated" + "panel_user_updated":"The user was successfully updated", + "panel_page_created":"The page was successfully created", + "panel_page_updated":"The page was successfully updated", + "panel_page_deleted":"The page was successfully deleted" }, "TmplPhrases": { @@ -352,6 +360,7 @@ "account_menu_username":"Username", "account_menu_password":"Password", "account_menu_email":"Email", + "account_menu_security":"Security", "account_menu_notifications":"Notifications", "account_avatar_head":"Edit Avatar", @@ -539,6 +548,7 @@ "panel_menu_users":"Users", "panel_menu_groups":"Groups", "panel_menu_forums":"Forums", + "panel_menu_pages":"Pages", "panel_menu_settings":"Settings", "panel_menu_word_filters":"Word Filters", "panel_menu_themes":"Themes", @@ -649,6 +659,23 @@ "panel_word_filters_create_replacement_placeholder":"fudge", "panel_word_filters_create_create_word_filter_button":"Add Filter", + "panel_pages_head":"Page Manager", + "panel_pages_edit_button_aria":"Edit Page", + "panel_pages_delete_button_aria":"Delete Page", + "panel_pages_no_pages":"There aren't any pages.", + "panel_pages_create_head":"Create Page", + "panel_pages_create_name":"Name", + "panel_pages_create_name_placeholder":"faq", + "panel_pages_create_title":"Title", + "panel_pages_create_title_placeholder":"Frequently Asked Questions", + "panel_pages_create_body_placeholder":"We understand you have a lot of questions.", + "panel_pages_create_submit_button":"Create Page", + + "panel_pages_edit_head":"Page Editor", + "panel_pages_name":"Name", + "panel_pages_title":"Title", + "panel_pages_edit_update_button":"Update Page", + "panel_statistics_views_head_suffix":" Views", "panel_statistics_user_agents_head":"User Agents", "panel_statistics_forums_head":"Forums", diff --git a/main.go b/main.go index 9029c845..7f613c64 100644 --- a/main.go +++ b/main.go @@ -106,6 +106,10 @@ func afterDBInit() (err error) { } log.Print("Initialising the stores") + common.Pages, err = common.NewDefaultPageStore(acc) + if err != nil { + return err + } common.Reports, err = common.NewDefaultReportStore(acc) if err != nil { return err diff --git a/misc_test.go b/misc_test.go index 4ee3961f..22ec756d 100644 --- a/misc_test.go +++ b/misc_test.go @@ -5,6 +5,7 @@ import ( "fmt" "net/http/httptest" "runtime/debug" + "strconv" "testing" "time" @@ -252,12 +253,12 @@ func userStoreTest(t *testing.T, newUserID int) { expectIntToBeX(t, user.Group, common.Config.DefaultGroup, "Sam should be back in group %d") - var reportsForumID = 1 + var reportsForumID = 1 // TODO: Use the constant in common? var generalForumID = 2 dummyResponseRecorder := httptest.NewRecorder() bytesBuffer := bytes.NewBuffer([]byte("")) - dummyRequest1 := httptest.NewRequest("", "/forum/1", bytesBuffer) - dummyRequest2 := httptest.NewRequest("", "/forum/2", bytesBuffer) + dummyRequest1 := httptest.NewRequest("", "/forum/"+strconv.Itoa(reportsForumID), bytesBuffer) + dummyRequest2 := httptest.NewRequest("", "/forum/"+strconv.Itoa(generalForumID), bytesBuffer) err = user.ChangeGroup(1) expectNilErr(t, err) diff --git a/mssql.go b/mssql.go index f296b68b..f1f4fb16 100644 --- a/mssql.go +++ b/mssql.go @@ -96,8 +96,9 @@ func initMSSQL() (err error) { return err } - log.Print("Preparing todaysReportCount statement.") - todaysReportCountStmt, err = db.Prepare("select count(*) from topics where createdAt >= DATEADD(DAY, -1, GETUTCDATE()) and parentID = 1") + log.Print("Preparing todaysTopicCountByForum statement.") + // TODO: Stop hard-coding this query + todaysTopicCountByForum, err = db.Prepare("select count(*) from topics where createdAt >= DATEADD(DAY, -1, GETUTCDATE()) and parentID = ?") if err != nil { return err } diff --git a/mysql.go b/mysql.go index de509031..e904e221 100644 --- a/mysql.go +++ b/mysql.go @@ -75,8 +75,9 @@ func initMySQL() (err error) { return err } - log.Print("Preparing todaysReportCount statement.") - stmts.todaysReportCount, err = db.Prepare("select count(*) from topics where createdAt BETWEEN (utc_timestamp() - interval 1 day) and utc_timestamp() and parentID = 1") + log.Print("Preparing todaysTopicCountByForum statement.") + // TODO: Stop hard-coding this query + stmts.todaysTopicCountByForum, err = db.Prepare("select count(*) from topics where createdAt BETWEEN (utc_timestamp() - interval 1 day) and utc_timestamp() and parentID = ?") if err != nil { return err } diff --git a/panel_routes.go b/panel_routes.go index 4d1995f7..ae78b417 100644 --- a/panel_routes.go +++ b/panel_routes.go @@ -35,11 +35,11 @@ func panelRenderTemplate(tmplName string, w http.ResponseWriter, r *http.Request } func routePanelDashboard(w http.ResponseWriter, r *http.Request, user common.User) common.RouteError { - headerVars, stats, ferr := common.PanelUserCheck(w, r, &user) + header, stats, ferr := common.PanelUserCheck(w, r, &user) if ferr != nil { return ferr } - headerVars.Title = common.GetTitlePhrase("panel_dashboard") + header.Title = common.GetTitlePhrase("panel_dashboard") // We won't calculate this on the spot anymore, as the system doesn't seem to like it if we do multiple fetches simultaneously. Should we constantly calculate this on a background thread? Perhaps, the watchdog to scale back heavy features under load? One plus side is that we'd get immediate CPU percentages here instead of waiting it to kick in with WebSockets var cpustr = "Unknown" @@ -93,8 +93,8 @@ func routePanelDashboard(w http.ResponseWriter, r *http.Request, user common.Use // TODO: Add a stat store for this? var intErr error - var extractStat = func(stmt *sql.Stmt) (stat int) { - err := stmt.QueryRow().Scan(&stat) + var extractStat = func(stmt *sql.Stmt, args ...interface{}) (stat int) { + err := stmt.QueryRow(args...).Scan(&stat) if err != nil && err != ErrNoRows { intErr = err } @@ -109,7 +109,7 @@ func routePanelDashboard(w http.ResponseWriter, r *http.Request, user common.Use var topicInterval = "day" var topicColour = greaterThanSwitch(topicCount, 0, 8) - var reportCount = extractStat(stmts.todaysReportCount) + var reportCount = extractStat(stmts.todaysTopicCountByForum, common.ReportForumID) var reportInterval = "week" var newUserCount = extractStat(stmts.todaysNewUserCount) @@ -120,11 +120,15 @@ func routePanelDashboard(w http.ResponseWriter, r *http.Request, user common.Use return common.InternalError(intErr, w, r) } + // TODO: Localise these var gridElements = []common.GridElement{ common.GridElement{"dash-version", "v" + version.String(), 0, "grid_istat stat_green", "", "", "Gosora is up-to-date :)"}, common.GridElement{"dash-cpu", "CPU: " + cpustr, 1, "grid_istat " + cpuColour, "", "", "The global CPU usage of this server"}, common.GridElement{"dash-ram", "RAM: " + ramstr, 2, "grid_istat " + ramColour, "", "", "The global RAM usage of this server"}, } + var addElement = func(element common.GridElement) { + gridElements = append(gridElements, element) + } if common.EnableWebsockets { uonline := common.WsHub.UserCount() @@ -140,41 +144,42 @@ func routePanelDashboard(w http.ResponseWriter, r *http.Request, user common.Use uonline, uunit := common.ConvertFriendlyUnit(uonline) gonline, gunit := common.ConvertFriendlyUnit(gonline) - gridElements = append(gridElements, common.GridElement{"dash-totonline", strconv.Itoa(totonline) + totunit + " online", 3, "grid_stat " + onlineColour, "", "", "The number of people who are currently online"}) - gridElements = append(gridElements, common.GridElement{"dash-gonline", strconv.Itoa(gonline) + gunit + " guests online", 4, "grid_stat " + onlineGuestsColour, "", "", "The number of guests who are currently online"}) - gridElements = append(gridElements, common.GridElement{"dash-uonline", strconv.Itoa(uonline) + uunit + " users online", 5, "grid_stat " + onlineUsersColour, "", "", "The number of logged-in users who are currently online"}) - gridElements = append(gridElements, common.GridElement{"dash-reqs", strconv.Itoa(reqCount) + " reqs / second", 7, "grid_stat grid_end_group " + topicColour, "", "", "The number of requests over the last 24 hours"}) + addElement(common.GridElement{"dash-totonline", strconv.Itoa(totonline) + totunit + " online", 3, "grid_stat " + onlineColour, "", "", "The number of people who are currently online"}) + addElement(common.GridElement{"dash-gonline", strconv.Itoa(gonline) + gunit + " guests online", 4, "grid_stat " + onlineGuestsColour, "", "", "The number of guests who are currently online"}) + addElement(common.GridElement{"dash-uonline", strconv.Itoa(uonline) + uunit + " users online", 5, "grid_stat " + onlineUsersColour, "", "", "The number of logged-in users who are currently online"}) + addElement(common.GridElement{"dash-reqs", strconv.Itoa(reqCount) + " reqs / second", 7, "grid_stat grid_end_group " + topicColour, "", "", "The number of requests over the last 24 hours"}) } - gridElements = append(gridElements, common.GridElement{"dash-postsperday", strconv.Itoa(postCount) + " posts / " + postInterval, 6, "grid_stat " + postColour, "", "", "The number of new posts over the last 24 hours"}) - gridElements = append(gridElements, common.GridElement{"dash-topicsperday", strconv.Itoa(topicCount) + " topics / " + topicInterval, 7, "grid_stat " + topicColour, "", "", "The number of new topics over the last 24 hours"}) - gridElements = append(gridElements, common.GridElement{"dash-totonlineperday", "20 online / day", 8, "grid_stat stat_disabled", "", "", "Coming Soon!" /*, "The people online over the last 24 hours"*/}) + addElement(common.GridElement{"dash-postsperday", strconv.Itoa(postCount) + " posts / " + postInterval, 6, "grid_stat " + postColour, "", "", "The number of new posts over the last 24 hours"}) + addElement(common.GridElement{"dash-topicsperday", strconv.Itoa(topicCount) + " topics / " + topicInterval, 7, "grid_stat " + topicColour, "", "", "The number of new topics over the last 24 hours"}) + addElement(common.GridElement{"dash-totonlineperday", "20 online / day", 8, "grid_stat stat_disabled", "", "", "Coming Soon!" /*, "The people online over the last 24 hours"*/}) - gridElements = append(gridElements, common.GridElement{"dash-searches", "8 searches / week", 9, "grid_stat stat_disabled", "", "", "Coming Soon!" /*"The number of searches over the last 7 days"*/}) - gridElements = append(gridElements, common.GridElement{"dash-newusers", strconv.Itoa(newUserCount) + " new users / " + newUserInterval, 10, "grid_stat", "", "", "The number of new users over the last 7 days"}) - gridElements = append(gridElements, common.GridElement{"dash-reports", strconv.Itoa(reportCount) + " reports / " + reportInterval, 11, "grid_stat", "", "", "The number of reports over the last 7 days"}) + addElement(common.GridElement{"dash-searches", "8 searches / week", 9, "grid_stat stat_disabled", "", "", "Coming Soon!" /*"The number of searches over the last 7 days"*/}) + addElement(common.GridElement{"dash-newusers", strconv.Itoa(newUserCount) + " new users / " + newUserInterval, 10, "grid_stat", "", "", "The number of new users over the last 7 days"}) + addElement(common.GridElement{"dash-reports", strconv.Itoa(reportCount) + " reports / " + reportInterval, 11, "grid_stat", "", "", "The number of reports over the last 7 days"}) if false { - gridElements = append(gridElements, common.GridElement{"dash-minperuser", "2 minutes / user / week", 12, "grid_stat stat_disabled", "", "", "Coming Soon!" /*"The average number of number of minutes spent by each active user over the last 7 days"*/}) - gridElements = append(gridElements, common.GridElement{"dash-visitorsperweek", "2 visitors / week", 13, "grid_stat stat_disabled", "", "", "Coming Soon!" /*"The number of unique visitors we've had over the last 7 days"*/}) - gridElements = append(gridElements, common.GridElement{"dash-postsperuser", "5 posts / user / week", 14, "grid_stat stat_disabled", "", "", "Coming Soon!" /*"The average number of posts made by each active user over the past week"*/}) + addElement(common.GridElement{"dash-minperuser", "2 minutes / user / week", 12, "grid_stat stat_disabled", "", "", "Coming Soon!" /*"The average number of number of minutes spent by each active user over the last 7 days"*/}) + addElement(common.GridElement{"dash-visitorsperweek", "2 visitors / week", 13, "grid_stat stat_disabled", "", "", "Coming Soon!" /*"The number of unique visitors we've had over the last 7 days"*/}) + addElement(common.GridElement{"dash-postsperuser", "5 posts / user / week", 14, "grid_stat stat_disabled", "", "", "Coming Soon!" /*"The average number of posts made by each active user over the past week"*/}) } - pi := common.PanelDashboardPage{headerVars, stats, "dashboard", gridElements} + pi := common.PanelDashboardPage{&common.BasePanelPage{header, stats, "dashboard", common.ReportForumID}, gridElements} return panelRenderTemplate("panel_dashboard", w, r, user, &pi) } func routePanelWordFilters(w http.ResponseWriter, r *http.Request, user common.User) common.RouteError { - headerVars, stats, ferr := common.PanelUserCheck(w, r, &user) + header, stats, ferr := common.PanelUserCheck(w, r, &user) if ferr != nil { return ferr } if !user.Perms.EditSettings { return common.NoPermissions(w, r, user) } + header.Title = common.GetTitlePhrase("panel_word_filters") var filterList = common.WordFilterBox.Load().(common.WordFilterMap) - pi := common.PanelPage{common.GetTitlePhrase("panel_word_filters"), user, headerVars, stats, "word-filters", tList, filterList} + pi := common.PanelPage{&common.BasePanelPage{header, stats, "word-filters", common.ReportForumID}, tList, filterList} return panelRenderTemplate("panel_word_filters", w, r, user, &pi) } @@ -212,17 +217,17 @@ func routePanelWordFiltersCreateSubmit(w http.ResponseWriter, r *http.Request, u // TODO: Implement this as a non-JS fallback func routePanelWordFiltersEdit(w http.ResponseWriter, r *http.Request, user common.User, wfid string) common.RouteError { - headerVars, stats, ferr := common.PanelUserCheck(w, r, &user) + header, stats, ferr := common.PanelUserCheck(w, r, &user) if ferr != nil { return ferr } if !user.Perms.EditSettings { return common.NoPermissions(w, r, user) } - + header.Title = common.GetTitlePhrase("panel_edit_word_filter") _ = wfid - pi := common.PanelPage{common.GetTitlePhrase("panel_edit_word_filter"), user, headerVars, stats, "word-filters", tList, nil} + pi := common.PanelPage{&common.BasePanelPage{header, stats, "word-filters", common.ReportForumID}, tList, nil} return panelRenderTemplate("panel_word_filters_edit", w, r, user, &pi) } @@ -293,20 +298,21 @@ func routePanelWordFiltersDeleteSubmit(w http.ResponseWriter, r *http.Request, u } func routePanelPlugins(w http.ResponseWriter, r *http.Request, user common.User) common.RouteError { - headerVars, stats, ferr := common.PanelUserCheck(w, r, &user) + header, stats, ferr := common.PanelUserCheck(w, r, &user) if ferr != nil { return ferr } if !user.Perms.ManagePlugins { return common.NoPermissions(w, r, user) } + header.Title = common.GetTitlePhrase("panel_plugins") var pluginList []interface{} for _, plugin := range common.Plugins { pluginList = append(pluginList, plugin) } - pi := common.PanelPage{common.GetTitlePhrase("panel_plugins"), user, headerVars, stats, "plugins", pluginList, nil} + pi := common.PanelPage{&common.BasePanelPage{header, stats, "plugins", common.ReportForumID}, pluginList, nil} return panelRenderTemplate("panel_plugins", w, r, user, &pi) } @@ -487,18 +493,19 @@ func routePanelUsers(w http.ResponseWriter, r *http.Request, user common.User) c } pageList := common.Paginate(stats.Users, perPage, 5) - pi := common.PanelUserPage{header, stats, "users", users, common.Paginator{pageList, page, lastPage}} + pi := common.PanelUserPage{&common.BasePanelPage{header, stats, "users", common.ReportForumID}, users, common.Paginator{pageList, page, lastPage}} return panelRenderTemplate("panel_users", w, r, user, &pi) } func routePanelUsersEdit(w http.ResponseWriter, r *http.Request, user common.User, suid string) common.RouteError { - headerVars, stats, ferr := common.PanelUserCheck(w, r, &user) + header, stats, ferr := common.PanelUserCheck(w, r, &user) if ferr != nil { return ferr } if !user.Perms.EditUser { return common.NoPermissions(w, r, user) } + header.Title = common.GetTitlePhrase("panel_edit_user") uid, err := strconv.Atoi(suid) if err != nil { @@ -534,10 +541,10 @@ func routePanelUsersEdit(w http.ResponseWriter, r *http.Request, user common.Use } if r.FormValue("updated") == "1" { - headerVars.NoticeList = append(headerVars.NoticeList, common.GetNoticePhrase("panel_user_updated")) + header.NoticeList = append(header.NoticeList, common.GetNoticePhrase("panel_user_updated")) } - pi := common.PanelPage{common.GetTitlePhrase("panel_edit_user"), user, headerVars, stats, "users", groupList, targetUser} + pi := common.PanelPage{&common.BasePanelPage{header, stats, "users", common.ReportForumID}, groupList, targetUser} if common.RunPreRenderHook("pre_render_panel_edit_user", w, r, &user, &pi) { return nil } @@ -635,10 +642,11 @@ func routePanelUsersEditSubmit(w http.ResponseWriter, r *http.Request, user comm } func routePanelGroups(w http.ResponseWriter, r *http.Request, user common.User) common.RouteError { - headerVars, stats, ferr := common.PanelUserCheck(w, r, &user) + header, stats, ferr := common.PanelUserCheck(w, r, &user) if ferr != nil { return ferr } + header.Title = common.GetTitlePhrase("panel_groups") page, _ := strconv.Atoi(r.FormValue("page")) perPage := 9 @@ -661,6 +669,7 @@ func routePanelGroups(w http.ResponseWriter, r *http.Request, user common.User) var canDelete = false // TODO: Use a switch for this + // TODO: Localise this if group.IsAdmin { rank = "Admin" rankClass = "admin" @@ -685,18 +694,19 @@ func routePanelGroups(w http.ResponseWriter, r *http.Request, user common.User) //log.Printf("groupList: %+v\n", groupList) pageList := common.Paginate(stats.Groups, perPage, 5) - pi := common.PanelGroupPage{common.GetTitlePhrase("panel_groups"), user, headerVars, stats, "groups", groupList, common.Paginator{pageList, page, lastPage}} + pi := common.PanelGroupPage{&common.BasePanelPage{header, stats, "groups", common.ReportForumID}, groupList, common.Paginator{pageList, page, lastPage}} return panelRenderTemplate("panel_groups", w, r, user, &pi) } func routePanelGroupsEdit(w http.ResponseWriter, r *http.Request, user common.User, sgid string) common.RouteError { - headerVars, stats, ferr := common.PanelUserCheck(w, r, &user) + header, stats, ferr := common.PanelUserCheck(w, r, &user) if ferr != nil { return ferr } if !user.Perms.EditGroup { return common.NoPermissions(w, r, user) } + header.Title = common.GetTitlePhrase("panel_edit_group") gid, err := strconv.Atoi(sgid) if err != nil { @@ -706,7 +716,7 @@ func routePanelGroupsEdit(w http.ResponseWriter, r *http.Request, user common.Us group, err := common.Groups.Get(gid) if err == ErrNoRows { //log.Print("aaaaa monsters") - return common.NotFound(w, r, headerVars) + return common.NotFound(w, r, header) } else if err != nil { return common.InternalError(err, w, r) } @@ -734,7 +744,7 @@ func routePanelGroupsEdit(w http.ResponseWriter, r *http.Request, user common.Us disableRank := !user.Perms.EditGroupGlobalPerms || (group.ID == 6) - pi := common.PanelEditGroupPage{common.GetTitlePhrase("panel_edit_group"), user, headerVars, stats, "groups", group.ID, group.Name, group.Tag, rank, disableRank} + pi := common.PanelEditGroupPage{&common.BasePanelPage{header, stats, "groups", common.ReportForumID}, group.ID, group.Name, group.Tag, rank, disableRank} if common.RunPreRenderHook("pre_render_panel_edit_group", w, r, &user, &pi) { return nil } @@ -746,13 +756,14 @@ func routePanelGroupsEdit(w http.ResponseWriter, r *http.Request, user common.Us } func routePanelGroupsEditPerms(w http.ResponseWriter, r *http.Request, user common.User, sgid string) common.RouteError { - headerVars, stats, ferr := common.PanelUserCheck(w, r, &user) + header, stats, ferr := common.PanelUserCheck(w, r, &user) if ferr != nil { return ferr } if !user.Perms.EditGroup { return common.NoPermissions(w, r, user) } + header.Title = common.GetTitlePhrase("panel_edit_group") gid, err := strconv.Atoi(sgid) if err != nil { @@ -762,7 +773,7 @@ func routePanelGroupsEditPerms(w http.ResponseWriter, r *http.Request, user comm group, err := common.Groups.Get(gid) if err == ErrNoRows { //log.Print("aaaaa monsters") - return common.NotFound(w, r, headerVars) + return common.NotFound(w, r, header) } else if err != nil { return common.InternalError(err, w, r) } @@ -820,7 +831,7 @@ func routePanelGroupsEditPerms(w http.ResponseWriter, r *http.Request, user comm addGlobalPerm("ViewIPs", group.Perms.ViewIPs) addGlobalPerm("UploadFiles", group.Perms.UploadFiles) - pi := common.PanelEditGroupPermsPage{common.GetTitlePhrase("panel_edit_group"), user, headerVars, stats, "groups", group.ID, group.Name, localPerms, globalPerms} + pi := common.PanelEditGroupPermsPage{&common.BasePanelPage{header, stats, "groups", common.ReportForumID}, group.ID, group.Name, localPerms, globalPerms} if common.RunPreRenderHook("pre_render_panel_edit_group_perms", w, r, &user, &pi) { return nil } @@ -1049,7 +1060,7 @@ func routePanelThemes(w http.ResponseWriter, r *http.Request, user common.User) } - pi := common.PanelThemesPage{header, stats, "themes", pThemeList, vThemeList} + pi := common.PanelThemesPage{&common.BasePanelPage{header, stats, "themes", common.ReportForumID}, pThemeList, vThemeList} return panelRenderTemplate("panel_themes", w, r, user, &pi) } @@ -1141,7 +1152,7 @@ func routePanelThemesMenus(w http.ResponseWriter, r *http.Request, user common.U }) } - pi := common.PanelMenuListPage{header, stats, "themes", menuList} + pi := common.PanelMenuListPage{&common.BasePanelPage{header, stats, "themes", common.ReportForumID}, menuList} return panelRenderTemplate("panel_themes_menus", w, r, user, &pi) } @@ -1189,7 +1200,7 @@ func routePanelThemesMenusEdit(w http.ResponseWriter, r *http.Request, user comm menuList = append(menuList, item) } - pi := common.PanelMenuPage{header, stats, "themes", mid, menuList} + pi := common.PanelMenuPage{&common.BasePanelPage{header, stats, "themes", common.ReportForumID}, mid, menuList} return panelRenderTemplate("panel_themes_menus_items", w, r, user, &pi) } @@ -1216,7 +1227,7 @@ func routePanelThemesMenuItemEdit(w http.ResponseWriter, r *http.Request, user c return common.InternalError(err, w, r) } - pi := common.PanelMenuItemPage{header, stats, "themes", menuItem} + pi := common.PanelMenuItemPage{&common.BasePanelPage{header, stats, "themes", common.ReportForumID}, menuItem} return panelRenderTemplate("panel_themes_menus_item_edit", w, r, user, &pi) } diff --git a/query_gen/lib/mssql.go b/query_gen/lib/mssql.go index 1c689602..6ee88d97 100644 --- a/query_gen/lib/mssql.go +++ b/query_gen/lib/mssql.go @@ -1152,7 +1152,7 @@ type Stmts struct { getActivityCountByWatcher *sql.Stmt todaysPostCount *sql.Stmt todaysTopicCount *sql.Stmt - todaysReportCount *sql.Stmt + todaysTopicCountByForum *sql.Stmt todaysNewUserCount *sql.Stmt Mocks bool diff --git a/query_gen/lib/mysql.go b/query_gen/lib/mysql.go index 1cd43d33..5f2eef80 100644 --- a/query_gen/lib/mysql.go +++ b/query_gen/lib/mysql.go @@ -737,7 +737,7 @@ type Stmts struct { getActivityCountByWatcher *sql.Stmt todaysPostCount *sql.Stmt todaysTopicCount *sql.Stmt - todaysReportCount *sql.Stmt + todaysTopicCountByForum *sql.Stmt todaysNewUserCount *sql.Stmt Mocks bool diff --git a/query_gen/lib/pgsql.go b/query_gen/lib/pgsql.go index 7afe90a3..a803b318 100644 --- a/query_gen/lib/pgsql.go +++ b/query_gen/lib/pgsql.go @@ -440,7 +440,7 @@ type Stmts struct { getActivityCountByWatcher *sql.Stmt todaysPostCount *sql.Stmt todaysTopicCount *sql.Stmt - todaysReportCount *sql.Stmt + todaysTopicCountByForum *sql.Stmt todaysNewUserCount *sql.Stmt Mocks bool diff --git a/query_gen/tables.go b/query_gen/tables.go index 320431a8..3d1535c5 100644 --- a/query_gen/tables.go +++ b/query_gen/tables.go @@ -62,6 +62,26 @@ func createTables(adapter qgen.Adapter) error { }, ) + /* + qgen.Install.CreateTable("users_2fa_keys", "utf8mb4", "utf8mb4_general_ci", + []qgen.DBTableColumn{ + qgen.DBTableColumn{"uid", "int", 0, false, false, ""}, + qgen.DBTableColumn{"secret", "varchar", 100, false, false, ""}, + qgen.DBTableColumn{"scratch1", "varchar", 50, false, false, ""}, + qgen.DBTableColumn{"scratch2", "varchar", 50, false, false, ""}, + qgen.DBTableColumn{"scratch3", "varchar", 50, false, false, ""}, + qgen.DBTableColumn{"scratch4", "varchar", 50, false, false, ""}, + qgen.DBTableColumn{"scratch5", "varchar", 50, false, false, ""}, + qgen.DBTableColumn{"scratch6", "varchar", 50, false, false, ""}, + qgen.DBTableColumn{"scratch7", "varchar", 50, false, false, ""}, + qgen.DBTableColumn{"scratch8", "varchar", 50, false, false, ""}, + }, + []qgen.DBTableKey{ + qgen.DBTableKey{"uid", "primary"}, + }, + ) + */ + // What should we do about global penalties? Put them on the users table for speed? Or keep them here? // Should we add IP Penalties? No, that's a stupid idea, just implement IP Bans properly. What about shadowbans? // TODO: Perm overrides diff --git a/router_gen/routes.go b/router_gen/routes.go index aed77310..06eb6b90 100644 --- a/router_gen/routes.go +++ b/router_gen/routes.go @@ -151,6 +151,12 @@ func buildPanelRoutes() { Action("routePanelWordFiltersEditSubmit", "/panel/settings/word-filters/edit/submit/", "extraData"), Action("routePanelWordFiltersDeleteSubmit", "/panel/settings/word-filters/delete/submit/", "extraData"), + View("panel.Pages", "/panel/pages/").Before("AdminOnly"), + Action("panel.PagesCreateSubmit", "/panel/pages/create/submit/").Before("AdminOnly"), + View("panel.PagesEdit", "/panel/pages/edit/", "extraData").Before("AdminOnly"), + Action("panel.PagesEditSubmit", "/panel/pages/edit/submit/", "extraData").Before("AdminOnly"), + Action("panel.PagesDeleteSubmit", "/panel/pages/delete/submit/", "extraData").Before("AdminOnly"), + View("routePanelThemes", "/panel/themes/"), Action("routePanelThemesSetDefault", "/panel/themes/default/", "extraData"), View("routePanelThemesMenus", "/panel/themes/menus/"), diff --git a/routes/account.go b/routes/account.go index 23b48a29..0d907e87 100644 --- a/routes/account.go +++ b/routes/account.go @@ -27,7 +27,8 @@ func AccountLogin(w http.ResponseWriter, r *http.Request, user common.User) comm if user.Loggedin { return common.LocalError("You're already logged in.", w, r, user) } - pi := common.Page{common.GetTitlePhrase("login"), user, header, tList, nil} + header.Title = common.GetTitlePhrase("login") + pi := common.Page{header, tList, nil} if common.RunPreRenderHook("pre_render_login", w, r, &user, &pi) { return nil } @@ -92,11 +93,13 @@ func AccountRegister(w http.ResponseWriter, r *http.Request, user common.User) c if user.Loggedin { return common.LocalError("You're already logged in.", w, r, user) } + header.Title = common.GetTitlePhrase("register") + h := sha256.New() h.Write([]byte(common.JSTokenBox.Load().(string))) h.Write([]byte(user.LastIP)) jsToken := hex.EncodeToString(h.Sum(nil)) - pi := common.Page{common.GetTitlePhrase("register"), user, header, tList, jsToken} + pi := common.Page{header, tList, jsToken} if common.RunPreRenderHook("pre_render_register", w, r, &user, &pi) { return nil } @@ -230,23 +233,27 @@ func AccountRegisterSubmit(w http.ResponseWriter, r *http.Request, user common.U return nil } +// TODO: Rename this func AccountEditCritical(w http.ResponseWriter, r *http.Request, user common.User) common.RouteError { header, ferr := common.UserCheck(w, r, &user) if ferr != nil { return ferr } + // TODO: Add a phrase for this + header.Title = "Edit Password" - pi := common.Page{"Edit Password", user, header, tList, nil} - if common.RunPreRenderHook("pre_render_account_own_edit_critical", w, r, &user, &pi) { + pi := common.Page{header, tList, nil} + if common.RunPreRenderHook("pre_render_account_own_edit_password", w, r, &user, &pi) { return nil } - err := common.Templates.ExecuteTemplate(w, "account_own_edit.html", pi) + err := common.Templates.ExecuteTemplate(w, "account_own_edit_password.html", pi) if err != nil { return common.InternalError(err, w, r) } return nil } +// TODO: Rename this func AccountEditCriticalSubmit(w http.ResponseWriter, r *http.Request, user common.User) common.RouteError { _, ferr := common.SimpleUserCheck(w, r, &user) if ferr != nil { @@ -285,12 +292,16 @@ func AccountEditCriticalSubmit(w http.ResponseWriter, r *http.Request, user comm } func AccountEditAvatar(w http.ResponseWriter, r *http.Request, user common.User) common.RouteError { - headerVars, ferr := common.UserCheck(w, r, &user) + header, ferr := common.UserCheck(w, r, &user) if ferr != nil { return ferr } + header.Title = common.GetTitlePhrase("account_avatar") + if r.FormValue("updated") == "1" { + header.NoticeList = append(header.NoticeList, common.GetNoticePhrase("account_avatar_updated")) + } - pi := common.Page{"Edit Avatar", user, headerVars, tList, nil} + pi := common.Page{header, tList, nil} if common.RunPreRenderHook("pre_render_account_own_edit_avatar", w, r, &user, &pi) { return nil } @@ -302,7 +313,7 @@ func AccountEditAvatar(w http.ResponseWriter, r *http.Request, user common.User) } func AccountEditAvatarSubmit(w http.ResponseWriter, r *http.Request, user common.User) common.RouteError { - headerVars, ferr := common.UserCheck(w, r, &user) + _, ferr := common.SimpleUserCheck(w, r, &user) if ferr != nil { return ferr } @@ -366,30 +377,21 @@ func AccountEditAvatarSubmit(w http.ResponseWriter, r *http.Request, user common if err != nil { return common.InternalError(err, w, r) } - user.Avatar = "/uploads/avatar_" + strconv.Itoa(user.ID) + "." + ext - headerVars.NoticeList = append(headerVars.NoticeList, common.GetNoticePhrase("account_avatar_updated")) - - pi := common.Page{"Edit Avatar", user, headerVars, tList, nil} - if common.RunPreRenderHook("pre_render_account_own_edit_avatar", w, r, &user, &pi) { - return nil - } - err = common.Templates.ExecuteTemplate(w, "account_own_edit_avatar.html", pi) - if err != nil { - return common.InternalError(err, w, r) - } + http.Redirect(w, r, "/user/edit/avatar/?updated=1", http.StatusSeeOther) return nil } func AccountEditUsername(w http.ResponseWriter, r *http.Request, user common.User) common.RouteError { - headerVars, ferr := common.UserCheck(w, r, &user) + header, ferr := common.UserCheck(w, r, &user) if ferr != nil { return ferr } + header.Title = common.GetTitlePhrase("account_username") if r.FormValue("updated") == "1" { - headerVars.NoticeList = append(headerVars.NoticeList, common.GetNoticePhrase("account_username_updated")) + header.NoticeList = append(header.NoticeList, common.GetNoticePhrase("account_username_updated")) } - pi := common.Page{"Edit Username", user, headerVars, tList, user.Name} + pi := common.Page{header, tList, user.Name} if common.RunPreRenderHook("pre_render_account_own_edit_username", w, r, &user, &pi) { return nil } @@ -421,8 +423,7 @@ func AccountEditEmail(w http.ResponseWriter, r *http.Request, user common.User) if ferr != nil { return ferr } - // TODO: Add a phrase for this - header.Title = "Email Manager" + header.Title = common.GetTitlePhrase("account_email") emails, err := common.Emails.GetEmailsByUser(&user) if err != nil { @@ -457,9 +458,9 @@ func AccountEditEmail(w http.ResponseWriter, r *http.Request, user common.User) return nil } -// TODO: Do a session check on this? +// TODO: Should we make this an AnonAction so someone can do this without being logged in? func AccountEditEmailTokenSubmit(w http.ResponseWriter, r *http.Request, user common.User, token string) common.RouteError { - headerVars, ferr := common.UserCheck(w, r, &user) + header, ferr := common.UserCheck(w, r, &user) if ferr != nil { return ferr } @@ -492,7 +493,7 @@ func AccountEditEmailTokenSubmit(w http.ResponseWriter, r *http.Request, user co } // If Email Activation is on, then activate the account while we're here - if headerVars.Settings["activation_type"] == 2 { + if header.Settings["activation_type"] == 2 { err = user.Activate() if err != nil { return common.InternalError(err, w, r) diff --git a/routes/misc.go b/routes/misc.go index 8548e110..8e3d8871 100644 --- a/routes/misc.go +++ b/routes/misc.go @@ -52,9 +52,10 @@ func Overview(w http.ResponseWriter, r *http.Request, user common.User) common.R if ferr != nil { return ferr } + header.Title = common.GetTitlePhrase("overview") header.Zone = "overview" - pi := common.Page{common.GetTitlePhrase("overview"), user, header, tList, nil} + pi := common.Page{header, tList, nil} if common.RunPreRenderHook("pre_render_overview", w, r, &user, &pi) { return nil } @@ -70,20 +71,38 @@ func CustomPage(w http.ResponseWriter, r *http.Request, user common.User, name s if ferr != nil { return ferr } + header.Title = common.GetTitlePhrase("page") header.Zone = "custom_page" + name = common.SanitiseSingleLine(name) + page, err := common.Pages.GetByName(name) + if err == nil { + header.Title = page.Title + pi := common.CustomPagePage{header, page} + if common.RunPreRenderHook("pre_render_custom_page", w, r, &user, &pi) { + return nil + } + err := common.RunThemeTemplate(header.Theme.Name, "custom_page", pi, w) + if err != nil { + return common.InternalError(err, w, r) + } + return nil + } else if err != sql.ErrNoRows { + return common.InternalError(err, w, r) + } + // ! Is this safe? if common.Templates.Lookup("page_"+name+".html") == nil { return common.NotFound(w, r, header) } - pi := common.Page{common.GetTitlePhrase("page"), user, header, tList, nil} + pi := common.Page{header, tList, nil} // TODO: Pass the page name to the pre-render hook? - if common.RunPreRenderHook("pre_render_custom_page", w, r, &user, &pi) { + if common.RunPreRenderHook("pre_render_tmpl_page", w, r, &user, &pi) { return nil } - err := common.Templates.ExecuteTemplate(w, "page_"+name+".html", pi) + err = common.Templates.ExecuteTemplate(w, "page_"+name+".html", pi) if err != nil { return common.InternalError(err, w, r) } @@ -96,7 +115,7 @@ type AttachmentStmts struct { var attachmentStmts AttachmentStmts -// TODO: Move these DbInits into a TopicList abstraction +// TODO: Abstract this with an attachment store func init() { common.DbInits.Add(func(acc *qgen.Accumulator) error { attachmentStmts = AttachmentStmts{ diff --git a/routes/panel/analytics.go b/routes/panel/analytics.go index f670aebb..e2a379fa 100644 --- a/routes/panel/analytics.go +++ b/routes/panel/analytics.go @@ -107,14 +107,25 @@ func analyticsRowsToViewMap(rows *sql.Rows, labelList []int64, viewMap map[int64 return viewMap, rows.Err() } +func PreAnalyticsDetail(w http.ResponseWriter, r *http.Request, user *common.User) (*common.BasePanelPage, common.RouteError) { + header, stats, ferr := common.PanelUserCheck(w, r, user) + if ferr != nil { + return nil, ferr + } + + header.Title = common.GetTitlePhrase("panel_analytics") + header.AddSheet("chartist/chartist.min.css") + header.AddScript("chartist/chartist.min.js") + header.AddScript("analytics.js") + + return &common.BasePanelPage{header, stats, "analytics", common.ReportForumID}, nil +} + func AnalyticsViews(w http.ResponseWriter, r *http.Request, user common.User) common.RouteError { - headerVars, stats, ferr := common.PanelUserCheck(w, r, &user) + basePage, ferr := PreAnalyticsDetail(w, r, &user) if ferr != nil { return ferr } - headerVars.AddSheet("chartist/chartist.min.css") - headerVars.AddScript("chartist/chartist.min.js") - headerVars.AddScript("analytics.js") timeRange, err := analyticsTimeRange(r.FormValue("timeRange")) if err != nil { @@ -143,18 +154,15 @@ func AnalyticsViews(w http.ResponseWriter, r *http.Request, user common.User) co graph := common.PanelTimeGraph{Series: viewList, Labels: labelList} common.DebugLogf("graph: %+v\n", graph) - pi := common.PanelAnalyticsPage{common.GetTitlePhrase("panel_analytics"), user, headerVars, stats, "analytics", graph, viewItems, timeRange.Range} + pi := common.PanelAnalyticsPage{basePage, graph, viewItems, timeRange.Range} return panelRenderTemplate("panel_analytics_views", w, r, user, &pi) } func AnalyticsRouteViews(w http.ResponseWriter, r *http.Request, user common.User, route string) common.RouteError { - headerVars, stats, ferr := common.PanelUserCheck(w, r, &user) + basePage, ferr := PreAnalyticsDetail(w, r, &user) if ferr != nil { return ferr } - headerVars.AddSheet("chartist/chartist.min.css") - headerVars.AddScript("chartist/chartist.min.js") - headerVars.AddScript("analytics.js") timeRange, err := analyticsTimeRange(r.FormValue("timeRange")) if err != nil { @@ -184,18 +192,15 @@ func AnalyticsRouteViews(w http.ResponseWriter, r *http.Request, user common.Use graph := common.PanelTimeGraph{Series: viewList, Labels: labelList} common.DebugLogf("graph: %+v\n", graph) - pi := common.PanelAnalyticsRoutePage{common.GetTitlePhrase("panel_analytics"), user, headerVars, stats, "analytics", common.SanitiseSingleLine(route), graph, viewItems, timeRange.Range} + pi := common.PanelAnalyticsRoutePage{basePage, common.SanitiseSingleLine(route), graph, viewItems, timeRange.Range} return panelRenderTemplate("panel_analytics_route_views", w, r, user, &pi) } func AnalyticsAgentViews(w http.ResponseWriter, r *http.Request, user common.User, agent string) common.RouteError { - headerVars, stats, ferr := common.PanelUserCheck(w, r, &user) + basePage, ferr := PreAnalyticsDetail(w, r, &user) if ferr != nil { return ferr } - headerVars.AddSheet("chartist/chartist.min.css") - headerVars.AddScript("chartist/chartist.min.js") - headerVars.AddScript("analytics.js") timeRange, err := analyticsTimeRange(r.FormValue("timeRange")) if err != nil { @@ -231,19 +236,15 @@ func AnalyticsAgentViews(w http.ResponseWriter, r *http.Request, user common.Use friendlyAgent = agent } - pi := common.PanelAnalyticsAgentPage{common.GetTitlePhrase("panel_analytics"), user, headerVars, stats, "analytics", agent, friendlyAgent, graph, timeRange.Range} + pi := common.PanelAnalyticsAgentPage{basePage, agent, friendlyAgent, graph, timeRange.Range} return panelRenderTemplate("panel_analytics_agent_views", w, r, user, &pi) } func AnalyticsForumViews(w http.ResponseWriter, r *http.Request, user common.User, sfid string) common.RouteError { - headerVars, stats, ferr := common.PanelUserCheck(w, r, &user) + basePage, ferr := PreAnalyticsDetail(w, r, &user) if ferr != nil { return ferr } - headerVars.AddSheet("chartist/chartist.min.css") - headerVars.AddScript("chartist/chartist.min.js") - headerVars.AddScript("analytics.js") - timeRange, err := analyticsTimeRange(r.FormValue("timeRange")) if err != nil { return common.LocalError(err.Error(), w, r, user) @@ -280,18 +281,15 @@ func AnalyticsForumViews(w http.ResponseWriter, r *http.Request, user common.Use return common.InternalError(err, w, r) } - pi := common.PanelAnalyticsAgentPage{common.GetTitlePhrase("panel_analytics"), user, headerVars, stats, "analytics", sfid, forum.Name, graph, timeRange.Range} + pi := common.PanelAnalyticsAgentPage{basePage, sfid, forum.Name, graph, timeRange.Range} return panelRenderTemplate("panel_analytics_forum_views", w, r, user, &pi) } func AnalyticsSystemViews(w http.ResponseWriter, r *http.Request, user common.User, system string) common.RouteError { - headerVars, stats, ferr := common.PanelUserCheck(w, r, &user) + basePage, ferr := PreAnalyticsDetail(w, r, &user) if ferr != nil { return ferr } - headerVars.AddSheet("chartist/chartist.min.css") - headerVars.AddScript("chartist/chartist.min.js") - headerVars.AddScript("analytics.js") timeRange, err := analyticsTimeRange(r.FormValue("timeRange")) if err != nil { @@ -325,19 +323,15 @@ func AnalyticsSystemViews(w http.ResponseWriter, r *http.Request, user common.Us friendlySystem = system } - pi := common.PanelAnalyticsAgentPage{common.GetTitlePhrase("panel_analytics"), user, headerVars, stats, "analytics", system, friendlySystem, graph, timeRange.Range} + pi := common.PanelAnalyticsAgentPage{basePage, system, friendlySystem, graph, timeRange.Range} return panelRenderTemplate("panel_analytics_system_views", w, r, user, &pi) } func AnalyticsLanguageViews(w http.ResponseWriter, r *http.Request, user common.User, lang string) common.RouteError { - headerVars, stats, ferr := common.PanelUserCheck(w, r, &user) + basePage, ferr := PreAnalyticsDetail(w, r, &user) if ferr != nil { return ferr } - headerVars.AddSheet("chartist/chartist.min.css") - headerVars.AddScript("chartist/chartist.min.js") - headerVars.AddScript("analytics.js") - timeRange, err := analyticsTimeRange(r.FormValue("timeRange")) if err != nil { return common.LocalError(err.Error(), w, r, user) @@ -370,19 +364,15 @@ func AnalyticsLanguageViews(w http.ResponseWriter, r *http.Request, user common. friendlyLang = lang } - pi := common.PanelAnalyticsAgentPage{common.GetTitlePhrase("panel_analytics"), user, headerVars, stats, "analytics", lang, friendlyLang, graph, timeRange.Range} + pi := common.PanelAnalyticsAgentPage{basePage, lang, friendlyLang, graph, timeRange.Range} return panelRenderTemplate("panel_analytics_lang_views", w, r, user, &pi) } func AnalyticsReferrerViews(w http.ResponseWriter, r *http.Request, user common.User, domain string) common.RouteError { - headerVars, stats, ferr := common.PanelUserCheck(w, r, &user) + basePage, ferr := PreAnalyticsDetail(w, r, &user) if ferr != nil { return ferr } - headerVars.AddSheet("chartist/chartist.min.css") - headerVars.AddScript("chartist/chartist.min.js") - headerVars.AddScript("analytics.js") - timeRange, err := analyticsTimeRange(r.FormValue("timeRange")) if err != nil { return common.LocalError(err.Error(), w, r, user) @@ -409,19 +399,15 @@ func AnalyticsReferrerViews(w http.ResponseWriter, r *http.Request, user common. graph := common.PanelTimeGraph{Series: viewList, Labels: labelList} common.DebugLogf("graph: %+v\n", graph) - pi := common.PanelAnalyticsAgentPage{common.GetTitlePhrase("panel_analytics"), user, headerVars, stats, "analytics", common.SanitiseSingleLine(domain), "", graph, timeRange.Range} + pi := common.PanelAnalyticsAgentPage{basePage, common.SanitiseSingleLine(domain), "", graph, timeRange.Range} return panelRenderTemplate("panel_analytics_referrer_views", w, r, user, &pi) } func AnalyticsTopics(w http.ResponseWriter, r *http.Request, user common.User) common.RouteError { - headerVars, stats, ferr := common.PanelUserCheck(w, r, &user) + basePage, ferr := PreAnalyticsDetail(w, r, &user) if ferr != nil { return ferr } - headerVars.AddSheet("chartist/chartist.min.css") - headerVars.AddScript("chartist/chartist.min.js") - headerVars.AddScript("analytics.js") - timeRange, err := analyticsTimeRange(r.FormValue("timeRange")) if err != nil { return common.LocalError(err.Error(), w, r, user) @@ -449,19 +435,15 @@ func AnalyticsTopics(w http.ResponseWriter, r *http.Request, user common.User) c graph := common.PanelTimeGraph{Series: viewList, Labels: labelList} common.DebugLogf("graph: %+v\n", graph) - pi := common.PanelAnalyticsPage{common.GetTitlePhrase("panel_analytics"), user, headerVars, stats, "analytics", graph, viewItems, timeRange.Range} + pi := common.PanelAnalyticsPage{basePage, graph, viewItems, timeRange.Range} return panelRenderTemplate("panel_analytics_topics", w, r, user, &pi) } func AnalyticsPosts(w http.ResponseWriter, r *http.Request, user common.User) common.RouteError { - headerVars, stats, ferr := common.PanelUserCheck(w, r, &user) + basePage, ferr := PreAnalyticsDetail(w, r, &user) if ferr != nil { return ferr } - headerVars.AddSheet("chartist/chartist.min.css") - headerVars.AddScript("chartist/chartist.min.js") - headerVars.AddScript("analytics.js") - timeRange, err := analyticsTimeRange(r.FormValue("timeRange")) if err != nil { return common.LocalError(err.Error(), w, r, user) @@ -489,7 +471,7 @@ func AnalyticsPosts(w http.ResponseWriter, r *http.Request, user common.User) co graph := common.PanelTimeGraph{Series: viewList, Labels: labelList} common.DebugLogf("graph: %+v\n", graph) - pi := common.PanelAnalyticsPage{common.GetTitlePhrase("panel_analytics"), user, headerVars, stats, "analytics", graph, viewItems, timeRange.Range} + pi := common.PanelAnalyticsPage{basePage, graph, viewItems, timeRange.Range} return panelRenderTemplate("panel_analytics_posts", w, r, user, &pi) } @@ -515,10 +497,11 @@ func analyticsRowsToNameMap(rows *sql.Rows) (map[string]int, error) { } func AnalyticsForums(w http.ResponseWriter, r *http.Request, user common.User) common.RouteError { - headerVars, stats, ferr := common.PanelUserCheck(w, r, &user) + header, stats, ferr := common.PanelUserCheck(w, r, &user) if ferr != nil { return ferr } + header.Title = common.GetTitlePhrase("panel_analytics") timeRange, err := analyticsTimeRange(r.FormValue("timeRange")) if err != nil { @@ -554,15 +537,17 @@ func AnalyticsForums(w http.ResponseWriter, r *http.Request, user common.User) c }) } - pi := common.PanelAnalyticsAgentsPage{common.GetTitlePhrase("panel_analytics"), user, headerVars, stats, "analytics", forumItems, timeRange.Range} + pi := common.PanelAnalyticsAgentsPage{&common.BasePanelPage{header, stats, "analytics", common.ReportForumID}, forumItems, timeRange.Range} return panelRenderTemplate("panel_analytics_forums", w, r, user, &pi) } func AnalyticsRoutes(w http.ResponseWriter, r *http.Request, user common.User) common.RouteError { - headerVars, stats, ferr := common.PanelUserCheck(w, r, &user) + header, stats, ferr := common.PanelUserCheck(w, r, &user) if ferr != nil { return ferr } + header.Title = common.GetTitlePhrase("panel_analytics") + timeRange, err := analyticsTimeRange(r.FormValue("timeRange")) if err != nil { return common.LocalError(err.Error(), w, r, user) @@ -588,15 +573,17 @@ func AnalyticsRoutes(w http.ResponseWriter, r *http.Request, user common.User) c }) } - pi := common.PanelAnalyticsRoutesPage{common.GetTitlePhrase("panel_analytics"), user, headerVars, stats, "analytics", routeItems, timeRange.Range} + pi := common.PanelAnalyticsRoutesPage{&common.BasePanelPage{header, stats, "analytics", common.ReportForumID}, routeItems, timeRange.Range} return panelRenderTemplate("panel_analytics_routes", w, r, user, &pi) } func AnalyticsAgents(w http.ResponseWriter, r *http.Request, user common.User) common.RouteError { - headerVars, stats, ferr := common.PanelUserCheck(w, r, &user) + header, stats, ferr := common.PanelUserCheck(w, r, &user) if ferr != nil { return ferr } + header.Title = common.GetTitlePhrase("panel_analytics") + timeRange, err := analyticsTimeRange(r.FormValue("timeRange")) if err != nil { return common.LocalError(err.Error(), w, r, user) @@ -627,15 +614,17 @@ func AnalyticsAgents(w http.ResponseWriter, r *http.Request, user common.User) c }) } - pi := common.PanelAnalyticsAgentsPage{common.GetTitlePhrase("panel_analytics"), user, headerVars, stats, "analytics", agentItems, timeRange.Range} + pi := common.PanelAnalyticsAgentsPage{&common.BasePanelPage{header, stats, "analytics", common.ReportForumID}, agentItems, timeRange.Range} return panelRenderTemplate("panel_analytics_agents", w, r, user, &pi) } func AnalyticsSystems(w http.ResponseWriter, r *http.Request, user common.User) common.RouteError { - headerVars, stats, ferr := common.PanelUserCheck(w, r, &user) + header, stats, ferr := common.PanelUserCheck(w, r, &user) if ferr != nil { return ferr } + header.Title = common.GetTitlePhrase("panel_analytics") + timeRange, err := analyticsTimeRange(r.FormValue("timeRange")) if err != nil { return common.LocalError(err.Error(), w, r, user) @@ -666,15 +655,17 @@ func AnalyticsSystems(w http.ResponseWriter, r *http.Request, user common.User) }) } - pi := common.PanelAnalyticsAgentsPage{common.GetTitlePhrase("panel_analytics"), user, headerVars, stats, "analytics", systemItems, timeRange.Range} + pi := common.PanelAnalyticsAgentsPage{&common.BasePanelPage{header, stats, "analytics", common.ReportForumID}, systemItems, timeRange.Range} return panelRenderTemplate("panel_analytics_systems", w, r, user, &pi) } func AnalyticsLanguages(w http.ResponseWriter, r *http.Request, user common.User) common.RouteError { - headerVars, stats, ferr := common.PanelUserCheck(w, r, &user) + header, stats, ferr := common.PanelUserCheck(w, r, &user) if ferr != nil { return ferr } + header.Title = common.GetTitlePhrase("panel_analytics") + timeRange, err := analyticsTimeRange(r.FormValue("timeRange")) if err != nil { return common.LocalError(err.Error(), w, r, user) @@ -706,15 +697,17 @@ func AnalyticsLanguages(w http.ResponseWriter, r *http.Request, user common.User }) } - pi := common.PanelAnalyticsAgentsPage{common.GetTitlePhrase("panel_analytics"), user, headerVars, stats, "analytics", langItems, timeRange.Range} + pi := common.PanelAnalyticsAgentsPage{&common.BasePanelPage{header, stats, "analytics", common.ReportForumID}, langItems, timeRange.Range} return panelRenderTemplate("panel_analytics_langs", w, r, user, &pi) } func AnalyticsReferrers(w http.ResponseWriter, r *http.Request, user common.User) common.RouteError { - headerVars, stats, ferr := common.PanelUserCheck(w, r, &user) + header, stats, ferr := common.PanelUserCheck(w, r, &user) if ferr != nil { return ferr } + header.Title = common.GetTitlePhrase("panel_analytics") + timeRange, err := analyticsTimeRange(r.FormValue("timeRange")) if err != nil { return common.LocalError(err.Error(), w, r, user) @@ -740,6 +733,6 @@ func AnalyticsReferrers(w http.ResponseWriter, r *http.Request, user common.User }) } - pi := common.PanelAnalyticsAgentsPage{common.GetTitlePhrase("panel_analytics"), user, headerVars, stats, "analytics", refItems, timeRange.Range} + pi := common.PanelAnalyticsAgentsPage{&common.BasePanelPage{header, stats, "analytics", common.ReportForumID}, refItems, timeRange.Range} return panelRenderTemplate("panel_analytics_referrers", w, r, user, &pi) } diff --git a/routes/panel/backups.go b/routes/panel/backups.go index 7f4614bb..131925eb 100644 --- a/routes/panel/backups.go +++ b/routes/panel/backups.go @@ -11,10 +11,11 @@ import ( ) func Backups(w http.ResponseWriter, r *http.Request, user common.User, backupURL string) common.RouteError { - headerVars, stats, ferr := common.PanelUserCheck(w, r, &user) + header, stats, ferr := common.PanelUserCheck(w, r, &user) if ferr != nil { return ferr } + header.Title = common.GetTitlePhrase("panel_backups") if backupURL != "" { // We don't want them trying to break out of this directory, it shouldn't hurt since it's a super admin, but it's always good to practice good security hygiene, especially if this is one of many instances on a managed server not controlled by the superadmin/s @@ -24,7 +25,7 @@ func Backups(w http.ResponseWriter, r *http.Request, user common.User, backupURL if ext == ".sql" { info, err := os.Stat("./backups/" + backupURL) if err != nil { - return common.NotFound(w, r, headerVars) + return common.NotFound(w, r, header) } // TODO: Change the served filename to gosora_backup_%timestamp%.sql, the time the file was generated, not when it was modified aka what the name of it should be w.Header().Set("Content-Disposition", "attachment; filename=gosora_backup.sql") @@ -33,7 +34,7 @@ func Backups(w http.ResponseWriter, r *http.Request, user common.User, backupURL http.ServeFile(w, r, "./backups/"+backupURL) return nil } - return common.NotFound(w, r, headerVars) + return common.NotFound(w, r, header) } var backupList []common.BackupItem @@ -49,6 +50,6 @@ func Backups(w http.ResponseWriter, r *http.Request, user common.User, backupURL backupList = append(backupList, common.BackupItem{backupFile.Name(), backupFile.ModTime()}) } - pi := common.PanelBackupPage{common.GetTitlePhrase("panel_backups"), user, headerVars, stats, "backups", backupList} + pi := common.PanelBackupPage{&common.BasePanelPage{header, stats, "backups", common.ReportForumID}, backupList} return panelRenderTemplate("panel_backups", w, r, user, &pi) } diff --git a/routes/panel/debug.go b/routes/panel/debug.go index cc2963fe..1ae1bb2a 100644 --- a/routes/panel/debug.go +++ b/routes/panel/debug.go @@ -11,10 +11,11 @@ import ( ) func Debug(w http.ResponseWriter, r *http.Request, user common.User) common.RouteError { - headerVars, stats, ferr := common.PanelUserCheck(w, r, &user) + header, stats, ferr := common.PanelUserCheck(w, r, &user) if ferr != nil { return ferr } + header.Title = common.GetTitlePhrase("panel_debug") goVersion := runtime.Version() dbVersion := qgen.Builder.DbVersion() @@ -37,6 +38,6 @@ func Debug(w http.ResponseWriter, r *http.Request, user common.User) common.Rout // Disk I/O? // TODO: Fetch the adapter from Builder rather than getting it from a global? - pi := common.PanelDebugPage{common.GetTitlePhrase("panel_debug"), user, headerVars, stats, "debug", goVersion, dbVersion, uptime, openConnCount, qgen.Builder.GetAdapter().GetName()} + pi := common.PanelDebugPage{&common.BasePanelPage{header, stats, "debug", common.ReportForumID}, goVersion, dbVersion, uptime, openConnCount, qgen.Builder.GetAdapter().GetName()} return panelRenderTemplate("panel_debug", w, r, user, &pi) } diff --git a/routes/panel/forums.go b/routes/panel/forums.go index cdaae236..424a0be5 100644 --- a/routes/panel/forums.go +++ b/routes/panel/forums.go @@ -11,13 +11,14 @@ import ( ) func Forums(w http.ResponseWriter, r *http.Request, user common.User) common.RouteError { - headerVars, stats, ferr := common.PanelUserCheck(w, r, &user) + header, stats, ferr := common.PanelUserCheck(w, r, &user) if ferr != nil { return ferr } if !user.Perms.ManageForums { return common.NoPermissions(w, r, user) } + header.Title = common.GetTitlePhrase("panel_forums") // TODO: Paginate this? var forumList []interface{} @@ -38,14 +39,14 @@ func Forums(w http.ResponseWriter, r *http.Request, user common.User) common.Rou } if r.FormValue("created") == "1" { - headerVars.NoticeList = append(headerVars.NoticeList, common.GetNoticePhrase("panel_forum_created")) + header.NoticeList = append(header.NoticeList, common.GetNoticePhrase("panel_forum_created")) } else if r.FormValue("deleted") == "1" { - headerVars.NoticeList = append(headerVars.NoticeList, common.GetNoticePhrase("panel_forum_deleted")) + header.NoticeList = append(header.NoticeList, common.GetNoticePhrase("panel_forum_deleted")) } else if r.FormValue("updated") == "1" { - headerVars.NoticeList = append(headerVars.NoticeList, common.GetNoticePhrase("panel_forum_updated")) + header.NoticeList = append(header.NoticeList, common.GetNoticePhrase("panel_forum_updated")) } - pi := common.PanelPage{common.GetTitlePhrase("panel_forums"), user, headerVars, stats, "forums", forumList, nil} + pi := common.PanelPage{&common.BasePanelPage{header, stats, "forums", common.ReportForumID}, forumList, nil} return panelRenderTemplate("panel_forums", w, r, user, &pi) } @@ -75,13 +76,14 @@ func ForumsCreateSubmit(w http.ResponseWriter, r *http.Request, user common.User // TODO: Revamp this func ForumsDelete(w http.ResponseWriter, r *http.Request, user common.User, sfid string) common.RouteError { - headerVars, stats, ferr := common.PanelUserCheck(w, r, &user) + header, stats, ferr := common.PanelUserCheck(w, r, &user) if ferr != nil { return ferr } if !user.Perms.ManageForums { return common.NoPermissions(w, r, user) } + header.Title = common.GetTitlePhrase("panel_delete_forum") fid, err := strconv.Atoi(sfid) if err != nil { @@ -99,7 +101,7 @@ func ForumsDelete(w http.ResponseWriter, r *http.Request, user common.User, sfid confirmMsg := "Are you sure you want to delete the '" + forum.Name + "' forum?" yousure := common.AreYouSure{"/panel/forums/delete/submit/" + strconv.Itoa(fid), confirmMsg} - pi := common.PanelPage{common.GetTitlePhrase("panel_delete_forum"), user, headerVars, stats, "forums", tList, yousure} + pi := common.PanelPage{&common.BasePanelPage{header, stats, "forums", common.ReportForumID}, tList, yousure} if common.RunPreRenderHook("pre_render_panel_delete_forum", w, r, &user, &pi) { return nil } @@ -136,13 +138,14 @@ func ForumsDeleteSubmit(w http.ResponseWriter, r *http.Request, user common.User } func ForumsEdit(w http.ResponseWriter, r *http.Request, user common.User, sfid string) common.RouteError { - headerVars, stats, ferr := common.PanelUserCheck(w, r, &user) + header, stats, ferr := common.PanelUserCheck(w, r, &user) if ferr != nil { return ferr } if !user.Perms.ManageForums { return common.NoPermissions(w, r, user) } + header.Title = common.GetTitlePhrase("panel_edit_forum") fid, err := strconv.Atoi(sfid) if err != nil { @@ -180,10 +183,10 @@ func ForumsEdit(w http.ResponseWriter, r *http.Request, user common.User, sfid s } if r.FormValue("updated") == "1" { - headerVars.NoticeList = append(headerVars.NoticeList, common.GetNoticePhrase("panel_forum_updated")) + header.NoticeList = append(header.NoticeList, common.GetNoticePhrase("panel_forum_updated")) } - pi := common.PanelEditForumPage{common.GetTitlePhrase("panel_edit_forum"), user, headerVars, stats, "forums", forum.ID, forum.Name, forum.Desc, forum.Active, forum.Preset, gplist} + pi := common.PanelEditForumPage{&common.BasePanelPage{header, stats, "forums", common.ReportForumID}, forum.ID, forum.Name, forum.Desc, forum.Active, forum.Preset, gplist} if common.RunPreRenderHook("pre_render_panel_edit_forum", w, r, &user, &pi) { return nil } @@ -294,13 +297,14 @@ func forumPermsExtractDash(paramList string) (fid int, gid int, err error) { } func ForumsEditPermsAdvance(w http.ResponseWriter, r *http.Request, user common.User, paramList string) common.RouteError { - headerVars, stats, ferr := common.PanelUserCheck(w, r, &user) + header, stats, ferr := common.PanelUserCheck(w, r, &user) if ferr != nil { return ferr } if !user.Perms.ManageForums { return common.NoPermissions(w, r, user) } + header.Title = common.GetTitlePhrase("panel_edit_forum") fid, gid, err := forumPermsExtractDash(paramList) if err != nil { @@ -346,10 +350,10 @@ func ForumsEditPermsAdvance(w http.ResponseWriter, r *http.Request, user common. addNameLangToggle("MoveTopic", forumPerms.MoveTopic) if r.FormValue("updated") == "1" { - headerVars.NoticeList = append(headerVars.NoticeList, common.GetNoticePhrase("panel_forums_perms_updated")) + header.NoticeList = append(header.NoticeList, common.GetNoticePhrase("panel_forums_perms_updated")) } - pi := common.PanelEditForumGroupPage{common.GetTitlePhrase("panel_edit_forum"), user, headerVars, stats, "forums", forum.ID, gid, forum.Name, forum.Desc, forum.Active, forum.Preset, formattedPermList} + pi := common.PanelEditForumGroupPage{&common.BasePanelPage{header, stats, "forums", common.ReportForumID}, forum.ID, gid, forum.Name, forum.Desc, forum.Active, forum.Preset, formattedPermList} if common.RunPreRenderHook("pre_render_panel_edit_forum", w, r, &user, &pi) { return nil } diff --git a/routes/panel/logs.go b/routes/panel/logs.go index 3f905aed..b9f34429 100644 --- a/routes/panel/logs.go +++ b/routes/panel/logs.go @@ -11,10 +11,11 @@ import ( ) func LogsRegs(w http.ResponseWriter, r *http.Request, user common.User) common.RouteError { - headerVars, stats, ferr := common.PanelUserCheck(w, r, &user) + header, stats, ferr := common.PanelUserCheck(w, r, &user) if ferr != nil { return ferr } + header.Title = common.GetTitlePhrase("panel_registration_logs") logCount := common.RegLogs.GlobalCount() page, _ := strconv.Atoi(r.FormValue("page")) @@ -31,7 +32,7 @@ func LogsRegs(w http.ResponseWriter, r *http.Request, user common.User) common.R } pageList := common.Paginate(logCount, perPage, 5) - pi := common.PanelRegLogsPage{common.GetTitlePhrase("panel_registration_logs"), user, headerVars, stats, "logs", llist, common.Paginator{pageList, page, lastPage}} + pi := common.PanelRegLogsPage{&common.BasePanelPage{header, stats, "logs", common.ReportForumID}, llist, common.Paginator{pageList, page, lastPage}} return panelRenderTemplate("panel_reglogs", w, r, user, &pi) } @@ -101,10 +102,11 @@ func modlogsElementType(action string, elementType string, elementID int, actor } func LogsMod(w http.ResponseWriter, r *http.Request, user common.User) common.RouteError { - headerVars, stats, ferr := common.PanelUserCheck(w, r, &user) + header, stats, ferr := common.PanelUserCheck(w, r, &user) if ferr != nil { return ferr } + header.Title = common.GetTitlePhrase("panel_mod_logs") logCount := common.ModLogs.GlobalCount() page, _ := strconv.Atoi(r.FormValue("page")) @@ -123,15 +125,16 @@ func LogsMod(w http.ResponseWriter, r *http.Request, user common.User) common.Ro } pageList := common.Paginate(logCount, perPage, 5) - pi := common.PanelLogsPage{common.GetTitlePhrase("panel_mod_logs"), user, headerVars, stats, "logs", llist, common.Paginator{pageList, page, lastPage}} + pi := common.PanelLogsPage{&common.BasePanelPage{header, stats, "logs", common.ReportForumID}, llist, common.Paginator{pageList, page, lastPage}} return panelRenderTemplate("panel_modlogs", w, r, user, &pi) } func LogsAdmin(w http.ResponseWriter, r *http.Request, user common.User) common.RouteError { - headerVars, stats, ferr := common.PanelUserCheck(w, r, &user) + header, stats, ferr := common.PanelUserCheck(w, r, &user) if ferr != nil { return ferr } + header.Title = common.GetTitlePhrase("panel_admin_logs") logCount := common.ModLogs.GlobalCount() page, _ := strconv.Atoi(r.FormValue("page")) @@ -150,6 +153,6 @@ func LogsAdmin(w http.ResponseWriter, r *http.Request, user common.User) common. } pageList := common.Paginate(logCount, perPage, 5) - pi := common.PanelLogsPage{common.GetTitlePhrase("panel_admin_logs"), user, headerVars, stats, "logs", llist, common.Paginator{pageList, page, lastPage}} + pi := common.PanelLogsPage{&common.BasePanelPage{header, stats, "logs", common.ReportForumID}, llist, common.Paginator{pageList, page, lastPage}} return panelRenderTemplate("panel_adminlogs", w, r, user, &pi) } diff --git a/routes/panel/pages.go b/routes/panel/pages.go new file mode 100644 index 00000000..67bd0225 --- /dev/null +++ b/routes/panel/pages.go @@ -0,0 +1,156 @@ +package panel + +import ( + "database/sql" + "net/http" + "strconv" + + "../../common" +) + +func Pages(w http.ResponseWriter, r *http.Request, user common.User) common.RouteError { + header, stats, ferr := common.PanelUserCheck(w, r, &user) + if ferr != nil { + return ferr + } + header.Title = common.GetTitlePhrase("panel_pages") + + if r.FormValue("created") == "1" { + header.AddNotice("panel_page_created") + } else if r.FormValue("deleted") == "1" { + header.AddNotice("panel_page_deleted") + } + + pageCount := common.Pages.GlobalCount() + page, _ := strconv.Atoi(r.FormValue("page")) + perPage := 10 + offset, page, lastPage := common.PageOffset(pageCount, page, perPage) + + cPages, err := common.Pages.GetOffset(offset, perPage) + if err != nil { + return common.InternalError(err, w, r) + } + + pageList := common.Paginate(pageCount, perPage, 5) + pi := common.PanelCustomPagesPage{&common.BasePanelPage{header, stats, "pages", common.ReportForumID}, cPages, common.Paginator{pageList, page, lastPage}} + return panelRenderTemplate("panel_pages", w, r, user, &pi) +} + +func PagesCreateSubmit(w http.ResponseWriter, r *http.Request, user common.User) common.RouteError { + _, ferr := common.SimplePanelUserCheck(w, r, &user) + if ferr != nil { + return ferr + } + + pname := r.PostFormValue("name") + if pname == "" { + return common.LocalError("No name was provided for this page", w, r, user) + } + ptitle := r.PostFormValue("title") + if ptitle == "" { + return common.LocalError("No title was provided for this page", w, r, user) + } + pbody := r.PostFormValue("body") + if pbody == "" { + return common.LocalError("No body was provided for this page", w, r, user) + } + + page := common.BlankCustomPage() + page.Name = pname + page.Title = ptitle + page.Body = pbody + _, err := page.Create() + if err != nil { + return common.InternalError(err, w, r) + } + + http.Redirect(w, r, "/panel/pages/?created=1", http.StatusSeeOther) + return nil +} + +func PagesEdit(w http.ResponseWriter, r *http.Request, user common.User, spid string) common.RouteError { + header, stats, ferr := common.PanelUserCheck(w, r, &user) + if ferr != nil { + return ferr + } + header.Title = common.GetTitlePhrase("panel_pages_edit") + + if r.FormValue("updated") == "1" { + header.AddNotice("panel_page_updated") + } + + pid, err := strconv.Atoi(spid) + if err != nil { + return common.LocalError("Page ID needs to be an integer", w, r, user) + } + + page, err := common.Pages.Get(pid) + if err == sql.ErrNoRows { + return common.NotFound(w, r, header) + } else if err != nil { + return common.InternalError(err, w, r) + } + + pi := common.PanelCustomPageEditPage{&common.BasePanelPage{header, stats, "pages", common.ReportForumID}, page} + return panelRenderTemplate("panel_pages_edit", w, r, user, &pi) +} + +func PagesEditSubmit(w http.ResponseWriter, r *http.Request, user common.User, spid string) common.RouteError { + _, ferr := common.SimplePanelUserCheck(w, r, &user) + if ferr != nil { + return ferr + } + + pid, err := strconv.Atoi(spid) + if err != nil { + return common.LocalError("Page ID needs to be an integer", w, r, user) + } + + pname := r.PostFormValue("name") + if pname == "" { + return common.LocalError("No name was provided for this page", w, r, user) + } + ptitle := r.PostFormValue("title") + if ptitle == "" { + return common.LocalError("No title was provided for this page", w, r, user) + } + pbody := r.PostFormValue("body") + if pbody == "" { + return common.LocalError("No body was provided for this page", w, r, user) + } + + page, err := common.Pages.Get(pid) + if err != nil { + return common.NotFound(w, r, nil) + } + page.Name = pname + page.Title = ptitle + page.Body = pbody + err = page.Commit() + if err != nil { + return common.InternalError(err, w, r) + } + + http.Redirect(w, r, "/panel/pages/?updated=1", http.StatusSeeOther) + return nil +} + +func PagesDeleteSubmit(w http.ResponseWriter, r *http.Request, user common.User, spid string) common.RouteError { + _, ferr := common.SimplePanelUserCheck(w, r, &user) + if ferr != nil { + return ferr + } + + pid, err := strconv.Atoi(spid) + if err != nil { + return common.LocalError("Page ID needs to be an integer", w, r, user) + } + + err = common.Pages.Delete(pid) + if err != nil { + return common.InternalError(err, w, r) + } + + http.Redirect(w, r, "/panel/pages/?deleted=1", http.StatusSeeOther) + return nil +} diff --git a/routes/panel/settings.go b/routes/panel/settings.go index 33eefa62..a3eeb73e 100644 --- a/routes/panel/settings.go +++ b/routes/panel/settings.go @@ -18,6 +18,7 @@ func Settings(w http.ResponseWriter, r *http.Request, user common.User) common.R if !user.Perms.EditSettings { return common.NoPermissions(w, r, user) } + header.Title = common.GetTitlePhrase("panel_settings") settings, err := header.Settings.BypassGetAll() if err != nil { @@ -48,7 +49,7 @@ func Settings(w http.ResponseWriter, r *http.Request, user common.User) common.R settingList = append(settingList, &common.PanelSetting{setting, common.GetSettingPhrase(setting.Name)}) } - pi := common.PanelPage{common.GetTitlePhrase("panel_settings"), user, header, stats, "settings", tList, settingList} + pi := common.PanelPage{&common.BasePanelPage{header, stats, "settings", common.ReportForumID}, tList, settingList} return panelRenderTemplate("panel_settings", w, r, user, &pi) } @@ -90,7 +91,7 @@ func SettingEdit(w http.ResponseWriter, r *http.Request, user common.User, sname } pSetting := &common.PanelSetting{setting, common.GetSettingPhrase(setting.Name)} - pi := common.PanelSettingPage{header, stats, "settings", itemList, pSetting} + pi := common.PanelSettingPage{&common.BasePanelPage{header, stats, "settings", common.ReportForumID}, itemList, pSetting} return panelRenderTemplate("panel_setting", w, r, user, &pi) } diff --git a/routes/profile.go b/routes/profile.go index a26d70a7..4b76ef5d 100644 --- a/routes/profile.go +++ b/routes/profile.go @@ -33,7 +33,7 @@ func ViewProfile(w http.ResponseWriter, r *http.Request, user common.User) commo return ferr } // TODO: Preload this? - header.AddScript("profile.css") + header.AddSheet(header.Theme.Name + "/profile.css") var err error var replyCreatedAt time.Time diff --git a/routes/reports.go b/routes/reports.go index 4a2239fc..b37e9faf 100644 --- a/routes/reports.go +++ b/routes/reports.go @@ -22,6 +22,7 @@ func ReportSubmit(w http.ResponseWriter, r *http.Request, user common.User, site } itemType := r.FormValue("type") + // TODO: Localise these titles and bodies var title, content string if itemType == "reply" { reply, err := common.Rstore.Get(itemID) diff --git a/templates/account_own_edit.html b/templates/account_own_edit_password.html similarity index 100% rename from templates/account_own_edit.html rename to templates/account_own_edit_password.html diff --git a/templates/custom-page.html b/templates/custom-page.html deleted file mode 100644 index 873b5a3b..00000000 --- a/templates/custom-page.html +++ /dev/null @@ -1,8 +0,0 @@ -{{template "header.html" . }} -
-
-
{{.Title}}
-
-
{{.Something}}
-
-{{template "footer.html" . }} diff --git a/templates/custom_page.html b/templates/custom_page.html new file mode 100644 index 00000000..71683235 --- /dev/null +++ b/templates/custom_page.html @@ -0,0 +1,10 @@ +{{template "header.html" . }} +
+
+

{{.Page.Title}}

+
+
+
{{.Page.Body}}
+
+
+{{template "footer.html" . }} diff --git a/templates/error.html b/templates/error.html index d4df460e..6fab6087 100644 --- a/templates/error.html +++ b/templates/error.html @@ -4,7 +4,7 @@

{{lang "error_head"}}

-
{{.Something}}
+
{{.Message}}
{{template "footer.html" . }} diff --git a/templates/forum.html b/templates/forum.html index 4df6f88b..a0d6802c 100644 --- a/templates/forum.html +++ b/templates/forum.html @@ -101,11 +101,13 @@
- {{.LastUser.Name}}'s Avatar - - {{.LastUser.Name}}
- {{.RelativeLastReplyAt}} -
+
+ {{.LastUser.Name}}'s Avatar + + {{.LastUser.Name}}
+ {{.RelativeLastReplyAt}} +
+
{{else}}
{{lang "forum_no_topics"}}{{if .CurrentUser.Perms.CreateTopic}} {{lang "forum_start_one"}}{{end}}
{{end}} diff --git a/templates/panel-forum-edit-perms.html b/templates/panel-forum-edit-perms.html index 687cc02e..397f651d 100644 --- a/templates/panel-forum-edit-perms.html +++ b/templates/panel-forum-edit-perms.html @@ -1,6 +1,6 @@ {{template "header.html" . }}
-{{template "panel-menu.html" . }} +{{template "panel_menu.html" . }}
diff --git a/templates/panel-forum-edit.html b/templates/panel-forum-edit.html index a2ccb201..31b41e2f 100644 --- a/templates/panel-forum-edit.html +++ b/templates/panel-forum-edit.html @@ -1,7 +1,7 @@ {{template "header.html" . }}
-{{template "panel-menu.html" . }} +{{template "panel_menu.html" . }} diff --git a/templates/panel-group-edit-perms.html b/templates/panel-group-edit-perms.html index 609fe8eb..235b12e2 100644 --- a/templates/panel-group-edit-perms.html +++ b/templates/panel-group-edit-perms.html @@ -9,7 +9,7 @@
-{{template "panel-inner-menu.html" . }} +{{template "panel_inner_menu.html" . }}
diff --git a/templates/panel-group-edit.html b/templates/panel-group-edit.html index c28d3618..b6903aa5 100644 --- a/templates/panel-group-edit.html +++ b/templates/panel-group-edit.html @@ -9,7 +9,7 @@
-{{template "panel-inner-menu.html" . }} +{{template "panel_inner_menu.html" . }}
diff --git a/templates/panel-user-edit.html b/templates/panel-user-edit.html index 00635e48..cc2ea86c 100644 --- a/templates/panel-user-edit.html +++ b/templates/panel-user-edit.html @@ -1,7 +1,7 @@ {{template "header.html" . }}
-{{template "panel-menu.html" . }} +{{template "panel_menu.html" . }}

{{lang "panel_user_head"}}

diff --git a/templates/panel_adminlogs.html b/templates/panel_adminlogs.html index 2bd46de4..d276392b 100644 --- a/templates/panel_adminlogs.html +++ b/templates/panel_adminlogs.html @@ -1,6 +1,6 @@ {{template "header.html" . }}
-{{template "panel-menu.html" . }} +{{template "panel_menu.html" . }}

{{lang "panel_logs_administration_head"}}

diff --git a/templates/panel_analytics_agent_views.html b/templates/panel_analytics_agent_views.html index 32d4bc45..f256cd59 100644 --- a/templates/panel_analytics_agent_views.html +++ b/templates/panel_analytics_agent_views.html @@ -1,6 +1,6 @@ {{template "header.html" . }}
-{{template "panel-menu.html" . }} +{{template "panel_menu.html" . }}
diff --git a/templates/panel_analytics_agents.html b/templates/panel_analytics_agents.html index 430c1e71..9194ef07 100644 --- a/templates/panel_analytics_agents.html +++ b/templates/panel_analytics_agents.html @@ -1,6 +1,6 @@ {{template "header.html" . }}
-{{template "panel-menu.html" . }} +{{template "panel_menu.html" . }}
diff --git a/templates/panel_analytics_forum_views.html b/templates/panel_analytics_forum_views.html index 6850b489..fc27f224 100644 --- a/templates/panel_analytics_forum_views.html +++ b/templates/panel_analytics_forum_views.html @@ -1,6 +1,6 @@ {{template "header.html" . }}
-{{template "panel-menu.html" . }} +{{template "panel_menu.html" . }}
diff --git a/templates/panel_analytics_forums.html b/templates/panel_analytics_forums.html index 36a47667..c5da95fc 100644 --- a/templates/panel_analytics_forums.html +++ b/templates/panel_analytics_forums.html @@ -1,6 +1,6 @@ {{template "header.html" . }}
-{{template "panel-menu.html" . }} +{{template "panel_menu.html" . }}
diff --git a/templates/panel_analytics_lang_views.html b/templates/panel_analytics_lang_views.html index 4717c36e..343aadec 100644 --- a/templates/panel_analytics_lang_views.html +++ b/templates/panel_analytics_lang_views.html @@ -1,6 +1,6 @@ {{template "header.html" . }}
-{{template "panel-menu.html" . }} +{{template "panel_menu.html" . }}
diff --git a/templates/panel_analytics_langs.html b/templates/panel_analytics_langs.html index 198a8b5d..f98f7165 100644 --- a/templates/panel_analytics_langs.html +++ b/templates/panel_analytics_langs.html @@ -1,6 +1,6 @@ {{template "header.html" . }}
-{{template "panel-menu.html" . }} +{{template "panel_menu.html" . }}
diff --git a/templates/panel_analytics_posts.html b/templates/panel_analytics_posts.html index c20cf996..2c04734f 100644 --- a/templates/panel_analytics_posts.html +++ b/templates/panel_analytics_posts.html @@ -1,6 +1,6 @@ {{template "header.html" . }}
-{{template "panel-menu.html" . }} +{{template "panel_menu.html" . }}
diff --git a/templates/panel_analytics_referrer_views.html b/templates/panel_analytics_referrer_views.html index d8e7a5ef..fad6fdca 100644 --- a/templates/panel_analytics_referrer_views.html +++ b/templates/panel_analytics_referrer_views.html @@ -1,6 +1,6 @@ {{template "header.html" . }}
-{{template "panel-menu.html" . }} +{{template "panel_menu.html" . }}
diff --git a/templates/panel_analytics_referrers.html b/templates/panel_analytics_referrers.html index d1b5934c..aee2e402 100644 --- a/templates/panel_analytics_referrers.html +++ b/templates/panel_analytics_referrers.html @@ -1,6 +1,6 @@ {{template "header.html" . }}
-{{template "panel-menu.html" . }} +{{template "panel_menu.html" . }}
diff --git a/templates/panel_analytics_route_views.html b/templates/panel_analytics_route_views.html index 6c48de57..21c9b3c5 100644 --- a/templates/panel_analytics_route_views.html +++ b/templates/panel_analytics_route_views.html @@ -1,6 +1,6 @@ {{template "header.html" . }}
-{{template "panel-menu.html" . }} +{{template "panel_menu.html" . }}
diff --git a/templates/panel_analytics_routes.html b/templates/panel_analytics_routes.html index 41f8e84a..43491aaf 100644 --- a/templates/panel_analytics_routes.html +++ b/templates/panel_analytics_routes.html @@ -1,6 +1,6 @@ {{template "header.html" . }}
-{{template "panel-menu.html" . }} +{{template "panel_menu.html" . }}
diff --git a/templates/panel_analytics_system_views.html b/templates/panel_analytics_system_views.html index 7019d17e..23679039 100644 --- a/templates/panel_analytics_system_views.html +++ b/templates/panel_analytics_system_views.html @@ -1,6 +1,6 @@ {{template "header.html" . }}
-{{template "panel-menu.html" . }} +{{template "panel_menu.html" . }}
diff --git a/templates/panel_analytics_systems.html b/templates/panel_analytics_systems.html index 9d336945..7c3ba309 100644 --- a/templates/panel_analytics_systems.html +++ b/templates/panel_analytics_systems.html @@ -1,6 +1,6 @@ {{template "header.html" . }}
-{{template "panel-menu.html" . }} +{{template "panel_menu.html" . }}
diff --git a/templates/panel_analytics_topics.html b/templates/panel_analytics_topics.html index 42394f28..d6fcb162 100644 --- a/templates/panel_analytics_topics.html +++ b/templates/panel_analytics_topics.html @@ -1,6 +1,6 @@ {{template "header.html" . }}
-{{template "panel-menu.html" . }} +{{template "panel_menu.html" . }}
diff --git a/templates/panel_analytics_views.html b/templates/panel_analytics_views.html index d1b36429..c811988e 100644 --- a/templates/panel_analytics_views.html +++ b/templates/panel_analytics_views.html @@ -1,6 +1,6 @@ {{template "header.html" . }}
-{{template "panel-menu.html" . }} +{{template "panel_menu.html" . }}
diff --git a/templates/panel_backups.html b/templates/panel_backups.html index 54cc0f29..4e20132b 100644 --- a/templates/panel_backups.html +++ b/templates/panel_backups.html @@ -1,6 +1,6 @@ {{template "header.html" . }}
- {{template "panel-menu.html" . }} + {{template "panel_menu.html" . }}

{{lang "panel_backups_head"}}

diff --git a/templates/panel_dashboard.html b/templates/panel_dashboard.html index a8e4ef71..9bc29332 100644 --- a/templates/panel_dashboard.html +++ b/templates/panel_dashboard.html @@ -1,6 +1,6 @@ {{template "header.html" . }}
-{{template "panel-menu.html" . }} +{{template "panel_menu.html" . }}
diff --git a/templates/panel_debug.html b/templates/panel_debug.html index bb8a088f..1f0bc7e6 100644 --- a/templates/panel_debug.html +++ b/templates/panel_debug.html @@ -1,6 +1,6 @@ {{template "header.html" . }}
-{{template "panel-menu.html" . }} +{{template "panel_menu.html" . }}
diff --git a/templates/panel_forums.html b/templates/panel_forums.html index 35a94915..1b52317d 100644 --- a/templates/panel_forums.html +++ b/templates/panel_forums.html @@ -1,7 +1,7 @@ {{template "header.html" . }}
-{{template "panel-menu.html" . }} +{{template "panel_menu.html" . }}