Mercurial Hosting > freedit
diff src/lib/Shared.luan @ 6:9166f6a14021
add email api
author | Franklin Schmidt <fschmidt@gmail.com> |
---|---|
date | Thu, 23 Jun 2022 23:05:28 -0600 |
parents | 2f20b11affdd |
children | 0472897e790d |
line wrap: on
line diff
--- a/src/lib/Shared.luan Tue Jun 21 21:39:27 2022 -0600 +++ b/src/lib/Shared.luan Thu Jun 23 23:05:28 2022 -0600 @@ -1,7 +1,13 @@ local Luan = require "luan:Luan.luan" local error = Luan.error local Http = require "luan:http/Http.luan" +local Io = require "luan:Io.luan" +local uri = Io.uri or error() +local Parsers = require "luan:Parsers.luan" +local json_parse = Parsers.json_parse or error() local Forum = require "site:/lib/Forum.luan" +local forum_title = Forum.title or error() +local mailer_url = Forum.mailer_url or error() local User = require "site:/lib/User.luan" local Logging = require "luan:logging/Logging.luan" local logger = Logging.logger "Shared" @@ -22,7 +28,7 @@ local user = User.current() %> <div header> - <a href="/"><%=Forum.title%></a> + <a href="/"><%=forum_title%></a> <% if user == nil then %> <a href="/login.html">login</a> <% else %> @@ -52,4 +58,13 @@ return Http.request.scheme.."://"..Http.request.headers["host"] end +function Shared.call_mail_api(cmd,parameters) + local url = mailer_url.."/api/"..cmd..".json" + local options = { + parameters = parameters + } + local response = uri(url,options).read_text() + return json_parse(response) +end + return Shared