changeset 5:2f20b11affdd

add tools
author Franklin Schmidt <fschmidt@gmail.com>
date Tue, 21 Jun 2022 21:39:27 -0600
parents a17e400ddaa1
children 9166f6a14021
files src/lib/Shared.luan src/private/admin.html.luan src/private/tools/run.luan src/private/tools/shell.html.luan src/site.css src/tools/cookies.html.luan src/tools/dimensions.html src/tools/request.txt.luan
diffstat 8 files changed, 119 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
diff -r a17e400ddaa1 -r 2f20b11affdd src/lib/Shared.luan
--- a/src/lib/Shared.luan	Tue Jun 21 11:58:27 2022 -0600
+++ b/src/lib/Shared.luan	Tue Jun 21 21:39:27 2022 -0600
@@ -23,7 +23,6 @@
 %>
 		<div header>
 			<a href="/"><%=Forum.title%></a>
-			-
 <%	if user == nil then %>
 			<a href="/login.html">login</a>
 <%	else %>
diff -r a17e400ddaa1 -r 2f20b11affdd src/private/admin.html.luan
--- a/src/private/admin.html.luan	Tue Jun 21 11:58:27 2022 -0600
+++ b/src/private/admin.html.luan	Tue Jun 21 21:39:27 2022 -0600
@@ -26,6 +26,11 @@
 
 			<h2>Tools</h2>
 			<p><a href="tools/lucene.html">lucene</a></p>
+			<p><a href="tools/shell.html">luan shell</a></p>
+			<p><a href="tools/run">luan batch</a></p>
+			<p><a href="/tools/cookies.html">cookies</a></p>
+			<p><a href="/tools/dimensions.html">dimensions</a></p>
+			<p><a href="/tools/request.txt">request</a></p>
 		</div>
 	</body>
 </html>
diff -r a17e400ddaa1 -r 2f20b11affdd src/private/tools/run.luan
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/private/tools/run.luan	Tue Jun 21 21:39:27 2022 -0600
@@ -0,0 +1,1 @@
+return require("luan:http/tools/Run.luan").respond
diff -r a17e400ddaa1 -r 2f20b11affdd src/private/tools/shell.html.luan
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/private/tools/shell.html.luan	Tue Jun 21 21:39:27 2022 -0600
@@ -0,0 +1,1 @@
+return require("luan:http/tools/Shell.luan").respond
diff -r a17e400ddaa1 -r 2f20b11affdd src/site.css
--- a/src/site.css	Tue Jun 21 11:58:27 2022 -0600
+++ b/src/site.css	Tue Jun 21 21:39:27 2022 -0600
@@ -2,9 +2,28 @@
  	box-sizing: border-box;
 }
 
+body {
+	font-family: Sans-Serif;
+	margin: 0;
+}
+
 a {
 	text-decoration: none;
 }
 a:hover {
 	text-decoration: underline;
 }
+
+div[header], div[footer] {
+	font-size: 14px;
+	background-color: #ddd;
+	padding: 8px 3%;
+	display: flex;
+	justify-content: space-between;
+}
+
+[content] {
+	margin-left: 3%;
+	margin-right: 3%;
+	margin-bottom: 2em;
+}
diff -r a17e400ddaa1 -r 2f20b11affdd src/tools/cookies.html.luan
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/tools/cookies.html.luan	Tue Jun 21 21:39:27 2022 -0600
@@ -0,0 +1,62 @@
+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>
+	<head>
+		<meta name="viewport" content="width=device-width, initial-scale=1">
+		<style>
+			form {
+				margin-bottom: 16px;
+			}
+		</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>
+			<%=name%> = <input name=value value="<%=value%>" size=100>
+			<label><input type=checkbox name=persistent>persistent</label>
+		</form>
+<%	end %>
+		<form>
+			<input name=name>
+			= <input name=value size=100>
+			<label><input type=checkbox name=persistent>persistent</label>
+			<input type=submit>
+		</form>
+	</body>
+</html>
+<%
+end
diff -r a17e400ddaa1 -r 2f20b11affdd src/tools/dimensions.html
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/tools/dimensions.html	Tue Jun 21 21:39:27 2022 -0600
@@ -0,0 +1,19 @@
+<!doctype html>
+<html>
+	<head>
+		<meta name="viewport" content="width=device-width, initial-scale=1">
+		<script>
+			function p() {
+				document.body.innerText = ''
+					+ window.innerWidth + 'px innerWidth\n' 
+					+ window.innerHeight + 'px innerHeight\n'
+					+ '\n'
+					+ window.outerWidth + 'px outerWidth\n' 
+					+ window.outerHeight + 'px outerHeight\n'
+				;
+			}
+		</script>
+	</head>
+	<body onload="p()" onresize="p()">
+	</body>
+</html>
diff -r a17e400ddaa1 -r 2f20b11affdd src/tools/request.txt.luan
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/tools/request.txt.luan	Tue Jun 21 21:39:27 2022 -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