-
Notifications
You must be signed in to change notification settings - Fork 3
/
xapp.lua
116 lines (90 loc) · 1.82 KB
/
xapp.lua
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
--[==[
webb | x-widgets-based apps
Written by Cosmin Apreutesei. Public Domain.
]==]
local ffi = require'ffi'
ffi.tls_libname = 'tls_bearssl'
require'webb_spa'
require'xrowset_sql'
math.randomseed(require'time'.clock())
js[[
function init() {
init_components()
init_auth()
init_action()
}
on_dom_load(init)
]]
cssfile[[
fontawesome.css
divs.css
x-widgets.css
]]
jsfile[[
markdown-it.js
markdown-it-easy-tables.js
x-widgets.js
x-nav.js
x-input.js
x-listbox.js
x-grid.js
x-module.js
]]
Sfile[[
webb.lua
webb_query.lua
webb_spa.lua
webb_xapp.lua
x-widgets.js
x-nav.js
x-input.js
x-listbox.js
x-grid.js
x-module.js
]]
fontfile'fa-solid-900.ttf'
require'xauth'
return function(app)
--config ------------------------------------------------------------------
if app.conf then
for k,v in pairs(app.conf) do
config(k, v)
end
end
Sfile((config'app_name')..'.lua')
if app.font == 'opensans' then
fontfile'OpenSans-Regular.ttf'
fontfile'OpenSans-SemiBold.ttf'
fontfile'OpenSansCondensed-Light.ttf'
fontfile'OpenSansCondensed-Bold.ttf'
end
--website -----------------------------------------------------------------
app.respond = glue.noop
app.spa = glue.noop
config('main_module', function()
if not app.respond() then
checkfound(action(unpack(args())))
end
end)
action['404.html'] = function(action)
spa(update({
body = html(),
body_classes = 'x-container',
body_attrs = catargs(' ', app.fullscreen, app.font),
client_action = true,
}, app.spa(action)))
end
--cmdline -----------------------------------------------------------------
function cmd.start()
local server = webb.server(app.server_options)
server.start()
end
function app:run_cmd(f, ...)
return webb.run(function(...)
local exit_code = f(...)
self:finish()
return exit_code
end, ...)
end
return app
end