view unsubscribe/src/unsubscribe.html.luan @ 3:b016e4b7c8da default tip

add read_me
author Franklin Schmidt <fschmidt@gmail.com>
date Sat, 12 Jul 2025 12:51:36 -0600
parents 8f4df159f06b
children
line wrap: on
line source

local Luan = require "luan:Luan.luan"
local error = Luan.error
local Io = require "luan:Io.luan"
local Http = require "luan:http/Http.luan"
local Shared = require "site:/lib/Shared.luan"
local head = Shared.head or error()
local header = Shared.header or error()
local footer = Shared.footer or error()
local validate_email = Shared.validate_email or error()
local Db = require "site:/lib/Db.luan"


return function()
	local email = Http.request.parameters.email or error()
	validate_email(email)
	Db.run_in_transaction( function()
		Db.delete("unsubscribe_email:"..email)
		Db.save{
			type = "unsubscribe"
			unsubscribe_email = email
		}
	end )
	Io.stdout = Http.response.text_writer()
%>
<!doctype html>
<html lang="en">
	<head>
<%		head() %>
		<title>Link My Style</title>
	</head>
	<body>
<%		header() %>
		<div content>
			<h1>Unsubscribed</h1>
			<p><%=email%> has been unsubscribed from linkmy.style .</p>
			<p>Unsubscribed by mistake? <a href="subscribe.html?email=<%=email%>">Subscribe</a></p>
		</div>
<%		footer() %>
	</body>
</html>
<%
end