changeset 100:0e3b22ece2fc

use luan web tools
author Franklin Schmidt <fschmidt@gmail.com>
date Mon, 30 Jun 2025 22:32:26 -0600
parents c14b903c8373
children 0fc454beff08
files .hgignore src/tools/cookies.html.luan src/tools/request.txt.luan
diffstat 3 files changed, 3 insertions(+), 74 deletions(-) [+]
line wrap: on
line diff
--- a/.hgignore	Sat Jun 28 19:46:25 2025 -0600
+++ b/.hgignore	Mon Jun 30 22:32:26 2025 -0600
@@ -6,3 +6,4 @@
 push-test.sh
 push-prod.sh
 .DS_Store
+dev.sh
--- a/src/tools/cookies.html.luan	Sat Jun 28 19:46:25 2025 -0600
+++ b/src/tools/cookies.html.luan	Mon Jun 30 22:32:26 2025 -0600
@@ -1,62 +1,1 @@
-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>
-			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
+return require "luan:http/tools/cookies.html.luan"
--- a/src/tools/request.txt.luan	Sat Jun 28 19:46:25 2025 -0600
+++ b/src/tools/request.txt.luan	Mon Jun 30 22:32:26 2025 -0600
@@ -1,12 +1,1 @@
-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
+return require "luan:http/tools/request.txt.luan"