-
Notifications
You must be signed in to change notification settings - Fork 18
/
globals.go
165 lines (154 loc) · 6 KB
/
globals.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
package W
import (
"os"
"github.com/kokizzu/gotro/M"
)
var Mailers map[string]*SmtpConfig // used in mailer.go
var Webmasters M.SS // used in engine.go
var Sessions SessionConnector // from session.go
var Globals SessionConnector // from session.go
var Routes map[string]Action
var Assets [][2]string // []{{`js css /js /css`,`filename`}, ...}
var Filters []Action
const PUBLIC_SUBDIR = `public/`
const VIEWS_SUBDIR = `views/`
const LOG_SUBDIR = `logs/`
var MIME2EXT = map[string]string{
`application/pdf`: `pdf`,
`image/png`: `png`,
`image/jpeg`: `jpg`,
`application/zip`: `zip`, // any open document format (odf) are also zip
}
// supported by youtube
var YOUTUBE_MIME2EXT = map[string]string{
`video/x-flv`: `flv`,
`video/mp4`: `mp4`,
`video/quicktime`: `mov`,
`video/x-msvideo`: `avi`,
`video/x-ms-wmv`: `wmv`,
`video/webm`: `webm`,
`video/3gpp`: `3gp`,
`video/mp2p`: `mpegps`,
`video/mp1s`: `mpegps`,
}
var YOUTUBE_MIME_LIST []string
func init() {
YOUTUBE_MIME_LIST = []string{}
for k, v := range YOUTUBE_MIME2EXT {
MIME2EXT[k] = v
YOUTUBE_MIME_LIST = append(YOUTUBE_MIME_LIST, k)
}
}
var Errors = map[int]string{
0: `Unknown Error`,
500: `Internal Server Error`,
404: `Page Not Found`,
403: `Forbidden`,
503: `Server is Overloaded`,
}
var DEFAULT_FILEDIR_PERM = os.FileMode(0755)
// locals: error_code, error_title, error_detail, project_name, requested_path, webmaster
const ERROR_DEFAULT_CONTENT = `
<div class="pusher" id="vm" style="text-align: center">
<div style="display: inline-block;">
<div class="ui message">
<div class="header">
Error #{error_code}: #{error_title}
</div>
</div>
<div class="ui grid">
<div class="ui sixteen wide centered column active" style="min-height: 200px">
<div class="eight wide centered column">
</div>
<div class="ui success message">
<div class="header">
#{requested_path}
</div>
<div class="detail">
#{error_detail}
</div>
</div>
<div class="ui negative message">
<div class="header">
<p id="err403" style="display:none">It's forbidden for you to access this page (insufficient privilege), either contact the #{webmaster} or
try again. Use your browser's <b>Back</b> button to navigate to the page you have previously come from</p>
<p id="err404" style="display:none">The page you requested could not be found, either contact the #{webmaster} or try again. Use your
browser's <b>Back</b> button to navigate to the page you have previously come from</p>
<p id="err" style="display:none">There is a possible programming mistake on this page, either contact the #{webmaster} or try again. Use
your browser's <b>Back</b> button to navigate to the page you have previously come from</p>
<p id="err503" style="display:none">Server is overloaded, please wait 2 minutes then try again by clicking your browser's <b>Refresh</b>
button (F5/Ctrl+R)</p>
<button class="ui blue button" onclick="window.history.back()">
<i class="glyphicon glyphicon-arrow-left"></i> Take Me Back
</button>
<button class="ui orange button" onclick="window.location='/'">
<i class="glyphicon glyphicon-home"></i> Take Me Home
</button>
</div>
</div>
<script>
var code = '#{error_code}';
if( code != '404' && code != '403' && code != '503' ) code = '';
document.getElementById('err'+code).style.display = 'block'
</script>
</div>
</div>
<hr/>
<div class="ui message">
<div class="header">
© <script>document.write(new Date().getFullYear())</script> #{project_name}
</div>
</div>
</div>
</div>
`
// locals: title, project_name, assets, contents, is_superadmin, debug_mode
const LAYOUT_DEFAULT_CONTENT = `
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>#{title} | #{project_name}</title>
<!--
<meta name="apple-mobile-web-app-capable" content="yes">
<meta name="apple-mobile-web-app-status-bar-style" content="black">
<link rel="apple-touch-icon" sizes="57x57" href="/apple-icon-57x57.png">
<link rel="apple-touch-icon" sizes="60x60" href="/apple-icon-60x60.png">
<link rel="apple-touch-icon" sizes="72x72" href="/apple-icon-72x72.png">
<link rel="apple-touch-icon" sizes="76x76" href="/apple-icon-76x76.png">
<link rel="apple-touch-icon" sizes="114x114" href="/apple-icon-114x114.png">
<link rel="apple-touch-icon" sizes="120x120" href="/apple-icon-120x120.png">
<link rel="apple-touch-icon" sizes="144x144" href="/apple-icon-144x144.png">
<link rel="apple-touch-icon" sizes="152x152" href="/apple-icon-152x152.png">
<link rel="apple-touch-icon" sizes="180x180" href="/apple-icon-180x180.png">
<link rel="icon" type="image/png" sizes="192x192" href="/android-icon-192x192.png">
<link rel="icon" type="image/png" sizes="32x32" href="/favicon-32x32.png">
<link rel="icon" type="image/png" sizes="96x96" href="/favicon-96x96.png">
<link rel="icon" type="image/png" sizes="16x16" href="/favicon-16x16.png">
-->
<link rel="manifest" href="/manifest.json">
<!--
<meta name="msapplication-TileColor" content="#ffffff">
<meta name="msapplication-TileImage" content="/ms-icon-144x144.png">
-->
<meta name="theme-color" content="#ffffff">
</head>
<body onload="_loaded()" style="width:100%; height: 100%; overflow-x: visible">
<div id='_backdrop'
style="position:absolute;top:0;left:0;width:100%;height:100%;z-index:10;text-align:center;vertical-align:middle;background-color:rgba(0, 0, 0, 0.5);">
<img src='/img/horizontal-loading.gif'/><br/>Loading scripts, please wait..
</div>
#{assets}
<script>
var is_superadmin = '#{is_superadmin}'=='true';
var debug_mode = '#{debug_mode}'=='true';
function _loaded() {$( '#_backdrop' ).remove();}
</script>
<noscript>Please enable Javascript or use Javascript-enabled browser.</noscript>
#{contents}
<!-- </body></html> anti telkom ad-inject -->
</body>
</html>
`