changeset 1418:732b5de211fc

add Hosted.luan
author Franklin Schmidt <fschmidt@gmail.com>
date Fri, 18 Oct 2019 22:29:46 -0600
parents c7f9dd062eda
children 59fd2e8b1b9d
files conv.txt examples/blog/src/lib/Db.luan scripts/test.luan src/luan/host/Util.luan src/luan/host/init.luan src/luan/host/main.luan src/luan/host/run.luan src/luan/modules/host/Hosted.luan src/luan/modules/host/Hosting.luan src/luan/modules/http/Http.luan
diffstat 10 files changed, 29 insertions(+), 37 deletions(-) [+]
line wrap: on
line diff
diff -r c7f9dd062eda -r 732b5de211fc conv.txt
--- a/conv.txt	Fri Oct 18 19:38:08 2019 -0600
+++ b/conv.txt	Fri Oct 18 22:29:46 2019 -0600
@@ -1,3 +1,6 @@
+Hosting.send_mail
+Hosting.luan
+
 Lucene.recover
 schedule_backups_to
 Backup.luan
diff -r c7f9dd062eda -r 732b5de211fc examples/blog/src/lib/Db.luan
--- a/examples/blog/src/lib/Db.luan	Fri Oct 18 19:38:08 2019 -0600
+++ b/examples/blog/src/lib/Db.luan	Fri Oct 18 22:29:46 2019 -0600
@@ -3,7 +3,7 @@
 local stringify = Luan.stringify or error()
 local Lucene = require "luan:lucene/Lucene.luan"
 local Io = require "luan:Io.luan"
-local Hosting = require "luan:host/Hosting.luan"
+local Hosted = require "luan:host/Hosted.luan"
 local Time = require "luan:Time.luan"
 local Thread = require "luan:Thread.luan"
 local Logging = require "luan:logging/Logging.luan"
@@ -12,7 +12,7 @@
 
 local Db = {}
 
-local postgres_spec = Hosting.postgres_spec and Hosting.postgres_spec()
+local postgres_spec = Hosted.postgres_spec()
 --logger.info(stringify(postgres_spec))
 
 local function completer(doc)
diff -r c7f9dd062eda -r 732b5de211fc scripts/test.luan
--- a/scripts/test.luan	Fri Oct 18 19:38:08 2019 -0600
+++ b/scripts/test.luan	Fri Oct 18 22:29:46 2019 -0600
@@ -8,7 +8,6 @@
 local Table = require "luan:Table.luan"
 local Thread = require "luan:Thread.luan"
 local Time = require "luan:Time.luan"
-local Hosting = require "luan:host/Hosting.luan"
 local Http = require "luan:http/Http.luan"
 local Http_test = require "luan:http/Http_test.luan"
 local Server = require "luan:http/Server.luan"
diff -r c7f9dd062eda -r 732b5de211fc src/luan/host/Util.luan
--- a/src/luan/host/Util.luan	Fri Oct 18 19:38:08 2019 -0600
+++ b/src/luan/host/Util.luan	Fri Oct 18 22:29:46 2019 -0600
@@ -9,7 +9,7 @@
 local format = String.format or error()
 local Binary = require "luan:Binary.luan"
 local bytes = Binary.byte or error()
-local Hosting = require "luan:host/Hosting.luan"
+local Hosted = require "luan:host/Hosted.luan"
 local Sql = require "luan:sql/Sql.luan"
 local database = Sql.database or error()
 local Logging = require "luan:logging/Logging.luan"
@@ -24,7 +24,7 @@
 
 function Util.read_password(domain)
 	domain = lower(domain)
-	return do_file(Hosting.sites_dir..domain.."/info.luan").password or error()
+	return do_file(Hosted.sites_dir..domain.."/info.luan").password or error()
 end
 
 local function basic_authentication(dir,password)
@@ -49,7 +49,7 @@
 end
 
 function Util.set_password(domain,password)
-	local dir = Hosting.sites_dir..lower(domain)
+	local dir = Hosted.sites_dir..lower(domain)
 	local file = Io.schemes.file(dir.."/info.luan")
 	file.delete()
 	file.write_text("return "..stringify{password=password}.."\n")
diff -r c7f9dd062eda -r 732b5de211fc src/luan/host/init.luan
--- a/src/luan/host/init.luan	Fri Oct 18 19:38:08 2019 -0600
+++ b/src/luan/host/init.luan	Fri Oct 18 22:29:46 2019 -0600
@@ -41,7 +41,7 @@
 
 local Io = require "luan:Io.luan"
 local Http = require "luan:http/Http.luan"
-local Hosting = require "luan:host/Hosting.luan"
+local Hosted = require "luan:host/Hosted.luan"
 local Mail = require "luan:mail/Mail.luan"
 
 Io.password = do_file(dir.."/info.luan").password or error()
@@ -54,19 +54,7 @@
 end
 
 Http.domain = domain
-Http.is_hosted = true
-
-
--- mail  - fix later
-
-Hosting.send_mail = Mail.Sender{
-	host = "smtpcorp.com"
-	username = "smtp@luan.ws"  -- ?
-	password = "luanhost"
-	port = 2525
-}.send
-
-
+Hosted.is_hosted = true
 
 
 -- postgres
@@ -79,7 +67,7 @@
 local fn = Luan.load_file("file:postgres.luan") or error()
 local pg = fn()
 
-function Hosting.postgres_spec()
+function Hosted.postgres_spec()
 	if pg == nil then
 		return nil
 	end
@@ -101,19 +89,15 @@
 end
 
 
-
-
-
 -- callback to luanhost code
 do_file "file:init.luan"
 
 
-
 require "java"
 local WebHandler = require "java:luan.host.WebHandler"
 local LuanJava = require "java:luan.Luan"
 
-function Hosting.no_security(password)
+function Hosted.no_security(password)
 	WebHandler.securityPassword == password or error "wrong password"
 	LuanJava.setSecurity(nil)
 end
diff -r c7f9dd062eda -r 732b5de211fc src/luan/host/main.luan
--- a/src/luan/host/main.luan	Fri Oct 18 19:38:08 2019 -0600
+++ b/src/luan/host/main.luan	Fri Oct 18 22:29:46 2019 -0600
@@ -11,10 +11,10 @@
 local literal = String.literal or error()
 local lower = String.lower or error()
 local matches = String.matches or error()
-local Hosting = require "luan:host/Hosting.luan"
+local Hosted = require "luan:host/Hosted.luan"
 local Logging = require "luan:logging/Logging.luan"
 local logger = Logging.logger "main"
-local WebHandler = Hosting.WebHandler or error()
+local WebHandler = Hosted.WebHandler or error()
 local Util = require "classpath:luan/host/Util.luan"
 local read_password = Util.read_password or error()
 local set_password = Util.set_password or error()
@@ -22,7 +22,7 @@
 local check_postgres_password = Util.check_postgres_password or error()
 
 
-local sites_dir = Io.schemes.file(Hosting.sites_dir)
+local sites_dir = Io.schemes.file(Hosted.sites_dir)
 
 sites_dir.mkdir()
 
diff -r c7f9dd062eda -r 732b5de211fc src/luan/host/run.luan
--- a/src/luan/host/run.luan	Fri Oct 18 19:38:08 2019 -0600
+++ b/src/luan/host/run.luan	Fri Oct 18 22:29:46 2019 -0600
@@ -4,17 +4,17 @@
 local do_file = Luan.do_file or error()
 local ipairs = Luan.ipairs or error()
 local Io = require "luan:Io.luan"
-local Hosting = require "luan:host/Hosting.luan"
+local Hosted = require "luan:host/Hosted.luan"
 local Logging = require "luan:logging/Logging.luan"
 local logger = Logging.logger "run"
 local NotFound = require "java:luan.modules.http.NotFound"
 local ListHandler = require "java:goodjava.webserver.handlers.ListHandler"
 local WebHandler = require "java:luan.host.WebHandler"
-Hosting.WebHandler = WebHandler
+Hosted.WebHandler = WebHandler
 
 
 local here = Io.schemes.file(".").canonical().to_string()
-Hosting.sites_dir = here.."/sites/"
+Hosted.sites_dir = here.."/sites/"
 
 do_file "classpath:luan/host/main.luan"
 
@@ -26,7 +26,7 @@
 local ContentTypeHandler = require "java:goodjava.webserver.handlers.ContentTypeHandler"
 local SafeHandler = require "java:goodjava.webserver.handlers.SafeHandler"
 
-local handler = WebHandler.new(Hosting.sites_dir)
+local handler = WebHandler.new(Hosted.sites_dir)
 local not_found_hander = NotFound.new(handler)
 handler = IndexHandler.new(handler)
 handler = ListHandler.new( handler, not_found_hander )
@@ -36,7 +36,7 @@
 server.start()
 
 
-local sites_dir = Io.schemes.file(Hosting.sites_dir)
+local sites_dir = Io.schemes.file(Hosted.sites_dir)
 for _, site_dir in ipairs(sites_dir.children()) do
 	local name = site_dir.name()
 	WebHandler.loadHandler(name)
diff -r c7f9dd062eda -r 732b5de211fc src/luan/modules/host/Hosted.luan
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/luan/modules/host/Hosted.luan	Fri Oct 18 22:29:46 2019 -0600
@@ -0,0 +1,9 @@
+local Hosted = {}
+
+Hosted.is_hosted = false
+
+function Hosted.postgres_spec()
+	return nil
+end
+
+return Hosted
diff -r c7f9dd062eda -r 732b5de211fc src/luan/modules/host/Hosting.luan
--- a/src/luan/modules/host/Hosting.luan	Fri Oct 18 19:38:08 2019 -0600
+++ b/src/luan/modules/host/Hosting.luan	Fri Oct 18 22:29:46 2019 -0600
@@ -1,5 +1,3 @@
--- Hosting
-
 local Luan = require "luan:Luan.luan"
 local error = Luan.error
 local ipairs = Luan.ipairs or error()
diff -r c7f9dd062eda -r 732b5de211fc src/luan/modules/http/Http.luan
--- a/src/luan/modules/http/Http.luan	Fri Oct 18 19:38:08 2019 -0600
+++ b/src/luan/modules/http/Http.luan	Fri Oct 18 22:29:46 2019 -0600
@@ -177,6 +177,5 @@
 Http.domain = nil  -- set in domain specific cases
 
 Http.is_serving = false
-Http.is_hosted = false
 
 return Http