Moved the last control panel theme manager route into /routes/panel/
Added the UpdateDefaultTheme function. Renamed panelRenderTemplate to renderTemplate. Renamed panelSuccessRedirect to successRedirect. Reduced the amount of boilerplate in panel.GroupsEdit with renderTemplate. Renamed the pre_render_panel_edit_group hook to pre_render_panel_group_edit. Reduced the amount of boilerplate in panel.GroupsEditPerms with renderTemplate. Renamed the pre_render_panel_edit_group_perms hook to pre_render_panel_group_edit_perms. Fixed a bug where the active status for themes didn't get loaded at start-up. Fixed a theoretical deadlock in NewThemeList. Updated CONTRIBUTING.md
This commit is contained in:
parent
750c0ff442
commit
b2e97e47c1
|
@ -1,14 +1,14 @@
|
|||
If you want to add a contribution, you'll have to open a pull request and to sign the CLA (contributor level agreement).
|
||||
# Contributing
|
||||
|
||||
It's mainly there to deal with any legal issues which come our way and to switch licenses without having to chase down contributors who have long stopped using the internet or are deceased or incapacitated.
|
||||
First and foremost, if you want to add a contribution, you'll have to open a pull request and to sign the CLA (contributor level agreement).
|
||||
|
||||
Other uses may arise in the future, e.g. commercial licensing for companies which might not be authorised to use open source licensing and what-not, although that's currently uncertain as I'm not knowledgable about the ins and outs of the law.
|
||||
It's mainly there to deal with any legal issues which may come our way and to switch licenses without having to track down every contributor who has ever contributed.
|
||||
|
||||
Some things we could do is commercial licensing for companies which are not authorised to use open source licenses or moving to a more permissive license, although I'm not too experianced in these matters, if anyone has any ideas, then feel free to put them forward.
|
||||
|
||||
Try to prefix commits which introduce a lot of bugs or otherwise has a large impact on the usability of Gosora with UNSTABLE.
|
||||
|
||||
If anything seems suspect, then feel free to bring up an alternative, although I'd rather not get hung up on the little details, if it's something which is purely a matter of opinion.
|
||||
|
||||
Also, please don't push new features, particularly ones which will require a great effort from other maintainers in the long term, particularly if it has fairly minor benefits to the ecosystem as a whole, unless you are willing to maintain it.
|
||||
If something seems to be strange, then feel free to bring up an alternative for it, although I'd rather not get hung up on the little details, if it's something which is purely a matter of opinion.
|
||||
|
||||
# Coding Standards
|
||||
|
||||
|
|
|
@ -171,8 +171,8 @@ var PreRenderHooks = map[string][]func(http.ResponseWriter, *http.Request, *User
|
|||
"pre_render_panel_users": nil,
|
||||
"pre_render_panel_edit_user": nil,
|
||||
"pre_render_panel_groups": nil,
|
||||
"pre_render_panel_edit_group": nil,
|
||||
"pre_render_panel_edit_group_perms": nil,
|
||||
"pre_render_panel_group_edit": nil,
|
||||
"pre_render_panel_group_edit_perms": nil,
|
||||
"pre_render_panel_themes": nil,
|
||||
"pre_render_panel_modlogs": nil,
|
||||
|
||||
|
|
|
@ -2,8 +2,8 @@
|
|||
package common
|
||||
|
||||
import (
|
||||
//"fmt"
|
||||
"bytes"
|
||||
"database/sql"
|
||||
"errors"
|
||||
"io"
|
||||
"io/ioutil"
|
||||
|
@ -16,6 +16,8 @@ import (
|
|||
"text/template"
|
||||
)
|
||||
|
||||
var ErrNoDefaultTheme = errors.New("The default theme isn't registered in the system")
|
||||
|
||||
type Theme struct {
|
||||
Path string // Redirect this file to another folder
|
||||
|
||||
|
@ -147,7 +149,6 @@ func (theme *Theme) MapTemplates() {
|
|||
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:
|
||||
|
@ -156,7 +157,6 @@ func (theme *Theme) MapTemplates() {
|
|||
case *func(TopicPage, io.Writer) error:
|
||||
switch sTmplPtr := sourceTmplPtr.(type) {
|
||||
case *func(TopicPage, io.Writer) error:
|
||||
//overridenTemplates[themeTmpl.Name] = d_tmpl_ptr
|
||||
overridenTemplates[themeTmpl.Name] = true
|
||||
*dTmplPtr = *sTmplPtr
|
||||
default:
|
||||
|
@ -165,7 +165,6 @@ func (theme *Theme) MapTemplates() {
|
|||
case *func(TopicListPage, io.Writer) error:
|
||||
switch sTmplPtr := sourceTmplPtr.(type) {
|
||||
case *func(TopicListPage, io.Writer) error:
|
||||
//overridenTemplates[themeTmpl.Name] = d_tmpl_ptr
|
||||
overridenTemplates[themeTmpl.Name] = true
|
||||
*dTmplPtr = *sTmplPtr
|
||||
default:
|
||||
|
@ -174,7 +173,6 @@ func (theme *Theme) MapTemplates() {
|
|||
case *func(ForumPage, io.Writer) error:
|
||||
switch sTmplPtr := sourceTmplPtr.(type) {
|
||||
case *func(ForumPage, io.Writer) error:
|
||||
//overridenTemplates[themeTmpl.Name] = d_tmpl_ptr
|
||||
overridenTemplates[themeTmpl.Name] = true
|
||||
*dTmplPtr = *sTmplPtr
|
||||
default:
|
||||
|
@ -183,7 +181,6 @@ func (theme *Theme) MapTemplates() {
|
|||
case *func(ForumsPage, io.Writer) error:
|
||||
switch sTmplPtr := sourceTmplPtr.(type) {
|
||||
case *func(ForumsPage, io.Writer) error:
|
||||
//overridenTemplates[themeTmpl.Name] = d_tmpl_ptr
|
||||
overridenTemplates[themeTmpl.Name] = true
|
||||
*dTmplPtr = *sTmplPtr
|
||||
default:
|
||||
|
@ -192,7 +189,6 @@ func (theme *Theme) MapTemplates() {
|
|||
case *func(ProfilePage, io.Writer) error:
|
||||
switch sTmplPtr := sourceTmplPtr.(type) {
|
||||
case *func(ProfilePage, io.Writer) error:
|
||||
//overridenTemplates[themeTmpl.Name] = d_tmpl_ptr
|
||||
overridenTemplates[themeTmpl.Name] = true
|
||||
*dTmplPtr = *sTmplPtr
|
||||
default:
|
||||
|
@ -201,7 +197,6 @@ func (theme *Theme) MapTemplates() {
|
|||
case *func(CreateTopicPage, io.Writer) error:
|
||||
switch sTmplPtr := sourceTmplPtr.(type) {
|
||||
case *func(CreateTopicPage, io.Writer) error:
|
||||
//overridenTemplates[themeTmpl.Name] = d_tmpl_ptr
|
||||
overridenTemplates[themeTmpl.Name] = true
|
||||
*dTmplPtr = *sTmplPtr
|
||||
default:
|
||||
|
@ -210,7 +205,6 @@ func (theme *Theme) MapTemplates() {
|
|||
case *func(IPSearchPage, io.Writer) error:
|
||||
switch sTmplPtr := sourceTmplPtr.(type) {
|
||||
case *func(IPSearchPage, io.Writer) error:
|
||||
//overridenTemplates[themeTmpl.Name] = d_tmpl_ptr
|
||||
overridenTemplates[themeTmpl.Name] = true
|
||||
*dTmplPtr = *sTmplPtr
|
||||
default:
|
||||
|
@ -219,7 +213,6 @@ func (theme *Theme) MapTemplates() {
|
|||
case *func(AccountDashPage, io.Writer) error:
|
||||
switch sTmplPtr := sourceTmplPtr.(type) {
|
||||
case *func(AccountDashPage, io.Writer) error:
|
||||
//overridenTemplates[themeTmpl.Name] = d_tmpl_ptr
|
||||
overridenTemplates[themeTmpl.Name] = true
|
||||
*dTmplPtr = *sTmplPtr
|
||||
default:
|
||||
|
@ -228,7 +221,6 @@ func (theme *Theme) MapTemplates() {
|
|||
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:
|
||||
|
@ -237,7 +229,6 @@ func (theme *Theme) MapTemplates() {
|
|||
case *func(Page, io.Writer) error:
|
||||
switch sTmplPtr := sourceTmplPtr.(type) {
|
||||
case *func(Page, io.Writer) error:
|
||||
//overridenTemplates[themeTmpl.Name] = d_tmpl_ptr
|
||||
overridenTemplates[themeTmpl.Name] = true
|
||||
*dTmplPtr = *sTmplPtr
|
||||
default:
|
||||
|
@ -252,6 +243,56 @@ func (theme *Theme) MapTemplates() {
|
|||
}
|
||||
}
|
||||
|
||||
func (theme *Theme) setActive(active bool) error {
|
||||
var sink bool
|
||||
err := themeStmts.isThemeDefault.QueryRow(theme.Name).Scan(&sink)
|
||||
if err != nil && err != sql.ErrNoRows {
|
||||
return err
|
||||
}
|
||||
|
||||
hasTheme := err != sql.ErrNoRows
|
||||
if hasTheme {
|
||||
_, err = themeStmts.updateTheme.Exec(active, theme.Name)
|
||||
} else {
|
||||
_, err = themeStmts.addTheme.Exec(theme.Name, active)
|
||||
}
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
// TODO: Think about what we want to do for multi-server configurations
|
||||
log.Printf("Setting theme '%s' as the default theme", theme.Name)
|
||||
theme.Active = active
|
||||
return nil
|
||||
}
|
||||
|
||||
func UpdateDefaultTheme(theme *Theme) error {
|
||||
ChangeDefaultThemeMutex.Lock()
|
||||
defer ChangeDefaultThemeMutex.Unlock()
|
||||
|
||||
err := theme.setActive(true)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
defaultTheme := DefaultThemeBox.Load().(string)
|
||||
dtheme, ok := Themes[defaultTheme]
|
||||
if !ok {
|
||||
return ErrNoDefaultTheme
|
||||
}
|
||||
|
||||
err = dtheme.setActive(false)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
DefaultThemeBox.Store(theme.Name)
|
||||
ResetTemplateOverrides()
|
||||
theme.MapTemplates()
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func (theme Theme) HasDock(name string) bool {
|
||||
for _, dock := range theme.Docks {
|
||||
if dock == name {
|
||||
|
|
|
@ -16,6 +16,7 @@ import (
|
|||
"../query_gen/lib"
|
||||
)
|
||||
|
||||
// TODO: Something more thread-safe
|
||||
type ThemeList map[string]*Theme
|
||||
|
||||
var Themes ThemeList = make(map[string]*Theme) // ? Refactor this into a store?
|
||||
|
@ -27,7 +28,10 @@ var fallbackTheme = "cosora"
|
|||
var overridenTemplates = make(map[string]bool) // ? What is this used for?
|
||||
|
||||
type ThemeStmts struct {
|
||||
getThemes *sql.Stmt
|
||||
getThemes *sql.Stmt
|
||||
isThemeDefault *sql.Stmt
|
||||
updateTheme *sql.Stmt
|
||||
addTheme *sql.Stmt
|
||||
}
|
||||
|
||||
var themeStmts ThemeStmts
|
||||
|
@ -36,7 +40,10 @@ func init() {
|
|||
DefaultThemeBox.Store(fallbackTheme)
|
||||
DbInits.Add(func(acc *qgen.Accumulator) error {
|
||||
themeStmts = ThemeStmts{
|
||||
getThemes: acc.Select("themes").Columns("uname, default").Prepare(),
|
||||
getThemes: acc.Select("themes").Columns("uname, default").Prepare(),
|
||||
isThemeDefault: acc.Select("themes").Columns("default").Where("uname = ?").Prepare(),
|
||||
updateTheme: acc.Update("themes").Set("default = ?").Where("uname = ?").Prepare(),
|
||||
addTheme: acc.Insert("themes").Columns("uname, default").Fields("?,?").Prepare(),
|
||||
}
|
||||
return acc.FirstError()
|
||||
})
|
||||
|
@ -129,6 +136,8 @@ func NewThemeList() (themes ThemeList, err error) {
|
|||
// ? - Delete themes which no longer exist in the themes folder from the database?
|
||||
func (themes ThemeList) LoadActiveStatus() error {
|
||||
ChangeDefaultThemeMutex.Lock()
|
||||
defer ChangeDefaultThemeMutex.Unlock()
|
||||
|
||||
rows, err := themeStmts.getThemes.Query()
|
||||
if err != nil {
|
||||
return err
|
||||
|
@ -150,18 +159,17 @@ func (themes ThemeList) LoadActiveStatus() error {
|
|||
}
|
||||
|
||||
if defaultThemeSwitch {
|
||||
log.Printf("Loading the default theme '%s'", theme.Name)
|
||||
DebugLogf("Loading the default theme '%s'", theme.Name)
|
||||
theme.Active = true
|
||||
DefaultThemeBox.Store(theme.Name)
|
||||
theme.MapTemplates()
|
||||
} else {
|
||||
log.Printf("Loading the theme '%s'", theme.Name)
|
||||
DebugLogf("Loading the theme '%s'", theme.Name)
|
||||
theme.Active = false
|
||||
}
|
||||
|
||||
themes[uname] = theme
|
||||
}
|
||||
ChangeDefaultThemeMutex.Unlock()
|
||||
return rows.Err()
|
||||
}
|
||||
|
||||
|
|
|
@ -99,8 +99,9 @@ func InitDatabase() (err error) {
|
|||
}
|
||||
|
||||
log.Print("Loading the themes.")
|
||||
err = common.Themes.LoadActiveStatus()
|
||||
if err != nil {
|
||||
return errors.WithStack(common.Themes.LoadActiveStatus())
|
||||
return errors.WithStack(err)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
|
27
gen_mssql.go
27
gen_mssql.go
|
@ -9,13 +9,10 @@ import "./common"
|
|||
|
||||
// nolint
|
||||
type Stmts struct {
|
||||
isThemeDefault *sql.Stmt
|
||||
forumEntryExists *sql.Stmt
|
||||
groupEntryExists *sql.Stmt
|
||||
getForumTopics *sql.Stmt
|
||||
addForumPermsToForum *sql.Stmt
|
||||
addTheme *sql.Stmt
|
||||
updateTheme *sql.Stmt
|
||||
updateEmail *sql.Stmt
|
||||
setTempGroup *sql.Stmt
|
||||
bumpSync *sql.Stmt
|
||||
|
@ -35,14 +32,6 @@ type Stmts struct {
|
|||
func _gen_mssql() (err error) {
|
||||
common.DebugLog("Building the generated statements")
|
||||
|
||||
common.DebugLog("Preparing isThemeDefault statement.")
|
||||
stmts.isThemeDefault, err = db.Prepare("SELECT [default] FROM [themes] WHERE [uname] = ?1")
|
||||
if err != nil {
|
||||
log.Print("Error in isThemeDefault statement.")
|
||||
log.Print("Bad Query: ","SELECT [default] FROM [themes] WHERE [uname] = ?1")
|
||||
return err
|
||||
}
|
||||
|
||||
common.DebugLog("Preparing forumEntryExists statement.")
|
||||
stmts.forumEntryExists, err = db.Prepare("SELECT [fid] FROM [forums] WHERE [name] = '' ORDER BY fid ASC OFFSET 0 ROWS FETCH NEXT 1 ROWS ONLY")
|
||||
if err != nil {
|
||||
|
@ -75,22 +64,6 @@ func _gen_mssql() (err error) {
|
|||
return err
|
||||
}
|
||||
|
||||
common.DebugLog("Preparing addTheme statement.")
|
||||
stmts.addTheme, err = db.Prepare("INSERT INTO [themes] ([uname],[default]) VALUES (?,?)")
|
||||
if err != nil {
|
||||
log.Print("Error in addTheme statement.")
|
||||
log.Print("Bad Query: ","INSERT INTO [themes] ([uname],[default]) VALUES (?,?)")
|
||||
return err
|
||||
}
|
||||
|
||||
common.DebugLog("Preparing updateTheme statement.")
|
||||
stmts.updateTheme, err = db.Prepare("UPDATE [themes] SET [default] = ? WHERE [uname] = ?")
|
||||
if err != nil {
|
||||
log.Print("Error in updateTheme statement.")
|
||||
log.Print("Bad Query: ","UPDATE [themes] SET [default] = ? WHERE [uname] = ?")
|
||||
return err
|
||||
}
|
||||
|
||||
common.DebugLog("Preparing updateEmail statement.")
|
||||
stmts.updateEmail, err = db.Prepare("UPDATE [emails] SET [email] = ?,[uid] = ?,[validated] = ?,[token] = ? WHERE [email] = ?")
|
||||
if err != nil {
|
||||
|
|
24
gen_mysql.go
24
gen_mysql.go
|
@ -11,13 +11,10 @@ import "./common"
|
|||
|
||||
// nolint
|
||||
type Stmts struct {
|
||||
isThemeDefault *sql.Stmt
|
||||
forumEntryExists *sql.Stmt
|
||||
groupEntryExists *sql.Stmt
|
||||
getForumTopics *sql.Stmt
|
||||
addForumPermsToForum *sql.Stmt
|
||||
addTheme *sql.Stmt
|
||||
updateTheme *sql.Stmt
|
||||
updateEmail *sql.Stmt
|
||||
setTempGroup *sql.Stmt
|
||||
bumpSync *sql.Stmt
|
||||
|
@ -37,13 +34,6 @@ type Stmts struct {
|
|||
func _gen_mysql() (err error) {
|
||||
common.DebugLog("Building the generated statements")
|
||||
|
||||
common.DebugLog("Preparing isThemeDefault statement.")
|
||||
stmts.isThemeDefault, err = db.Prepare("SELECT `default` FROM `themes` WHERE `uname` = ?")
|
||||
if err != nil {
|
||||
log.Print("Error in isThemeDefault statement.")
|
||||
return err
|
||||
}
|
||||
|
||||
common.DebugLog("Preparing forumEntryExists statement.")
|
||||
stmts.forumEntryExists, err = db.Prepare("SELECT `fid` FROM `forums` WHERE `name` = '' ORDER BY `fid` ASC LIMIT 0,1")
|
||||
if err != nil {
|
||||
|
@ -72,20 +62,6 @@ func _gen_mysql() (err error) {
|
|||
return err
|
||||
}
|
||||
|
||||
common.DebugLog("Preparing addTheme statement.")
|
||||
stmts.addTheme, err = db.Prepare("INSERT INTO `themes`(`uname`,`default`) VALUES (?,?)")
|
||||
if err != nil {
|
||||
log.Print("Error in addTheme statement.")
|
||||
return err
|
||||
}
|
||||
|
||||
common.DebugLog("Preparing updateTheme statement.")
|
||||
stmts.updateTheme, err = db.Prepare("UPDATE `themes` SET `default` = ? WHERE `uname` = ?")
|
||||
if err != nil {
|
||||
log.Print("Error in updateTheme statement.")
|
||||
return err
|
||||
}
|
||||
|
||||
common.DebugLog("Preparing updateEmail statement.")
|
||||
stmts.updateEmail, err = db.Prepare("UPDATE `emails` SET `email` = ?,`uid` = ?,`validated` = ?,`token` = ? WHERE `email` = ?")
|
||||
if err != nil {
|
||||
|
|
16
gen_pgsql.go
16
gen_pgsql.go
|
@ -10,8 +10,6 @@ import "./common"
|
|||
// nolint
|
||||
type Stmts struct {
|
||||
addForumPermsToForum *sql.Stmt
|
||||
addTheme *sql.Stmt
|
||||
updateTheme *sql.Stmt
|
||||
updateEmail *sql.Stmt
|
||||
setTempGroup *sql.Stmt
|
||||
bumpSync *sql.Stmt
|
||||
|
@ -37,20 +35,6 @@ func _gen_pgsql() (err error) {
|
|||
return err
|
||||
}
|
||||
|
||||
common.DebugLog("Preparing addTheme statement.")
|
||||
stmts.addTheme, err = db.Prepare("INSERT INTO \"themes\"(\"uname\",\"default\") VALUES (?,?)")
|
||||
if err != nil {
|
||||
log.Print("Error in addTheme statement.")
|
||||
return err
|
||||
}
|
||||
|
||||
common.DebugLog("Preparing updateTheme statement.")
|
||||
stmts.updateTheme, err = db.Prepare("UPDATE \"themes\" SET `default` = ? WHERE `uname` = ?")
|
||||
if err != nil {
|
||||
log.Print("Error in updateTheme statement.")
|
||||
return err
|
||||
}
|
||||
|
||||
common.DebugLog("Preparing updateEmail statement.")
|
||||
stmts.updateEmail, err = db.Prepare("UPDATE \"emails\" SET `email` = ?,`uid` = ?,`validated` = ?,`token` = ? WHERE `email` = ?")
|
||||
if err != nil {
|
||||
|
|
|
@ -61,7 +61,7 @@ var RouteMap = map[string]interface{}{
|
|||
"panel.PagesEditSubmit": panel.PagesEditSubmit,
|
||||
"panel.PagesDeleteSubmit": panel.PagesDeleteSubmit,
|
||||
"panel.Themes": panel.Themes,
|
||||
"routePanelThemesSetDefault": routePanelThemesSetDefault,
|
||||
"panel.ThemesSetDefault": panel.ThemesSetDefault,
|
||||
"panel.ThemesMenus": panel.ThemesMenus,
|
||||
"panel.ThemesMenusEdit": panel.ThemesMenusEdit,
|
||||
"panel.ThemesMenuItemEdit": panel.ThemesMenuItemEdit,
|
||||
|
@ -192,7 +192,7 @@ var routeMapEnum = map[string]int{
|
|||
"panel.PagesEditSubmit": 35,
|
||||
"panel.PagesDeleteSubmit": 36,
|
||||
"panel.Themes": 37,
|
||||
"routePanelThemesSetDefault": 38,
|
||||
"panel.ThemesSetDefault": 38,
|
||||
"panel.ThemesMenus": 39,
|
||||
"panel.ThemesMenusEdit": 40,
|
||||
"panel.ThemesMenuItemEdit": 41,
|
||||
|
@ -321,7 +321,7 @@ var reverseRouteMapEnum = map[int]string{
|
|||
35: "panel.PagesEditSubmit",
|
||||
36: "panel.PagesDeleteSubmit",
|
||||
37: "panel.Themes",
|
||||
38: "routePanelThemesSetDefault",
|
||||
38: "panel.ThemesSetDefault",
|
||||
39: "panel.ThemesMenus",
|
||||
40: "panel.ThemesMenusEdit",
|
||||
41: "panel.ThemesMenuItemEdit",
|
||||
|
@ -1184,7 +1184,7 @@ func (router *GenRouter) routeSwitch(w http.ResponseWriter, req *http.Request, u
|
|||
}
|
||||
|
||||
counters.RouteViewCounter.Bump(38)
|
||||
err = routePanelThemesSetDefault(w,req,user,extraData)
|
||||
err = panel.ThemesSetDefault(w,req,user,extraData)
|
||||
case "/panel/themes/menus/":
|
||||
counters.RouteViewCounter.Bump(39)
|
||||
err = panel.ThemesMenus(w,req,user)
|
||||
|
|
|
@ -2,9 +2,7 @@ package main
|
|||
|
||||
import (
|
||||
"database/sql"
|
||||
"errors"
|
||||
"fmt"
|
||||
"log"
|
||||
"net/http"
|
||||
"strconv"
|
||||
|
||||
|
@ -168,68 +166,3 @@ func routePanelDashboard(w http.ResponseWriter, r *http.Request, user common.Use
|
|||
pi := common.PanelDashboardPage{&common.BasePanelPage{header, stats, "dashboard", common.ReportForumID}, gridElements}
|
||||
return panelRenderTemplate("panel_dashboard", w, r, user, &pi)
|
||||
}
|
||||
|
||||
func routePanelThemesSetDefault(w http.ResponseWriter, r *http.Request, user common.User, uname string) common.RouteError {
|
||||
_, ferr := common.SimplePanelUserCheck(w, r, &user)
|
||||
if ferr != nil {
|
||||
return ferr
|
||||
}
|
||||
if !user.Perms.ManageThemes {
|
||||
return common.NoPermissions(w, r, user)
|
||||
}
|
||||
|
||||
theme, ok := common.Themes[uname]
|
||||
if !ok {
|
||||
return common.LocalError("The theme isn't registered in the system", w, r, user)
|
||||
}
|
||||
if theme.Disabled {
|
||||
return common.LocalError("You must not enable this theme", w, r, user)
|
||||
}
|
||||
|
||||
var isDefault bool
|
||||
err := stmts.isThemeDefault.QueryRow(uname).Scan(&isDefault)
|
||||
if err != nil && err != ErrNoRows {
|
||||
return common.InternalError(err, w, r)
|
||||
}
|
||||
|
||||
hasTheme := err != ErrNoRows
|
||||
if hasTheme {
|
||||
if isDefault {
|
||||
return common.LocalError("The theme is already active", w, r, user)
|
||||
}
|
||||
_, err = stmts.updateTheme.Exec(1, uname)
|
||||
} else {
|
||||
_, err = stmts.addTheme.Exec(uname, 1)
|
||||
}
|
||||
if err != nil {
|
||||
return common.InternalError(err, w, r)
|
||||
}
|
||||
|
||||
// TODO: Make this less racey
|
||||
// TODO: Move this to common
|
||||
common.ChangeDefaultThemeMutex.Lock()
|
||||
defaultTheme := common.DefaultThemeBox.Load().(string)
|
||||
_, err = stmts.updateTheme.Exec(0, defaultTheme)
|
||||
if err != nil {
|
||||
return common.InternalError(err, w, r)
|
||||
}
|
||||
|
||||
log.Printf("Setting theme '%s' as the default theme", theme.Name)
|
||||
theme.Active = true
|
||||
common.Themes[uname] = theme
|
||||
|
||||
dTheme, ok := common.Themes[defaultTheme]
|
||||
if !ok {
|
||||
return common.InternalError(errors.New("The default theme is missing"), w, r)
|
||||
}
|
||||
dTheme.Active = false
|
||||
common.Themes[defaultTheme] = dTheme
|
||||
|
||||
common.DefaultThemeBox.Store(uname)
|
||||
common.ResetTemplateOverrides()
|
||||
theme.MapTemplates()
|
||||
common.ChangeDefaultThemeMutex.Unlock()
|
||||
|
||||
http.Redirect(w, r, "/panel/themes/", http.StatusSeeOther)
|
||||
return nil
|
||||
}
|
||||
|
|
|
@ -258,8 +258,6 @@ func writeSelects(adapter qgen.Adapter) error {
|
|||
|
||||
//build.Select("isPluginInstalled").Table("plugins").Columns("installed").Where("uname = ?").Parse()
|
||||
|
||||
build.Select("isThemeDefault").Table("themes").Columns("default").Where("uname = ?").Parse()
|
||||
|
||||
build.Select("forumEntryExists").Table("forums").Columns("fid").Where("name = ''").Orderby("fid ASC").Limit("0,1").Parse()
|
||||
|
||||
build.Select("groupEntryExists").Table("users_groups").Columns("gid").Where("name = ''").Orderby("gid ASC").Limit("0,1").Parse()
|
||||
|
@ -282,16 +280,12 @@ func writeInserts(adapter qgen.Adapter) error {
|
|||
|
||||
build.Insert("addForumPermsToForum").Table("forums_permissions").Columns("gid,fid,preset,permissions").Fields("?,?,?,?").Parse()
|
||||
|
||||
build.Insert("addTheme").Table("themes").Columns("uname, default").Fields("?,?").Parse()
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func writeUpdates(adapter qgen.Adapter) error {
|
||||
build := adapter.Builder()
|
||||
|
||||
build.Update("updateTheme").Table("themes").Set("default = ?").Where("uname = ?").Parse()
|
||||
|
||||
build.Update("updateEmail").Table("emails").Set("email = ?, uid = ?, validated = ?, token = ?").Where("email = ?").Parse()
|
||||
|
||||
build.Update("setTempGroup").Table("users").Set("temp_group = ?").Where("uid = ?").Parse()
|
||||
|
|
|
@ -170,7 +170,7 @@ func buildPanelRoutes() {
|
|||
Action("panel.PagesDeleteSubmit", "/panel/pages/delete/submit/", "extraData").Before("AdminOnly"),
|
||||
|
||||
View("panel.Themes", "/panel/themes/"),
|
||||
Action("routePanelThemesSetDefault", "/panel/themes/default/", "extraData"),
|
||||
Action("panel.ThemesSetDefault", "/panel/themes/default/", "extraData"),
|
||||
View("panel.ThemesMenus", "/panel/themes/menus/"),
|
||||
View("panel.ThemesMenusEdit", "/panel/themes/menus/edit/", "extraData"),
|
||||
View("panel.ThemesMenuItemEdit", "/panel/themes/menus/item/edit/", "extraData"),
|
||||
|
|
|
@ -153,7 +153,7 @@ func AnalyticsViews(w http.ResponseWriter, r *http.Request, user common.User) co
|
|||
common.DebugLogf("graph: %+v\n", graph)
|
||||
|
||||
pi := common.PanelAnalyticsPage{basePage, graph, viewItems, timeRange.Range}
|
||||
return panelRenderTemplate("panel_analytics_views", w, r, user, &pi)
|
||||
return renderTemplate("panel_analytics_views", w, r, user, &pi)
|
||||
}
|
||||
|
||||
func AnalyticsRouteViews(w http.ResponseWriter, r *http.Request, user common.User, route string) common.RouteError {
|
||||
|
@ -190,7 +190,7 @@ func AnalyticsRouteViews(w http.ResponseWriter, r *http.Request, user common.Use
|
|||
common.DebugLogf("graph: %+v\n", graph)
|
||||
|
||||
pi := common.PanelAnalyticsRoutePage{basePage, common.SanitiseSingleLine(route), graph, viewItems, timeRange.Range}
|
||||
return panelRenderTemplate("panel_analytics_route_views", w, r, user, &pi)
|
||||
return renderTemplate("panel_analytics_route_views", w, r, user, &pi)
|
||||
}
|
||||
|
||||
func AnalyticsAgentViews(w http.ResponseWriter, r *http.Request, user common.User, agent string) common.RouteError {
|
||||
|
@ -233,7 +233,7 @@ func AnalyticsAgentViews(w http.ResponseWriter, r *http.Request, user common.Use
|
|||
}
|
||||
|
||||
pi := common.PanelAnalyticsAgentPage{basePage, agent, friendlyAgent, graph, timeRange.Range}
|
||||
return panelRenderTemplate("panel_analytics_agent_views", w, r, user, &pi)
|
||||
return renderTemplate("panel_analytics_agent_views", w, r, user, &pi)
|
||||
}
|
||||
|
||||
func AnalyticsForumViews(w http.ResponseWriter, r *http.Request, user common.User, sfid string) common.RouteError {
|
||||
|
@ -277,7 +277,7 @@ func AnalyticsForumViews(w http.ResponseWriter, r *http.Request, user common.Use
|
|||
}
|
||||
|
||||
pi := common.PanelAnalyticsAgentPage{basePage, sfid, forum.Name, graph, timeRange.Range}
|
||||
return panelRenderTemplate("panel_analytics_forum_views", w, r, user, &pi)
|
||||
return renderTemplate("panel_analytics_forum_views", w, r, user, &pi)
|
||||
}
|
||||
|
||||
func AnalyticsSystemViews(w http.ResponseWriter, r *http.Request, user common.User, system string) common.RouteError {
|
||||
|
@ -318,7 +318,7 @@ func AnalyticsSystemViews(w http.ResponseWriter, r *http.Request, user common.Us
|
|||
}
|
||||
|
||||
pi := common.PanelAnalyticsAgentPage{basePage, system, friendlySystem, graph, timeRange.Range}
|
||||
return panelRenderTemplate("panel_analytics_system_views", w, r, user, &pi)
|
||||
return renderTemplate("panel_analytics_system_views", w, r, user, &pi)
|
||||
}
|
||||
|
||||
func AnalyticsLanguageViews(w http.ResponseWriter, r *http.Request, user common.User, lang string) common.RouteError {
|
||||
|
@ -358,7 +358,7 @@ func AnalyticsLanguageViews(w http.ResponseWriter, r *http.Request, user common.
|
|||
}
|
||||
|
||||
pi := common.PanelAnalyticsAgentPage{basePage, lang, friendlyLang, graph, timeRange.Range}
|
||||
return panelRenderTemplate("panel_analytics_lang_views", w, r, user, &pi)
|
||||
return renderTemplate("panel_analytics_lang_views", w, r, user, &pi)
|
||||
}
|
||||
|
||||
func AnalyticsReferrerViews(w http.ResponseWriter, r *http.Request, user common.User, domain string) common.RouteError {
|
||||
|
@ -392,7 +392,7 @@ func AnalyticsReferrerViews(w http.ResponseWriter, r *http.Request, user common.
|
|||
common.DebugLogf("graph: %+v\n", graph)
|
||||
|
||||
pi := common.PanelAnalyticsAgentPage{basePage, common.SanitiseSingleLine(domain), "", graph, timeRange.Range}
|
||||
return panelRenderTemplate("panel_analytics_referrer_views", w, r, user, &pi)
|
||||
return renderTemplate("panel_analytics_referrer_views", w, r, user, &pi)
|
||||
}
|
||||
|
||||
func AnalyticsTopics(w http.ResponseWriter, r *http.Request, user common.User) common.RouteError {
|
||||
|
@ -427,7 +427,7 @@ func AnalyticsTopics(w http.ResponseWriter, r *http.Request, user common.User) c
|
|||
common.DebugLogf("graph: %+v\n", graph)
|
||||
|
||||
pi := common.PanelAnalyticsPage{basePage, graph, viewItems, timeRange.Range}
|
||||
return panelRenderTemplate("panel_analytics_topics", w, r, user, &pi)
|
||||
return renderTemplate("panel_analytics_topics", w, r, user, &pi)
|
||||
}
|
||||
|
||||
func AnalyticsPosts(w http.ResponseWriter, r *http.Request, user common.User) common.RouteError {
|
||||
|
@ -462,7 +462,7 @@ func AnalyticsPosts(w http.ResponseWriter, r *http.Request, user common.User) co
|
|||
common.DebugLogf("graph: %+v\n", graph)
|
||||
|
||||
pi := common.PanelAnalyticsPage{basePage, graph, viewItems, timeRange.Range}
|
||||
return panelRenderTemplate("panel_analytics_posts", w, r, user, &pi)
|
||||
return renderTemplate("panel_analytics_posts", w, r, user, &pi)
|
||||
}
|
||||
|
||||
func analyticsRowsToNameMap(rows *sql.Rows) (map[string]int, error) {
|
||||
|
@ -525,7 +525,7 @@ func AnalyticsForums(w http.ResponseWriter, r *http.Request, user common.User) c
|
|||
}
|
||||
|
||||
pi := common.PanelAnalyticsAgentsPage{basePage, forumItems, timeRange.Range}
|
||||
return panelRenderTemplate("panel_analytics_forums", w, r, user, &pi)
|
||||
return renderTemplate("panel_analytics_forums", w, r, user, &pi)
|
||||
}
|
||||
|
||||
func AnalyticsRoutes(w http.ResponseWriter, r *http.Request, user common.User) common.RouteError {
|
||||
|
@ -558,7 +558,7 @@ func AnalyticsRoutes(w http.ResponseWriter, r *http.Request, user common.User) c
|
|||
}
|
||||
|
||||
pi := common.PanelAnalyticsRoutesPage{basePage, routeItems, timeRange.Range}
|
||||
return panelRenderTemplate("panel_analytics_routes", w, r, user, &pi)
|
||||
return renderTemplate("panel_analytics_routes", w, r, user, &pi)
|
||||
}
|
||||
|
||||
func AnalyticsAgents(w http.ResponseWriter, r *http.Request, user common.User) common.RouteError {
|
||||
|
@ -596,7 +596,7 @@ func AnalyticsAgents(w http.ResponseWriter, r *http.Request, user common.User) c
|
|||
}
|
||||
|
||||
pi := common.PanelAnalyticsAgentsPage{basePage, agentItems, timeRange.Range}
|
||||
return panelRenderTemplate("panel_analytics_agents", w, r, user, &pi)
|
||||
return renderTemplate("panel_analytics_agents", w, r, user, &pi)
|
||||
}
|
||||
|
||||
func AnalyticsSystems(w http.ResponseWriter, r *http.Request, user common.User) common.RouteError {
|
||||
|
@ -634,7 +634,7 @@ func AnalyticsSystems(w http.ResponseWriter, r *http.Request, user common.User)
|
|||
}
|
||||
|
||||
pi := common.PanelAnalyticsAgentsPage{basePage, systemItems, timeRange.Range}
|
||||
return panelRenderTemplate("panel_analytics_systems", w, r, user, &pi)
|
||||
return renderTemplate("panel_analytics_systems", w, r, user, &pi)
|
||||
}
|
||||
|
||||
func AnalyticsLanguages(w http.ResponseWriter, r *http.Request, user common.User) common.RouteError {
|
||||
|
@ -673,7 +673,7 @@ func AnalyticsLanguages(w http.ResponseWriter, r *http.Request, user common.User
|
|||
}
|
||||
|
||||
pi := common.PanelAnalyticsAgentsPage{basePage, langItems, timeRange.Range}
|
||||
return panelRenderTemplate("panel_analytics_langs", w, r, user, &pi)
|
||||
return renderTemplate("panel_analytics_langs", w, r, user, &pi)
|
||||
}
|
||||
|
||||
func AnalyticsReferrers(w http.ResponseWriter, r *http.Request, user common.User) common.RouteError {
|
||||
|
@ -706,5 +706,5 @@ func AnalyticsReferrers(w http.ResponseWriter, r *http.Request, user common.User
|
|||
}
|
||||
|
||||
pi := common.PanelAnalyticsAgentsPage{basePage, refItems, timeRange.Range}
|
||||
return panelRenderTemplate("panel_analytics_referrers", w, r, user, &pi)
|
||||
return renderTemplate("panel_analytics_referrers", w, r, user, &pi)
|
||||
}
|
||||
|
|
|
@ -51,5 +51,5 @@ func Backups(w http.ResponseWriter, r *http.Request, user common.User, backupURL
|
|||
}
|
||||
|
||||
pi := common.PanelBackupPage{basePage, backupList}
|
||||
return panelRenderTemplate("panel_backups", w, r, user, &pi)
|
||||
return renderTemplate("panel_backups", w, r, user, &pi)
|
||||
}
|
||||
|
|
|
@ -11,7 +11,7 @@ var tList []interface{}
|
|||
var successJSONBytes = []byte(`{"success":"1"}`)
|
||||
|
||||
// We're trying to reduce the amount of boilerplate in here, so I added these two functions, they might wind up circulating outside this file in the future
|
||||
func panelSuccessRedirect(dest string, w http.ResponseWriter, r *http.Request, isJs bool) common.RouteError {
|
||||
func successRedirect(dest string, w http.ResponseWriter, r *http.Request, isJs bool) common.RouteError {
|
||||
if !isJs {
|
||||
http.Redirect(w, r, dest, http.StatusSeeOther)
|
||||
} else {
|
||||
|
@ -20,7 +20,7 @@ func panelSuccessRedirect(dest string, w http.ResponseWriter, r *http.Request, i
|
|||
return nil
|
||||
}
|
||||
|
||||
func panelRenderTemplate(tmplName string, w http.ResponseWriter, r *http.Request, user common.User, pi interface{}) common.RouteError {
|
||||
func renderTemplate(tmplName string, w http.ResponseWriter, r *http.Request, user common.User, pi interface{}) common.RouteError {
|
||||
if common.RunPreRenderHook("pre_render_"+tmplName, w, r, &user, pi) {
|
||||
return nil
|
||||
}
|
||||
|
|
|
@ -42,5 +42,5 @@ func Debug(w http.ResponseWriter, r *http.Request, user common.User) common.Rout
|
|||
runtime.ReadMemStats(&memStats)
|
||||
|
||||
pi := common.PanelDebugPage{basePage, goVersion, dbVersion, uptime, openConnCount, qgen.Builder.GetAdapter().GetName(), goroutines, cpus, memStats}
|
||||
return panelRenderTemplate("panel_debug", w, r, user, &pi)
|
||||
return renderTemplate("panel_debug", w, r, user, &pi)
|
||||
}
|
||||
|
|
|
@ -46,7 +46,7 @@ func Forums(w http.ResponseWriter, r *http.Request, user common.User) common.Rou
|
|||
}
|
||||
|
||||
pi := common.PanelPage{basePage, forumList, nil}
|
||||
return panelRenderTemplate("panel_forums", w, r, user, &pi)
|
||||
return renderTemplate("panel_forums", w, r, user, &pi)
|
||||
}
|
||||
|
||||
func ForumsCreateSubmit(w http.ResponseWriter, r *http.Request, user common.User) common.RouteError {
|
||||
|
@ -233,7 +233,7 @@ func ForumsEditSubmit(w http.ResponseWriter, r *http.Request, user common.User,
|
|||
return common.InternalErrorJSQ(err, w, r, isJs)
|
||||
}
|
||||
// ? Should we redirect to the forum editor instead?
|
||||
return panelSuccessRedirect("/panel/forums/", w, r, isJs)
|
||||
return successRedirect("/panel/forums/", w, r, isJs)
|
||||
}
|
||||
|
||||
func ForumsEditPermsSubmit(w http.ResponseWriter, r *http.Request, user common.User, sfid string) common.RouteError {
|
||||
|
@ -269,7 +269,7 @@ func ForumsEditPermsSubmit(w http.ResponseWriter, r *http.Request, user common.U
|
|||
return common.LocalErrorJSQ(err.Error(), w, r, user, isJs)
|
||||
}
|
||||
|
||||
return panelSuccessRedirect("/panel/forums/edit/"+strconv.Itoa(fid)+"?updated=1", w, r, isJs)
|
||||
return successRedirect("/panel/forums/edit/"+strconv.Itoa(fid)+"?updated=1", w, r, isJs)
|
||||
}
|
||||
|
||||
// A helper function for the Advanced portion of the Forum Perms Editor
|
||||
|
@ -412,5 +412,5 @@ func ForumsEditPermsAdvanceSubmit(w http.ResponseWriter, r *http.Request, user c
|
|||
return common.LocalErrorJSQ(err.Error(), w, r, user, isJs)
|
||||
}
|
||||
|
||||
return panelSuccessRedirect("/panel/forums/edit/perms/"+strconv.Itoa(fid)+"-"+strconv.Itoa(gid)+"?updated=1", w, r, isJs)
|
||||
return successRedirect("/panel/forums/edit/perms/"+strconv.Itoa(fid)+"-"+strconv.Itoa(gid)+"?updated=1", w, r, isJs)
|
||||
}
|
||||
|
|
|
@ -29,7 +29,6 @@ func Groups(w http.ResponseWriter, r *http.Request, user common.User) common.Rou
|
|||
if count == perPage {
|
||||
break
|
||||
}
|
||||
|
||||
var rank string
|
||||
var rankClass string
|
||||
var canDelete = false
|
||||
|
@ -60,7 +59,7 @@ func Groups(w http.ResponseWriter, r *http.Request, user common.User) common.Rou
|
|||
|
||||
pageList := common.Paginate(basePage.Stats.Groups, perPage, 5)
|
||||
pi := common.PanelGroupPage{basePage, groupList, common.Paginator{pageList, page, lastPage}}
|
||||
return panelRenderTemplate("panel_groups", w, r, user, &pi)
|
||||
return renderTemplate("panel_groups", w, r, user, &pi)
|
||||
}
|
||||
|
||||
//routePanelGroupsEdit
|
||||
|
@ -109,14 +108,7 @@ func GroupsEdit(w http.ResponseWriter, r *http.Request, user common.User, sgid s
|
|||
disableRank := !user.Perms.EditGroupGlobalPerms || (group.ID == 6)
|
||||
|
||||
pi := common.PanelEditGroupPage{basePage, group.ID, group.Name, group.Tag, rank, disableRank}
|
||||
if common.RunPreRenderHook("pre_render_panel_edit_group", w, r, &user, &pi) {
|
||||
return nil
|
||||
}
|
||||
err = common.Templates.ExecuteTemplate(w, "panel_group_edit.html", pi)
|
||||
if err != nil {
|
||||
return common.InternalError(err, w, r)
|
||||
}
|
||||
return nil
|
||||
return renderTemplate("group_edit", w, r, user, pi)
|
||||
}
|
||||
|
||||
//routePanelGroupsEditPerms
|
||||
|
@ -196,14 +188,7 @@ func GroupsEditPerms(w http.ResponseWriter, r *http.Request, user common.User, s
|
|||
addGlobalPerm("UploadFiles", group.Perms.UploadFiles)
|
||||
|
||||
pi := common.PanelEditGroupPermsPage{basePage, group.ID, group.Name, localPerms, globalPerms}
|
||||
if common.RunPreRenderHook("pre_render_panel_edit_group_perms", w, r, &user, &pi) {
|
||||
return nil
|
||||
}
|
||||
err = common.Templates.ExecuteTemplate(w, "panel_group_edit_perms.html", pi)
|
||||
if err != nil {
|
||||
return common.InternalError(err, w, r)
|
||||
}
|
||||
return nil
|
||||
return renderTemplate("group_edit_perms", w, r, user, pi)
|
||||
}
|
||||
|
||||
//routePanelGroupsEditSubmit
|
||||
|
|
|
@ -33,7 +33,7 @@ func LogsRegs(w http.ResponseWriter, r *http.Request, user common.User) common.R
|
|||
|
||||
pageList := common.Paginate(logCount, perPage, 5)
|
||||
pi := common.PanelRegLogsPage{basePage, llist, common.Paginator{pageList, page, lastPage}}
|
||||
return panelRenderTemplate("panel_reglogs", w, r, user, &pi)
|
||||
return renderTemplate("panel_reglogs", w, r, user, &pi)
|
||||
}
|
||||
|
||||
// TODO: Log errors when something really screwy is going on?
|
||||
|
@ -125,7 +125,7 @@ func LogsMod(w http.ResponseWriter, r *http.Request, user common.User) common.Ro
|
|||
|
||||
pageList := common.Paginate(logCount, perPage, 5)
|
||||
pi := common.PanelLogsPage{basePage, llist, common.Paginator{pageList, page, lastPage}}
|
||||
return panelRenderTemplate("panel_modlogs", w, r, user, &pi)
|
||||
return renderTemplate("panel_modlogs", w, r, user, &pi)
|
||||
}
|
||||
|
||||
func LogsAdmin(w http.ResponseWriter, r *http.Request, user common.User) common.RouteError {
|
||||
|
@ -152,5 +152,5 @@ func LogsAdmin(w http.ResponseWriter, r *http.Request, user common.User) common.
|
|||
|
||||
pageList := common.Paginate(logCount, perPage, 5)
|
||||
pi := common.PanelLogsPage{basePage, llist, common.Paginator{pageList, page, lastPage}}
|
||||
return panelRenderTemplate("panel_adminlogs", w, r, user, &pi)
|
||||
return renderTemplate("panel_adminlogs", w, r, user, &pi)
|
||||
}
|
||||
|
|
|
@ -32,7 +32,7 @@ func Pages(w http.ResponseWriter, r *http.Request, user common.User) common.Rout
|
|||
|
||||
pageList := common.Paginate(pageCount, perPage, 5)
|
||||
pi := common.PanelCustomPagesPage{basePage, cPages, common.Paginator{pageList, page, lastPage}}
|
||||
return panelRenderTemplate("panel_pages", w, r, user, &pi)
|
||||
return renderTemplate("panel_pages", w, r, user, &pi)
|
||||
}
|
||||
|
||||
func PagesCreateSubmit(w http.ResponseWriter, r *http.Request, user common.User) common.RouteError {
|
||||
|
@ -89,7 +89,7 @@ func PagesEdit(w http.ResponseWriter, r *http.Request, user common.User, spid st
|
|||
}
|
||||
|
||||
pi := common.PanelCustomPageEditPage{basePage, page}
|
||||
return panelRenderTemplate("panel_pages_edit", w, r, user, &pi)
|
||||
return renderTemplate("panel_pages_edit", w, r, user, &pi)
|
||||
}
|
||||
|
||||
func PagesEditSubmit(w http.ResponseWriter, r *http.Request, user common.User, spid string) common.RouteError {
|
||||
|
|
|
@ -24,7 +24,7 @@ func Plugins(w http.ResponseWriter, r *http.Request, user common.User) common.Ro
|
|||
}
|
||||
|
||||
pi := common.PanelPage{basePage, pluginList, nil}
|
||||
return panelRenderTemplate("panel_plugins", w, r, user, &pi)
|
||||
return renderTemplate("panel_plugins", w, r, user, &pi)
|
||||
}
|
||||
|
||||
//routePanelPluginsActivate
|
||||
|
|
|
@ -48,7 +48,7 @@ func Settings(w http.ResponseWriter, r *http.Request, user common.User) common.R
|
|||
}
|
||||
|
||||
pi := common.PanelPage{basePage, tList, settingList}
|
||||
return panelRenderTemplate("panel_settings", w, r, user, &pi)
|
||||
return renderTemplate("panel_settings", w, r, user, &pi)
|
||||
}
|
||||
|
||||
func SettingEdit(w http.ResponseWriter, r *http.Request, user common.User, sname string) common.RouteError {
|
||||
|
@ -89,7 +89,7 @@ func SettingEdit(w http.ResponseWriter, r *http.Request, user common.User, sname
|
|||
|
||||
pSetting := &common.PanelSetting{setting, common.GetSettingPhrase(setting.Name)}
|
||||
pi := common.PanelSettingPage{basePage, itemList, pSetting}
|
||||
return panelRenderTemplate("panel_setting", w, r, user, &pi)
|
||||
return renderTemplate("panel_setting", w, r, user, &pi)
|
||||
}
|
||||
|
||||
func SettingEditSubmit(w http.ResponseWriter, r *http.Request, user common.User, sname string) common.RouteError {
|
||||
|
|
|
@ -32,7 +32,34 @@ func Themes(w http.ResponseWriter, r *http.Request, user common.User) common.Rou
|
|||
}
|
||||
|
||||
pi := common.PanelThemesPage{basePage, pThemeList, vThemeList}
|
||||
return panelRenderTemplate("panel_themes", w, r, user, &pi)
|
||||
return renderTemplate("panel_themes", w, r, user, &pi)
|
||||
}
|
||||
|
||||
//routePanelThemesSetDefault
|
||||
func ThemesSetDefault(w http.ResponseWriter, r *http.Request, user common.User, uname string) common.RouteError {
|
||||
_, ferr := common.SimplePanelUserCheck(w, r, &user)
|
||||
if ferr != nil {
|
||||
return ferr
|
||||
}
|
||||
if !user.Perms.ManageThemes {
|
||||
return common.NoPermissions(w, r, user)
|
||||
}
|
||||
|
||||
theme, ok := common.Themes[uname]
|
||||
if !ok {
|
||||
return common.LocalError("The theme isn't registered in the system", w, r, user)
|
||||
}
|
||||
if theme.Disabled {
|
||||
return common.LocalError("You must not enable this theme", w, r, user)
|
||||
}
|
||||
|
||||
err := common.UpdateDefaultTheme(theme)
|
||||
if err != nil {
|
||||
return common.InternalError(err, w, r)
|
||||
}
|
||||
|
||||
http.Redirect(w, r, "/panel/themes/", http.StatusSeeOther)
|
||||
return nil
|
||||
}
|
||||
|
||||
//routePanelThemesMenus
|
||||
|
@ -59,7 +86,7 @@ func ThemesMenus(w http.ResponseWriter, r *http.Request, user common.User) commo
|
|||
}
|
||||
|
||||
pi := common.PanelMenuListPage{basePage, menuList}
|
||||
return panelRenderTemplate("panel_themes_menus", w, r, user, &pi)
|
||||
return renderTemplate("panel_themes_menus", w, r, user, &pi)
|
||||
}
|
||||
|
||||
//routePanelThemesMenusEdit
|
||||
|
@ -107,7 +134,7 @@ func ThemesMenusEdit(w http.ResponseWriter, r *http.Request, user common.User, s
|
|||
}
|
||||
|
||||
pi := common.PanelMenuPage{basePage, mid, menuList}
|
||||
return panelRenderTemplate("panel_themes_menus_items", w, r, user, &pi)
|
||||
return renderTemplate("panel_themes_menus_items", w, r, user, &pi)
|
||||
}
|
||||
|
||||
//routePanelThemesMenuItemEdit
|
||||
|
@ -134,7 +161,7 @@ func ThemesMenuItemEdit(w http.ResponseWriter, r *http.Request, user common.User
|
|||
}
|
||||
|
||||
pi := common.PanelMenuItemPage{basePage, menuItem}
|
||||
return panelRenderTemplate("panel_themes_menus_item_edit", w, r, user, &pi)
|
||||
return renderTemplate("panel_themes_menus_item_edit", w, r, user, &pi)
|
||||
}
|
||||
|
||||
func themesMenuItemSetters(r *http.Request, menuItem common.MenuItem) common.MenuItem {
|
||||
|
@ -212,7 +239,7 @@ func ThemesMenuItemEditSubmit(w http.ResponseWriter, r *http.Request, user commo
|
|||
if err != nil {
|
||||
return common.InternalErrorJSQ(err, w, r, isJs)
|
||||
}
|
||||
return panelSuccessRedirect("/panel/themes/menus/item/edit/"+strconv.Itoa(itemID), w, r, isJs)
|
||||
return successRedirect("/panel/themes/menus/item/edit/"+strconv.Itoa(itemID), w, r, isJs)
|
||||
}
|
||||
|
||||
//routePanelThemesMenuItemCreateSubmit
|
||||
|
@ -241,7 +268,7 @@ func ThemesMenuItemCreateSubmit(w http.ResponseWriter, r *http.Request, user com
|
|||
if err != nil {
|
||||
return common.InternalErrorJSQ(err, w, r, isJs)
|
||||
}
|
||||
return panelSuccessRedirect("/panel/themes/menus/item/edit/"+strconv.Itoa(itemID), w, r, isJs)
|
||||
return successRedirect("/panel/themes/menus/item/edit/"+strconv.Itoa(itemID), w, r, isJs)
|
||||
}
|
||||
|
||||
//routePanelThemesMenuItemDeleteSubmit
|
||||
|
@ -271,7 +298,7 @@ func ThemesMenuItemDeleteSubmit(w http.ResponseWriter, r *http.Request, user com
|
|||
if err != nil {
|
||||
return common.InternalErrorJSQ(err, w, r, isJs)
|
||||
}
|
||||
return panelSuccessRedirect("/panel/themes/menus/", w, r, isJs)
|
||||
return successRedirect("/panel/themes/menus/", w, r, isJs)
|
||||
}
|
||||
|
||||
//routePanelThemesMenuItemOrderSubmit
|
||||
|
@ -309,5 +336,5 @@ func ThemesMenuItemOrderSubmit(w http.ResponseWriter, r *http.Request, user comm
|
|||
}
|
||||
menuHold.UpdateOrder(updateMap)
|
||||
|
||||
return panelSuccessRedirect("/panel/themes/menus/edit/"+strconv.Itoa(mid), w, r, isJs)
|
||||
return successRedirect("/panel/themes/menus/edit/"+strconv.Itoa(mid), w, r, isJs)
|
||||
}
|
||||
|
|
|
@ -25,7 +25,7 @@ func Users(w http.ResponseWriter, r *http.Request, user common.User) common.Rout
|
|||
|
||||
pageList := common.Paginate(basePage.Stats.Users, perPage, 5)
|
||||
pi := common.PanelUserPage{basePage, users, common.Paginator{pageList, page, lastPage}}
|
||||
return panelRenderTemplate("panel_users", w, r, user, &pi)
|
||||
return renderTemplate("panel_users", w, r, user, &pi)
|
||||
}
|
||||
|
||||
func UsersEdit(w http.ResponseWriter, r *http.Request, user common.User, suid string) common.RouteError {
|
||||
|
|
|
@ -9,7 +9,6 @@ import (
|
|||
"../../common"
|
||||
)
|
||||
|
||||
//routePanelWordFilter
|
||||
func WordFilters(w http.ResponseWriter, r *http.Request, user common.User) common.RouteError {
|
||||
basePage, ferr := buildBasePage(w, r, &user, "word_filters", "word-filters")
|
||||
if ferr != nil {
|
||||
|
@ -25,10 +24,9 @@ func WordFilters(w http.ResponseWriter, r *http.Request, user common.User) commo
|
|||
}
|
||||
|
||||
pi := common.PanelPage{basePage, tList, filterList}
|
||||
return panelRenderTemplate("panel_word_filters", w, r, user, &pi)
|
||||
return renderTemplate("panel_word_filters", w, r, user, &pi)
|
||||
}
|
||||
|
||||
//routePanelWordFiltersCreateSubmit
|
||||
func WordFiltersCreateSubmit(w http.ResponseWriter, r *http.Request, user common.User) common.RouteError {
|
||||
_, ferr := common.SimplePanelUserCheck(w, r, &user)
|
||||
if ferr != nil {
|
||||
|
@ -53,11 +51,10 @@ func WordFiltersCreateSubmit(w http.ResponseWriter, r *http.Request, user common
|
|||
return common.InternalErrorJSQ(err, w, r, isJs)
|
||||
}
|
||||
|
||||
return panelSuccessRedirect("/panel/settings/word-filters/", w, r, isJs)
|
||||
return successRedirect("/panel/settings/word-filters/", w, r, isJs)
|
||||
}
|
||||
|
||||
// TODO: Implement this as a non-JS fallback
|
||||
//routePanelWordFiltersEdit
|
||||
func WordFiltersEdit(w http.ResponseWriter, r *http.Request, user common.User, wfid string) common.RouteError {
|
||||
basePage, ferr := buildBasePage(w, r, &user, "edit_word_filter", "word-filters")
|
||||
if ferr != nil {
|
||||
|
@ -69,10 +66,9 @@ func WordFiltersEdit(w http.ResponseWriter, r *http.Request, user common.User, w
|
|||
_ = wfid
|
||||
|
||||
pi := common.PanelPage{basePage, tList, nil}
|
||||
return panelRenderTemplate("panel_word_filters_edit", w, r, user, &pi)
|
||||
return renderTemplate("panel_word_filters_edit", w, r, user, &pi)
|
||||
}
|
||||
|
||||
//routePanelWordFiltersEditSubmit
|
||||
func WordFiltersEditSubmit(w http.ResponseWriter, r *http.Request, user common.User, wfid string) common.RouteError {
|
||||
_, ferr := common.SimplePanelUserCheck(w, r, &user)
|
||||
if ferr != nil {
|
||||
|
@ -106,7 +102,6 @@ func WordFiltersEditSubmit(w http.ResponseWriter, r *http.Request, user common.U
|
|||
return nil
|
||||
}
|
||||
|
||||
//routePanelWordFiltersDeleteSubmit
|
||||
func WordFiltersDeleteSubmit(w http.ResponseWriter, r *http.Request, user common.User, wfid string) common.RouteError {
|
||||
_, ferr := common.SimplePanelUserCheck(w, r, &user)
|
||||
if ferr != nil {
|
||||
|
|
Loading…
Reference in New Issue