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