-
Notifications
You must be signed in to change notification settings - Fork 0
/
admin.go
784 lines (670 loc) · 21.9 KB
/
admin.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
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
package admin
import (
"bytes"
_ "embed"
"encoding/json"
"html/template"
"log"
"net/http"
"net/url"
"reflect"
textTemplate "text/template"
"github.com/evanw/esbuild/pkg/api"
"github.com/admin-golang/admin/dataloader"
"github.com/admin-golang/admin/icon"
"github.com/admin-golang/admin/layout"
"github.com/admin-golang/admin/menu"
"github.com/admin-golang/admin/navigation"
"github.com/admin-golang/admin/state"
)
//go:embed templates/materialUI.tsx
var materialUIJSXTemplateText string
//go:embed templates/antDesignUI.tsx
var antDesignUIJSXTemplateText string
type UITheme int8
const (
MaterialUI UITheme = iota + 1
AntDesignUI
)
type FieldType uint
const (
InputPassword FieldType = iota
InputText
InputFile
InputNumber
InputCents
InputMulti
InputCheckbox
InputSelect
)
type PageType uint
const (
DashboardPage PageType = iota
SideFormPage
ListPage
FormPage
EditPage
UploadPage
CardListPage
)
type Field struct {
ID string `json:"id"`
Label string `json:"label"`
Type FieldType `json:"type"`
IsRequired bool
FullWidth bool `json:"fullWidth"`
Value string
IsMultiline bool
NumberOfRows int
Fields Fields
Width int `json:"width"`
Disabled bool
}
type Fields []Field
type Pager interface {
IsDefault() bool
ID() string
URL() string
Type() PageType
Icon() icon.Icon
ToolbarEnabled() bool
NavTabs() navigation.NavTabs
Navigation() *navigation.Navigation
PageHeader() *PageHeader
}
type Page struct {
page page
Header *PageHeader
}
type PageHeader struct {
ID string
FieldName string
}
type PageConfig struct {
ID string
Icon icon.Icon
IsDefault bool
ToolbarEnabled bool
Type PageType
URL string
NavTabs navigation.NavTabs
Navigation *navigation.Navigation
Header *PageHeader
}
type OnListRowClick struct {
RedirectURL string
}
type ListRowConfig struct {
DataRowFieldName string
ParamKey string
OnClick *OnListRowClick
}
type PaginationConfig struct {
RowsPerPage int
}
type ListSearchConfig struct {
InputPlaceholder string
InputID string
}
type ListPageConfig struct {
PageConfig
MainButton *MainButton
Title string
DataLoader *dataloader.DataLoader
Pagination *PaginationConfig
ListRowConfig *ListRowConfig
SearchConfig *ListSearchConfig
}
type EditPageConfig struct {
PageConfig
ParamKey string
DataLoader *dataloader.DataLoader
Form Form
}
func NewPage(p PageConfig) Pager {
page := page{
icon: p.Icon,
id: p.ID,
isDefault: p.IsDefault,
toolbarEnabled: p.ToolbarEnabled,
ttype: p.Type,
url: p.URL,
navTabs: p.NavTabs,
navigation: p.Navigation,
header: p.Header,
}
return &Page{page: page, Header: p.Header}
}
type page struct {
icon icon.Icon
id string
isDefault bool
toolbarEnabled bool
ttype PageType
url string
navTabs navigation.NavTabs
navigation *navigation.Navigation
header *PageHeader
}
func (p *Page) Icon() icon.Icon { return p.page.icon }
func (p *Page) ID() string { return p.page.id }
func (p *Page) IsDefault() bool { return p.page.isDefault }
func (p *Page) ToolbarEnabled() bool { return p.page.toolbarEnabled }
func (p *Page) Type() PageType { return p.page.ttype }
func (p *Page) URL() string { return p.page.url }
func (p *Page) NavTabs() navigation.NavTabs { return p.page.navTabs }
func (p *Page) Navigation() *navigation.Navigation { return p.page.navigation }
func (p *Page) PageHeader() *PageHeader { return p.page.header }
type MainButton struct {
Label string
URL string
}
type LListPage struct {
page page
MainButton *MainButton
Title string
DataLoader *dataloader.DataLoader
Pagination *PaginationConfig
ListRowConfig *ListRowConfig
SearchConfig *ListSearchConfig
Header *PageHeader
}
func (p *LListPage) Icon() icon.Icon { return p.page.icon }
func (p *LListPage) ID() string { return p.page.id }
func (p *LListPage) IsDefault() bool { return p.page.isDefault }
func (p *LListPage) ToolbarEnabled() bool { return p.page.toolbarEnabled }
func (p *LListPage) Type() PageType { return p.page.ttype }
func (p *LListPage) URL() string { return p.page.url }
func (p *LListPage) NavTabs() navigation.NavTabs { return p.page.navTabs }
func (p *LListPage) Navigation() *navigation.Navigation { return p.page.navigation }
func (p *LListPage) PageHeader() *PageHeader { return p.page.header }
func NewListPage(p ListPageConfig) Pager {
page := page{
icon: p.Icon,
id: p.ID,
isDefault: p.IsDefault,
toolbarEnabled: p.ToolbarEnabled,
ttype: p.Type,
url: p.URL,
navTabs: p.NavTabs,
header: p.Header,
navigation: p.Navigation,
}
return &LListPage{
page: page,
MainButton: p.MainButton,
Title: p.Title,
DataLoader: p.DataLoader,
ListRowConfig: p.ListRowConfig,
SearchConfig: p.SearchConfig,
Pagination: p.Pagination,
Header: p.Header,
}
}
type CardListPageConfig struct {
PageConfig
ParamKey string
MainButton *MainButton
Title string
DataLoader *dataloader.DataLoader
Pagination *PaginationConfig
ListRowConfig *ListRowConfig
Form *Form
}
type CCardListPage struct {
page page
ParamKey string
MainButton *MainButton
Title string
DataLoader *dataloader.DataLoader
Pagination *PaginationConfig
ListRowConfig *ListRowConfig
Header *PageHeader
Form *Form
}
func (p *CCardListPage) Icon() icon.Icon { return p.page.icon }
func (p *CCardListPage) ID() string { return p.page.id }
func (p *CCardListPage) IsDefault() bool { return p.page.isDefault }
func (p *CCardListPage) ToolbarEnabled() bool { return p.page.toolbarEnabled }
func (p *CCardListPage) Type() PageType { return p.page.ttype }
func (p *CCardListPage) URL() string { return p.page.url }
func (p *CCardListPage) NavTabs() navigation.NavTabs { return p.page.navTabs }
func (p *CCardListPage) Navigation() *navigation.Navigation { return p.page.navigation }
func (p *CCardListPage) PageHeader() *PageHeader { return p.page.header }
func NewCardListPage(p CardListPageConfig) Pager {
page := page{
icon: p.Icon,
id: p.ID,
isDefault: p.IsDefault,
toolbarEnabled: p.ToolbarEnabled,
ttype: p.Type,
url: p.URL,
navTabs: p.NavTabs,
navigation: p.Navigation,
header: p.Header,
}
return &CCardListPage{page: page, MainButton: p.MainButton, Title: p.Title, DataLoader: p.DataLoader, ListRowConfig: p.ListRowConfig, Pagination: p.Pagination, ParamKey: p.ParamKey, Header: p.Header, Form: p.Form}
}
type EEditPage struct {
page page
DataLoader *dataloader.DataLoader
Form Form
Header *PageHeader
}
func (p *EEditPage) Icon() icon.Icon { return p.page.icon }
func (p *EEditPage) ID() string { return p.page.id }
func (p *EEditPage) IsDefault() bool { return p.page.isDefault }
func (p *EEditPage) ToolbarEnabled() bool { return p.page.toolbarEnabled }
func (p *EEditPage) Type() PageType { return p.page.ttype }
func (p *EEditPage) URL() string { return p.page.url }
func (p *EEditPage) NavTabs() navigation.NavTabs { return p.page.navTabs }
func (p *EEditPage) Navigation() *navigation.Navigation { return p.page.navigation }
func (p *EEditPage) PageHeader() *PageHeader { return p.page.header }
func NewEditPage(p EditPageConfig) Pager {
page := page{
icon: p.Icon,
id: p.ID,
ttype: p.Type,
url: p.URL,
navTabs: p.NavTabs,
header: p.Header,
navigation: p.Navigation,
toolbarEnabled: p.ToolbarEnabled,
}
return &EEditPage{page: page, Form: p.Form, DataLoader: p.DataLoader, Header: p.Header}
}
type UUploadPage struct {
page page
ParamKey string
DataLoader *dataloader.DataLoader
Form Form
Header *PageHeader
}
func (p *UUploadPage) Icon() icon.Icon { return p.page.icon }
func (p *UUploadPage) ID() string { return p.page.id }
func (p *UUploadPage) IsDefault() bool { return p.page.isDefault }
func (p *UUploadPage) ToolbarEnabled() bool { return p.page.toolbarEnabled }
func (p *UUploadPage) Type() PageType { return p.page.ttype }
func (p *UUploadPage) URL() string { return p.page.url }
func (p *UUploadPage) NavTabs() navigation.NavTabs { return p.page.navTabs }
func (p *UUploadPage) Navigation() *navigation.Navigation { return p.page.navigation }
func (p *UUploadPage) PageHeader() *PageHeader { return p.page.header }
type UploadPageConfig struct {
PageConfig
ParamKey string
DataLoader *dataloader.DataLoader
Form Form
}
func NewUploadPage(p UploadPageConfig) Pager {
page := page{
icon: p.Icon,
id: p.ID,
ttype: p.Type,
url: p.URL,
navTabs: p.NavTabs,
header: p.Header,
navigation: p.Navigation,
toolbarEnabled: p.ToolbarEnabled,
}
return &UUploadPage{page: page, Form: p.Form, DataLoader: p.DataLoader, ParamKey: p.ParamKey, Header: p.Header}
}
type SSideFormPage struct {
page page
Form Form
BackgroundImage *url.URL
FooterLabel string
}
func (p *SSideFormPage) Icon() icon.Icon { return p.page.icon }
func (p *SSideFormPage) ID() string { return p.page.id }
func (p *SSideFormPage) IsDefault() bool { return p.page.isDefault }
func (p *SSideFormPage) ToolbarEnabled() bool { return p.page.toolbarEnabled }
func (p *SSideFormPage) Type() PageType { return p.page.ttype }
func (p *SSideFormPage) URL() string { return p.page.url }
func (p *SSideFormPage) NavTabs() navigation.NavTabs { return p.page.navTabs }
func (p *SSideFormPage) Navigation() *navigation.Navigation { return p.page.navigation }
func (p *SSideFormPage) PageHeader() *PageHeader { return p.page.header }
type SideFormPageConfig struct {
PageConfig
Form Form
BackgroundImage *url.URL
FooterLabel string
}
func NewSideFormPage(p SideFormPageConfig) Pager {
page := page{
icon: p.Icon,
id: p.ID,
isDefault: p.IsDefault,
toolbarEnabled: p.ToolbarEnabled,
ttype: p.Type,
url: p.URL,
navTabs: p.NavTabs,
header: p.Header,
navigation: p.Navigation,
}
return &SSideFormPage{
page: page,
Form: p.Form,
BackgroundImage: p.BackgroundImage,
FooterLabel: p.FooterLabel,
}
}
type FFormPage struct {
page page
Form Form
}
func (p *FFormPage) Icon() icon.Icon { return p.page.icon }
func (p *FFormPage) ID() string { return p.page.id }
func (p *FFormPage) IsDefault() bool { return p.page.isDefault }
func (p *FFormPage) ToolbarEnabled() bool { return p.page.toolbarEnabled }
func (p *FFormPage) Type() PageType { return p.page.ttype }
func (p *FFormPage) URL() string { return p.page.url }
func (p *FFormPage) NavTabs() navigation.NavTabs { return p.page.navTabs }
func (p *FFormPage) Navigation() *navigation.Navigation { return p.page.navigation }
func (p *FFormPage) PageHeader() *PageHeader { return p.page.header }
type FormPageConfig struct {
PageConfig
Form Form
}
func NewFormPage(p FormPageConfig) Pager {
page := page{
icon: p.Icon,
id: p.ID,
isDefault: p.IsDefault,
toolbarEnabled: p.ToolbarEnabled,
ttype: p.Type,
url: p.URL,
navTabs: p.NavTabs,
header: p.Header,
navigation: p.Navigation,
}
return &FFormPage{page: page, Form: p.Form}
}
type Pages []Pager
type Submit struct {
Label string `json:"label"`
URL string `json:"url"`
SearchParams *navigation.SearchParams `json:"searchParams"`
Method string `json:"method"`
Header *Header `json:"header"`
OnSuccess *OnSubmitSuccess `json:"onSuccess"`
}
type Header struct {
Key string `json:"key"`
Value HeaderValue `json:"value"`
}
type HeaderValue struct {
Prefix string `json:"prefix"`
AppStateFieldPath string `json:"appStateFieldPath"`
}
type RedirectURL struct {
URL string `json:"url"`
SearchParams *navigation.SearchParams `json:"searchParams"`
}
type OnSubmitSuccess struct {
SetAppState bool
SetAppStateFieldName string
RedirectURL *RedirectURL `json:"redirectUrl"`
}
type Form struct {
Navigation *navigation.Navigation
Fields Fields `json:"fields"`
ID string `json:"id"`
Submit Submit `json:"submit"`
Title string
}
type Config struct {
DebugMode bool
Layout *layout.Layout
UITheme UITheme
Pages Pages
JSXTemplateText *string
AdminTemplateText *string
}
type (
Admin interface {
ServeHTTP(w http.ResponseWriter, r *http.Request)
}
admin struct {
debugMode bool
layout *layout.Layout
pages Pages
uiTheme UITheme
jsxTemplateText string
adminTemplateText string
}
)
func newTemplate(name string) *textTemplate.Template {
return textTemplate.New(name).Delims("[[", "]]")
}
func (ad *admin) ServeHTTP(w http.ResponseWriter, r *http.Request) {
isNotNil := func(val interface{}) bool {
return !reflect.ValueOf(val).IsNil()
}
wrap := func(ID string, label string, isRequired bool, value string, fullWidth bool, isMultiline bool, numberOfRows int) map[string]interface{} {
return map[string]interface{}{
"ID": ID,
"label": label,
"isRequired": isRequired,
"value": value,
"fullWidth": fullWidth,
"isMultiline": isMultiline,
"numberOfRows": numberOfRows,
}
}
wrapPage := func(layout *layout.Layout, page Pager, pages Pages) map[string]interface{} {
return map[string]interface{}{
"layout": layout,
"page": page,
"pages": pages,
"inputTypes": map[string]interface{}{
"inputCents": InputCents,
"inputMulti": InputMulti,
"inputCheckbox": InputCheckbox,
"inputSelect": InputSelect,
},
}
}
wrapComponent := func() map[string]interface{} {
return map[string]interface{}{
"inputTypes": map[string]interface{}{
"inputCents": InputCents,
"inputMulti": InputMulti,
"inputCheckbox": InputCheckbox,
},
}
}
wrapMenuIcons := func(menu *menu.Menu) map[string]interface{} {
return map[string]interface{}{
"menu": menu,
}
}
wrapListPage := func(page Pager) *LListPage {
return page.(*LListPage)
}
wrapCardListPage := func(page Pager) *CCardListPage {
return page.(*CCardListPage)
}
wrapEditPage := func(page Pager) *EEditPage {
return page.(*EEditPage)
}
wrapUploadPage := func(page Pager) *UUploadPage {
return page.(*UUploadPage)
}
marshal := func(v interface{}) template.JS {
d, _ := json.Marshal(v)
return template.JS(d)
}
jsxTemplate, err := newTemplate("JSX").Funcs(textTemplate.FuncMap{
"IsNotNil": isNotNil,
"Wrap": wrap,
"WrapPage": wrapPage,
"WrapMenuIcons": wrapMenuIcons,
"WrapListPage": wrapListPage,
"WrapCardListPage": wrapCardListPage,
"WrapEditPage": wrapEditPage,
"WrapUploadPage": wrapUploadPage,
"WrapComponent": wrapComponent,
"Marshal": marshal,
}).Parse(ad.jsxTemplateText)
if err != nil {
log.Printf("failed to parse TSX template: %v", err)
http.Error(w, err.Error(), http.StatusInternalServerError)
return
}
var jsxWriter bytes.Buffer
jsxData := struct {
Layout *layout.Layout
Pages Pages
DashboardPage PageType
SideFormPage PageType
ListPage PageType
CardListPage PageType
FormPage PageType
EditPage PageType
UploadPage PageType
RedirectAction state.ActionType
ClearAppStateAction state.ActionType
AccountCircleIcon icon.IconType
NotificationsIcon icon.IconType
PeopleIcon icon.IconType
SettingsIcon icon.IconType
SellIcon icon.IconType
InventoryIcon icon.IconType
DashboardIcon icon.IconType
}{
Layout: ad.layout,
Pages: ad.pages,
DashboardPage: DashboardPage,
SideFormPage: SideFormPage,
ListPage: ListPage,
CardListPage: CardListPage,
FormPage: FormPage,
EditPage: EditPage,
UploadPage: UploadPage,
RedirectAction: state.Redirect,
ClearAppStateAction: state.ClearAppState,
AccountCircleIcon: icon.AccountCircle,
NotificationsIcon: icon.Notifications,
PeopleIcon: icon.People,
SettingsIcon: icon.Settings,
SellIcon: icon.Sell,
InventoryIcon: icon.Inventory,
DashboardIcon: icon.Dashboard,
}
if err := jsxTemplate.Execute(&jsxWriter, jsxData); err != nil {
log.Printf("failed to render Go template to TSX template: %v", err)
http.Error(w, err.Error(), http.StatusInternalServerError)
return
}
indexJSMinified := api.Transform(jsxWriter.String(), api.TransformOptions{
Loader: api.LoaderTSX,
MinifyWhitespace: !ad.debugMode,
MinifyIdentifiers: !ad.debugMode,
MinifySyntax: !ad.debugMode,
})
if len(indexJSMinified.Errors) > 0 {
log.Printf("failed to transform and minify TSX template, errors: %+v: %+v", indexJSMinified.Errors, indexJSMinified.Errors[0].Location)
http.Error(w, "failed to render", http.StatusInternalServerError)
return
}
indexData := struct {
Debug bool
ThemeJS template.JS
Title string
Pages Pages
UITheme UITheme
MaterialUI UITheme
AntDesignUI UITheme
}{
Debug: ad.debugMode,
ThemeJS: template.JS(indexJSMinified.Code),
Title: ad.layout.Title,
Pages: ad.pages,
UITheme: ad.uiTheme,
MaterialUI: MaterialUI,
AntDesignUI: AntDesignUI,
}
adminTemplate, err := newTemplate("Admin").Parse(ad.adminTemplateText)
if err != nil {
log.Printf("failed to parse TSX template: %v", err)
http.Error(w, err.Error(), http.StatusInternalServerError)
return
}
if err := adminTemplate.Execute(w, indexData); err != nil {
log.Printf("failed to render Go template to http.ResponseWriter: %v", err)
http.Error(w, err.Error(), http.StatusInternalServerError)
return
}
}
func New(config *Config) Admin {
jsxTemplateText := config.JSXTemplateText
if config.JSXTemplateText == nil {
switch config.UITheme {
case MaterialUI:
jsxTemplateText = &materialUIJSXTemplateText
case AntDesignUI:
jsxTemplateText = &antDesignUIJSXTemplateText
default:
jsxTemplateText = &materialUIJSXTemplateText
}
}
adminTemplateText := config.AdminTemplateText
if config.AdminTemplateText == nil {
tmpl := defaultAdminTemplateText
adminTemplateText = &tmpl
}
return &admin{
debugMode: config.DebugMode,
layout: config.Layout,
pages: config.Pages,
uiTheme: config.UITheme,
jsxTemplateText: *jsxTemplateText,
adminTemplateText: *adminTemplateText,
}
}
const defaultAdminTemplateText string = `
[[- define "Admin" -]]
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<meta name="viewport" content="user-scalable=no, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, minimal-ui" />
<title>[[ .Title ]]</title>
[[- if and (eq .UITheme .AntDesignUI) .Debug ]]
<link rel="stylesheet" href="//cdn.jsdelivr.net/npm/[email protected]/dist/antd.css">
[[- end -]]
[[- if and (eq .UITheme .AntDesignUI) (not .Debug) ]]
<link rel="stylesheet" href="//cdn.jsdelivr.net/npm/[email protected]/dist/antd.min.css">
[[- end -]]
[[- if and (eq .UITheme .MaterialUI) ]]
<link rel="stylesheet" href="//fonts.googleapis.com/css?family=Roboto:300,400,500,700&display=swap" />
<link rel="stylesheet" href="//fonts.googleapis.com/icon?family=Material+Icons" />
[[- end ]]
</head>
<body>
<div id="root"></div>
[[ if .Debug -]]
<script src="//cdn.jsdelivr.net/npm/[email protected]/umd/react.development.js"></script>
<script src="//cdn.jsdelivr.net/npm/[email protected]/umd/react-dom.development.js"></script>
<script src="//cdn.jsdelivr.net/npm/[email protected]/umd/react-router-dom.js"></script>
[[- else -]]
<script src="//cdn.jsdelivr.net/npm/[email protected]/umd/react.production.min.js"></script>
<script src="//cdn.jsdelivr.net/npm/[email protected]/umd/react-dom.production.min.js"></script>
<script src="//cdn.jsdelivr.net/npm/[email protected]/umd/react-router-dom.min.js"></script>
[[- end -]]
[[- if and (eq .UITheme .AntDesignUI) .Debug ]]
<script src="//cdn.jsdelivr.net/npm/[email protected]/dist/antd.js"></script>
[[- end -]]
[[- if and (eq .UITheme .AntDesignUI) (not .Debug) ]]
<script src="//cdn.jsdelivr.net/npm/[email protected]/dist/antd.min.js"></script>
[[- end -]]
[[- if and (eq .UITheme .MaterialUI) .Debug ]]
<script src="//cdn.jsdelivr.net/npm/@material-ui/[email protected]/umd/material-ui.development.js"></script>
[[- end -]]
[[- if and (eq .UITheme .MaterialUI) (not .Debug) ]]
<script src="//cdn.jsdelivr.net/npm/@material-ui/[email protected]/umd/material-ui.production.min.js"></script>
[[- end ]]
<script type="text/javascript">[[ .ThemeJS ]]</script>
</body>
[[- end -]]
`