2017-11-10 03:33:11 +00:00
package common
import (
2022-02-21 03:53:13 +00:00
"html/template"
"net/http"
"runtime"
"sync"
"time"
2018-11-01 06:43:56 +00:00
2022-02-21 03:53:13 +00:00
p "git.tuxpa.in/a/gosora/common/phrases"
2017-11-10 03:33:11 +00:00
)
2019-04-02 07:43:11 +00:00
/ * type HResource struct {
2022-02-21 03:32:53 +00:00
Name string
Hash string
2019-04-02 07:43:11 +00:00
} * /
2019-03-21 22:59:41 +00:00
2019-08-14 10:39:04 +00:00
// TODO: Allow resources in spots other than /s/ and possibly even external domains (e.g. CDNs)
2018-04-04 04:49:13 +00:00
// TODO: Preload Trumboyg on Cosora on the forum list
2018-04-22 12:33:56 +00:00
type Header struct {
2022-02-21 03:32:53 +00:00
Title string
//Title []byte // Experimenting with []byte for increased efficiency, let's avoid converting too many things to []byte, as it involves a lot of extra boilerplate
NoticeList [ ] string
Scripts [ ] HScript
PreScriptsAsync [ ] HScript
ScriptsAsync [ ] HScript
//Preload []string
Stylesheets [ ] HScript
Widgets PageWidgets
Site * site
Settings SettingMap
//Themes map[string]*Theme // TODO: Use a slice containing every theme instead of the main map for speed?
ThemesSlice [ ] * Theme
Theme * Theme
//TemplateName string // TODO: Use this to move template calls to the router rather than duplicating them over and over and over?
CurrentUser * User // TODO: Deprecate CurrentUser on the page structs and use a pointer here
Hooks * HookTable
Zone string
ZoneID int
ZoneData interface { }
Path string
MetaDesc string
//OGImage string
OGDesc string
GoogSiteVerify string
IsoCode string
LooseCSP bool
ExternalMedia bool
//StartedAt time.Time
StartedAt int64
Elapsed1 string
Writer http . ResponseWriter
ExtData ExtData
2017-11-10 03:33:11 +00:00
}
2020-07-31 05:33:29 +00:00
type HScript struct {
2022-02-21 03:32:53 +00:00
Name string
Hash string
2020-07-31 05:33:29 +00:00
}
func ( h * Header ) getScript ( name string ) HScript {
2022-02-21 03:32:53 +00:00
if name [ 0 ] == '/' && name [ 1 ] == '/' {
} else {
file , ok := StaticFiles . GetShort ( name )
if ok {
return HScript { file . OName , file . Sha256I }
}
}
return HScript { name , "" }
2020-07-31 05:33:29 +00:00
}
func ( h * Header ) AddScript ( name string ) {
2022-02-21 03:32:53 +00:00
//log.Print("name:", name)
h . Scripts = append ( h . Scripts , h . getScript ( name ) )
2018-04-04 04:49:13 +00:00
}
2019-08-14 10:39:04 +00:00
func ( h * Header ) AddPreScriptAsync ( name string ) {
2022-02-21 03:32:53 +00:00
h . PreScriptsAsync = append ( h . PreScriptsAsync , h . getScript ( name ) )
2019-03-21 22:59:41 +00:00
}
2019-08-14 10:39:04 +00:00
func ( h * Header ) AddScriptAsync ( name string ) {
2022-02-21 03:32:53 +00:00
h . ScriptsAsync = append ( h . ScriptsAsync , h . getScript ( name ) )
2019-02-28 07:28:17 +00:00
}
2019-08-14 10:39:04 +00:00
/ * func ( h * Header ) Preload ( name string ) {
2022-02-21 03:32:53 +00:00
h . Preload = append ( h . Preload , name )
2018-04-04 04:49:13 +00:00
} * /
2019-08-14 10:39:04 +00:00
func ( h * Header ) AddSheet ( name string ) {
2022-02-21 03:32:53 +00:00
h . Stylesheets = append ( h . Stylesheets , h . getScript ( name ) )
2018-04-04 04:49:13 +00:00
}
2020-03-13 02:56:23 +00:00
// ! Experimental
func ( h * Header ) AddXRes ( names ... string ) {
2022-02-21 03:32:53 +00:00
var o string
for i , name := range names {
if name [ 0 ] == '/' && name [ 1 ] == '/' {
} else {
file , ok := StaticFiles . GetShort ( name )
if ok {
name = file . OName
}
}
if i != 0 {
o += "," + name
} else {
o += name
}
}
h . Writer . Header ( ) . Set ( "X-Res" , o )
2020-03-13 02:56:23 +00:00
}
2019-08-14 10:39:04 +00:00
func ( h * Header ) AddNotice ( name string ) {
2022-02-21 03:32:53 +00:00
h . NoticeList = append ( h . NoticeList , p . GetNoticePhrase ( name ) )
2018-06-06 00:21:22 +00:00
}
2017-11-10 03:33:11 +00:00
// TODO: Add this to routes which don't use templates. E.g. Json APIs.
type HeaderLite struct {
2022-02-21 03:32:53 +00:00
Site * site
Settings SettingMap
Hooks * HookTable
ExtData ExtData
2017-11-10 03:33:11 +00:00
}
type PageWidgets struct {
2022-02-21 03:32:53 +00:00
LeftSidebar template . HTML
RightSidebar template . HTML
2017-11-10 03:33:11 +00:00
}
// TODO: Add a ExtDataHolder interface with methods for manipulating the contents?
// ? - Could we use a sync.Map instead?
type ExtData struct {
2022-02-21 03:32:53 +00:00
Items map [ string ] interface { } // Key: pluginname
sync . RWMutex
2017-11-10 03:33:11 +00:00
}
type Page struct {
2022-02-21 03:32:53 +00:00
* Header
ItemList [ ] interface { }
Something interface { }
2018-06-06 00:21:22 +00:00
}
type SimplePage struct {
2022-02-21 03:32:53 +00:00
* Header
2018-06-06 00:21:22 +00:00
}
type ErrorPage struct {
2022-02-21 03:32:53 +00:00
* Header
Message string
2017-11-10 03:33:11 +00:00
}
2018-04-22 12:33:56 +00:00
type Paginator struct {
2022-02-21 03:32:53 +00:00
PageList [ ] int
Page int
LastPage int
2018-04-22 12:33:56 +00:00
}
2021-01-18 22:11:30 +00:00
type PaginatorMod struct {
2022-02-21 03:32:53 +00:00
Params template . URL
PageList [ ] int
Page int
LastPage int
2021-01-18 22:11:30 +00:00
}
2018-06-06 00:21:22 +00:00
type CustomPagePage struct {
2022-02-21 03:32:53 +00:00
* Header
Page * CustomPage
2018-06-06 00:21:22 +00:00
}
2019-04-11 05:46:57 +00:00
type TopicCEditPost struct {
2022-02-21 03:32:53 +00:00
ID int
Source string
Ref string
2019-04-11 05:46:57 +00:00
}
2019-04-15 01:54:13 +00:00
type TopicCAttachItem struct {
2022-02-21 03:32:53 +00:00
ID int
ImgSrc string
Path string
FullPath string
2019-04-15 01:54:13 +00:00
}
2019-06-16 07:26:31 +00:00
type TopicCPollInput struct {
2022-02-21 03:32:53 +00:00
Index int
Place string
2019-06-16 07:26:31 +00:00
}
2019-04-11 05:46:57 +00:00
2017-11-10 03:33:11 +00:00
type TopicPage struct {
2022-02-21 03:32:53 +00:00
* Header
ItemList [ ] * ReplyUser
Topic TopicUser
Forum * Forum
Poll * Poll
Paginator
2017-11-10 03:33:11 +00:00
}
2018-09-20 08:56:50 +00:00
type TopicListSort struct {
2022-02-21 03:32:53 +00:00
SortBy string // lastupdate, mostviewed, mostviewedtoday, mostviewedthisweek, mostviewedthismonth
Ascending bool
2018-09-20 08:56:50 +00:00
}
2020-07-19 03:26:56 +00:00
type QuickTools struct {
2022-02-21 03:32:53 +00:00
CanDelete bool
CanLock bool
CanMove bool
2020-07-19 03:26:56 +00:00
}
2018-04-22 12:33:56 +00:00
type TopicListPage struct {
2022-02-21 03:32:53 +00:00
* Header
TopicList [ ] TopicsRowMut
ForumList [ ] Forum
DefaultForum int
Sort TopicListSort
SelectedFids [ ] int
QuickTools
Paginator
2017-11-10 03:33:11 +00:00
}
type ForumPage struct {
2022-02-21 03:32:53 +00:00
* Header
ItemList [ ] TopicsRowMut
Forum * Forum
CanLock bool
CanMove bool
Paginator
2017-11-10 03:33:11 +00:00
}
type ForumsPage struct {
2022-02-21 03:32:53 +00:00
* Header
ItemList [ ] Forum
2017-11-10 03:33:11 +00:00
}
type ProfilePage struct {
2022-02-21 03:32:53 +00:00
* Header
ItemList [ ] * ReplyUser
ProfileOwner User
CurrentScore int
NextScore int
Blocked bool
CanMessage bool
CanComment bool
ShowComments bool
2017-11-10 03:33:11 +00:00
}
type CreateTopicPage struct {
2022-02-21 03:32:53 +00:00
* Header
ItemList [ ] Forum
FID int
2017-11-10 03:33:11 +00:00
}
type IPSearchPage struct {
2022-02-21 03:32:53 +00:00
* Header
ItemList map [ int ] * User
IP string
2017-11-10 03:33:11 +00:00
}
2020-08-15 02:44:08 +00:00
// WIP: Optional anti-bot methods
type RegisterVerifyImageGridImage struct {
2022-02-21 03:32:53 +00:00
Src string
2020-08-15 02:44:08 +00:00
}
type RegisterVerifyImageGrid struct {
2022-02-21 03:32:53 +00:00
Question string
Items [ ] RegisterVerifyImageGridImage
2020-08-15 02:44:08 +00:00
}
type RegisterVerify struct {
2022-02-21 03:32:53 +00:00
NoScript bool
2020-08-15 02:44:08 +00:00
2022-02-21 03:32:53 +00:00
Image * RegisterVerifyImageGrid
2020-08-15 02:44:08 +00:00
}
2020-06-19 06:38:32 +00:00
type RegisterPage struct {
2022-02-21 03:32:53 +00:00
* Header
RequireEmail bool
Token string
Verify [ ] RegisterVerify
2020-06-19 06:38:32 +00:00
}
2018-12-17 04:58:55 +00:00
type Account struct {
2022-02-21 03:32:53 +00:00
* Header
HTMLID string
TmplName string
Inner nobreak
2018-12-17 04:58:55 +00:00
}
2018-05-27 09:36:35 +00:00
type EmailListPage struct {
2022-02-21 03:32:53 +00:00
* Header
ItemList [ ] Email
2018-12-17 04:58:55 +00:00
}
type AccountLoginsPage struct {
2022-02-21 03:32:53 +00:00
* Header
ItemList [ ] LoginLogItem
Paginator
2018-05-27 09:36:35 +00:00
}
2019-11-12 06:17:46 +00:00
type AccountBlocksPage struct {
2022-02-21 03:32:53 +00:00
* Header
Users [ ] * User
Paginator
2019-11-12 06:17:46 +00:00
}
2019-12-08 03:40:56 +00:00
type AccountPrivacyPage struct {
2022-02-21 03:32:53 +00:00
* Header
ProfileComments int
ReceiveConvos int
EnableEmbeds bool
2019-12-08 03:40:56 +00:00
}
2018-06-17 07:28:18 +00:00
type AccountDashPage struct {
2022-02-21 03:32:53 +00:00
* Header
MFASetup bool
CurrentScore int
NextScore int
NextLevel int
Percentage int
2018-06-17 07:28:18 +00:00
}
2018-10-10 07:33:51 +00:00
type LevelListItem struct {
2022-02-21 03:32:53 +00:00
Level int
Score int
Status string
Percentage int // 0 to 200 to fit with the CSS logic
2018-10-10 07:33:51 +00:00
}
type LevelListPage struct {
2022-02-21 03:32:53 +00:00
* Header
Levels [ ] LevelListItem
2018-10-10 07:33:51 +00:00
}
2019-03-11 08:47:45 +00:00
type ResetPage struct {
2022-02-21 03:32:53 +00:00
* Header
UID int
Token string
MFA bool
2019-03-11 08:47:45 +00:00
}
2020-02-12 09:11:27 +00:00
type ConvoListRow struct {
2022-02-21 03:32:53 +00:00
* ConversationExtra
ShortUsers [ ] * User
OneOnOne bool
2020-02-12 09:11:27 +00:00
}
2019-07-26 23:29:42 +00:00
type ConvoListPage struct {
2022-02-21 03:32:53 +00:00
* Header
Convos [ ] ConvoListRow
Paginator
2019-07-26 23:29:42 +00:00
}
2019-08-14 10:39:04 +00:00
type ConvoViewRow struct {
2022-02-21 03:32:53 +00:00
* ConversationPost
User * User
ClassName string
ContentLines int
2019-10-18 00:35:13 +00:00
2022-02-21 03:32:53 +00:00
CanModify bool
2019-08-14 10:39:04 +00:00
}
2019-07-26 23:29:42 +00:00
type ConvoViewPage struct {
2022-02-21 03:32:53 +00:00
* Header
Convo * Conversation
Posts [ ] ConvoViewRow
Users [ ] * User
CanReply bool
Paginator
2019-07-26 23:29:42 +00:00
}
type ConvoCreatePage struct {
2022-02-21 03:32:53 +00:00
* Header
RecpName string
2019-07-26 23:29:42 +00:00
}
2019-04-29 01:28:55 +00:00
/* WIP for dyntmpl */
type Panel struct {
2022-02-21 03:32:53 +00:00
* BasePanelPage
HTMLID string
ClassNames string
TmplName string
Inner nobreak
2019-04-29 01:28:55 +00:00
}
2019-04-29 06:11:26 +00:00
type PanelAnalytics struct {
2022-02-21 03:32:53 +00:00
* BasePanelPage
FormAction string
TmplName string
Inner nobreak
2019-04-29 06:11:26 +00:00
}
2019-05-13 09:17:44 +00:00
type PanelAnalyticsStd struct {
2022-02-21 03:32:53 +00:00
Graph PanelTimeGraph
ViewItems [ ] PanelAnalyticsItem
TimeRange string
Unit string
TimeType string
2019-04-29 06:11:26 +00:00
}
2019-05-13 09:17:44 +00:00
type PanelAnalyticsStdUnit struct {
2022-02-21 03:32:53 +00:00
Graph PanelTimeGraph
ViewItems [ ] PanelAnalyticsItemUnit
TimeRange string
Unit string
TimeType string
2019-05-01 06:59:51 +00:00
}
2019-05-19 01:01:11 +00:00
type PanelAnalyticsActiveMemory struct {
2022-02-21 03:32:53 +00:00
Graph PanelTimeGraph
ViewItems [ ] PanelAnalyticsItemUnit
TimeRange string
Unit string
TimeType string
MemType int
2019-05-19 01:01:11 +00:00
}
2020-02-23 09:08:47 +00:00
type PanelAnalyticsPerf struct {
2022-02-21 03:32:53 +00:00
Graph PanelTimeGraph
ViewItems [ ] PanelAnalyticsItemUnit
TimeRange string
Unit string
TimeType string
PerfType int
2020-02-23 09:08:47 +00:00
}
2019-04-29 01:28:55 +00:00
2017-11-10 03:33:11 +00:00
type PanelStats struct {
2022-02-21 03:32:53 +00:00
Users int
Groups int
Forums int
Pages int
Settings int
WordFilters int
Themes int
Reports int
2017-11-10 03:33:11 +00:00
}
2018-06-06 00:21:22 +00:00
type BasePanelPage struct {
2022-02-21 03:32:53 +00:00
* Header
Stats PanelStats
Zone string
ReportForumID int
DebugAdmin bool
2018-06-06 00:21:22 +00:00
}
2017-11-10 03:33:11 +00:00
type PanelPage struct {
2022-02-21 03:32:53 +00:00
* BasePanelPage
ItemList [ ] interface { }
Something interface { }
2017-11-10 03:33:11 +00:00
}
type GridElement struct {
2022-02-21 03:32:53 +00:00
ID string
Href string
Body string
Order int // For future use
Class string
Background string
TextColour string
Note string
2017-11-10 03:33:11 +00:00
}
2019-06-03 05:26:27 +00:00
type DashGrids struct {
2022-02-21 03:32:53 +00:00
Grid1 [ ] GridElement
Grid2 [ ] GridElement
2019-06-03 05:26:27 +00:00
}
2017-11-10 03:33:11 +00:00
type PanelDashboardPage struct {
2022-02-21 03:32:53 +00:00
* BasePanelPage
Grids DashGrids
2017-11-10 03:33:11 +00:00
}
2018-05-27 09:36:35 +00:00
type PanelSetting struct {
2022-02-21 03:32:53 +00:00
* Setting
FriendlyName string
2018-05-27 09:36:35 +00:00
}
2019-11-06 02:00:44 +00:00
type PanelSettingPage struct {
2022-02-21 03:32:53 +00:00
* BasePanelPage
ItemList [ ] OptionLabel
Setting * PanelSetting
2019-11-06 02:00:44 +00:00
}
2018-05-27 09:36:35 +00:00
2019-11-04 23:49:37 +00:00
type PanelUserEditPage struct {
2022-02-21 03:32:53 +00:00
* BasePanelPage
Groups [ ] * Group
User * User
ShowEmail bool
2019-11-04 23:49:37 +00:00
}
2018-06-06 00:21:22 +00:00
type PanelCustomPagesPage struct {
2022-02-21 03:32:53 +00:00
* BasePanelPage
ItemList [ ] * CustomPage
Paginator
2018-06-06 00:21:22 +00:00
}
type PanelCustomPageEditPage struct {
2022-02-21 03:32:53 +00:00
* BasePanelPage
Page * CustomPage
2018-06-06 00:21:22 +00:00
}
2019-02-23 06:29:19 +00:00
/ * type PanelTimeGraph struct {
2022-02-21 03:32:53 +00:00
Series [ ] int64 // The counts on the left
Labels [ ] int64 // unixtimes for the bottom, gets converted into 1:00, 2:00, etc. with JS
2019-02-23 06:29:19 +00:00
} * /
type PanelTimeGraph struct {
2022-02-21 03:32:53 +00:00
Series [ ] [ ] int64 // The counts on the left
Labels [ ] int64 // unixtimes for the bottom, gets converted into 1:00, 2:00, etc. with JS
Legends [ ] string
2018-01-03 07:46:18 +00:00
}
2018-01-08 08:53:51 +00:00
type PanelAnalyticsItem struct {
2022-02-21 03:32:53 +00:00
Time int64
Count int64
2018-01-08 08:53:51 +00:00
}
2019-05-01 06:59:51 +00:00
type PanelAnalyticsItemUnit struct {
2022-02-21 03:32:53 +00:00
Time int64
Count int64
Unit string
2019-05-01 06:59:51 +00:00
}
2018-01-08 08:53:51 +00:00
2018-01-03 07:46:18 +00:00
type PanelAnalyticsPage struct {
2022-02-21 03:32:53 +00:00
* BasePanelPage
Graph PanelTimeGraph
ViewItems [ ] PanelAnalyticsItem
TimeRange string
Unit string
TimeType string
2018-01-03 07:46:18 +00:00
}
2018-01-04 10:23:33 +00:00
type PanelAnalyticsRoutesItem struct {
2022-02-21 03:32:53 +00:00
Route string
Count int
2018-01-04 10:23:33 +00:00
}
type PanelAnalyticsRoutesPage struct {
2022-02-21 03:32:53 +00:00
* BasePanelPage
ItemList [ ] PanelAnalyticsRoutesItem
Graph PanelTimeGraph
TimeRange string
2018-01-05 22:47:13 +00:00
}
2018-01-09 07:39:29 +00:00
2020-02-28 04:52:45 +00:00
type PanelAnalyticsRoutesPerfItem struct {
2022-02-21 03:32:53 +00:00
Route string
Count int
Unit string
2020-02-28 04:52:45 +00:00
}
type PanelAnalyticsRoutesPerfPage struct {
2022-02-21 03:32:53 +00:00
* BasePanelPage
ItemList [ ] PanelAnalyticsRoutesPerfItem
Graph PanelTimeGraph
TimeRange string
2020-02-28 04:52:45 +00:00
}
2019-02-24 01:29:06 +00:00
// TODO: Rename the fields as this structure is being used in a generic way now
2018-01-09 07:39:29 +00:00
type PanelAnalyticsAgentsItem struct {
2022-02-21 03:32:53 +00:00
Agent string
FriendlyAgent string
Count int
2018-01-09 07:39:29 +00:00
}
type PanelAnalyticsAgentsPage struct {
2022-02-21 03:32:53 +00:00
* BasePanelPage
ItemList [ ] PanelAnalyticsAgentsItem
TimeRange string
2018-01-09 07:39:29 +00:00
}
2018-01-05 22:47:13 +00:00
2019-05-18 00:33:35 +00:00
type PanelAnalyticsReferrersPage struct {
2022-02-21 03:32:53 +00:00
* BasePanelPage
ItemList [ ] PanelAnalyticsAgentsItem
TimeRange string
ShowSpam bool
2019-05-18 00:33:35 +00:00
}
2018-01-05 22:47:13 +00:00
type PanelAnalyticsRoutePage struct {
2022-02-21 03:32:53 +00:00
* BasePanelPage
Route string
Graph PanelTimeGraph
ViewItems [ ] PanelAnalyticsItem
TimeRange string
2018-01-04 10:23:33 +00:00
}
2018-01-10 03:32:48 +00:00
type PanelAnalyticsAgentPage struct {
2022-02-21 03:32:53 +00:00
* BasePanelPage
Agent string
FriendlyAgent string
Graph PanelTimeGraph
TimeRange string
2018-01-10 03:32:48 +00:00
}
2019-02-23 06:29:19 +00:00
type PanelAnalyticsDuoPage struct {
2022-02-21 03:32:53 +00:00
* BasePanelPage
ItemList [ ] PanelAnalyticsAgentsItem
Graph PanelTimeGraph
TimeRange string
2019-02-23 06:29:19 +00:00
}
2017-11-10 03:33:11 +00:00
type PanelThemesPage struct {
2022-02-21 03:32:53 +00:00
* BasePanelPage
PrimaryThemes [ ] * Theme
VariantThemes [ ] * Theme
2017-11-10 03:33:11 +00:00
}
2018-05-11 05:41:51 +00:00
type PanelMenuListItem struct {
2022-02-21 03:32:53 +00:00
Name string
ID int
ItemCount int
2018-05-11 05:41:51 +00:00
}
type PanelMenuListPage struct {
2022-02-21 03:32:53 +00:00
* BasePanelPage
ItemList [ ] PanelMenuListItem
2018-05-11 05:41:51 +00:00
}
2019-01-21 12:27:59 +00:00
type PanelWidgetListPage struct {
2022-02-21 03:32:53 +00:00
* BasePanelPage
Docks map [ string ] [ ] WidgetEdit
BlankWidget WidgetEdit
2019-01-21 12:27:59 +00:00
}
2018-05-11 05:41:51 +00:00
type PanelMenuPage struct {
2022-02-21 03:32:53 +00:00
* BasePanelPage
MenuID int
ItemList [ ] MenuItem
2018-05-11 05:41:51 +00:00
}
type PanelMenuItemPage struct {
2022-02-21 03:32:53 +00:00
* BasePanelPage
Item MenuItem
2018-05-11 05:41:51 +00:00
}
2021-01-18 22:11:30 +00:00
type PanelUserPageSearch struct {
2022-02-21 03:32:53 +00:00
Name string
Email string
Group int
2021-01-19 23:47:08 +00:00
2022-02-21 03:32:53 +00:00
Any bool
2021-01-18 22:11:30 +00:00
}
2017-11-10 03:33:11 +00:00
type PanelUserPage struct {
2022-02-21 03:32:53 +00:00
* BasePanelPage
ItemList [ ] * User
Groups [ ] * Group
Search PanelUserPageSearch
PaginatorMod
2017-11-10 03:33:11 +00:00
}
type PanelGroupPage struct {
2022-02-21 03:32:53 +00:00
* BasePanelPage
ItemList [ ] GroupAdmin
Paginator
2017-11-10 03:33:11 +00:00
}
type PanelEditGroupPage struct {
2022-02-21 03:32:53 +00:00
* BasePanelPage
ID int
Name string
Tag string
Rank string
DisableRank bool
2017-11-10 03:33:11 +00:00
}
type GroupForumPermPreset struct {
2022-02-21 03:32:53 +00:00
Group * Group
Preset string
DefaultPreset bool
2017-11-10 03:33:11 +00:00
}
type PanelEditForumPage struct {
2022-02-21 03:32:53 +00:00
* BasePanelPage
ID int
Name string
Desc string
Active bool
Preset string
Groups [ ] GroupForumPermPreset
Actions [ ] * ForumActionAction
2021-04-07 14:23:11 +00:00
}
type ForumActionAction struct {
2022-02-21 03:32:53 +00:00
* ForumAction
ActionName string
2017-11-10 03:33:11 +00:00
}
type NameLangToggle struct {
2022-02-21 03:32:53 +00:00
Name string
LangStr string
Toggle bool
2017-11-10 03:33:11 +00:00
}
2018-01-10 03:32:48 +00:00
type PanelEditForumGroupPage struct {
2022-02-21 03:32:53 +00:00
* BasePanelPage
ForumID int
GroupID int
Name string
Desc string
Active bool
Preset string
Perms [ ] NameLangToggle
2018-01-10 03:32:48 +00:00
}
2017-11-10 03:33:11 +00:00
type PanelEditGroupPermsPage struct {
2022-02-21 03:32:53 +00:00
* BasePanelPage
ID int
Name string
LocalPerms [ ] NameLangToggle
GlobalPerms [ ] NameLangToggle
ModPerms [ ] NameLangToggle
2017-11-10 03:33:11 +00:00
}
2019-09-29 04:56:39 +00:00
type GroupPromotionExtend struct {
2022-02-21 03:32:53 +00:00
* GroupPromotion
FromGroup * Group
ToGroup * Group
2019-09-29 04:56:39 +00:00
}
type PanelEditGroupPromotionsPage struct {
2022-02-21 03:32:53 +00:00
* BasePanelPage
ID int
Name string
Promotions [ ] * GroupPromotionExtend
Groups [ ] * Group
2019-09-29 04:56:39 +00:00
}
2017-11-11 04:06:16 +00:00
type BackupItem struct {
2022-02-21 03:32:53 +00:00
SQLURL string
2017-11-10 03:33:11 +00:00
2022-02-21 03:32:53 +00:00
// TODO: Add an easier to parse format here for Gosora to be able to more easily reimport portions of the dump and to strip unnecessary data (e.g. table defs and parsed post data)
2017-11-10 03:33:11 +00:00
2022-02-21 03:32:53 +00:00
Timestamp time . Time
2017-11-10 03:33:11 +00:00
}
type PanelBackupPage struct {
2022-02-21 03:32:53 +00:00
* BasePanelPage
Backups [ ] BackupItem
2017-11-10 03:33:11 +00:00
}
2018-05-16 10:46:14 +00:00
type PageLogItem struct {
2022-02-21 03:32:53 +00:00
Action template . HTML
IP string
DoneAt string
2017-11-10 03:33:11 +00:00
}
type PanelLogsPage struct {
2022-02-21 03:32:53 +00:00
* BasePanelPage
Logs [ ] PageLogItem
Paginator
2018-05-16 10:46:14 +00:00
}
type PageRegLogItem struct {
2022-02-21 03:32:53 +00:00
RegLogItem
ParsedReason string
2018-05-16 10:46:14 +00:00
}
type PanelRegLogsPage struct {
2022-02-21 03:32:53 +00:00
* BasePanelPage
Logs [ ] PageRegLogItem
Paginator
2017-11-10 03:33:11 +00:00
}
2020-02-23 09:08:47 +00:00
type DebugPageTasks struct {
2022-02-21 03:32:53 +00:00
HalfSecond int
Second int
FifteenMinute int
Hour int
Day int
Shutdown int
2020-02-23 09:08:47 +00:00
}
2019-06-01 12:31:48 +00:00
type DebugPageCache struct {
2022-02-21 03:32:53 +00:00
Topics int
Users int
Replies int
2019-06-01 12:31:48 +00:00
2022-02-21 03:32:53 +00:00
TCap int
UCap int
RCap int
2019-06-01 12:31:48 +00:00
2022-02-21 03:32:53 +00:00
TopicListThaw bool
2019-06-01 12:31:48 +00:00
}
type DebugPageDatabase struct {
2022-02-21 03:32:53 +00:00
Topics int
Users int
Replies int
ProfileReplies int
ActivityStream int
Likes int
Attachments int
Polls int
LoginLogs int
RegLogs int
ModLogs int
AdminLogs int
Views int
ViewsAgents int
ViewsForums int
ViewsLangs int
ViewsReferrers int
ViewsSystems int
PostChunks int
TopicChunks int
2019-06-01 12:31:48 +00:00
}
type DebugPageDisk struct {
2022-02-21 03:32:53 +00:00
Static int
Attachments int
Avatars int
Logs int
Backups int
Git int
2019-06-01 12:31:48 +00:00
}
2017-11-10 03:33:11 +00:00
type PanelDebugPage struct {
2022-02-21 03:32:53 +00:00
* BasePanelPage
GoVersion string
DBVersion string
Uptime string
2018-08-16 05:27:26 +00:00
2022-02-21 03:32:53 +00:00
DBConns int
DBAdapter string
2018-08-16 05:27:26 +00:00
2022-02-21 03:32:53 +00:00
Goroutines int
CPUs int
HttpConns int
2019-05-13 09:17:44 +00:00
2022-02-21 03:32:53 +00:00
Tasks DebugPageTasks
MemStats runtime . MemStats
Cache DebugPageCache
Database DebugPageDatabase
Disk DebugPageDisk
2017-11-10 03:33:11 +00:00
}
2021-05-04 11:14:48 +00:00
type PanelTaskTask struct {
2022-02-21 03:32:53 +00:00
Name string
Type int // 0 = halfsec, 1 = sec, 2 = fifteenmin, 3 = hour, 4 = shutdown
2021-01-02 21:46:24 +00:00
}
2021-05-04 11:14:48 +00:00
type PanelTaskType struct {
2022-02-21 03:32:53 +00:00
Name string
FAvg string
2021-05-04 11:14:48 +00:00
}
type PanelTaskPage struct {
2022-02-21 03:32:53 +00:00
* BasePanelPage
Tasks [ ] PanelTaskTask
Types [ ] PanelTaskType
2021-01-02 21:46:24 +00:00
}
2017-11-10 03:33:11 +00:00
type PageSimple struct {
2022-02-21 03:32:53 +00:00
Title string
Something interface { }
2017-11-10 03:33:11 +00:00
}
type AreYouSure struct {
2022-02-21 03:32:53 +00:00
URL string
Message string
2017-11-10 03:33:11 +00:00
}
// TODO: Write a test for this
2020-08-20 22:18:54 +00:00
func DefaultHeader ( w http . ResponseWriter , u * User ) * Header {
2022-02-21 03:32:53 +00:00
return & Header { Site : Site , Theme : Themes [ fallbackTheme ] , CurrentUser : u , Writer : w }
2017-11-10 03:33:11 +00:00
}
2019-01-21 12:27:59 +00:00
func SimpleDefaultHeader ( w http . ResponseWriter ) * Header {
2022-02-21 03:32:53 +00:00
return & Header { Site : Site , Theme : Themes [ fallbackTheme ] , CurrentUser : & GuestUser , Writer : w }
2019-01-21 12:27:59 +00:00
}