Mercurial Hosting > chat
diff src/lib/Shared.luan @ 117:e2deb5236f26
better login
| author | Franklin Schmidt <fschmidt@gmail.com> |
|---|---|
| date | Thu, 04 Dec 2025 21:43:47 -0700 |
| parents | 15cf43dd144c |
| children |
line wrap: on
line diff
--- a/src/lib/Shared.luan Thu Dec 04 12:13:01 2025 -0700 +++ b/src/lib/Shared.luan Thu Dec 04 21:43:47 2025 -0700 @@ -2,6 +2,8 @@ local error = Luan.error local ipairs = Luan.ipairs or error() local parse = Luan.parse or error() +local String = require "luan:String.luan" +local contains = String.contains or error() local Table = require "luan:Table.luan" local concat = Table.concat or error() local Time = require "luan:Time.luan" @@ -9,6 +11,7 @@ local thread_run = Thread.run or error() local Html = require "luan:Html.luan" local html_encode = Html.encode or error() +local url_encode = Html.url_encode or error() local Http = require "luan:http/Http.luan" local Mail = require "luan:mail/Mail.luan" local User = require "site:/lib/User.luan" @@ -18,6 +21,7 @@ local chat_search = Chat.search or error() local Utils = require "site:/lib/Utils.luan" local base_url = Utils.base_url or error() +local to_list = Utils.to_list or error() local Db = require "site:/lib/Db.luan" local Post = require "site:/lib/Post.luan" local get_post_by_id = Post.get_by_id or error() @@ -184,4 +188,25 @@ Shared.compressed = {compressed=true} +function Shared.add_with(path) + local with = Http.request.parameters.with + if with ~= nil then + with = to_list(with) + local t = {} + for _, email in ipairs(with) do + t[#t+1] = "with="..url_encode(email) + end + path = path..(contains(path,"?") and "&" or "?")..concat(t,"&") + end + return path +end + +function Shared.hidden_with() + local with = Http.request.parameters.with + with = to_list(with) + for _, email in ipairs(with) do %> + <input type=hidden name=with value="<%=html_encode(email)%>"> +<% end +end + return Shared
