Mercurial Hosting > luan
comparison src/luan/host/init.luan @ 1418:732b5de211fc
add Hosted.luan
author | Franklin Schmidt <fschmidt@gmail.com> |
---|---|
date | Fri, 18 Oct 2019 22:29:46 -0600 |
parents | db57d562c4bd |
children | 94a6a209d4e2 |
comparison
equal
deleted
inserted
replaced
1417:c7f9dd062eda | 1418:732b5de211fc |
---|---|
39 | 39 |
40 -- set vars | 40 -- set vars |
41 | 41 |
42 local Io = require "luan:Io.luan" | 42 local Io = require "luan:Io.luan" |
43 local Http = require "luan:http/Http.luan" | 43 local Http = require "luan:http/Http.luan" |
44 local Hosting = require "luan:host/Hosting.luan" | 44 local Hosted = require "luan:host/Hosted.luan" |
45 local Mail = require "luan:mail/Mail.luan" | 45 local Mail = require "luan:mail/Mail.luan" |
46 | 46 |
47 Io.password = do_file(dir.."/info.luan").password or error() | 47 Io.password = do_file(dir.."/info.luan").password or error() |
48 | 48 |
49 Http.dir = "file:"..dir.."/site" | 49 Http.dir = "file:"..dir.."/site" |
52 function Io.schemes.site(path,loading) | 52 function Io.schemes.site(path,loading) |
53 return Io.uri( Http.dir..path, loading ) | 53 return Io.uri( Http.dir..path, loading ) |
54 end | 54 end |
55 | 55 |
56 Http.domain = domain | 56 Http.domain = domain |
57 Http.is_hosted = true | 57 Hosted.is_hosted = true |
58 | |
59 | |
60 -- mail - fix later | |
61 | |
62 Hosting.send_mail = Mail.Sender{ | |
63 host = "smtpcorp.com" | |
64 username = "smtp@luan.ws" -- ? | |
65 password = "luanhost" | |
66 port = 2525 | |
67 }.send | |
68 | |
69 | |
70 | 58 |
71 | 59 |
72 -- postgres | 60 -- postgres |
73 | 61 |
74 local Sql = require "luan:sql/Sql.luan" | 62 local Sql = require "luan:sql/Sql.luan" |
77 local logger = Logging.logger "init" | 65 local logger = Logging.logger "init" |
78 | 66 |
79 local fn = Luan.load_file("file:postgres.luan") or error() | 67 local fn = Luan.load_file("file:postgres.luan") or error() |
80 local pg = fn() | 68 local pg = fn() |
81 | 69 |
82 function Hosting.postgres_spec() | 70 function Hosted.postgres_spec() |
83 if pg == nil then | 71 if pg == nil then |
84 return nil | 72 return nil |
85 end | 73 end |
86 local spec = { | 74 local spec = { |
87 class = "org.postgresql.Driver" | 75 class = "org.postgresql.Driver" |
99 db.close() | 87 db.close() |
100 return spec | 88 return spec |
101 end | 89 end |
102 | 90 |
103 | 91 |
104 | |
105 | |
106 | |
107 -- callback to luanhost code | 92 -- callback to luanhost code |
108 do_file "file:init.luan" | 93 do_file "file:init.luan" |
109 | |
110 | 94 |
111 | 95 |
112 require "java" | 96 require "java" |
113 local WebHandler = require "java:luan.host.WebHandler" | 97 local WebHandler = require "java:luan.host.WebHandler" |
114 local LuanJava = require "java:luan.Luan" | 98 local LuanJava = require "java:luan.Luan" |
115 | 99 |
116 function Hosting.no_security(password) | 100 function Hosted.no_security(password) |
117 WebHandler.securityPassword == password or error "wrong password" | 101 WebHandler.securityPassword == password or error "wrong password" |
118 LuanJava.setSecurity(nil) | 102 LuanJava.setSecurity(nil) |
119 end | 103 end |
120 | 104 |
121 function Http.reset_luan() | 105 function Http.reset_luan() |