Mercurial Hosting > luan
changeset 1988:8020dd486ae3
better web tools
author | Franklin Schmidt <fschmidt@gmail.com> |
---|---|
date | Mon, 30 Jun 2025 18:58:49 -0600 |
parents | 535921391867 |
children | 14c7fb7e3c03 |
files | src/luan/modules/host/change_domain.luan src/luan/modules/http/tools/Run.luan src/luan/modules/http/tools/Shell.luan src/luan/modules/http/tools/cookies.html.luan src/luan/modules/http/tools/request.txt.luan src/luan/modules/lucene/Web_search.luan |
diffstat | 6 files changed, 132 insertions(+), 28 deletions(-) [+] |
line wrap: on
line diff
--- a/src/luan/modules/host/change_domain.luan Sun Jun 29 17:58:25 2025 -0600 +++ b/src/luan/modules/host/change_domain.luan Mon Jun 30 18:58:49 2025 -0600 @@ -3,7 +3,7 @@ local Hosting = require "luan:host/Hosting.luan" if #{...} ~= 3 then - Io.stderr.write "usage: luan luan:host/push.luan old_domain new_domain password\n" + Io.stderr.write "usage: luan luan:host/change_domain.luan old_domain new_domain password\n" return end
--- a/src/luan/modules/http/tools/Run.luan Sun Jun 29 17:58:25 2025 -0600 +++ b/src/luan/modules/http/tools/Run.luan Mon Jun 30 18:58:49 2025 -0600 @@ -34,6 +34,7 @@ <!doctype html> <html lang="en"> <head> + <meta name="viewport" content="width=device-width, initial-scale=1"> <title>Run Luan Code</title> <style> body { @@ -41,16 +42,12 @@ text-align: center; } textarea { - font: inherit; + width: 90%; + max-width: 840px; } input[type="submit"] { - margin-top: .3em; - color: white; - background: #337ab7; - border-color: #337ab7; - font: inherit; - padding: .5em; - border-radius: 4px; + margin-top: .5em; + font-size: 110%; cursor: pointer; } </style> @@ -59,7 +56,7 @@ <h2>Run Luan Code</h2> <form method="post"> <div> - <textarea name="code" rows="20" cols="90" autofocus></textarea> + <textarea name="code" rows="20" autofocus></textarea> </div> <div> <input type="submit" value="Execute Luan Code"/>
--- a/src/luan/modules/http/tools/Shell.luan Sun Jun 29 17:58:25 2025 -0600 +++ b/src/luan/modules/http/tools/Shell.luan Mon Jun 30 18:58:49 2025 -0600 @@ -93,6 +93,7 @@ <!doctype html> <html lang="en"> <head> + <meta name="viewport" content="width=device-width, initial-scale=1"> <title>Luan Shell</title> <script>
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/luan/modules/http/tools/cookies.html.luan Mon Jun 30 18:58:49 2025 -0600 @@ -0,0 +1,77 @@ +local Luan = require "luan:Luan.luan" +local error = Luan.error +local pairs = Luan.pairs or error() +local Html = require "luan:Html.luan" +local html_encode = Html.encode or error() +local Io = require "luan:Io.luan" +local Http = require "luan:http/Http.luan" +local Logging = require "luan:logging/Logging.luan" +local logger = Logging.logger "cookies.html" + + +return function() + local name = Http.request.parameters.name + if name ~= nil then + local value = Http.request.parameters.value + local persistent = Http.request.parameters.persistent + if #value == 0 then + Http.response.remove_cookie(name) + elseif persistent ~= nil then + Http.response.set_persistent_cookie(name,value) + else + Http.response.set_cookie(name,value) + end + Http.response.send_redirect "cookies.html" + return + end + + Io.stdout = Http.response.text_writer() +%> +<!doctype html> +<html lang="en"> + <head> + <meta name="viewport" content="width=device-width, initial-scale=1"> + <style> + * { + box-sizing: border-box; + } + body { + font-family: Sans-Serif; + margin-left: 3%; + margin-right: 3%; + } + form { + display: flex; + margin-bottom: 16px; + white-space: nowrap; + } + input[wide] { + width: 100%; + } + </style> + </head> + <body> + <h2>Cookies Tool</h2> +<% + for name, value in pairs(Http.request.cookies) do + name = html_encode(name) + value = html_encode(value) +%> + <form> + <input name=name value="<%=name%>" type=hidden> + <span><%=name%> = </span> + <input name=value value="<%=value%>" wide> + <label><input type=checkbox name=persistent>persistent</label> + </form> +<% end %> + <form> + <input name=name> + <span> = </span> + <input name=value wide> + <label><input type=checkbox name=persistent>persistent </label> + <input type=submit> + </form> + </body> +</html> +<% +end
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/luan/modules/http/tools/request.txt.luan Mon Jun 30 18:58:49 2025 -0600 @@ -0,0 +1,12 @@ +local Binary = require "luan:Binary.luan" +local Io = require "luan:Io.luan" +local Http = require "luan:http/Http.luan" + + +return function() + Io.stdout = Http.response.text_writer() + %><%= Http.request.raw_head %><% + if Http.request.body ~= nil then + %><%=Binary.to_string(Http.request.body,"utf-8")%><% + end +end
--- a/src/luan/modules/lucene/Web_search.luan Sun Jun 29 17:58:25 2025 -0600 +++ b/src/luan/modules/lucene/Web_search.luan Mon Jun 30 18:58:49 2025 -0600 @@ -23,6 +23,9 @@ local function style() %> + * { + box-sizing: border-box; + } body { font-family: sans-serif; margin: 2em 5%; @@ -33,21 +36,15 @@ label { text-align: right; min-width: 6em; - display: inline-block; margin-right: .5em; } - input, textarea { - margin-top: 1em; - font: inherit; - } - span[tip] { + [tip] { color: #888; font-size: smaller; + margin-top: 2px; } input[type="submit"] { cursor: pointer; - padding: .5em; - border-radius: 4px; } textarea[name="old"] { display: none; @@ -60,9 +57,21 @@ <!doctype html> <html lang="en"> <head> + <meta name="viewport" content="width=device-width, initial-scale=1"> <title>Lucene</title> <style> <% style() %> + form > div { + display: flex; + margin-top: 1em; + width: 100%; + } + form > div > div { + width: 100%; + } + input[wide] { + width: 100%; + } </style> </head> <body> @@ -70,11 +79,10 @@ <form> <div> <label>Query:</label> - <input type=text name="query" size="80" autofocus> - </div> - <div> - <label></label> - <span tip>Query examples: <i>type:user</i> or <i>+type:user +name:Joe"</i></span> + <div> + <input type=text name="query" wide autofocus> + <div tip>Query examples: <i>type:user</i> or <i>+type:user +name:Joe"</i></div> + </div> </div> <div> <label>Max Rows:</label> @@ -82,11 +90,10 @@ </div> <div> <label>Sort:</label> - <input type=text name="sort" size="60"> - </div> - <div> - <label></label> - <span tip>Sort examples: <i>name, id</i></span> + <div> + <input type=text name="sort" wide> + <div tip>Sort examples: <i>name, id</i></div> + </div> </div> <div> <label></label> @@ -118,6 +125,7 @@ <!doctype html> <html lang="en"> <head> + <meta name="viewport" content="width=device-width, initial-scale=1"> <title>Lucene</title> <style> <% style() %> @@ -156,6 +164,7 @@ <!doctype html> <html lang="en"> <head> + <meta name="viewport" content="width=device-width, initial-scale=1"> <title>Lucene</title> <style> <% style() %> @@ -216,9 +225,16 @@ <!doctype html> <html lang="en"> <head> + <meta name="viewport" content="width=device-width, initial-scale=1"> <title>Lucene</title> <style> <% style() %> + textarea { + max-width: 100%; + } + input[type=submit] { + margin-top: 0.5em; + } </style> </head> <body> @@ -275,6 +291,7 @@ <!doctype html> <html lang="en"> <head> + <meta name="viewport" content="width=device-width, initial-scale=1"> <title>Lucene</title> <style> <% style() %>