forked from uadmin/uadmin
-
Notifications
You must be signed in to change notification settings - Fork 0
/
global.go
197 lines (131 loc) · 3.64 KB
/
global.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
package uadmin
import (
"regexp"
)
// Constants
// cPOST post
const cPOST = "POST"
// cID true
const cID = "id"
// cTRUE true
const cTRUE = "true"
// cJPG jpg
const cJPG = "jpg"
// cJPEG jpeg
const cJPEG = "jpeg"
// cPNG png
const cPNG = "png"
// cGIF gif
const cGIF = "gif"
// cSTRING !
const cSTRING = "string"
// cNUMBER !
const cNUMBER = "number"
// cDATE !
const cDATE = "date"
// cBOOL !
const cBOOL = "bool"
// cLIST !
const cLIST = "list"
// cIMAGE !
const cIMAGE = "image"
// cFK !
const cFK = "fk"
// cLINK !
const cLINK = "link"
// cMONRY !
const cMONEY = "money"
// cCODE !
const cCODE = "code"
// cHTML !
const cHTML = "html"
// cMULTILINGUAL !
const cMULTILINGUAL = "multilingual"
// cPROGRESSBAR !
const cPROGRESSBAR = "progress_bar"
// cPASSWORD !
const cPASSWORD = "password"
// cFILE !
const cFILE = "file"
// cEMAIL !
const cEMAIL = "email"
// cM2M !
const cM2M = "m2m"
// Version number as per Semantic Versioning 2.0.0 (semver.org)
const Version = "0.1.0-rc.1"
// Public Global Variables
// DefaultLang is the default language of the system
var defaultLang Language
// Theme is the name of the theme used in uAdmin
var Theme = "default"
// SiteName is the name of the website that shows on title and dashboard
var SiteName = "uAdmin"
// ReportingLevel is the standard reporting level
var ReportingLevel = DEBUG
// ReportTimeStamp set this to true to hav a time stamp in your logs
var ReportTimeStamp = false
// DebugDB prints all SQL statements going to DB
var DebugDB = false
// Schema is the gblobal schema of the system
var Schema map[string]ModelSchema
// PageLength is the list view max number of records
var PageLength = 100
// MaxImageHeight !
var MaxImageHeight = 600
// MaxImageWidth !
var MaxImageWidth = 800
// MaxUploadFileSize is the maximum upload file size in bytes
var MaxUploadFileSize = int64(25 * 1024 * 1024)
// BindIP is the IP the application listens to
var BindIP = ""
// Port is the port used for http or https server
var Port = 8080
// EmailFrom email from
var EmailFrom string
// EmailUsername !
var EmailUsername string
// EmailPassword !
var EmailPassword string
// EmailSMTPServer !
var EmailSMTPServer string
// EmailSMTPServerPort !
var EmailSMTPServerPort int
// RootURL is where the listener is mapped to
var RootURL = "/"
// OTPAlgorithm is the hashing algorithm of OTP
var OTPAlgorithm = "sha1"
// OTPDigits is the number of degits for the OTP
var OTPDigits = 6
// OTPPeriod is the number of seconds for the OTP to change
var OTPPeriod = uint(30)
// OTPSkew is the number of minutes to search around the OTP
var OTPSkew = uint(5)
// PublicMedia allows public access to media handler without authentication
var PublicMedia = false
// EncryptKey is a key for encyption and decryption of data in the DB
var EncryptKey = []byte{}
// LogDelete adds a log when a record is deleted
var LogDelete = true
// LogAdd adds a log when a record is added
var LogAdd = true
// LogEdit adds a log when a record is edited
var LogEdit = true
// LogRead adds a log when a record is read
var LogRead = false
// Private Global Variables
// Regex
var matchFirstCap = regexp.MustCompile("(.)([A-Z][a-z]+)")
var matchAllCap = regexp.MustCompile("([a-z0-9])([A-Z])")
// Global active languages
var activeLangs []Language
// Models is where we keep all registered models
var models map[string]interface{}
// Inlines is where we keep all registered models' inlines
var inlines map[string][]interface{}
// ForeignKeys is the link between models' and their inlines
var foreignKeys map[string]map[string]string
// Menu ?
var menu []interface{}
var registered = false
var handlersRegistered = false
var defaultProgressBarColor = "#07c"