You can now reorder menu items by dragging them around in the menu item manager.
You can now create menu items. You can now delete menu items. Renamed ID to MenuID on PanelMenuPage struct. Bumped the copyright year in a place in advance. The footer is no longer hidden in the Control Panel in Tempra Simple. Fixed the notifications URL, although that page still isn't implemented yet. Fixed config_default.noparse so that Travis won't error over that. Refactored some user queries.
This commit is contained in:
parent
3801232d93
commit
185f00e019
|
@ -59,7 +59,7 @@ func (store *DefaultMenuStore) Load(mid int) error {
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
hold := &MenuListHolder{mlist, make(map[int]menuTmpl)}
|
hold := &MenuListHolder{mid, mlist, make(map[int]menuTmpl)}
|
||||||
err = hold.Preparse()
|
err = hold.Preparse()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
|
|
|
@ -14,6 +14,7 @@ import (
|
||||||
type MenuItemList []MenuItem
|
type MenuItemList []MenuItem
|
||||||
|
|
||||||
type MenuListHolder struct {
|
type MenuListHolder struct {
|
||||||
|
MenuID int
|
||||||
List MenuItemList
|
List MenuItemList
|
||||||
Variations map[int]menuTmpl // 0 = Guest Menu, 1 = Member Menu, 2 = Super Mod Menu, 3 = Admin Menu
|
Variations map[int]menuTmpl // 0 = Guest Menu, 1 = Member Menu, 2 = Super Mod Menu, 3 = Admin Menu
|
||||||
}
|
}
|
||||||
|
@ -43,8 +44,12 @@ type MenuItem struct {
|
||||||
AdminOnly bool
|
AdminOnly bool
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// TODO: Move the menu item stuff to it's own file
|
||||||
type MenuItemStmts struct {
|
type MenuItemStmts struct {
|
||||||
update *sql.Stmt
|
update *sql.Stmt
|
||||||
|
insert *sql.Stmt
|
||||||
|
delete *sql.Stmt
|
||||||
|
updateOrder *sql.Stmt
|
||||||
}
|
}
|
||||||
|
|
||||||
var menuItemStmts MenuItemStmts
|
var menuItemStmts MenuItemStmts
|
||||||
|
@ -53,6 +58,9 @@ func init() {
|
||||||
DbInits.Add(func(acc *qgen.Accumulator) error {
|
DbInits.Add(func(acc *qgen.Accumulator) error {
|
||||||
menuItemStmts = MenuItemStmts{
|
menuItemStmts = MenuItemStmts{
|
||||||
update: acc.Update("menu_items").Set("name = ?, htmlID = ?, cssClass = ?, position = ?, path = ?, aria = ?, tooltip = ?, tmplName = ?, guestOnly = ?, memberOnly = ?, staffOnly = ?, adminOnly = ?").Where("miid = ?").Prepare(),
|
update: acc.Update("menu_items").Set("name = ?, htmlID = ?, cssClass = ?, position = ?, path = ?, aria = ?, tooltip = ?, tmplName = ?, guestOnly = ?, memberOnly = ?, staffOnly = ?, adminOnly = ?").Where("miid = ?").Prepare(),
|
||||||
|
insert: acc.Insert("menu_items").Columns("mid, name, htmlID, cssClass, position, path, aria, tooltip, tmplName, guestOnly, memberOnly, staffOnly, adminOnly").Fields("?,?,?,?,?,?,?,?,?,?,?,?,?").Prepare(),
|
||||||
|
delete: acc.Delete("menu_items").Where("miid = ?").Prepare(),
|
||||||
|
updateOrder: acc.Update("menu_items").Set("order = ?").Where("miid = ?").Prepare(),
|
||||||
}
|
}
|
||||||
return acc.FirstError()
|
return acc.FirstError()
|
||||||
})
|
})
|
||||||
|
@ -64,6 +72,23 @@ func (item MenuItem) Commit() error {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (item MenuItem) Create() (int, error) {
|
||||||
|
res, err := menuItemStmts.insert.Exec(item.MenuID, item.Name, item.HTMLID, item.CSSClass, item.Position, item.Path, item.Aria, item.Tooltip, item.TmplName, item.GuestOnly, item.MemberOnly, item.SuperModOnly, item.AdminOnly)
|
||||||
|
if err != nil {
|
||||||
|
return 0, err
|
||||||
|
}
|
||||||
|
Menus.Load(item.MenuID)
|
||||||
|
|
||||||
|
miid64, err := res.LastInsertId()
|
||||||
|
return int(miid64), err
|
||||||
|
}
|
||||||
|
|
||||||
|
func (item MenuItem) Delete() error {
|
||||||
|
_, err := menuItemStmts.delete.Exec(item.ID)
|
||||||
|
Menus.Load(item.MenuID)
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
func (hold *MenuListHolder) LoadTmpl(name string) (menuTmpl MenuTmpl, err error) {
|
func (hold *MenuListHolder) LoadTmpl(name string) (menuTmpl MenuTmpl, err error) {
|
||||||
data, err := ioutil.ReadFile("./templates/" + name + ".html")
|
data, err := ioutil.ReadFile("./templates/" + name + ".html")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
@ -72,6 +97,18 @@ func (hold *MenuListHolder) LoadTmpl(name string) (menuTmpl MenuTmpl, err error)
|
||||||
return hold.Parse(name, data), nil
|
return hold.Parse(name, data), nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// TODO: Make this atomic, maybe with a transaction or store the order on the menu itself?
|
||||||
|
func (hold *MenuListHolder) UpdateOrder(updateMap map[int]int) error {
|
||||||
|
for miid, order := range updateMap {
|
||||||
|
_, err := menuItemStmts.updateOrder.Exec(order, miid)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Menus.Load(hold.MenuID)
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
func (hold *MenuListHolder) LoadTmpls() (tmpls map[string]MenuTmpl, err error) {
|
func (hold *MenuListHolder) LoadTmpls() (tmpls map[string]MenuTmpl, err error) {
|
||||||
tmpls = make(map[string]MenuTmpl)
|
tmpls = make(map[string]MenuTmpl)
|
||||||
var loadTmpl = func(name string) error {
|
var loadTmpl = func(name string) error {
|
||||||
|
|
|
@ -276,7 +276,7 @@ type PanelMenuPage struct {
|
||||||
*Header
|
*Header
|
||||||
Stats PanelStats
|
Stats PanelStats
|
||||||
Zone string
|
Zone string
|
||||||
ID int
|
MenuID int
|
||||||
ItemList []MenuItem
|
ItemList []MenuItem
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
/*
|
/*
|
||||||
*
|
*
|
||||||
* Gosora User File
|
* Gosora User File
|
||||||
* Copyright Azareal 2017 - 2018
|
* Copyright Azareal 2017 - 2019
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
package common
|
package common
|
||||||
|
@ -88,7 +88,7 @@ func init() {
|
||||||
activate: acc.SimpleUpdate("users", "active = 1", where),
|
activate: acc.SimpleUpdate("users", "active = 1", where),
|
||||||
changeGroup: acc.SimpleUpdate("users", "group = ?", where), // TODO: Implement user_count for users_groups here
|
changeGroup: acc.SimpleUpdate("users", "group = ?", where), // TODO: Implement user_count for users_groups here
|
||||||
delete: acc.SimpleDelete("users", where),
|
delete: acc.SimpleDelete("users", where),
|
||||||
setAvatar: acc.SimpleUpdate("users", "avatar = ?", where),
|
setAvatar: acc.Update("users").Set("avatar = ?").Where(where).Prepare(),
|
||||||
setUsername: acc.Update("users").Set("name = ?").Where(where).Prepare(),
|
setUsername: acc.Update("users").Set("name = ?").Where(where).Prepare(),
|
||||||
incrementTopics: acc.SimpleUpdate("users", "topics = topics + ?", where),
|
incrementTopics: acc.SimpleUpdate("users", "topics = topics + ?", where),
|
||||||
updateLevel: acc.SimpleUpdate("users", "level = ?", where),
|
updateLevel: acc.SimpleUpdate("users", "level = ?", where),
|
||||||
|
@ -101,7 +101,7 @@ func init() {
|
||||||
//recalcLastLiked: acc...
|
//recalcLastLiked: acc...
|
||||||
updateLastIP: acc.SimpleUpdate("users", "last_ip = ?", where),
|
updateLastIP: acc.SimpleUpdate("users", "last_ip = ?", where),
|
||||||
|
|
||||||
setPassword: acc.SimpleUpdate("users", "password = ?, salt = ?", where),
|
setPassword: acc.Update("users").Set("password = ?, salt = ?").Where(where).Prepare(),
|
||||||
}
|
}
|
||||||
return acc.FirstError()
|
return acc.FirstError()
|
||||||
})
|
})
|
||||||
|
@ -244,9 +244,7 @@ func (user *User) ChangeName(username string) (err error) {
|
||||||
}
|
}
|
||||||
|
|
||||||
func (user *User) ChangeAvatar(avatar string) (err error) {
|
func (user *User) ChangeAvatar(avatar string) (err error) {
|
||||||
_, err = userStmts.setAvatar.Exec(avatar, user.ID)
|
return user.bindStmt(userStmts.setAvatar, avatar)
|
||||||
user.CacheRemove()
|
|
||||||
return err
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func (user *User) ChangeGroup(group int) (err error) {
|
func (user *User) ChangeGroup(group int) (err error) {
|
||||||
|
|
|
@ -1,8 +1,8 @@
|
||||||
package main
|
package main
|
||||||
|
|
||||||
import "./common"
|
import "../common"
|
||||||
|
|
||||||
func init() {
|
func Config() {
|
||||||
// Site Info
|
// Site Info
|
||||||
common.Site.ShortName = "Ts" // This should be less than three letters to fit in the navbar
|
common.Site.ShortName = "Ts" // This should be less than three letters to fit in the navbar
|
||||||
common.Site.Name = "Test Site"
|
common.Site.Name = "Test Site"
|
||||||
|
|
486
gen_router.go
486
gen_router.go
|
@ -53,6 +53,9 @@ var RouteMap = map[string]interface{}{
|
||||||
"routePanelThemesMenusEdit": routePanelThemesMenusEdit,
|
"routePanelThemesMenusEdit": routePanelThemesMenusEdit,
|
||||||
"routePanelThemesMenuItemEdit": routePanelThemesMenuItemEdit,
|
"routePanelThemesMenuItemEdit": routePanelThemesMenuItemEdit,
|
||||||
"routePanelThemesMenuItemEditSubmit": routePanelThemesMenuItemEditSubmit,
|
"routePanelThemesMenuItemEditSubmit": routePanelThemesMenuItemEditSubmit,
|
||||||
|
"routePanelThemesMenuItemCreateSubmit": routePanelThemesMenuItemCreateSubmit,
|
||||||
|
"routePanelThemesMenuItemDeleteSubmit": routePanelThemesMenuItemDeleteSubmit,
|
||||||
|
"routePanelThemesMenuItemOrderSubmit": routePanelThemesMenuItemOrderSubmit,
|
||||||
"routePanelPlugins": routePanelPlugins,
|
"routePanelPlugins": routePanelPlugins,
|
||||||
"routePanelPluginsActivate": routePanelPluginsActivate,
|
"routePanelPluginsActivate": routePanelPluginsActivate,
|
||||||
"routePanelPluginsDeactivate": routePanelPluginsDeactivate,
|
"routePanelPluginsDeactivate": routePanelPluginsDeactivate,
|
||||||
|
@ -166,81 +169,84 @@ var routeMapEnum = map[string]int{
|
||||||
"routePanelThemesMenusEdit": 31,
|
"routePanelThemesMenusEdit": 31,
|
||||||
"routePanelThemesMenuItemEdit": 32,
|
"routePanelThemesMenuItemEdit": 32,
|
||||||
"routePanelThemesMenuItemEditSubmit": 33,
|
"routePanelThemesMenuItemEditSubmit": 33,
|
||||||
"routePanelPlugins": 34,
|
"routePanelThemesMenuItemCreateSubmit": 34,
|
||||||
"routePanelPluginsActivate": 35,
|
"routePanelThemesMenuItemDeleteSubmit": 35,
|
||||||
"routePanelPluginsDeactivate": 36,
|
"routePanelThemesMenuItemOrderSubmit": 36,
|
||||||
"routePanelPluginsInstall": 37,
|
"routePanelPlugins": 37,
|
||||||
"routePanelUsers": 38,
|
"routePanelPluginsActivate": 38,
|
||||||
"routePanelUsersEdit": 39,
|
"routePanelPluginsDeactivate": 39,
|
||||||
"routePanelUsersEditSubmit": 40,
|
"routePanelPluginsInstall": 40,
|
||||||
"routePanelAnalyticsViews": 41,
|
"routePanelUsers": 41,
|
||||||
"routePanelAnalyticsRoutes": 42,
|
"routePanelUsersEdit": 42,
|
||||||
"routePanelAnalyticsAgents": 43,
|
"routePanelUsersEditSubmit": 43,
|
||||||
"routePanelAnalyticsSystems": 44,
|
"routePanelAnalyticsViews": 44,
|
||||||
"routePanelAnalyticsLanguages": 45,
|
"routePanelAnalyticsRoutes": 45,
|
||||||
"routePanelAnalyticsReferrers": 46,
|
"routePanelAnalyticsAgents": 46,
|
||||||
"routePanelAnalyticsRouteViews": 47,
|
"routePanelAnalyticsSystems": 47,
|
||||||
"routePanelAnalyticsAgentViews": 48,
|
"routePanelAnalyticsLanguages": 48,
|
||||||
"routePanelAnalyticsForumViews": 49,
|
"routePanelAnalyticsReferrers": 49,
|
||||||
"routePanelAnalyticsSystemViews": 50,
|
"routePanelAnalyticsRouteViews": 50,
|
||||||
"routePanelAnalyticsLanguageViews": 51,
|
"routePanelAnalyticsAgentViews": 51,
|
||||||
"routePanelAnalyticsReferrerViews": 52,
|
"routePanelAnalyticsForumViews": 52,
|
||||||
"routePanelAnalyticsPosts": 53,
|
"routePanelAnalyticsSystemViews": 53,
|
||||||
"routePanelAnalyticsTopics": 54,
|
"routePanelAnalyticsLanguageViews": 54,
|
||||||
"routePanelAnalyticsForums": 55,
|
"routePanelAnalyticsReferrerViews": 55,
|
||||||
"routePanelGroups": 56,
|
"routePanelAnalyticsPosts": 56,
|
||||||
"routePanelGroupsEdit": 57,
|
"routePanelAnalyticsTopics": 57,
|
||||||
"routePanelGroupsEditPerms": 58,
|
"routePanelAnalyticsForums": 58,
|
||||||
"routePanelGroupsEditSubmit": 59,
|
"routePanelGroups": 59,
|
||||||
"routePanelGroupsEditPermsSubmit": 60,
|
"routePanelGroupsEdit": 60,
|
||||||
"routePanelGroupsCreateSubmit": 61,
|
"routePanelGroupsEditPerms": 61,
|
||||||
"routePanelBackups": 62,
|
"routePanelGroupsEditSubmit": 62,
|
||||||
"routePanelLogsMod": 63,
|
"routePanelGroupsEditPermsSubmit": 63,
|
||||||
"routePanelDebug": 64,
|
"routePanelGroupsCreateSubmit": 64,
|
||||||
"routePanelDashboard": 65,
|
"routePanelBackups": 65,
|
||||||
"routes.AccountEditCritical": 66,
|
"routePanelLogsMod": 66,
|
||||||
"routeAccountEditCriticalSubmit": 67,
|
"routePanelDebug": 67,
|
||||||
"routeAccountEditAvatar": 68,
|
"routePanelDashboard": 68,
|
||||||
"routeAccountEditAvatarSubmit": 69,
|
"routes.AccountEditCritical": 69,
|
||||||
"routeAccountEditUsername": 70,
|
"routeAccountEditCriticalSubmit": 70,
|
||||||
"routeAccountEditUsernameSubmit": 71,
|
"routeAccountEditAvatar": 71,
|
||||||
"routeAccountEditEmail": 72,
|
"routeAccountEditAvatarSubmit": 72,
|
||||||
"routeAccountEditEmailTokenSubmit": 73,
|
"routeAccountEditUsername": 73,
|
||||||
"routes.ViewProfile": 74,
|
"routeAccountEditUsernameSubmit": 74,
|
||||||
"routes.BanUserSubmit": 75,
|
"routeAccountEditEmail": 75,
|
||||||
"routes.UnbanUser": 76,
|
"routeAccountEditEmailTokenSubmit": 76,
|
||||||
"routes.ActivateUser": 77,
|
"routes.ViewProfile": 77,
|
||||||
"routes.IPSearch": 78,
|
"routes.BanUserSubmit": 78,
|
||||||
"routes.CreateTopicSubmit": 79,
|
"routes.UnbanUser": 79,
|
||||||
"routes.EditTopicSubmit": 80,
|
"routes.ActivateUser": 80,
|
||||||
"routes.DeleteTopicSubmit": 81,
|
"routes.IPSearch": 81,
|
||||||
"routes.StickTopicSubmit": 82,
|
"routes.CreateTopicSubmit": 82,
|
||||||
"routes.UnstickTopicSubmit": 83,
|
"routes.EditTopicSubmit": 83,
|
||||||
"routes.LockTopicSubmit": 84,
|
"routes.DeleteTopicSubmit": 84,
|
||||||
"routes.UnlockTopicSubmit": 85,
|
"routes.StickTopicSubmit": 85,
|
||||||
"routes.MoveTopicSubmit": 86,
|
"routes.UnstickTopicSubmit": 86,
|
||||||
"routeLikeTopicSubmit": 87,
|
"routes.LockTopicSubmit": 87,
|
||||||
"routes.ViewTopic": 88,
|
"routes.UnlockTopicSubmit": 88,
|
||||||
"routes.CreateReplySubmit": 89,
|
"routes.MoveTopicSubmit": 89,
|
||||||
"routes.ReplyEditSubmit": 90,
|
"routeLikeTopicSubmit": 90,
|
||||||
"routes.ReplyDeleteSubmit": 91,
|
"routes.ViewTopic": 91,
|
||||||
"routeReplyLikeSubmit": 92,
|
"routes.CreateReplySubmit": 92,
|
||||||
"routeProfileReplyCreateSubmit": 93,
|
"routes.ReplyEditSubmit": 93,
|
||||||
"routes.ProfileReplyEditSubmit": 94,
|
"routes.ReplyDeleteSubmit": 94,
|
||||||
"routes.ProfileReplyDeleteSubmit": 95,
|
"routeReplyLikeSubmit": 95,
|
||||||
"routes.PollVote": 96,
|
"routeProfileReplyCreateSubmit": 96,
|
||||||
"routes.PollResults": 97,
|
"routes.ProfileReplyEditSubmit": 97,
|
||||||
"routes.AccountLogin": 98,
|
"routes.ProfileReplyDeleteSubmit": 98,
|
||||||
"routes.AccountRegister": 99,
|
"routes.PollVote": 99,
|
||||||
"routeLogout": 100,
|
"routes.PollResults": 100,
|
||||||
"routes.AccountLoginSubmit": 101,
|
"routes.AccountLogin": 101,
|
||||||
"routes.AccountRegisterSubmit": 102,
|
"routes.AccountRegister": 102,
|
||||||
"routeDynamic": 103,
|
"routeLogout": 103,
|
||||||
"routeUploads": 104,
|
"routes.AccountLoginSubmit": 104,
|
||||||
"routes.StaticFile": 105,
|
"routes.AccountRegisterSubmit": 105,
|
||||||
"routes.RobotsTxt": 106,
|
"routeDynamic": 106,
|
||||||
"routes.SitemapXml": 107,
|
"routeUploads": 107,
|
||||||
"BadRoute": 108,
|
"routes.StaticFile": 108,
|
||||||
|
"routes.RobotsTxt": 109,
|
||||||
|
"routes.SitemapXml": 110,
|
||||||
|
"BadRoute": 111,
|
||||||
}
|
}
|
||||||
var reverseRouteMapEnum = map[int]string{
|
var reverseRouteMapEnum = map[int]string{
|
||||||
0: "routeAPI",
|
0: "routeAPI",
|
||||||
|
@ -277,81 +283,84 @@ var reverseRouteMapEnum = map[int]string{
|
||||||
31: "routePanelThemesMenusEdit",
|
31: "routePanelThemesMenusEdit",
|
||||||
32: "routePanelThemesMenuItemEdit",
|
32: "routePanelThemesMenuItemEdit",
|
||||||
33: "routePanelThemesMenuItemEditSubmit",
|
33: "routePanelThemesMenuItemEditSubmit",
|
||||||
34: "routePanelPlugins",
|
34: "routePanelThemesMenuItemCreateSubmit",
|
||||||
35: "routePanelPluginsActivate",
|
35: "routePanelThemesMenuItemDeleteSubmit",
|
||||||
36: "routePanelPluginsDeactivate",
|
36: "routePanelThemesMenuItemOrderSubmit",
|
||||||
37: "routePanelPluginsInstall",
|
37: "routePanelPlugins",
|
||||||
38: "routePanelUsers",
|
38: "routePanelPluginsActivate",
|
||||||
39: "routePanelUsersEdit",
|
39: "routePanelPluginsDeactivate",
|
||||||
40: "routePanelUsersEditSubmit",
|
40: "routePanelPluginsInstall",
|
||||||
41: "routePanelAnalyticsViews",
|
41: "routePanelUsers",
|
||||||
42: "routePanelAnalyticsRoutes",
|
42: "routePanelUsersEdit",
|
||||||
43: "routePanelAnalyticsAgents",
|
43: "routePanelUsersEditSubmit",
|
||||||
44: "routePanelAnalyticsSystems",
|
44: "routePanelAnalyticsViews",
|
||||||
45: "routePanelAnalyticsLanguages",
|
45: "routePanelAnalyticsRoutes",
|
||||||
46: "routePanelAnalyticsReferrers",
|
46: "routePanelAnalyticsAgents",
|
||||||
47: "routePanelAnalyticsRouteViews",
|
47: "routePanelAnalyticsSystems",
|
||||||
48: "routePanelAnalyticsAgentViews",
|
48: "routePanelAnalyticsLanguages",
|
||||||
49: "routePanelAnalyticsForumViews",
|
49: "routePanelAnalyticsReferrers",
|
||||||
50: "routePanelAnalyticsSystemViews",
|
50: "routePanelAnalyticsRouteViews",
|
||||||
51: "routePanelAnalyticsLanguageViews",
|
51: "routePanelAnalyticsAgentViews",
|
||||||
52: "routePanelAnalyticsReferrerViews",
|
52: "routePanelAnalyticsForumViews",
|
||||||
53: "routePanelAnalyticsPosts",
|
53: "routePanelAnalyticsSystemViews",
|
||||||
54: "routePanelAnalyticsTopics",
|
54: "routePanelAnalyticsLanguageViews",
|
||||||
55: "routePanelAnalyticsForums",
|
55: "routePanelAnalyticsReferrerViews",
|
||||||
56: "routePanelGroups",
|
56: "routePanelAnalyticsPosts",
|
||||||
57: "routePanelGroupsEdit",
|
57: "routePanelAnalyticsTopics",
|
||||||
58: "routePanelGroupsEditPerms",
|
58: "routePanelAnalyticsForums",
|
||||||
59: "routePanelGroupsEditSubmit",
|
59: "routePanelGroups",
|
||||||
60: "routePanelGroupsEditPermsSubmit",
|
60: "routePanelGroupsEdit",
|
||||||
61: "routePanelGroupsCreateSubmit",
|
61: "routePanelGroupsEditPerms",
|
||||||
62: "routePanelBackups",
|
62: "routePanelGroupsEditSubmit",
|
||||||
63: "routePanelLogsMod",
|
63: "routePanelGroupsEditPermsSubmit",
|
||||||
64: "routePanelDebug",
|
64: "routePanelGroupsCreateSubmit",
|
||||||
65: "routePanelDashboard",
|
65: "routePanelBackups",
|
||||||
66: "routes.AccountEditCritical",
|
66: "routePanelLogsMod",
|
||||||
67: "routeAccountEditCriticalSubmit",
|
67: "routePanelDebug",
|
||||||
68: "routeAccountEditAvatar",
|
68: "routePanelDashboard",
|
||||||
69: "routeAccountEditAvatarSubmit",
|
69: "routes.AccountEditCritical",
|
||||||
70: "routeAccountEditUsername",
|
70: "routeAccountEditCriticalSubmit",
|
||||||
71: "routeAccountEditUsernameSubmit",
|
71: "routeAccountEditAvatar",
|
||||||
72: "routeAccountEditEmail",
|
72: "routeAccountEditAvatarSubmit",
|
||||||
73: "routeAccountEditEmailTokenSubmit",
|
73: "routeAccountEditUsername",
|
||||||
74: "routes.ViewProfile",
|
74: "routeAccountEditUsernameSubmit",
|
||||||
75: "routes.BanUserSubmit",
|
75: "routeAccountEditEmail",
|
||||||
76: "routes.UnbanUser",
|
76: "routeAccountEditEmailTokenSubmit",
|
||||||
77: "routes.ActivateUser",
|
77: "routes.ViewProfile",
|
||||||
78: "routes.IPSearch",
|
78: "routes.BanUserSubmit",
|
||||||
79: "routes.CreateTopicSubmit",
|
79: "routes.UnbanUser",
|
||||||
80: "routes.EditTopicSubmit",
|
80: "routes.ActivateUser",
|
||||||
81: "routes.DeleteTopicSubmit",
|
81: "routes.IPSearch",
|
||||||
82: "routes.StickTopicSubmit",
|
82: "routes.CreateTopicSubmit",
|
||||||
83: "routes.UnstickTopicSubmit",
|
83: "routes.EditTopicSubmit",
|
||||||
84: "routes.LockTopicSubmit",
|
84: "routes.DeleteTopicSubmit",
|
||||||
85: "routes.UnlockTopicSubmit",
|
85: "routes.StickTopicSubmit",
|
||||||
86: "routes.MoveTopicSubmit",
|
86: "routes.UnstickTopicSubmit",
|
||||||
87: "routeLikeTopicSubmit",
|
87: "routes.LockTopicSubmit",
|
||||||
88: "routes.ViewTopic",
|
88: "routes.UnlockTopicSubmit",
|
||||||
89: "routes.CreateReplySubmit",
|
89: "routes.MoveTopicSubmit",
|
||||||
90: "routes.ReplyEditSubmit",
|
90: "routeLikeTopicSubmit",
|
||||||
91: "routes.ReplyDeleteSubmit",
|
91: "routes.ViewTopic",
|
||||||
92: "routeReplyLikeSubmit",
|
92: "routes.CreateReplySubmit",
|
||||||
93: "routeProfileReplyCreateSubmit",
|
93: "routes.ReplyEditSubmit",
|
||||||
94: "routes.ProfileReplyEditSubmit",
|
94: "routes.ReplyDeleteSubmit",
|
||||||
95: "routes.ProfileReplyDeleteSubmit",
|
95: "routeReplyLikeSubmit",
|
||||||
96: "routes.PollVote",
|
96: "routeProfileReplyCreateSubmit",
|
||||||
97: "routes.PollResults",
|
97: "routes.ProfileReplyEditSubmit",
|
||||||
98: "routes.AccountLogin",
|
98: "routes.ProfileReplyDeleteSubmit",
|
||||||
99: "routes.AccountRegister",
|
99: "routes.PollVote",
|
||||||
100: "routeLogout",
|
100: "routes.PollResults",
|
||||||
101: "routes.AccountLoginSubmit",
|
101: "routes.AccountLogin",
|
||||||
102: "routes.AccountRegisterSubmit",
|
102: "routes.AccountRegister",
|
||||||
103: "routeDynamic",
|
103: "routeLogout",
|
||||||
104: "routeUploads",
|
104: "routes.AccountLoginSubmit",
|
||||||
105: "routes.StaticFile",
|
105: "routes.AccountRegisterSubmit",
|
||||||
106: "routes.RobotsTxt",
|
106: "routeDynamic",
|
||||||
107: "routes.SitemapXml",
|
107: "routeUploads",
|
||||||
108: "BadRoute",
|
108: "routes.StaticFile",
|
||||||
|
109: "routes.RobotsTxt",
|
||||||
|
110: "routes.SitemapXml",
|
||||||
|
111: "BadRoute",
|
||||||
}
|
}
|
||||||
var osMapEnum = map[string]int{
|
var osMapEnum = map[string]int{
|
||||||
"unknown": 0,
|
"unknown": 0,
|
||||||
|
@ -647,7 +656,7 @@ func (router *GenRouter) ServeHTTP(w http.ResponseWriter, req *http.Request) {
|
||||||
counters.GlobalViewCounter.Bump()
|
counters.GlobalViewCounter.Bump()
|
||||||
|
|
||||||
if prefix == "/static" {
|
if prefix == "/static" {
|
||||||
counters.RouteViewCounter.Bump(105)
|
counters.RouteViewCounter.Bump(108)
|
||||||
req.URL.Path += extraData
|
req.URL.Path += extraData
|
||||||
routes.StaticFile(w, req)
|
routes.StaticFile(w, req)
|
||||||
return
|
return
|
||||||
|
@ -1068,8 +1077,35 @@ func (router *GenRouter) ServeHTTP(w http.ResponseWriter, req *http.Request) {
|
||||||
|
|
||||||
counters.RouteViewCounter.Bump(33)
|
counters.RouteViewCounter.Bump(33)
|
||||||
err = routePanelThemesMenuItemEditSubmit(w,req,user,extraData)
|
err = routePanelThemesMenuItemEditSubmit(w,req,user,extraData)
|
||||||
case "/panel/plugins/":
|
case "/panel/themes/menus/item/create/submit/":
|
||||||
|
err = common.NoSessionMismatch(w,req,user)
|
||||||
|
if err != nil {
|
||||||
|
router.handleError(err,w,req,user)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
counters.RouteViewCounter.Bump(34)
|
counters.RouteViewCounter.Bump(34)
|
||||||
|
err = routePanelThemesMenuItemCreateSubmit(w,req,user)
|
||||||
|
case "/panel/themes/menus/item/delete/submit/":
|
||||||
|
err = common.NoSessionMismatch(w,req,user)
|
||||||
|
if err != nil {
|
||||||
|
router.handleError(err,w,req,user)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
counters.RouteViewCounter.Bump(35)
|
||||||
|
err = routePanelThemesMenuItemDeleteSubmit(w,req,user,extraData)
|
||||||
|
case "/panel/themes/menus/item/order/edit/submit/":
|
||||||
|
err = common.NoSessionMismatch(w,req,user)
|
||||||
|
if err != nil {
|
||||||
|
router.handleError(err,w,req,user)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
counters.RouteViewCounter.Bump(36)
|
||||||
|
err = routePanelThemesMenuItemOrderSubmit(w,req,user,extraData)
|
||||||
|
case "/panel/plugins/":
|
||||||
|
counters.RouteViewCounter.Bump(37)
|
||||||
err = routePanelPlugins(w,req,user)
|
err = routePanelPlugins(w,req,user)
|
||||||
case "/panel/plugins/activate/":
|
case "/panel/plugins/activate/":
|
||||||
err = common.NoSessionMismatch(w,req,user)
|
err = common.NoSessionMismatch(w,req,user)
|
||||||
|
@ -1078,7 +1114,7 @@ func (router *GenRouter) ServeHTTP(w http.ResponseWriter, req *http.Request) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
counters.RouteViewCounter.Bump(35)
|
counters.RouteViewCounter.Bump(38)
|
||||||
err = routePanelPluginsActivate(w,req,user,extraData)
|
err = routePanelPluginsActivate(w,req,user,extraData)
|
||||||
case "/panel/plugins/deactivate/":
|
case "/panel/plugins/deactivate/":
|
||||||
err = common.NoSessionMismatch(w,req,user)
|
err = common.NoSessionMismatch(w,req,user)
|
||||||
|
@ -1087,7 +1123,7 @@ func (router *GenRouter) ServeHTTP(w http.ResponseWriter, req *http.Request) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
counters.RouteViewCounter.Bump(36)
|
counters.RouteViewCounter.Bump(39)
|
||||||
err = routePanelPluginsDeactivate(w,req,user,extraData)
|
err = routePanelPluginsDeactivate(w,req,user,extraData)
|
||||||
case "/panel/plugins/install/":
|
case "/panel/plugins/install/":
|
||||||
err = common.NoSessionMismatch(w,req,user)
|
err = common.NoSessionMismatch(w,req,user)
|
||||||
|
@ -1096,13 +1132,13 @@ func (router *GenRouter) ServeHTTP(w http.ResponseWriter, req *http.Request) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
counters.RouteViewCounter.Bump(37)
|
counters.RouteViewCounter.Bump(40)
|
||||||
err = routePanelPluginsInstall(w,req,user,extraData)
|
err = routePanelPluginsInstall(w,req,user,extraData)
|
||||||
case "/panel/users/":
|
case "/panel/users/":
|
||||||
counters.RouteViewCounter.Bump(38)
|
counters.RouteViewCounter.Bump(41)
|
||||||
err = routePanelUsers(w,req,user)
|
err = routePanelUsers(w,req,user)
|
||||||
case "/panel/users/edit/":
|
case "/panel/users/edit/":
|
||||||
counters.RouteViewCounter.Bump(39)
|
counters.RouteViewCounter.Bump(42)
|
||||||
err = routePanelUsersEdit(w,req,user,extraData)
|
err = routePanelUsersEdit(w,req,user,extraData)
|
||||||
case "/panel/users/edit/submit/":
|
case "/panel/users/edit/submit/":
|
||||||
err = common.NoSessionMismatch(w,req,user)
|
err = common.NoSessionMismatch(w,req,user)
|
||||||
|
@ -1111,7 +1147,7 @@ func (router *GenRouter) ServeHTTP(w http.ResponseWriter, req *http.Request) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
counters.RouteViewCounter.Bump(40)
|
counters.RouteViewCounter.Bump(43)
|
||||||
err = routePanelUsersEditSubmit(w,req,user,extraData)
|
err = routePanelUsersEditSubmit(w,req,user,extraData)
|
||||||
case "/panel/analytics/views/":
|
case "/panel/analytics/views/":
|
||||||
err = common.ParseForm(w,req,user)
|
err = common.ParseForm(w,req,user)
|
||||||
|
@ -1120,7 +1156,7 @@ func (router *GenRouter) ServeHTTP(w http.ResponseWriter, req *http.Request) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
counters.RouteViewCounter.Bump(41)
|
counters.RouteViewCounter.Bump(44)
|
||||||
err = routePanelAnalyticsViews(w,req,user)
|
err = routePanelAnalyticsViews(w,req,user)
|
||||||
case "/panel/analytics/routes/":
|
case "/panel/analytics/routes/":
|
||||||
err = common.ParseForm(w,req,user)
|
err = common.ParseForm(w,req,user)
|
||||||
|
@ -1129,7 +1165,7 @@ func (router *GenRouter) ServeHTTP(w http.ResponseWriter, req *http.Request) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
counters.RouteViewCounter.Bump(42)
|
counters.RouteViewCounter.Bump(45)
|
||||||
err = routePanelAnalyticsRoutes(w,req,user)
|
err = routePanelAnalyticsRoutes(w,req,user)
|
||||||
case "/panel/analytics/agents/":
|
case "/panel/analytics/agents/":
|
||||||
err = common.ParseForm(w,req,user)
|
err = common.ParseForm(w,req,user)
|
||||||
|
@ -1138,7 +1174,7 @@ func (router *GenRouter) ServeHTTP(w http.ResponseWriter, req *http.Request) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
counters.RouteViewCounter.Bump(43)
|
counters.RouteViewCounter.Bump(46)
|
||||||
err = routePanelAnalyticsAgents(w,req,user)
|
err = routePanelAnalyticsAgents(w,req,user)
|
||||||
case "/panel/analytics/systems/":
|
case "/panel/analytics/systems/":
|
||||||
err = common.ParseForm(w,req,user)
|
err = common.ParseForm(w,req,user)
|
||||||
|
@ -1147,7 +1183,7 @@ func (router *GenRouter) ServeHTTP(w http.ResponseWriter, req *http.Request) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
counters.RouteViewCounter.Bump(44)
|
counters.RouteViewCounter.Bump(47)
|
||||||
err = routePanelAnalyticsSystems(w,req,user)
|
err = routePanelAnalyticsSystems(w,req,user)
|
||||||
case "/panel/analytics/langs/":
|
case "/panel/analytics/langs/":
|
||||||
err = common.ParseForm(w,req,user)
|
err = common.ParseForm(w,req,user)
|
||||||
|
@ -1156,7 +1192,7 @@ func (router *GenRouter) ServeHTTP(w http.ResponseWriter, req *http.Request) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
counters.RouteViewCounter.Bump(45)
|
counters.RouteViewCounter.Bump(48)
|
||||||
err = routePanelAnalyticsLanguages(w,req,user)
|
err = routePanelAnalyticsLanguages(w,req,user)
|
||||||
case "/panel/analytics/referrers/":
|
case "/panel/analytics/referrers/":
|
||||||
err = common.ParseForm(w,req,user)
|
err = common.ParseForm(w,req,user)
|
||||||
|
@ -1165,25 +1201,25 @@ func (router *GenRouter) ServeHTTP(w http.ResponseWriter, req *http.Request) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
counters.RouteViewCounter.Bump(46)
|
counters.RouteViewCounter.Bump(49)
|
||||||
err = routePanelAnalyticsReferrers(w,req,user)
|
err = routePanelAnalyticsReferrers(w,req,user)
|
||||||
case "/panel/analytics/route/":
|
case "/panel/analytics/route/":
|
||||||
counters.RouteViewCounter.Bump(47)
|
counters.RouteViewCounter.Bump(50)
|
||||||
err = routePanelAnalyticsRouteViews(w,req,user,extraData)
|
err = routePanelAnalyticsRouteViews(w,req,user,extraData)
|
||||||
case "/panel/analytics/agent/":
|
case "/panel/analytics/agent/":
|
||||||
counters.RouteViewCounter.Bump(48)
|
counters.RouteViewCounter.Bump(51)
|
||||||
err = routePanelAnalyticsAgentViews(w,req,user,extraData)
|
err = routePanelAnalyticsAgentViews(w,req,user,extraData)
|
||||||
case "/panel/analytics/forum/":
|
case "/panel/analytics/forum/":
|
||||||
counters.RouteViewCounter.Bump(49)
|
counters.RouteViewCounter.Bump(52)
|
||||||
err = routePanelAnalyticsForumViews(w,req,user,extraData)
|
err = routePanelAnalyticsForumViews(w,req,user,extraData)
|
||||||
case "/panel/analytics/system/":
|
case "/panel/analytics/system/":
|
||||||
counters.RouteViewCounter.Bump(50)
|
counters.RouteViewCounter.Bump(53)
|
||||||
err = routePanelAnalyticsSystemViews(w,req,user,extraData)
|
err = routePanelAnalyticsSystemViews(w,req,user,extraData)
|
||||||
case "/panel/analytics/lang/":
|
case "/panel/analytics/lang/":
|
||||||
counters.RouteViewCounter.Bump(51)
|
counters.RouteViewCounter.Bump(54)
|
||||||
err = routePanelAnalyticsLanguageViews(w,req,user,extraData)
|
err = routePanelAnalyticsLanguageViews(w,req,user,extraData)
|
||||||
case "/panel/analytics/referrer/":
|
case "/panel/analytics/referrer/":
|
||||||
counters.RouteViewCounter.Bump(52)
|
counters.RouteViewCounter.Bump(55)
|
||||||
err = routePanelAnalyticsReferrerViews(w,req,user,extraData)
|
err = routePanelAnalyticsReferrerViews(w,req,user,extraData)
|
||||||
case "/panel/analytics/posts/":
|
case "/panel/analytics/posts/":
|
||||||
err = common.ParseForm(w,req,user)
|
err = common.ParseForm(w,req,user)
|
||||||
|
@ -1192,7 +1228,7 @@ func (router *GenRouter) ServeHTTP(w http.ResponseWriter, req *http.Request) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
counters.RouteViewCounter.Bump(53)
|
counters.RouteViewCounter.Bump(56)
|
||||||
err = routePanelAnalyticsPosts(w,req,user)
|
err = routePanelAnalyticsPosts(w,req,user)
|
||||||
case "/panel/analytics/topics/":
|
case "/panel/analytics/topics/":
|
||||||
err = common.ParseForm(w,req,user)
|
err = common.ParseForm(w,req,user)
|
||||||
|
@ -1201,7 +1237,7 @@ func (router *GenRouter) ServeHTTP(w http.ResponseWriter, req *http.Request) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
counters.RouteViewCounter.Bump(54)
|
counters.RouteViewCounter.Bump(57)
|
||||||
err = routePanelAnalyticsTopics(w,req,user)
|
err = routePanelAnalyticsTopics(w,req,user)
|
||||||
case "/panel/analytics/forums/":
|
case "/panel/analytics/forums/":
|
||||||
err = common.ParseForm(w,req,user)
|
err = common.ParseForm(w,req,user)
|
||||||
|
@ -1210,16 +1246,16 @@ func (router *GenRouter) ServeHTTP(w http.ResponseWriter, req *http.Request) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
counters.RouteViewCounter.Bump(55)
|
counters.RouteViewCounter.Bump(58)
|
||||||
err = routePanelAnalyticsForums(w,req,user)
|
err = routePanelAnalyticsForums(w,req,user)
|
||||||
case "/panel/groups/":
|
case "/panel/groups/":
|
||||||
counters.RouteViewCounter.Bump(56)
|
counters.RouteViewCounter.Bump(59)
|
||||||
err = routePanelGroups(w,req,user)
|
err = routePanelGroups(w,req,user)
|
||||||
case "/panel/groups/edit/":
|
case "/panel/groups/edit/":
|
||||||
counters.RouteViewCounter.Bump(57)
|
counters.RouteViewCounter.Bump(60)
|
||||||
err = routePanelGroupsEdit(w,req,user,extraData)
|
err = routePanelGroupsEdit(w,req,user,extraData)
|
||||||
case "/panel/groups/edit/perms/":
|
case "/panel/groups/edit/perms/":
|
||||||
counters.RouteViewCounter.Bump(58)
|
counters.RouteViewCounter.Bump(61)
|
||||||
err = routePanelGroupsEditPerms(w,req,user,extraData)
|
err = routePanelGroupsEditPerms(w,req,user,extraData)
|
||||||
case "/panel/groups/edit/submit/":
|
case "/panel/groups/edit/submit/":
|
||||||
err = common.NoSessionMismatch(w,req,user)
|
err = common.NoSessionMismatch(w,req,user)
|
||||||
|
@ -1228,7 +1264,7 @@ func (router *GenRouter) ServeHTTP(w http.ResponseWriter, req *http.Request) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
counters.RouteViewCounter.Bump(59)
|
counters.RouteViewCounter.Bump(62)
|
||||||
err = routePanelGroupsEditSubmit(w,req,user,extraData)
|
err = routePanelGroupsEditSubmit(w,req,user,extraData)
|
||||||
case "/panel/groups/edit/perms/submit/":
|
case "/panel/groups/edit/perms/submit/":
|
||||||
err = common.NoSessionMismatch(w,req,user)
|
err = common.NoSessionMismatch(w,req,user)
|
||||||
|
@ -1237,7 +1273,7 @@ func (router *GenRouter) ServeHTTP(w http.ResponseWriter, req *http.Request) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
counters.RouteViewCounter.Bump(60)
|
counters.RouteViewCounter.Bump(63)
|
||||||
err = routePanelGroupsEditPermsSubmit(w,req,user,extraData)
|
err = routePanelGroupsEditPermsSubmit(w,req,user,extraData)
|
||||||
case "/panel/groups/create/":
|
case "/panel/groups/create/":
|
||||||
err = common.NoSessionMismatch(w,req,user)
|
err = common.NoSessionMismatch(w,req,user)
|
||||||
|
@ -1246,7 +1282,7 @@ func (router *GenRouter) ServeHTTP(w http.ResponseWriter, req *http.Request) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
counters.RouteViewCounter.Bump(61)
|
counters.RouteViewCounter.Bump(64)
|
||||||
err = routePanelGroupsCreateSubmit(w,req,user)
|
err = routePanelGroupsCreateSubmit(w,req,user)
|
||||||
case "/panel/backups/":
|
case "/panel/backups/":
|
||||||
err = common.SuperAdminOnly(w,req,user)
|
err = common.SuperAdminOnly(w,req,user)
|
||||||
|
@ -1255,10 +1291,10 @@ func (router *GenRouter) ServeHTTP(w http.ResponseWriter, req *http.Request) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
counters.RouteViewCounter.Bump(62)
|
counters.RouteViewCounter.Bump(65)
|
||||||
err = routePanelBackups(w,req,user,extraData)
|
err = routePanelBackups(w,req,user,extraData)
|
||||||
case "/panel/logs/mod/":
|
case "/panel/logs/mod/":
|
||||||
counters.RouteViewCounter.Bump(63)
|
counters.RouteViewCounter.Bump(66)
|
||||||
err = routePanelLogsMod(w,req,user)
|
err = routePanelLogsMod(w,req,user)
|
||||||
case "/panel/debug/":
|
case "/panel/debug/":
|
||||||
err = common.AdminOnly(w,req,user)
|
err = common.AdminOnly(w,req,user)
|
||||||
|
@ -1267,10 +1303,10 @@ func (router *GenRouter) ServeHTTP(w http.ResponseWriter, req *http.Request) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
counters.RouteViewCounter.Bump(64)
|
counters.RouteViewCounter.Bump(67)
|
||||||
err = routePanelDebug(w,req,user)
|
err = routePanelDebug(w,req,user)
|
||||||
default:
|
default:
|
||||||
counters.RouteViewCounter.Bump(65)
|
counters.RouteViewCounter.Bump(68)
|
||||||
err = routePanelDashboard(w,req,user)
|
err = routePanelDashboard(w,req,user)
|
||||||
}
|
}
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
@ -1285,7 +1321,7 @@ func (router *GenRouter) ServeHTTP(w http.ResponseWriter, req *http.Request) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
counters.RouteViewCounter.Bump(66)
|
counters.RouteViewCounter.Bump(69)
|
||||||
err = routes.AccountEditCritical(w,req,user)
|
err = routes.AccountEditCritical(w,req,user)
|
||||||
case "/user/edit/critical/submit/":
|
case "/user/edit/critical/submit/":
|
||||||
err = common.NoSessionMismatch(w,req,user)
|
err = common.NoSessionMismatch(w,req,user)
|
||||||
|
@ -1300,7 +1336,7 @@ func (router *GenRouter) ServeHTTP(w http.ResponseWriter, req *http.Request) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
counters.RouteViewCounter.Bump(67)
|
counters.RouteViewCounter.Bump(70)
|
||||||
err = routeAccountEditCriticalSubmit(w,req,user)
|
err = routeAccountEditCriticalSubmit(w,req,user)
|
||||||
case "/user/edit/avatar/":
|
case "/user/edit/avatar/":
|
||||||
err = common.MemberOnly(w,req,user)
|
err = common.MemberOnly(w,req,user)
|
||||||
|
@ -1309,7 +1345,7 @@ func (router *GenRouter) ServeHTTP(w http.ResponseWriter, req *http.Request) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
counters.RouteViewCounter.Bump(68)
|
counters.RouteViewCounter.Bump(71)
|
||||||
err = routeAccountEditAvatar(w,req,user)
|
err = routeAccountEditAvatar(w,req,user)
|
||||||
case "/user/edit/avatar/submit/":
|
case "/user/edit/avatar/submit/":
|
||||||
err = common.MemberOnly(w,req,user)
|
err = common.MemberOnly(w,req,user)
|
||||||
|
@ -1329,7 +1365,7 @@ func (router *GenRouter) ServeHTTP(w http.ResponseWriter, req *http.Request) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
counters.RouteViewCounter.Bump(69)
|
counters.RouteViewCounter.Bump(72)
|
||||||
err = routeAccountEditAvatarSubmit(w,req,user)
|
err = routeAccountEditAvatarSubmit(w,req,user)
|
||||||
case "/user/edit/username/":
|
case "/user/edit/username/":
|
||||||
err = common.MemberOnly(w,req,user)
|
err = common.MemberOnly(w,req,user)
|
||||||
|
@ -1338,7 +1374,7 @@ func (router *GenRouter) ServeHTTP(w http.ResponseWriter, req *http.Request) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
counters.RouteViewCounter.Bump(70)
|
counters.RouteViewCounter.Bump(73)
|
||||||
err = routeAccountEditUsername(w,req,user)
|
err = routeAccountEditUsername(w,req,user)
|
||||||
case "/user/edit/username/submit/":
|
case "/user/edit/username/submit/":
|
||||||
err = common.NoSessionMismatch(w,req,user)
|
err = common.NoSessionMismatch(w,req,user)
|
||||||
|
@ -1353,7 +1389,7 @@ func (router *GenRouter) ServeHTTP(w http.ResponseWriter, req *http.Request) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
counters.RouteViewCounter.Bump(71)
|
counters.RouteViewCounter.Bump(74)
|
||||||
err = routeAccountEditUsernameSubmit(w,req,user)
|
err = routeAccountEditUsernameSubmit(w,req,user)
|
||||||
case "/user/edit/email/":
|
case "/user/edit/email/":
|
||||||
err = common.MemberOnly(w,req,user)
|
err = common.MemberOnly(w,req,user)
|
||||||
|
@ -1362,7 +1398,7 @@ func (router *GenRouter) ServeHTTP(w http.ResponseWriter, req *http.Request) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
counters.RouteViewCounter.Bump(72)
|
counters.RouteViewCounter.Bump(75)
|
||||||
err = routeAccountEditEmail(w,req,user)
|
err = routeAccountEditEmail(w,req,user)
|
||||||
case "/user/edit/token/":
|
case "/user/edit/token/":
|
||||||
err = common.NoSessionMismatch(w,req,user)
|
err = common.NoSessionMismatch(w,req,user)
|
||||||
|
@ -1377,11 +1413,11 @@ func (router *GenRouter) ServeHTTP(w http.ResponseWriter, req *http.Request) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
counters.RouteViewCounter.Bump(73)
|
counters.RouteViewCounter.Bump(76)
|
||||||
err = routeAccountEditEmailTokenSubmit(w,req,user,extraData)
|
err = routeAccountEditEmailTokenSubmit(w,req,user,extraData)
|
||||||
default:
|
default:
|
||||||
req.URL.Path += extraData
|
req.URL.Path += extraData
|
||||||
counters.RouteViewCounter.Bump(74)
|
counters.RouteViewCounter.Bump(77)
|
||||||
err = routes.ViewProfile(w,req,user)
|
err = routes.ViewProfile(w,req,user)
|
||||||
}
|
}
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
@ -1402,7 +1438,7 @@ func (router *GenRouter) ServeHTTP(w http.ResponseWriter, req *http.Request) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
counters.RouteViewCounter.Bump(75)
|
counters.RouteViewCounter.Bump(78)
|
||||||
err = routes.BanUserSubmit(w,req,user,extraData)
|
err = routes.BanUserSubmit(w,req,user,extraData)
|
||||||
case "/users/unban/":
|
case "/users/unban/":
|
||||||
err = common.NoSessionMismatch(w,req,user)
|
err = common.NoSessionMismatch(w,req,user)
|
||||||
|
@ -1417,7 +1453,7 @@ func (router *GenRouter) ServeHTTP(w http.ResponseWriter, req *http.Request) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
counters.RouteViewCounter.Bump(76)
|
counters.RouteViewCounter.Bump(79)
|
||||||
err = routes.UnbanUser(w,req,user,extraData)
|
err = routes.UnbanUser(w,req,user,extraData)
|
||||||
case "/users/activate/":
|
case "/users/activate/":
|
||||||
err = common.NoSessionMismatch(w,req,user)
|
err = common.NoSessionMismatch(w,req,user)
|
||||||
|
@ -1432,7 +1468,7 @@ func (router *GenRouter) ServeHTTP(w http.ResponseWriter, req *http.Request) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
counters.RouteViewCounter.Bump(77)
|
counters.RouteViewCounter.Bump(80)
|
||||||
err = routes.ActivateUser(w,req,user,extraData)
|
err = routes.ActivateUser(w,req,user,extraData)
|
||||||
case "/users/ips/":
|
case "/users/ips/":
|
||||||
err = common.MemberOnly(w,req,user)
|
err = common.MemberOnly(w,req,user)
|
||||||
|
@ -1441,7 +1477,7 @@ func (router *GenRouter) ServeHTTP(w http.ResponseWriter, req *http.Request) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
counters.RouteViewCounter.Bump(78)
|
counters.RouteViewCounter.Bump(81)
|
||||||
err = routes.IPSearch(w,req,user)
|
err = routes.IPSearch(w,req,user)
|
||||||
}
|
}
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
@ -1467,7 +1503,7 @@ func (router *GenRouter) ServeHTTP(w http.ResponseWriter, req *http.Request) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
counters.RouteViewCounter.Bump(79)
|
counters.RouteViewCounter.Bump(82)
|
||||||
err = routes.CreateTopicSubmit(w,req,user)
|
err = routes.CreateTopicSubmit(w,req,user)
|
||||||
case "/topic/edit/submit/":
|
case "/topic/edit/submit/":
|
||||||
err = common.NoSessionMismatch(w,req,user)
|
err = common.NoSessionMismatch(w,req,user)
|
||||||
|
@ -1482,7 +1518,7 @@ func (router *GenRouter) ServeHTTP(w http.ResponseWriter, req *http.Request) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
counters.RouteViewCounter.Bump(80)
|
counters.RouteViewCounter.Bump(83)
|
||||||
err = routes.EditTopicSubmit(w,req,user,extraData)
|
err = routes.EditTopicSubmit(w,req,user,extraData)
|
||||||
case "/topic/delete/submit/":
|
case "/topic/delete/submit/":
|
||||||
err = common.NoSessionMismatch(w,req,user)
|
err = common.NoSessionMismatch(w,req,user)
|
||||||
|
@ -1498,7 +1534,7 @@ func (router *GenRouter) ServeHTTP(w http.ResponseWriter, req *http.Request) {
|
||||||
}
|
}
|
||||||
|
|
||||||
req.URL.Path += extraData
|
req.URL.Path += extraData
|
||||||
counters.RouteViewCounter.Bump(81)
|
counters.RouteViewCounter.Bump(84)
|
||||||
err = routes.DeleteTopicSubmit(w,req,user)
|
err = routes.DeleteTopicSubmit(w,req,user)
|
||||||
case "/topic/stick/submit/":
|
case "/topic/stick/submit/":
|
||||||
err = common.NoSessionMismatch(w,req,user)
|
err = common.NoSessionMismatch(w,req,user)
|
||||||
|
@ -1513,7 +1549,7 @@ func (router *GenRouter) ServeHTTP(w http.ResponseWriter, req *http.Request) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
counters.RouteViewCounter.Bump(82)
|
counters.RouteViewCounter.Bump(85)
|
||||||
err = routes.StickTopicSubmit(w,req,user,extraData)
|
err = routes.StickTopicSubmit(w,req,user,extraData)
|
||||||
case "/topic/unstick/submit/":
|
case "/topic/unstick/submit/":
|
||||||
err = common.NoSessionMismatch(w,req,user)
|
err = common.NoSessionMismatch(w,req,user)
|
||||||
|
@ -1528,7 +1564,7 @@ func (router *GenRouter) ServeHTTP(w http.ResponseWriter, req *http.Request) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
counters.RouteViewCounter.Bump(83)
|
counters.RouteViewCounter.Bump(86)
|
||||||
err = routes.UnstickTopicSubmit(w,req,user,extraData)
|
err = routes.UnstickTopicSubmit(w,req,user,extraData)
|
||||||
case "/topic/lock/submit/":
|
case "/topic/lock/submit/":
|
||||||
err = common.NoSessionMismatch(w,req,user)
|
err = common.NoSessionMismatch(w,req,user)
|
||||||
|
@ -1544,7 +1580,7 @@ func (router *GenRouter) ServeHTTP(w http.ResponseWriter, req *http.Request) {
|
||||||
}
|
}
|
||||||
|
|
||||||
req.URL.Path += extraData
|
req.URL.Path += extraData
|
||||||
counters.RouteViewCounter.Bump(84)
|
counters.RouteViewCounter.Bump(87)
|
||||||
err = routes.LockTopicSubmit(w,req,user)
|
err = routes.LockTopicSubmit(w,req,user)
|
||||||
case "/topic/unlock/submit/":
|
case "/topic/unlock/submit/":
|
||||||
err = common.NoSessionMismatch(w,req,user)
|
err = common.NoSessionMismatch(w,req,user)
|
||||||
|
@ -1559,7 +1595,7 @@ func (router *GenRouter) ServeHTTP(w http.ResponseWriter, req *http.Request) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
counters.RouteViewCounter.Bump(85)
|
counters.RouteViewCounter.Bump(88)
|
||||||
err = routes.UnlockTopicSubmit(w,req,user,extraData)
|
err = routes.UnlockTopicSubmit(w,req,user,extraData)
|
||||||
case "/topic/move/submit/":
|
case "/topic/move/submit/":
|
||||||
err = common.NoSessionMismatch(w,req,user)
|
err = common.NoSessionMismatch(w,req,user)
|
||||||
|
@ -1574,7 +1610,7 @@ func (router *GenRouter) ServeHTTP(w http.ResponseWriter, req *http.Request) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
counters.RouteViewCounter.Bump(86)
|
counters.RouteViewCounter.Bump(89)
|
||||||
err = routes.MoveTopicSubmit(w,req,user,extraData)
|
err = routes.MoveTopicSubmit(w,req,user,extraData)
|
||||||
case "/topic/like/submit/":
|
case "/topic/like/submit/":
|
||||||
err = common.NoSessionMismatch(w,req,user)
|
err = common.NoSessionMismatch(w,req,user)
|
||||||
|
@ -1595,10 +1631,10 @@ func (router *GenRouter) ServeHTTP(w http.ResponseWriter, req *http.Request) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
counters.RouteViewCounter.Bump(87)
|
counters.RouteViewCounter.Bump(90)
|
||||||
err = routeLikeTopicSubmit(w,req,user,extraData)
|
err = routeLikeTopicSubmit(w,req,user,extraData)
|
||||||
default:
|
default:
|
||||||
counters.RouteViewCounter.Bump(88)
|
counters.RouteViewCounter.Bump(91)
|
||||||
err = routes.ViewTopic(w,req,user, extraData)
|
err = routes.ViewTopic(w,req,user, extraData)
|
||||||
}
|
}
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
@ -1624,7 +1660,7 @@ func (router *GenRouter) ServeHTTP(w http.ResponseWriter, req *http.Request) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
counters.RouteViewCounter.Bump(89)
|
counters.RouteViewCounter.Bump(92)
|
||||||
err = routes.CreateReplySubmit(w,req,user)
|
err = routes.CreateReplySubmit(w,req,user)
|
||||||
case "/reply/edit/submit/":
|
case "/reply/edit/submit/":
|
||||||
err = common.NoSessionMismatch(w,req,user)
|
err = common.NoSessionMismatch(w,req,user)
|
||||||
|
@ -1639,7 +1675,7 @@ func (router *GenRouter) ServeHTTP(w http.ResponseWriter, req *http.Request) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
counters.RouteViewCounter.Bump(90)
|
counters.RouteViewCounter.Bump(93)
|
||||||
err = routes.ReplyEditSubmit(w,req,user,extraData)
|
err = routes.ReplyEditSubmit(w,req,user,extraData)
|
||||||
case "/reply/delete/submit/":
|
case "/reply/delete/submit/":
|
||||||
err = common.NoSessionMismatch(w,req,user)
|
err = common.NoSessionMismatch(w,req,user)
|
||||||
|
@ -1654,7 +1690,7 @@ func (router *GenRouter) ServeHTTP(w http.ResponseWriter, req *http.Request) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
counters.RouteViewCounter.Bump(91)
|
counters.RouteViewCounter.Bump(94)
|
||||||
err = routes.ReplyDeleteSubmit(w,req,user,extraData)
|
err = routes.ReplyDeleteSubmit(w,req,user,extraData)
|
||||||
case "/reply/like/submit/":
|
case "/reply/like/submit/":
|
||||||
err = common.NoSessionMismatch(w,req,user)
|
err = common.NoSessionMismatch(w,req,user)
|
||||||
|
@ -1675,7 +1711,7 @@ func (router *GenRouter) ServeHTTP(w http.ResponseWriter, req *http.Request) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
counters.RouteViewCounter.Bump(92)
|
counters.RouteViewCounter.Bump(95)
|
||||||
err = routeReplyLikeSubmit(w,req,user,extraData)
|
err = routeReplyLikeSubmit(w,req,user,extraData)
|
||||||
}
|
}
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
@ -1696,7 +1732,7 @@ func (router *GenRouter) ServeHTTP(w http.ResponseWriter, req *http.Request) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
counters.RouteViewCounter.Bump(93)
|
counters.RouteViewCounter.Bump(96)
|
||||||
err = routeProfileReplyCreateSubmit(w,req,user)
|
err = routeProfileReplyCreateSubmit(w,req,user)
|
||||||
case "/profile/reply/edit/submit/":
|
case "/profile/reply/edit/submit/":
|
||||||
err = common.NoSessionMismatch(w,req,user)
|
err = common.NoSessionMismatch(w,req,user)
|
||||||
|
@ -1711,7 +1747,7 @@ func (router *GenRouter) ServeHTTP(w http.ResponseWriter, req *http.Request) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
counters.RouteViewCounter.Bump(94)
|
counters.RouteViewCounter.Bump(97)
|
||||||
err = routes.ProfileReplyEditSubmit(w,req,user,extraData)
|
err = routes.ProfileReplyEditSubmit(w,req,user,extraData)
|
||||||
case "/profile/reply/delete/submit/":
|
case "/profile/reply/delete/submit/":
|
||||||
err = common.NoSessionMismatch(w,req,user)
|
err = common.NoSessionMismatch(w,req,user)
|
||||||
|
@ -1726,7 +1762,7 @@ func (router *GenRouter) ServeHTTP(w http.ResponseWriter, req *http.Request) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
counters.RouteViewCounter.Bump(95)
|
counters.RouteViewCounter.Bump(98)
|
||||||
err = routes.ProfileReplyDeleteSubmit(w,req,user,extraData)
|
err = routes.ProfileReplyDeleteSubmit(w,req,user,extraData)
|
||||||
}
|
}
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
@ -1747,10 +1783,10 @@ func (router *GenRouter) ServeHTTP(w http.ResponseWriter, req *http.Request) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
counters.RouteViewCounter.Bump(96)
|
counters.RouteViewCounter.Bump(99)
|
||||||
err = routes.PollVote(w,req,user,extraData)
|
err = routes.PollVote(w,req,user,extraData)
|
||||||
case "/poll/results/":
|
case "/poll/results/":
|
||||||
counters.RouteViewCounter.Bump(97)
|
counters.RouteViewCounter.Bump(100)
|
||||||
err = routes.PollResults(w,req,user,extraData)
|
err = routes.PollResults(w,req,user,extraData)
|
||||||
}
|
}
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
@ -1759,10 +1795,10 @@ func (router *GenRouter) ServeHTTP(w http.ResponseWriter, req *http.Request) {
|
||||||
case "/accounts":
|
case "/accounts":
|
||||||
switch(req.URL.Path) {
|
switch(req.URL.Path) {
|
||||||
case "/accounts/login/":
|
case "/accounts/login/":
|
||||||
counters.RouteViewCounter.Bump(98)
|
counters.RouteViewCounter.Bump(101)
|
||||||
err = routes.AccountLogin(w,req,user)
|
err = routes.AccountLogin(w,req,user)
|
||||||
case "/accounts/create/":
|
case "/accounts/create/":
|
||||||
counters.RouteViewCounter.Bump(99)
|
counters.RouteViewCounter.Bump(102)
|
||||||
err = routes.AccountRegister(w,req,user)
|
err = routes.AccountRegister(w,req,user)
|
||||||
case "/accounts/logout/":
|
case "/accounts/logout/":
|
||||||
err = common.NoSessionMismatch(w,req,user)
|
err = common.NoSessionMismatch(w,req,user)
|
||||||
|
@ -1777,7 +1813,7 @@ func (router *GenRouter) ServeHTTP(w http.ResponseWriter, req *http.Request) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
counters.RouteViewCounter.Bump(100)
|
counters.RouteViewCounter.Bump(103)
|
||||||
err = routeLogout(w,req,user)
|
err = routeLogout(w,req,user)
|
||||||
case "/accounts/login/submit/":
|
case "/accounts/login/submit/":
|
||||||
err = common.ParseForm(w,req,user)
|
err = common.ParseForm(w,req,user)
|
||||||
|
@ -1786,7 +1822,7 @@ func (router *GenRouter) ServeHTTP(w http.ResponseWriter, req *http.Request) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
counters.RouteViewCounter.Bump(101)
|
counters.RouteViewCounter.Bump(104)
|
||||||
err = routes.AccountLoginSubmit(w,req,user)
|
err = routes.AccountLoginSubmit(w,req,user)
|
||||||
case "/accounts/create/submit/":
|
case "/accounts/create/submit/":
|
||||||
err = common.ParseForm(w,req,user)
|
err = common.ParseForm(w,req,user)
|
||||||
|
@ -1795,7 +1831,7 @@ func (router *GenRouter) ServeHTTP(w http.ResponseWriter, req *http.Request) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
counters.RouteViewCounter.Bump(102)
|
counters.RouteViewCounter.Bump(105)
|
||||||
err = routes.AccountRegisterSubmit(w,req,user)
|
err = routes.AccountRegisterSubmit(w,req,user)
|
||||||
}
|
}
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
@ -1812,7 +1848,7 @@ func (router *GenRouter) ServeHTTP(w http.ResponseWriter, req *http.Request) {
|
||||||
common.NotFound(w,req,nil)
|
common.NotFound(w,req,nil)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
counters.RouteViewCounter.Bump(104)
|
counters.RouteViewCounter.Bump(107)
|
||||||
req.URL.Path += extraData
|
req.URL.Path += extraData
|
||||||
// TODO: Find a way to propagate errors up from this?
|
// TODO: Find a way to propagate errors up from this?
|
||||||
router.UploadHandler(w,req) // TODO: Count these views
|
router.UploadHandler(w,req) // TODO: Count these views
|
||||||
|
@ -1821,14 +1857,14 @@ func (router *GenRouter) ServeHTTP(w http.ResponseWriter, req *http.Request) {
|
||||||
// TODO: Add support for favicons and robots.txt files
|
// TODO: Add support for favicons and robots.txt files
|
||||||
switch(extraData) {
|
switch(extraData) {
|
||||||
case "robots.txt":
|
case "robots.txt":
|
||||||
counters.RouteViewCounter.Bump(106)
|
counters.RouteViewCounter.Bump(109)
|
||||||
err = routes.RobotsTxt(w,req)
|
err = routes.RobotsTxt(w,req)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
router.handleError(err,w,req,user)
|
router.handleError(err,w,req,user)
|
||||||
}
|
}
|
||||||
return
|
return
|
||||||
/*case "sitemap.xml":
|
/*case "sitemap.xml":
|
||||||
counters.RouteViewCounter.Bump(107)
|
counters.RouteViewCounter.Bump(110)
|
||||||
err = routes.SitemapXml(w,req)
|
err = routes.SitemapXml(w,req)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
router.handleError(err,w,req,user)
|
router.handleError(err,w,req,user)
|
||||||
|
@ -1857,7 +1893,7 @@ func (router *GenRouter) ServeHTTP(w http.ResponseWriter, req *http.Request) {
|
||||||
router.RUnlock()
|
router.RUnlock()
|
||||||
|
|
||||||
if ok {
|
if ok {
|
||||||
counters.RouteViewCounter.Bump(103) // TODO: Be more specific about *which* dynamic route it is
|
counters.RouteViewCounter.Bump(106) // TODO: Be more specific about *which* dynamic route it is
|
||||||
req.URL.Path += extraData
|
req.URL.Path += extraData
|
||||||
err = handle(w,req,user)
|
err = handle(w,req,user)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
@ -1872,7 +1908,7 @@ func (router *GenRouter) ServeHTTP(w http.ResponseWriter, req *http.Request) {
|
||||||
} else {
|
} else {
|
||||||
router.DumpRequest(req,"Bad Route")
|
router.DumpRequest(req,"Bad Route")
|
||||||
}
|
}
|
||||||
counters.RouteViewCounter.Bump(108)
|
counters.RouteViewCounter.Bump(111)
|
||||||
common.NotFound(w,req,nil)
|
common.NotFound(w,req,nil)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -701,15 +701,21 @@
|
||||||
"panel_themes_make_default":"Make Default",
|
"panel_themes_make_default":"Make Default",
|
||||||
|
|
||||||
"panel_themes_menus_head":"Menus",
|
"panel_themes_menus_head":"Menus",
|
||||||
|
"panel_themes_menus_item_edit_button_aria":"Edit menu item",
|
||||||
|
"panel_themes_menus_item_delete_button_aria":"Delete menu item",
|
||||||
|
|
||||||
"panel_themes_menus_edit_head":"Menu Editor",
|
"panel_themes_menus_edit_head":"Menu Editor",
|
||||||
|
"panel_themes_menus_create_head":"Create Menu Item",
|
||||||
"panel_themes_menus_name":"Name",
|
"panel_themes_menus_name":"Name",
|
||||||
|
"panel_themes_menus_name_placeholder":"Item Name",
|
||||||
"panel_themes_menus_htmlid":"HTML ID",
|
"panel_themes_menus_htmlid":"HTML ID",
|
||||||
"panel_themes_menus_cssclass":"CSS Class",
|
"panel_themes_menus_cssclass":"CSS Class",
|
||||||
"panel_themes_menus_position":"Position",
|
"panel_themes_menus_position":"Position",
|
||||||
"panel_themes_menus_path":"Path",
|
"panel_themes_menus_path":"Path",
|
||||||
"panel_themes_menus_aria":"Aria",
|
"panel_themes_menus_aria":"Aria",
|
||||||
|
"panel_themes_menus_aria_placeholder":"Short description for helping those with poor vision",
|
||||||
"panel_themes_menus_tooltip":"Tooltip",
|
"panel_themes_menus_tooltip":"Tooltip",
|
||||||
|
"panel_themes_menus_tooltip_placeholder":"A tooltip shown when you hover over it",
|
||||||
"panel_themes_menus_tmplname":"Template",
|
"panel_themes_menus_tmplname":"Template",
|
||||||
"panel_themes_menus_permissions":"Who Can See",
|
"panel_themes_menus_permissions":"Who Can See",
|
||||||
"panel_themes_menus_everyone": "Everyone",
|
"panel_themes_menus_everyone": "Everyone",
|
||||||
|
@ -718,6 +724,7 @@
|
||||||
"panel_themes_menus_supermodonly":"Super Mods",
|
"panel_themes_menus_supermodonly":"Super Mods",
|
||||||
"panel_themes_menus_adminonly":"Admins",
|
"panel_themes_menus_adminonly":"Admins",
|
||||||
"panel_themes_menus_edit_update_button":"Update",
|
"panel_themes_menus_edit_update_button":"Update",
|
||||||
|
"panel_themes_menus_create_button":"Create",
|
||||||
|
|
||||||
"panel_settings_head":"Settings",
|
"panel_settings_head":"Settings",
|
||||||
"panel_setting_head":"Edit Setting",
|
"panel_setting_head":"Edit Setting",
|
||||||
|
|
148
panel_routes.go
148
panel_routes.go
|
@ -2417,6 +2417,7 @@ func routePanelThemesMenusEdit(w http.ResponseWriter, r *http.Request, user comm
|
||||||
}
|
}
|
||||||
// TODO: Something like Menu #1 for the title?
|
// TODO: Something like Menu #1 for the title?
|
||||||
header.Title = common.GetTitlePhrase("panel_themes_menus_edit")
|
header.Title = common.GetTitlePhrase("panel_themes_menus_edit")
|
||||||
|
header.AddScript("Sortable-1.4.0/Sortable.min.js")
|
||||||
|
|
||||||
mid, err := strconv.Atoi(smid)
|
mid, err := strconv.Atoi(smid)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
@ -2481,29 +2482,7 @@ func routePanelThemesMenuItemEdit(w http.ResponseWriter, r *http.Request, user c
|
||||||
return panelRenderTemplate("panel_themes_menus_item_edit", w, r, user, &pi)
|
return panelRenderTemplate("panel_themes_menus_item_edit", w, r, user, &pi)
|
||||||
}
|
}
|
||||||
|
|
||||||
func routePanelThemesMenuItemEditSubmit(w http.ResponseWriter, r *http.Request, user common.User, sitemID string) common.RouteError {
|
func routePanelThemesMenuItemSetters(r *http.Request, menuItem common.MenuItem) common.MenuItem {
|
||||||
_, ferr := common.SimplePanelUserCheck(w, r, &user)
|
|
||||||
if ferr != nil {
|
|
||||||
return ferr
|
|
||||||
}
|
|
||||||
isJs := (r.PostFormValue("js") == "1")
|
|
||||||
if !user.Perms.ManageThemes {
|
|
||||||
return common.NoPermissionsJSQ(w, r, user, isJs)
|
|
||||||
}
|
|
||||||
|
|
||||||
itemID, err := strconv.Atoi(sitemID)
|
|
||||||
if err != nil {
|
|
||||||
return common.LocalErrorJSQ("Invalid integer", w, r, user, isJs)
|
|
||||||
}
|
|
||||||
|
|
||||||
menuItem, err := common.Menus.ItemStore().Get(itemID)
|
|
||||||
if err == ErrNoRows {
|
|
||||||
return common.LocalErrorJSQ("This item doesn't exist.", w, r, user, isJs)
|
|
||||||
} else if err != nil {
|
|
||||||
return common.InternalErrorJSQ(err, w, r, isJs)
|
|
||||||
}
|
|
||||||
//menuItem = menuItem.Copy() // If we switch this for a pointer, we might need this as a scratchpad
|
|
||||||
|
|
||||||
var getItem = func(name string) string {
|
var getItem = func(name string) string {
|
||||||
return html.EscapeString(strings.Replace(r.PostFormValue("item-"+name), "\n", "", -1))
|
return html.EscapeString(strings.Replace(r.PostFormValue("item-"+name), "\n", "", -1))
|
||||||
}
|
}
|
||||||
|
@ -2519,8 +2498,7 @@ func routePanelThemesMenuItemEditSubmit(w http.ResponseWriter, r *http.Request,
|
||||||
menuItem.Tooltip = getItem("tooltip")
|
menuItem.Tooltip = getItem("tooltip")
|
||||||
menuItem.TmplName = getItem("tmplname")
|
menuItem.TmplName = getItem("tmplname")
|
||||||
|
|
||||||
var perms = getItem("permissions")
|
switch getItem("permissions") {
|
||||||
switch perms {
|
|
||||||
case "everyone":
|
case "everyone":
|
||||||
menuItem.GuestOnly = false
|
menuItem.GuestOnly = false
|
||||||
menuItem.MemberOnly = false
|
menuItem.MemberOnly = false
|
||||||
|
@ -2547,6 +2525,32 @@ func routePanelThemesMenuItemEditSubmit(w http.ResponseWriter, r *http.Request,
|
||||||
menuItem.SuperModOnly = true
|
menuItem.SuperModOnly = true
|
||||||
menuItem.AdminOnly = true
|
menuItem.AdminOnly = true
|
||||||
}
|
}
|
||||||
|
return menuItem
|
||||||
|
}
|
||||||
|
|
||||||
|
func routePanelThemesMenuItemEditSubmit(w http.ResponseWriter, r *http.Request, user common.User, sitemID string) common.RouteError {
|
||||||
|
_, ferr := common.SimplePanelUserCheck(w, r, &user)
|
||||||
|
if ferr != nil {
|
||||||
|
return ferr
|
||||||
|
}
|
||||||
|
isJs := (r.PostFormValue("js") == "1")
|
||||||
|
if !user.Perms.ManageThemes {
|
||||||
|
return common.NoPermissionsJSQ(w, r, user, isJs)
|
||||||
|
}
|
||||||
|
|
||||||
|
itemID, err := strconv.Atoi(sitemID)
|
||||||
|
if err != nil {
|
||||||
|
return common.LocalErrorJSQ("Invalid integer", w, r, user, isJs)
|
||||||
|
}
|
||||||
|
|
||||||
|
menuItem, err := common.Menus.ItemStore().Get(itemID)
|
||||||
|
if err == ErrNoRows {
|
||||||
|
return common.LocalErrorJSQ("This item doesn't exist.", w, r, user, isJs)
|
||||||
|
} else if err != nil {
|
||||||
|
return common.InternalErrorJSQ(err, w, r, isJs)
|
||||||
|
}
|
||||||
|
//menuItem = menuItem.Copy() // If we switch this for a pointer, we might need this as a scratchpad
|
||||||
|
menuItem = routePanelThemesMenuItemSetters(r, menuItem)
|
||||||
|
|
||||||
err = menuItem.Commit()
|
err = menuItem.Commit()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
@ -2555,6 +2559,100 @@ func routePanelThemesMenuItemEditSubmit(w http.ResponseWriter, r *http.Request,
|
||||||
return panelSuccessRedirect("/panel/themes/menus/item/edit/"+strconv.Itoa(itemID), w, r, isJs)
|
return panelSuccessRedirect("/panel/themes/menus/item/edit/"+strconv.Itoa(itemID), w, r, isJs)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func routePanelThemesMenuItemCreateSubmit(w http.ResponseWriter, r *http.Request, user common.User) common.RouteError {
|
||||||
|
_, ferr := common.SimplePanelUserCheck(w, r, &user)
|
||||||
|
if ferr != nil {
|
||||||
|
return ferr
|
||||||
|
}
|
||||||
|
|
||||||
|
isJs := (r.PostFormValue("js") == "1")
|
||||||
|
if !user.Perms.ManageThemes {
|
||||||
|
return common.NoPermissionsJSQ(w, r, user, isJs)
|
||||||
|
}
|
||||||
|
smenuID := r.PostFormValue("mid")
|
||||||
|
if smenuID == "" {
|
||||||
|
return common.LocalErrorJSQ("No menuID provided", w, r, user, isJs)
|
||||||
|
}
|
||||||
|
menuID, err := strconv.Atoi(smenuID)
|
||||||
|
if err != nil {
|
||||||
|
return common.LocalErrorJSQ("Invalid integer", w, r, user, isJs)
|
||||||
|
}
|
||||||
|
|
||||||
|
menuItem := common.MenuItem{MenuID: menuID}
|
||||||
|
menuItem = routePanelThemesMenuItemSetters(r, menuItem)
|
||||||
|
itemID, err := menuItem.Create()
|
||||||
|
if err != nil {
|
||||||
|
return common.InternalErrorJSQ(err, w, r, isJs)
|
||||||
|
}
|
||||||
|
return panelSuccessRedirect("/panel/themes/menus/item/edit/"+strconv.Itoa(itemID), w, r, isJs)
|
||||||
|
}
|
||||||
|
|
||||||
|
func routePanelThemesMenuItemDeleteSubmit(w http.ResponseWriter, r *http.Request, user common.User, sitemID string) common.RouteError {
|
||||||
|
_, ferr := common.SimplePanelUserCheck(w, r, &user)
|
||||||
|
if ferr != nil {
|
||||||
|
return ferr
|
||||||
|
}
|
||||||
|
isJs := (r.PostFormValue("js") == "1")
|
||||||
|
if !user.Perms.ManageThemes {
|
||||||
|
return common.NoPermissionsJSQ(w, r, user, isJs)
|
||||||
|
}
|
||||||
|
|
||||||
|
itemID, err := strconv.Atoi(sitemID)
|
||||||
|
if err != nil {
|
||||||
|
return common.LocalErrorJSQ("Invalid integer", w, r, user, isJs)
|
||||||
|
}
|
||||||
|
menuItem, err := common.Menus.ItemStore().Get(itemID)
|
||||||
|
if err == ErrNoRows {
|
||||||
|
return common.LocalErrorJSQ("This item doesn't exist.", w, r, user, isJs)
|
||||||
|
} else if err != nil {
|
||||||
|
return common.InternalErrorJSQ(err, w, r, isJs)
|
||||||
|
}
|
||||||
|
//menuItem = menuItem.Copy() // If we switch this for a pointer, we might need this as a scratchpad
|
||||||
|
|
||||||
|
err = menuItem.Delete()
|
||||||
|
if err != nil {
|
||||||
|
return common.InternalErrorJSQ(err, w, r, isJs)
|
||||||
|
}
|
||||||
|
return panelSuccessRedirect("/panel/themes/menus/", w, r, isJs)
|
||||||
|
}
|
||||||
|
|
||||||
|
func routePanelThemesMenuItemOrderSubmit(w http.ResponseWriter, r *http.Request, user common.User, smid string) common.RouteError {
|
||||||
|
_, ferr := common.SimplePanelUserCheck(w, r, &user)
|
||||||
|
if ferr != nil {
|
||||||
|
return ferr
|
||||||
|
}
|
||||||
|
isJs := (r.PostFormValue("js") == "1")
|
||||||
|
if !user.Perms.ManageThemes {
|
||||||
|
return common.NoPermissionsJSQ(w, r, user, isJs)
|
||||||
|
}
|
||||||
|
|
||||||
|
mid, err := strconv.Atoi(smid)
|
||||||
|
if err != nil {
|
||||||
|
return common.LocalErrorJSQ("Invalid integer", w, r, user, isJs)
|
||||||
|
}
|
||||||
|
menuHold, err := common.Menus.Get(mid)
|
||||||
|
if err == ErrNoRows {
|
||||||
|
return common.LocalErrorJSQ("Can't find menu", w, r, user, isJs)
|
||||||
|
} else if err != nil {
|
||||||
|
return common.InternalErrorJSQ(err, w, r, isJs)
|
||||||
|
}
|
||||||
|
|
||||||
|
sitems := strings.TrimSuffix(strings.TrimPrefix(r.PostFormValue("items"), "{"), "}")
|
||||||
|
fmt.Printf("sitems: %+v\n", sitems)
|
||||||
|
|
||||||
|
var updateMap = make(map[int]int)
|
||||||
|
for index, smiid := range strings.Split(sitems, ",") {
|
||||||
|
miid, err := strconv.Atoi(smiid)
|
||||||
|
if err != nil {
|
||||||
|
return common.LocalErrorJSQ("Invalid integer in menu item list", w, r, user, isJs)
|
||||||
|
}
|
||||||
|
updateMap[miid] = index
|
||||||
|
}
|
||||||
|
menuHold.UpdateOrder(updateMap)
|
||||||
|
|
||||||
|
return panelSuccessRedirect("/panel/themes/menus/edit/"+strconv.Itoa(mid), w, r, isJs)
|
||||||
|
}
|
||||||
|
|
||||||
func routePanelBackups(w http.ResponseWriter, r *http.Request, user common.User, backupURL string) common.RouteError {
|
func routePanelBackups(w http.ResponseWriter, r *http.Request, user common.User, backupURL string) common.RouteError {
|
||||||
headerVars, stats, ferr := common.PanelUserCheck(w, r, &user)
|
headerVars, stats, ferr := common.PanelUserCheck(w, r, &user)
|
||||||
if ferr != nil {
|
if ferr != nil {
|
||||||
|
|
|
@ -0,0 +1,12 @@
|
||||||
|
# editorconfig.org
|
||||||
|
root = true
|
||||||
|
|
||||||
|
[*]
|
||||||
|
indent_style = tab
|
||||||
|
end_of_line = lf
|
||||||
|
charset = utf-8
|
||||||
|
trim_trailing_whitespace = true
|
||||||
|
insert_final_newline = true
|
||||||
|
|
||||||
|
[*.md]
|
||||||
|
trim_trailing_whitespace = false
|
|
@ -0,0 +1,5 @@
|
||||||
|
node_modules
|
||||||
|
mock.png
|
||||||
|
.*.sw*
|
||||||
|
.build*
|
||||||
|
jquery.fn.*
|
|
@ -0,0 +1,24 @@
|
||||||
|
{
|
||||||
|
"strict": true,
|
||||||
|
"newcap": false,
|
||||||
|
"node": true,
|
||||||
|
"expr": true,
|
||||||
|
"supernew": true,
|
||||||
|
"laxbreak": true,
|
||||||
|
"white": true,
|
||||||
|
"globals": {
|
||||||
|
"define": true,
|
||||||
|
"test": true,
|
||||||
|
"expect": true,
|
||||||
|
"module": true,
|
||||||
|
"asyncTest": true,
|
||||||
|
"start": true,
|
||||||
|
"ok": true,
|
||||||
|
"equal": true,
|
||||||
|
"notEqual": true,
|
||||||
|
"deepEqual": true,
|
||||||
|
"window": true,
|
||||||
|
"document": true,
|
||||||
|
"performance": true
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,23 @@
|
||||||
|
# Contribution Guidelines
|
||||||
|
|
||||||
|
### Issue
|
||||||
|
|
||||||
|
1. Try [dev](https://github.com/RubaXa/Sortable/tree/dev/)-branch, perhaps the problem has been solved;
|
||||||
|
2. [Use the search](https://github.com/RubaXa/Sortable/search?q=problem), maybe already have an answer;
|
||||||
|
3. If not found, create example on [jsbin.com (draft)](http://jsbin.com/zunibaxada/1/edit?html,js,output) and describe the problem.
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
### Pull Request
|
||||||
|
|
||||||
|
1. Before PR run `grunt`;
|
||||||
|
2. Only into [dev](https://github.com/RubaXa/Sortable/tree/dev/)-branch.
|
||||||
|
|
||||||
|
### Setup
|
||||||
|
|
||||||
|
Pieced together from [gruntjs](http://gruntjs.com/getting-started)
|
||||||
|
|
||||||
|
1. Fork repo on [github](https://github.com)
|
||||||
|
2. Clone locally
|
||||||
|
3. from local repro ```npm install```
|
||||||
|
4. Install grunt-cli globally ```sudo -H npm install -g grunt-cli```
|
|
@ -0,0 +1,713 @@
|
||||||
|
# Sortable
|
||||||
|
Sortable is a minimalist JavaScript library for reorderable drag-and-drop lists.
|
||||||
|
|
||||||
|
Demo: http://rubaxa.github.io/Sortable/
|
||||||
|
|
||||||
|
|
||||||
|
## Features
|
||||||
|
|
||||||
|
* Supports touch devices and [modern](http://caniuse.com/#search=drag) browsers (including IE9)
|
||||||
|
* Can drag from one list to another or within the same list
|
||||||
|
* CSS animation when moving items
|
||||||
|
* Supports drag handles *and selectable text* (better than voidberg's html5sortable)
|
||||||
|
* Smart auto-scrolling
|
||||||
|
* Built using native HTML5 drag and drop API
|
||||||
|
* Supports [Meteor](meteor/README.md), [AngularJS](#ng), [React](#react) and [Polymer](#polymer)
|
||||||
|
* Supports any CSS library, e.g. [Bootstrap](#bs)
|
||||||
|
* Simple API
|
||||||
|
* [CDN](#cdn)
|
||||||
|
* No jQuery (but there is [support](#jq))
|
||||||
|
|
||||||
|
|
||||||
|
<br/>
|
||||||
|
|
||||||
|
|
||||||
|
### Articles
|
||||||
|
* [Sortable v1.0 — New capabilities](https://github.com/RubaXa/Sortable/wiki/Sortable-v1.0-—-New-capabilities/) (December 22, 2014)
|
||||||
|
* [Sorting with the help of HTML5 Drag'n'Drop API](https://github.com/RubaXa/Sortable/wiki/Sorting-with-the-help-of-HTML5-Drag'n'Drop-API/) (December 23, 2013)
|
||||||
|
|
||||||
|
|
||||||
|
<br/>
|
||||||
|
|
||||||
|
|
||||||
|
### Usage
|
||||||
|
```html
|
||||||
|
<ul id="items">
|
||||||
|
<li>item 1</li>
|
||||||
|
<li>item 2</li>
|
||||||
|
<li>item 3</li>
|
||||||
|
</ul>
|
||||||
|
```
|
||||||
|
|
||||||
|
```js
|
||||||
|
var el = document.getElementById('items');
|
||||||
|
var sortable = Sortable.create(el);
|
||||||
|
```
|
||||||
|
|
||||||
|
You can use any element for the list and its elements, not just `ul`/`li`. Here is an [example with `div`s](http://jsbin.com/luxero/2/edit?html,js,output).
|
||||||
|
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
|
||||||
|
### Options
|
||||||
|
```js
|
||||||
|
var sortable = new Sortable(el, {
|
||||||
|
group: "name", // or { name: "...", pull: [true, false, clone], put: [true, false, array] }
|
||||||
|
sort: true, // sorting inside list
|
||||||
|
delay: 0, // time in milliseconds to define when the sorting should start
|
||||||
|
disabled: false, // Disables the sortable if set to true.
|
||||||
|
store: null, // @see Store
|
||||||
|
animation: 150, // ms, animation speed moving items when sorting, `0` — without animation
|
||||||
|
handle: ".my-handle", // Drag handle selector within list items
|
||||||
|
filter: ".ignore-elements", // Selectors that do not lead to dragging (String or Function)
|
||||||
|
draggable: ".item", // Specifies which items inside the element should be sortable
|
||||||
|
ghostClass: "sortable-ghost", // Class name for the drop placeholder
|
||||||
|
chosenClass: "sortable-chosen", // Class name for the chosen item
|
||||||
|
dataIdAttr: 'data-id',
|
||||||
|
|
||||||
|
forceFallback: false, // ignore the HTML5 DnD behaviour and force the fallback to kick in
|
||||||
|
fallbackClass: "sortable-fallback" // Class name for the cloned DOM Element when using forceFallback
|
||||||
|
fallbackOnBody: false // Appends the cloned DOM Element into the Document's Body
|
||||||
|
|
||||||
|
scroll: true, // or HTMLElement
|
||||||
|
scrollSensitivity: 30, // px, how near the mouse must be to an edge to start scrolling.
|
||||||
|
scrollSpeed: 10, // px
|
||||||
|
|
||||||
|
setData: function (dataTransfer, dragEl) {
|
||||||
|
dataTransfer.setData('Text', dragEl.textContent);
|
||||||
|
},
|
||||||
|
|
||||||
|
// dragging started
|
||||||
|
onStart: function (/**Event*/evt) {
|
||||||
|
evt.oldIndex; // element index within parent
|
||||||
|
},
|
||||||
|
|
||||||
|
// dragging ended
|
||||||
|
onEnd: function (/**Event*/evt) {
|
||||||
|
evt.oldIndex; // element's old index within parent
|
||||||
|
evt.newIndex; // element's new index within parent
|
||||||
|
},
|
||||||
|
|
||||||
|
// Element is dropped into the list from another list
|
||||||
|
onAdd: function (/**Event*/evt) {
|
||||||
|
var itemEl = evt.item; // dragged HTMLElement
|
||||||
|
evt.from; // previous list
|
||||||
|
// + indexes from onEnd
|
||||||
|
},
|
||||||
|
|
||||||
|
// Changed sorting within list
|
||||||
|
onUpdate: function (/**Event*/evt) {
|
||||||
|
var itemEl = evt.item; // dragged HTMLElement
|
||||||
|
// + indexes from onEnd
|
||||||
|
},
|
||||||
|
|
||||||
|
// Called by any change to the list (add / update / remove)
|
||||||
|
onSort: function (/**Event*/evt) {
|
||||||
|
// same properties as onUpdate
|
||||||
|
},
|
||||||
|
|
||||||
|
// Element is removed from the list into another list
|
||||||
|
onRemove: function (/**Event*/evt) {
|
||||||
|
// same properties as onUpdate
|
||||||
|
},
|
||||||
|
|
||||||
|
// Attempt to drag a filtered element
|
||||||
|
onFilter: function (/**Event*/evt) {
|
||||||
|
var itemEl = evt.item; // HTMLElement receiving the `mousedown|tapstart` event.
|
||||||
|
},
|
||||||
|
|
||||||
|
// Event when you move an item in the list or between lists
|
||||||
|
onMove: function (/**Event*/evt) {
|
||||||
|
// Example: http://jsbin.com/tuyafe/1/edit?js,output
|
||||||
|
evt.dragged; // dragged HTMLElement
|
||||||
|
evt.draggedRect; // TextRectangle {left, top, right и bottom}
|
||||||
|
evt.related; // HTMLElement on which have guided
|
||||||
|
evt.relatedRect; // TextRectangle
|
||||||
|
// return false; — for cancel
|
||||||
|
}
|
||||||
|
});
|
||||||
|
```
|
||||||
|
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
|
||||||
|
#### `group` option
|
||||||
|
To drag elements from one list into another, both lists must have the same `group` value.
|
||||||
|
You can also define whether lists can give away, give and keep a copy (`clone`), and receive elements.
|
||||||
|
|
||||||
|
* name: `String` — group name
|
||||||
|
* pull: `true|false|'clone'` — ability to move from the list. `clone` — copy the item, rather than move.
|
||||||
|
* put: `true|false|["foo", "bar"]` — whether elements can be added from other lists, or an array of group names from which elements can be taken. Demo: http://jsbin.com/naduvo/2/edit?html,js,output
|
||||||
|
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
|
||||||
|
#### `sort` option
|
||||||
|
Sorting inside list.
|
||||||
|
|
||||||
|
Demo: http://jsbin.com/xizeh/2/edit?html,js,output
|
||||||
|
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
|
||||||
|
#### `delay` option
|
||||||
|
Time in milliseconds to define when the sorting should start.
|
||||||
|
|
||||||
|
Demo: http://jsbin.com/xizeh/4/edit?html,js,output
|
||||||
|
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
|
||||||
|
#### `disabled` options
|
||||||
|
Disables the sortable if set to `true`.
|
||||||
|
|
||||||
|
Demo: http://jsbin.com/xiloqu/1/edit?html,js,output
|
||||||
|
|
||||||
|
```js
|
||||||
|
var sortable = Sortable.create(list);
|
||||||
|
|
||||||
|
document.getElementById("switcher").onclick = function () {
|
||||||
|
var state = sortable.option("disabled"); // get
|
||||||
|
|
||||||
|
sortable.option("disabled", !state); // set
|
||||||
|
};
|
||||||
|
```
|
||||||
|
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
|
||||||
|
#### `handle` option
|
||||||
|
To make list items draggable, Sortable disables text selection by the user.
|
||||||
|
That's not always desirable. To allow text selection, define a drag handler,
|
||||||
|
which is an area of every list element that allows it to be dragged around.
|
||||||
|
|
||||||
|
Demo: http://jsbin.com/newize/1/edit?html,js,output
|
||||||
|
|
||||||
|
```js
|
||||||
|
Sortable.create(el, {
|
||||||
|
handle: ".my-handle"
|
||||||
|
});
|
||||||
|
```
|
||||||
|
|
||||||
|
```html
|
||||||
|
<ul>
|
||||||
|
<li><span class="my-handle">::</span> list item text one
|
||||||
|
<li><span class="my-handle">::</span> list item text two
|
||||||
|
</ul>
|
||||||
|
```
|
||||||
|
|
||||||
|
```css
|
||||||
|
.my-handle {
|
||||||
|
cursor: move;
|
||||||
|
cursor: -webkit-grabbing;
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
|
||||||
|
#### `filter` option
|
||||||
|
|
||||||
|
|
||||||
|
```js
|
||||||
|
Sortable.create(list, {
|
||||||
|
filter: ".js-remove, .js-edit",
|
||||||
|
onFilter: function (evt) {
|
||||||
|
var item = evt.item,
|
||||||
|
ctrl = evt.target;
|
||||||
|
|
||||||
|
if (Sortable.utils.is(ctrl, ".js-remove")) { // Click on remove button
|
||||||
|
item.parentNode.removeChild(item); // remove sortable item
|
||||||
|
}
|
||||||
|
else if (Sortable.utils.is(ctrl, ".js-edit")) { // Click on edit link
|
||||||
|
// ...
|
||||||
|
}
|
||||||
|
}
|
||||||
|
})
|
||||||
|
```
|
||||||
|
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
|
||||||
|
#### `ghostClass` option
|
||||||
|
Class name for the drop placeholder (default `sortable-ghost`).
|
||||||
|
|
||||||
|
Demo: http://jsbin.com/hunifu/1/edit?css,js,output
|
||||||
|
|
||||||
|
```css
|
||||||
|
.ghost {
|
||||||
|
opacity: 0.4;
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
```js
|
||||||
|
Sortable.create(list, {
|
||||||
|
ghostClass: "ghost"
|
||||||
|
});
|
||||||
|
```
|
||||||
|
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
|
||||||
|
#### `chosenClass` option
|
||||||
|
Class name for the chosen item (default `sortable-chosen`).
|
||||||
|
|
||||||
|
Demo: http://jsbin.com/hunifu/edit?html,css,js,output
|
||||||
|
|
||||||
|
```css
|
||||||
|
.chosen {
|
||||||
|
color: #fff;
|
||||||
|
background-color: #c00;
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
```js
|
||||||
|
Sortable.create(list, {
|
||||||
|
delay: 500,
|
||||||
|
chosenClass: "chosen"
|
||||||
|
});
|
||||||
|
```
|
||||||
|
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
|
||||||
|
#### `forceFallback` option
|
||||||
|
If set to `true`, the Fallback for non HTML5 Browser will be used, even if we are using an HTML5 Browser.
|
||||||
|
This gives us the possiblity to test the behaviour for older Browsers even in newer Browser, or make the Drag 'n Drop feel more consistent between Desktop , Mobile and old Browsers.
|
||||||
|
|
||||||
|
On top of that, the Fallback always generates a copy of that DOM Element and appends the class `fallbackClass` definied in the options. This behaviour controls the look of this 'dragged' Element.
|
||||||
|
|
||||||
|
Demo: http://jsbin.com/pucurizace/edit?html,css,js,output
|
||||||
|
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
|
||||||
|
#### `scroll` option
|
||||||
|
If set to `true`, the page (or sortable-area) scrolls when coming to an edge.
|
||||||
|
|
||||||
|
Demo:
|
||||||
|
- `window`: http://jsbin.com/boqugumiqi/1/edit?html,js,output
|
||||||
|
- `overflow: hidden`: http://jsbin.com/kohamakiwi/1/edit?html,js,output
|
||||||
|
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
|
||||||
|
#### `scrollSensitivity` option
|
||||||
|
Defines how near the mouse must be to an edge to start scrolling.
|
||||||
|
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
|
||||||
|
#### `scrollSpeed` option
|
||||||
|
The speed at which the window should scroll once the mouse pointer gets within the `scrollSensitivity` distance.
|
||||||
|
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
|
||||||
|
<a name="ng"></a>
|
||||||
|
### Support AngularJS
|
||||||
|
Include [ng-sortable.js](ng-sortable.js)
|
||||||
|
|
||||||
|
Demo: http://jsbin.com/naduvo/1/edit?html,js,output
|
||||||
|
|
||||||
|
```html
|
||||||
|
<div ng-app="myApp" ng-controller="demo">
|
||||||
|
<ul ng-sortable>
|
||||||
|
<li ng-repeat="item in items">{{item}}</li>
|
||||||
|
</ul>
|
||||||
|
|
||||||
|
<ul ng-sortable="{ group: 'foobar' }">
|
||||||
|
<li ng-repeat="item in foo">{{item}}</li>
|
||||||
|
</ul>
|
||||||
|
|
||||||
|
<ul ng-sortable="barConfig">
|
||||||
|
<li ng-repeat="item in bar">{{item}}</li>
|
||||||
|
</ul>
|
||||||
|
</div>
|
||||||
|
```
|
||||||
|
|
||||||
|
|
||||||
|
```js
|
||||||
|
angular.module('myApp', ['ng-sortable'])
|
||||||
|
.controller('demo', ['$scope', function ($scope) {
|
||||||
|
$scope.items = ['item 1', 'item 2'];
|
||||||
|
$scope.foo = ['foo 1', '..'];
|
||||||
|
$scope.bar = ['bar 1', '..'];
|
||||||
|
$scope.barConfig = {
|
||||||
|
group: 'foobar',
|
||||||
|
animation: 150,
|
||||||
|
onSort: function (/** ngSortEvent */evt){
|
||||||
|
// @see https://github.com/RubaXa/Sortable/blob/master/ng-sortable.js#L18-L24
|
||||||
|
}
|
||||||
|
};
|
||||||
|
}]);
|
||||||
|
```
|
||||||
|
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
|
||||||
|
<a name="react"></a>
|
||||||
|
### Support React
|
||||||
|
Include [react-sortable-mixin.js](react-sortable-mixin.js).
|
||||||
|
See [more options](react-sortable-mixin.js#L26).
|
||||||
|
|
||||||
|
|
||||||
|
```jsx
|
||||||
|
var SortableList = React.createClass({
|
||||||
|
mixins: [SortableMixin],
|
||||||
|
|
||||||
|
getInitialState: function() {
|
||||||
|
return {
|
||||||
|
items: ['Mixin', 'Sortable']
|
||||||
|
};
|
||||||
|
},
|
||||||
|
|
||||||
|
handleSort: function (/** Event */evt) { /*..*/ },
|
||||||
|
|
||||||
|
render: function() {
|
||||||
|
return <ul>{
|
||||||
|
this.state.items.map(function (text) {
|
||||||
|
return <li>{text}</li>
|
||||||
|
})
|
||||||
|
}</ul>
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
React.render(<SortableList />, document.body);
|
||||||
|
|
||||||
|
|
||||||
|
//
|
||||||
|
// Groups
|
||||||
|
//
|
||||||
|
var AllUsers = React.createClass({
|
||||||
|
mixins: [SortableMixin],
|
||||||
|
|
||||||
|
sortableOptions: {
|
||||||
|
ref: "user",
|
||||||
|
group: "shared",
|
||||||
|
model: "users"
|
||||||
|
},
|
||||||
|
|
||||||
|
getInitialState: function() {
|
||||||
|
return { users: ['Abbi', 'Adela', 'Bud', 'Cate', 'Davis', 'Eric']; };
|
||||||
|
},
|
||||||
|
|
||||||
|
render: function() {
|
||||||
|
return (
|
||||||
|
<h1>Users</h1>
|
||||||
|
<ul ref="user">{
|
||||||
|
this.state.users.map(function (text) {
|
||||||
|
return <li>{text}</li>
|
||||||
|
})
|
||||||
|
}</ul>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
var ApprovedUsers = React.createClass({
|
||||||
|
mixins: [SortableMixin],
|
||||||
|
sortableOptions: { group: "shared" },
|
||||||
|
|
||||||
|
getInitialState: function() {
|
||||||
|
return { items: ['Hal', 'Judy']; };
|
||||||
|
},
|
||||||
|
|
||||||
|
render: function() {
|
||||||
|
return <ul>{
|
||||||
|
this.state.items.map(function (text) {
|
||||||
|
return <li>{text}</li>
|
||||||
|
})
|
||||||
|
}</ul>
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
React.render(<div>
|
||||||
|
<AllUsers/>
|
||||||
|
<hr/>
|
||||||
|
<ApprovedUsers/>
|
||||||
|
</div>, document.body);
|
||||||
|
```
|
||||||
|
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
|
||||||
|
<a name="ko"></a>
|
||||||
|
### Support KnockoutJS
|
||||||
|
Include [knockout-sortable.js](knockout-sortable.js)
|
||||||
|
|
||||||
|
```html
|
||||||
|
<div data-bind="sortable: {foreach: yourObservableArray, options: {/* sortable options here */}}">
|
||||||
|
<!-- optional item template here -->
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div data-bind="draggable: {foreach: yourObservableArray, options: {/* sortable options here */}}">
|
||||||
|
<!-- optional item template here -->
|
||||||
|
</div>
|
||||||
|
```
|
||||||
|
|
||||||
|
Using this bindingHandler sorts the observableArray when the user sorts the HTMLElements.
|
||||||
|
|
||||||
|
The sortable/draggable bindingHandlers supports the same syntax as Knockouts built in [template](http://knockoutjs.com/documentation/template-binding.html) binding except for the `data` option, meaning that you could supply the name of a template or specify a separate templateEngine. The difference between the sortable and draggable handlers is that the draggable has the sortable `group` option set to `{pull:'clone',put: false}` and the `sort` option set to false by default (overridable).
|
||||||
|
|
||||||
|
Other attributes are:
|
||||||
|
* options: an object that contains settings for the underlaying sortable, ie `group`,`handle`, events etc.
|
||||||
|
* collection: if your `foreach` array is a computed then you would supply the underlaying observableArray that you would like to sort here.
|
||||||
|
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
<a name="polymer"></a>
|
||||||
|
### Support Polymer
|
||||||
|
```html
|
||||||
|
|
||||||
|
<link rel="import" href="bower_components/Sortable/Sortable-js.html">
|
||||||
|
|
||||||
|
<sortable-js handle=".handle">
|
||||||
|
<template is="dom-repeat" items={{names}}>
|
||||||
|
<div>{{item}}</div>
|
||||||
|
</template>
|
||||||
|
<sortable-js>
|
||||||
|
```
|
||||||
|
|
||||||
|
### Method
|
||||||
|
|
||||||
|
|
||||||
|
##### option(name:`String`[, value:`*`]):`*`
|
||||||
|
Get or set the option.
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
##### closest(el:`String`[, selector:`HTMLElement`]):`HTMLElement|null`
|
||||||
|
For each element in the set, get the first element that matches the selector by testing the element itself and traversing up through its ancestors in the DOM tree.
|
||||||
|
|
||||||
|
|
||||||
|
##### toArray():`String[]`
|
||||||
|
Serializes the sortable's item `data-id`'s (`dataIdAttr` option) into an array of string.
|
||||||
|
|
||||||
|
|
||||||
|
##### sort(order:`String[]`)
|
||||||
|
Sorts the elements according to the array.
|
||||||
|
|
||||||
|
```js
|
||||||
|
var order = sortable.toArray();
|
||||||
|
sortable.sort(order.reverse()); // apply
|
||||||
|
```
|
||||||
|
|
||||||
|
|
||||||
|
##### save()
|
||||||
|
Save the current sorting (see [store](#store))
|
||||||
|
|
||||||
|
|
||||||
|
##### destroy()
|
||||||
|
Removes the sortable functionality completely.
|
||||||
|
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
|
||||||
|
<a name="store"></a>
|
||||||
|
### Store
|
||||||
|
Saving and restoring of the sort.
|
||||||
|
|
||||||
|
```html
|
||||||
|
<ul>
|
||||||
|
<li data-id="1">order</li>
|
||||||
|
<li data-id="2">save</li>
|
||||||
|
<li data-id="3">restore</li>
|
||||||
|
</ul>
|
||||||
|
```
|
||||||
|
|
||||||
|
```js
|
||||||
|
Sortable.create(el, {
|
||||||
|
group: "localStorage-example",
|
||||||
|
store: {
|
||||||
|
/**
|
||||||
|
* Get the order of elements. Called once during initialization.
|
||||||
|
* @param {Sortable} sortable
|
||||||
|
* @returns {Array}
|
||||||
|
*/
|
||||||
|
get: function (sortable) {
|
||||||
|
var order = localStorage.getItem(sortable.options.group);
|
||||||
|
return order ? order.split('|') : [];
|
||||||
|
},
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Save the order of elements. Called onEnd (when the item is dropped).
|
||||||
|
* @param {Sortable} sortable
|
||||||
|
*/
|
||||||
|
set: function (sortable) {
|
||||||
|
var order = sortable.toArray();
|
||||||
|
localStorage.setItem(sortable.options.group, order.join('|'));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
})
|
||||||
|
```
|
||||||
|
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
|
||||||
|
<a name="bs"></a>
|
||||||
|
### Bootstrap
|
||||||
|
Demo: http://jsbin.com/luxero/2/edit?html,js,output
|
||||||
|
|
||||||
|
```html
|
||||||
|
<!-- Latest compiled and minified CSS -->
|
||||||
|
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.1/css/bootstrap.min.css"/>
|
||||||
|
|
||||||
|
|
||||||
|
<!-- Latest Sortable -->
|
||||||
|
<script src="http://rubaxa.github.io/Sortable/Sortable.js"></script>
|
||||||
|
|
||||||
|
|
||||||
|
<!-- Simple List -->
|
||||||
|
<ul id="simpleList" class="list-group">
|
||||||
|
<li class="list-group-item">This is <a href="http://rubaxa.github.io/Sortable/">Sortable</a></li>
|
||||||
|
<li class="list-group-item">It works with Bootstrap...</li>
|
||||||
|
<li class="list-group-item">...out of the box.</li>
|
||||||
|
<li class="list-group-item">It has support for touch devices.</li>
|
||||||
|
<li class="list-group-item">Just drag some elements around.</li>
|
||||||
|
</ul>
|
||||||
|
|
||||||
|
<script>
|
||||||
|
// Simple list
|
||||||
|
Sortable.create(simpleList, { /* options */ });
|
||||||
|
</script>
|
||||||
|
```
|
||||||
|
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
|
||||||
|
### Static methods & properties
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
##### Sortable.create(el:`HTMLElement`[, options:`Object`]):`Sortable`
|
||||||
|
Create new instance.
|
||||||
|
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
|
||||||
|
##### Sortable.active:`Sortable`
|
||||||
|
Link to the active instance.
|
||||||
|
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
|
||||||
|
##### Sortable.utils
|
||||||
|
* on(el`:HTMLElement`, event`:String`, fn`:Function`) — attach an event handler function
|
||||||
|
* off(el`:HTMLElement`, event`:String`, fn`:Function`) — remove an event handler
|
||||||
|
* css(el`:HTMLElement`)`:Object` — get the values of all the CSS properties
|
||||||
|
* css(el`:HTMLElement`, prop`:String`)`:Mixed` — get the value of style properties
|
||||||
|
* css(el`:HTMLElement`, prop`:String`, value`:String`) — set one CSS properties
|
||||||
|
* css(el`:HTMLElement`, props`:Object`) — set more CSS properties
|
||||||
|
* find(ctx`:HTMLElement`, tagName`:String`[, iterator`:Function`])`:Array` — get elements by tag name
|
||||||
|
* bind(ctx`:Mixed`, fn`:Function`)`:Function` — Takes a function and returns a new one that will always have a particular context
|
||||||
|
* is(el`:HTMLElement`, selector`:String`)`:Boolean` — check the current matched set of elements against a selector
|
||||||
|
* closest(el`:HTMLElement`, selector`:String`[, ctx`:HTMLElement`])`:HTMLElement|Null` — for each element in the set, get the first element that matches the selector by testing the element itself and traversing up through its ancestors in the DOM tree
|
||||||
|
* toggleClass(el`:HTMLElement`, name`:String`, state`:Boolean`) — add or remove one classes from each element
|
||||||
|
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
|
||||||
|
<a name="cdn"></a>
|
||||||
|
### CDN
|
||||||
|
|
||||||
|
```html
|
||||||
|
<!-- CDNJS :: Sortable (https://cdnjs.com/) -->
|
||||||
|
<script src="//cdnjs.cloudflare.com/ajax/libs/Sortable/1.3.0-rc1/Sortable.min.js"></script>
|
||||||
|
|
||||||
|
|
||||||
|
<!-- jsDelivr :: Sortable (http://www.jsdelivr.com/) -->
|
||||||
|
<script src="//cdn.jsdelivr.net/sortable/1.3.0-rc1/Sortable.min.js"></script>
|
||||||
|
|
||||||
|
|
||||||
|
<!-- jsDelivr :: Sortable :: Latest (http://www.jsdelivr.com/) -->
|
||||||
|
<script src="//cdn.jsdelivr.net/sortable/latest/Sortable.min.js"></script>
|
||||||
|
```
|
||||||
|
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
|
||||||
|
<a name="jq"></a>
|
||||||
|
### jQuery compatibility
|
||||||
|
To assemble plugin for jQuery, perform the following steps:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
cd Sortable
|
||||||
|
npm install
|
||||||
|
grunt jquery
|
||||||
|
```
|
||||||
|
|
||||||
|
Now you can use `jquery.fn.sortable.js`:<br/>
|
||||||
|
(or `jquery.fn.sortable.min.js` if you run `grunt jquery:min`)
|
||||||
|
|
||||||
|
```js
|
||||||
|
$("#list").sortable({ /* options */ }); // init
|
||||||
|
|
||||||
|
$("#list").sortable("widget"); // get Sortable instance
|
||||||
|
|
||||||
|
$("#list").sortable("destroy"); // destroy Sortable instance
|
||||||
|
|
||||||
|
$("#list").sortable("{method-name}"); // call an instance method
|
||||||
|
|
||||||
|
$("#list").sortable("{method-name}", "foo", "bar"); // call an instance method with parameters
|
||||||
|
```
|
||||||
|
|
||||||
|
And `grunt jquery:mySortableFunc` → `jquery.fn.mySortableFunc.js`
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
|
||||||
|
### Contributing (Issue/PR)
|
||||||
|
|
||||||
|
Please, [read this](CONTRIBUTING.md).
|
||||||
|
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
|
||||||
|
## MIT LICENSE
|
||||||
|
Copyright 2013-2015 Lebedev Konstantin <ibnRubaXa@gmail.com>
|
||||||
|
http://rubaxa.github.io/Sortable/
|
||||||
|
|
||||||
|
Permission is hereby granted, free of charge, to any person obtaining
|
||||||
|
a copy of this software and associated documentation files (the
|
||||||
|
"Software"), to deal in the Software without restriction, including
|
||||||
|
without limitation the rights to use, copy, modify, merge, publish,
|
||||||
|
distribute, sublicense, and/or sell copies of the Software, and to
|
||||||
|
permit persons to whom the Software is furnished to do so, subject to
|
||||||
|
the following conditions:
|
||||||
|
|
||||||
|
The above copyright notice and this permission notice shall be
|
||||||
|
included in all copies or substantial portions of the Software.
|
||||||
|
|
||||||
|
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||||
|
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||||
|
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||||
|
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
||||||
|
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
||||||
|
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
||||||
|
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||||
|
|
File diff suppressed because it is too large
Load Diff
File diff suppressed because one or more lines are too long
|
@ -0,0 +1,35 @@
|
||||||
|
{
|
||||||
|
"name": "Sortable",
|
||||||
|
"main": [
|
||||||
|
"Sortable.js",
|
||||||
|
"ng-sortable.js",
|
||||||
|
"knockout-sortable.js",
|
||||||
|
"react-sortable-mixin.js"
|
||||||
|
],
|
||||||
|
"homepage": "http://rubaxa.github.io/Sortable/",
|
||||||
|
"authors": [
|
||||||
|
"RubaXa <ibnRubaXa@gmail.com>"
|
||||||
|
],
|
||||||
|
"description": "Minimalist library for reorderable drag-and-drop lists on modern browsers and touch devices. No jQuery.",
|
||||||
|
"keywords": [
|
||||||
|
"sortable",
|
||||||
|
"reorder",
|
||||||
|
"list",
|
||||||
|
"html5",
|
||||||
|
"drag",
|
||||||
|
"and",
|
||||||
|
"drop",
|
||||||
|
"dnd",
|
||||||
|
"web-components"
|
||||||
|
],
|
||||||
|
"license": "MIT",
|
||||||
|
"ignore": [
|
||||||
|
"node_modules",
|
||||||
|
"bower_components",
|
||||||
|
"test",
|
||||||
|
"tests"
|
||||||
|
],
|
||||||
|
"dependencies": {
|
||||||
|
"polymer": "Polymer/polymer#~1.1.4",
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,32 @@
|
||||||
|
{
|
||||||
|
"name": "Sortable",
|
||||||
|
"main": "Sortable.js",
|
||||||
|
"version": "1.3.0",
|
||||||
|
"homepage": "http://rubaxa.github.io/Sortable/",
|
||||||
|
"repo": "RubaXa/Sortable",
|
||||||
|
"authors": [
|
||||||
|
"RubaXa <ibnRubaXa@gmail.com>"
|
||||||
|
],
|
||||||
|
"description": "Minimalist library for reorderable drag-and-drop lists on modern browsers and touch devices. No jQuery.",
|
||||||
|
"keywords": [
|
||||||
|
"sortable",
|
||||||
|
"reorder",
|
||||||
|
"list",
|
||||||
|
"html5",
|
||||||
|
"drag",
|
||||||
|
"and",
|
||||||
|
"drop",
|
||||||
|
"dnd"
|
||||||
|
],
|
||||||
|
"license": "MIT",
|
||||||
|
"ignore": [
|
||||||
|
"node_modules",
|
||||||
|
"bower_components",
|
||||||
|
"test",
|
||||||
|
"tests"
|
||||||
|
],
|
||||||
|
|
||||||
|
"scripts": [
|
||||||
|
"Sortable.js"
|
||||||
|
]
|
||||||
|
}
|
|
@ -0,0 +1,61 @@
|
||||||
|
/**
|
||||||
|
* jQuery plugin for Sortable
|
||||||
|
* @author RubaXa <trash@rubaxa.org>
|
||||||
|
* @license MIT
|
||||||
|
*/
|
||||||
|
(function (factory) {
|
||||||
|
"use strict";
|
||||||
|
|
||||||
|
if (typeof define === "function" && define.amd) {
|
||||||
|
define(["jquery"], factory);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
/* jshint sub:true */
|
||||||
|
factory(jQuery);
|
||||||
|
}
|
||||||
|
})(function ($) {
|
||||||
|
"use strict";
|
||||||
|
|
||||||
|
|
||||||
|
/* CODE */
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* jQuery plugin for Sortable
|
||||||
|
* @param {Object|String} options
|
||||||
|
* @param {..*} [args]
|
||||||
|
* @returns {jQuery|*}
|
||||||
|
*/
|
||||||
|
$.fn.sortable = function (options) {
|
||||||
|
var retVal,
|
||||||
|
args = arguments;
|
||||||
|
|
||||||
|
this.each(function () {
|
||||||
|
var $el = $(this),
|
||||||
|
sortable = $el.data('sortable');
|
||||||
|
|
||||||
|
if (!sortable && (options instanceof Object || !options)) {
|
||||||
|
sortable = new Sortable(this, options);
|
||||||
|
$el.data('sortable', sortable);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (sortable) {
|
||||||
|
if (options === 'widget') {
|
||||||
|
return sortable;
|
||||||
|
}
|
||||||
|
else if (options === 'destroy') {
|
||||||
|
sortable.destroy();
|
||||||
|
$el.removeData('sortable');
|
||||||
|
}
|
||||||
|
else if (typeof sortable[options] === 'function') {
|
||||||
|
retVal = sortable[options].apply(sortable, [].slice.call(args, 1));
|
||||||
|
}
|
||||||
|
else if (options in sortable.options) {
|
||||||
|
retVal = sortable.option.apply(sortable, args);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
return (retVal === void 0) ? this : retVal;
|
||||||
|
};
|
||||||
|
});
|
|
@ -0,0 +1,41 @@
|
||||||
|
{
|
||||||
|
"name": "sortablejs",
|
||||||
|
"exportName": "Sortable",
|
||||||
|
"version": "1.4.0",
|
||||||
|
"devDependencies": {
|
||||||
|
"grunt": "*",
|
||||||
|
"grunt-version": "*",
|
||||||
|
"grunt-exec": "*",
|
||||||
|
"grunt-contrib-jshint": "0.9.2",
|
||||||
|
"grunt-contrib-uglify": "*",
|
||||||
|
"spacejam": "*"
|
||||||
|
},
|
||||||
|
"description": "Minimalist JavaScript library for reorderable drag-and-drop lists on modern browsers and touch devices. No jQuery. Supports AngularJS and any CSS library, e.g. Bootstrap.",
|
||||||
|
"main": "Sortable.js",
|
||||||
|
"scripts": {
|
||||||
|
"test": "grunt"
|
||||||
|
},
|
||||||
|
"repository": {
|
||||||
|
"type": "git",
|
||||||
|
"url": "git://github.com/rubaxa/Sortable.git"
|
||||||
|
},
|
||||||
|
"keywords": [
|
||||||
|
"sortable",
|
||||||
|
"reorder",
|
||||||
|
"drag",
|
||||||
|
"meteor",
|
||||||
|
"angular",
|
||||||
|
"ng-sortable",
|
||||||
|
"react",
|
||||||
|
"mixin"
|
||||||
|
],
|
||||||
|
"author": "Konstantin Lebedev <ibnRubaXa@gmail.com>",
|
||||||
|
"license": "MIT",
|
||||||
|
"spm": {
|
||||||
|
"main": "Sortable.js",
|
||||||
|
"ignore": [
|
||||||
|
"meteor",
|
||||||
|
"st"
|
||||||
|
]
|
||||||
|
}
|
||||||
|
}
|
|
@ -157,6 +157,9 @@ func buildPanelRoutes() {
|
||||||
View("routePanelThemesMenusEdit", "/panel/themes/menus/edit/", "extraData"),
|
View("routePanelThemesMenusEdit", "/panel/themes/menus/edit/", "extraData"),
|
||||||
View("routePanelThemesMenuItemEdit", "/panel/themes/menus/item/edit/", "extraData"),
|
View("routePanelThemesMenuItemEdit", "/panel/themes/menus/item/edit/", "extraData"),
|
||||||
Action("routePanelThemesMenuItemEditSubmit", "/panel/themes/menus/item/edit/submit/", "extraData"),
|
Action("routePanelThemesMenuItemEditSubmit", "/panel/themes/menus/item/edit/submit/", "extraData"),
|
||||||
|
Action("routePanelThemesMenuItemCreateSubmit", "/panel/themes/menus/item/create/submit/"),
|
||||||
|
Action("routePanelThemesMenuItemDeleteSubmit", "/panel/themes/menus/item/delete/submit/", "extraData"),
|
||||||
|
Action("routePanelThemesMenuItemOrderSubmit", "/panel/themes/menus/item/order/edit/submit/", "extraData"),
|
||||||
|
|
||||||
View("routePanelPlugins", "/panel/plugins/"),
|
View("routePanelPlugins", "/panel/plugins/"),
|
||||||
Action("routePanelPluginsActivate", "/panel/plugins/activate/", "extraData"),
|
Action("routePanelPluginsActivate", "/panel/plugins/activate/", "extraData"),
|
||||||
|
|
|
@ -9,7 +9,7 @@
|
||||||
<div class="rowitem passive"><a href="/user/edit/username/">{{lang "account_menu_username"}}</a></div>
|
<div class="rowitem passive"><a href="/user/edit/username/">{{lang "account_menu_username"}}</a></div>
|
||||||
<div class="rowitem passive"><a href="/user/edit/critical/">{{lang "account_menu_password"}}</a></div>
|
<div class="rowitem passive"><a href="/user/edit/critical/">{{lang "account_menu_password"}}</a></div>
|
||||||
<div class="rowitem passive"><a href="/user/edit/email/">{{lang "account_menu_email"}}</a></div>
|
<div class="rowitem passive"><a href="/user/edit/email/">{{lang "account_menu_email"}}</a></div>
|
||||||
<div class="rowitem passive"><a href="/user/edit/notifications">{{lang "account_menu_notifications"}}</a></div>
|
<div class="rowitem passive"><a href="/user/edit/notifications/">{{lang "account_menu_notifications"}}</a></div>
|
||||||
{{/** TODO: Add an alerts page with pagination to go through alerts which either don't fit in the alerts drop-down or which have already been dismissed. Bear in mind though that dismissed alerts older than two weeks might be purged to save space and to speed up the database **/}}
|
{{/** TODO: Add an alerts page with pagination to go through alerts which either don't fit in the alerts drop-down or which have already been dismissed. Bear in mind though that dismissed alerts older than two weeks might be purged to save space and to speed up the database **/}}
|
||||||
</div>
|
</div>
|
||||||
</nav>
|
</nav>
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
{{template "header.html" . }}
|
{{template "header.html" . }}
|
||||||
<div class="colstack panel_stack">
|
<div class="colstack panel_stack">
|
||||||
<nav class="colstack_left" aria-label="Theme manager menu">
|
<nav class="colstack_left" aria-label="Control panel menu">
|
||||||
<div class="colstack_item colstack_head">
|
<div class="colstack_item colstack_head">
|
||||||
<div class="rowitem"><a href="/panel/themes/">Theme Manager</a></div>
|
<div class="rowitem"><a href="/panel/themes/">Theme Manager</a></div>
|
||||||
</div>
|
</div>
|
||||||
|
@ -16,14 +16,135 @@
|
||||||
<div class="colstack_item colstack_head">
|
<div class="colstack_item colstack_head">
|
||||||
<div class="rowitem"><h1>{{lang "panel_themes_menus_head"}}</h1></div>
|
<div class="rowitem"><h1>{{lang "panel_themes_menus_head"}}</h1></div>
|
||||||
</div>
|
</div>
|
||||||
<div id="panel_settings" class="colstack_item rowlist">
|
<div id="panel_menu_item_holder" class="colstack_item rowlist">
|
||||||
{{range .ItemList}}
|
{{range .ItemList}}
|
||||||
<div class="rowitem panel_compactrow editable_parent">
|
<div class="panel_menu_item rowitem panel_compactrow editable_parent" data-miid="{{.ID}}">
|
||||||
<a href="/panel/themes/menus/item/edit/{{.ID}}" class="editable_block panel_upshift">{{.Name}}</a>
|
<a href="/panel/themes/menus/item/edit/{{.ID}}" class="editable_block panel_upshift">{{.Name}}</a>
|
||||||
<a class="panel_compacttext to_right">...</a>
|
<span class="panel_buttons">
|
||||||
|
<a href="/panel/themes/menus/item/edit/{{.ID}}" class="panel_tag panel_right_button edit_button" aria-label="{{lang "panel_themes_menus_item_edit_button_aria"}}"></a>
|
||||||
|
<a href="/panel/themes/menus/item/delete/submit/{{.ID}}?session={{$.CurrentUser.Session}}" class="panel_tag panel_right_button delete_button" aria-label="{{lang "panel_themes_menus_item_delete_button_aria"}}"></a>
|
||||||
|
</span>
|
||||||
|
</div>{{end}}
|
||||||
</div>
|
</div>
|
||||||
{{end}}
|
<div class="colstack_item rowlist panel_submitrow">
|
||||||
|
<div class="rowitem"><button id="panel_menu_items_order_button" class="formbutton">Update</button></div>
|
||||||
</div>
|
</div>
|
||||||
|
<div class="colstack_item colstack_head">
|
||||||
|
<div class="rowitem"><h1>{{lang "panel_themes_menus_create_head"}}</h1></div>
|
||||||
|
</div>
|
||||||
|
<form action="/panel/themes/menus/item/create/submit/?session={{.CurrentUser.Session}}" method="post">
|
||||||
|
<input name="mid" value="{{.MenuID}}" type="hidden" />
|
||||||
|
<div id="panel_themes_menu_item_create" class="colstack_item">
|
||||||
|
{{/** TODO: Let an admin move a menu item from one menu to another? **/}}
|
||||||
|
<div class="formrow">
|
||||||
|
<div class="formitem formlabel"><a>{{lang "panel_themes_menus_name"}}</a></div>
|
||||||
|
<div class="formitem"><input name="item-name" type="text" placeholder="{{lang "panel_themes_menus_name_placeholder"}}" /></div>
|
||||||
|
</div>
|
||||||
|
<div class="formrow">
|
||||||
|
<div class="formitem formlabel"><a>{{lang "panel_themes_menus_htmlid"}}</a></div>
|
||||||
|
<div class="formitem"><input name="item-htmlid" type="text" /></div>
|
||||||
|
</div>
|
||||||
|
<div class="formrow">
|
||||||
|
<div class="formitem formlabel"><a>{{lang "panel_themes_menus_cssclass"}}</a></div>
|
||||||
|
<div class="formitem"><input name="item-cssclass" type="text" /></div>
|
||||||
|
</div>
|
||||||
|
<div class="formrow">
|
||||||
|
<div class="formitem formlabel"><a>{{lang "panel_themes_menus_position"}}</a></div>
|
||||||
|
<div class="formitem">
|
||||||
|
<select name="item-position">
|
||||||
|
<option selected value="left">left</option>
|
||||||
|
<option value="right">right</option>
|
||||||
|
</select>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="formrow">
|
||||||
|
<div class="formitem formlabel"><a>{{lang "panel_themes_menus_path"}}</a></div>
|
||||||
|
<div class="formitem"><input name="item-path" type="text" value="/" /></div>
|
||||||
|
</div>
|
||||||
|
<div class="formrow">
|
||||||
|
<div class="formitem formlabel"><a>{{lang "panel_themes_menus_aria"}}</a></div>
|
||||||
|
<div class="formitem"><input name="item-aria" type="text" placeholder="{{lang "panel_themes_menus_aria_placeholder"}}" /></div>
|
||||||
|
</div>
|
||||||
|
<div class="formrow">
|
||||||
|
<div class="formitem formlabel"><a>{{lang "panel_themes_menus_tooltip"}}</a></div>
|
||||||
|
<div class="formitem"><input name="item-tooltip" type="text" placeholder="{{lang "panel_themes_menus_tooltip_placeholder"}}" /></div>
|
||||||
|
</div>
|
||||||
|
<div class="formrow">
|
||||||
|
<div class="formitem formlabel"><a>{{lang "panel_themes_menus_permissions"}}</a></div>
|
||||||
|
<div class="formitem"><select name="item-permissions">
|
||||||
|
<option selected value="everyone">{{lang "panel_themes_menus_everyone" }}</option>
|
||||||
|
<option value="guest-only">{{lang "panel_themes_menus_guestonly"}}</option>
|
||||||
|
<option value="member-only">{{lang "panel_themes_menus_memberonly"}}</option>
|
||||||
|
<option value="supermod-only">{{lang "panel_themes_menus_supermodonly"}}</option>
|
||||||
|
<option value="admin-only">{{lang "panel_themes_menus_adminonly"}}</option>
|
||||||
|
</select></div>
|
||||||
|
</div>
|
||||||
|
<div class="formrow">
|
||||||
|
<div class="formitem"><button name="panel-button" class="formbutton">{{lang "panel_themes_menus_create_button"}}</button></div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</form>
|
||||||
</main>
|
</main>
|
||||||
</div>
|
</div>
|
||||||
|
<script type="text/javascript">
|
||||||
|
var menuItems = {};
|
||||||
|
let items = document.getElementsByClassName("panel_menu_item");
|
||||||
|
//console.log("items: ", items);
|
||||||
|
for(let i = 0; item = items[i];i++) {
|
||||||
|
let miid = item.getAttribute("data-miid");
|
||||||
|
//console.log("miid: ", miid);
|
||||||
|
menuItems[i] = miid;
|
||||||
|
}
|
||||||
|
Sortable.create(document.getElementById("panel_menu_item_holder"), {
|
||||||
|
sort: true,
|
||||||
|
onEnd: (evt) => {
|
||||||
|
console.log("pre menuItems: ", menuItems)
|
||||||
|
console.log("evt: ", evt)
|
||||||
|
let oldMiid = menuItems[evt.newIndex];
|
||||||
|
menuItems[evt.oldIndex] = oldMiid;
|
||||||
|
let newMiid = evt.item.getAttribute("data-miid");
|
||||||
|
console.log("newMiid: ", newMiid)
|
||||||
|
menuItems[evt.newIndex] = newMiid;
|
||||||
|
console.log("post menuItems: ", menuItems)
|
||||||
|
}
|
||||||
|
});
|
||||||
|
document.getElementById("panel_menu_items_order_button").addEventListener("click", () => {
|
||||||
|
let req = new XMLHttpRequest();
|
||||||
|
if(!req) {
|
||||||
|
console.log("Failed to create request");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
req.onreadystatechange = () => {
|
||||||
|
try {
|
||||||
|
if(req.readyState!==XMLHttpRequest.DONE) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
// TODO: Signal the error with a notice
|
||||||
|
if(req.status===200) {
|
||||||
|
let resp = JSON.parse(req.responseText);
|
||||||
|
console.log("resp: ", resp);
|
||||||
|
if(resp.success==1) {
|
||||||
|
// TODO: Have a successfully updated notice
|
||||||
|
console.log("success");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} catch(ex) {
|
||||||
|
console.error("exception: ", ex)
|
||||||
|
}
|
||||||
|
console.trace();
|
||||||
|
}
|
||||||
|
// ? - Is encodeURIComponent the right function for this?
|
||||||
|
req.open("POST","/panel/themes/menus/item/order/edit/submit/{{.MenuID}}?session=" + encodeURIComponent(session));
|
||||||
|
req.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
|
||||||
|
let items = "";
|
||||||
|
for(let i = 0; item = menuItems[i];i++) {
|
||||||
|
items += item+",";
|
||||||
|
}
|
||||||
|
if(items.length > 0) {
|
||||||
|
items = items.slice(0,-1);
|
||||||
|
}
|
||||||
|
req.send("js=1&items={"+items+"}");
|
||||||
|
});
|
||||||
|
</script>
|
||||||
{{template "footer.html" . }}
|
{{template "footer.html" . }}
|
||||||
|
|
|
@ -180,6 +180,19 @@
|
||||||
content: "{{index .Phrases "panel_perms_default" }}";
|
content: "{{index .Phrases "panel_perms_default" }}";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.panel_submitrow .rowitem {
|
||||||
|
display: flex;
|
||||||
|
}
|
||||||
|
.panel_submitrow .rowitem *:first-child {
|
||||||
|
margin-left: auto;
|
||||||
|
}
|
||||||
|
.panel_submitrow .rowitem *:last-child {
|
||||||
|
margin-right: auto;
|
||||||
|
}
|
||||||
|
.panel_submitrow .rowitem button {
|
||||||
|
margin-top: 0px;
|
||||||
|
}
|
||||||
|
|
||||||
.colstack_graph_holder {
|
.colstack_graph_holder {
|
||||||
background-color: var(--element-background-color);
|
background-color: var(--element-background-color);
|
||||||
border: 1px solid var(--element-border-color);
|
border: 1px solid var(--element-border-color);
|
||||||
|
|
|
@ -68,6 +68,20 @@
|
||||||
padding-right: 2px;
|
padding-right: 2px;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.panel_submitrow {
|
||||||
|
display: flex;
|
||||||
|
}
|
||||||
|
.panel_submitrow *:first-child {
|
||||||
|
margin-left: auto;
|
||||||
|
}
|
||||||
|
.panel_submitrow *:last-child {
|
||||||
|
margin-right: auto;
|
||||||
|
}
|
||||||
|
.panel_submitrow button {
|
||||||
|
padding-top: 5px;
|
||||||
|
padding-bottom: 5px;
|
||||||
|
}
|
||||||
|
|
||||||
.colstack_graph_holder {
|
.colstack_graph_holder {
|
||||||
background-color: var(--main-block-color);
|
background-color: var(--main-block-color);
|
||||||
padding: 10px;
|
padding: 10px;
|
||||||
|
|
|
@ -102,6 +102,9 @@
|
||||||
padding-left: 2px;
|
padding-left: 2px;
|
||||||
padding-right: 2px;
|
padding-right: 2px;
|
||||||
}
|
}
|
||||||
|
.colstack_item + .panel_submitrow {
|
||||||
|
margin-bottom: 0px;
|
||||||
|
}
|
||||||
|
|
||||||
.ct_chart {
|
.ct_chart {
|
||||||
padding-left: 10px;
|
padding-left: 10px;
|
||||||
|
|
|
@ -118,9 +118,8 @@
|
||||||
display: none;
|
display: none;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* TODO: Figure out how to handle this on the Control Panel */
|
.colstack_item + .panel_submitrow {
|
||||||
.footer {
|
margin-bottom: 0px;
|
||||||
display: none;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#panel_word_filters .itemSeparator:before {
|
#panel_word_filters .itemSeparator:before {
|
||||||
|
|
Loading…
Reference in New Issue