annotate 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
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
8f4df159f06b start public repo
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
1 local Luan = require "luan:Luan.luan"
8f4df159f06b start public repo
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
2 local error = Luan.error
8f4df159f06b start public repo
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
3 local Io = require "luan:Io.luan"
8f4df159f06b start public repo
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
4 local Http = require "luan:http/Http.luan"
8f4df159f06b start public repo
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
5 local Shared = require "site:/lib/Shared.luan"
8f4df159f06b start public repo
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
6 local head = Shared.head or error()
8f4df159f06b start public repo
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
7 local header = Shared.header or error()
8f4df159f06b start public repo
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
8 local footer = Shared.footer or error()
8f4df159f06b start public repo
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
9 local validate_email = Shared.validate_email or error()
8f4df159f06b start public repo
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
10 local Db = require "site:/lib/Db.luan"
8f4df159f06b start public repo
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
11
8f4df159f06b start public repo
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
12
8f4df159f06b start public repo
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
13 return function()
8f4df159f06b start public repo
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
14 local email = Http.request.parameters.email or error()
8f4df159f06b start public repo
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
15 validate_email(email)
8f4df159f06b start public repo
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
16 Db.run_in_transaction( function()
8f4df159f06b start public repo
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
17 Db.delete("unsubscribe_email:"..email)
8f4df159f06b start public repo
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
18 Db.save{
8f4df159f06b start public repo
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
19 type = "unsubscribe"
8f4df159f06b start public repo
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
20 unsubscribe_email = email
8f4df159f06b start public repo
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
21 }
8f4df159f06b start public repo
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
22 end )
8f4df159f06b start public repo
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
23 Io.stdout = Http.response.text_writer()
8f4df159f06b start public repo
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
24 %>
8f4df159f06b start public repo
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
25 <!doctype html>
8f4df159f06b start public repo
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
26 <html lang="en">
8f4df159f06b start public repo
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
27 <head>
8f4df159f06b start public repo
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
28 <% head() %>
8f4df159f06b start public repo
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
29 <title>Link My Style</title>
8f4df159f06b start public repo
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
30 </head>
8f4df159f06b start public repo
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
31 <body>
8f4df159f06b start public repo
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
32 <% header() %>
8f4df159f06b start public repo
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
33 <div content>
8f4df159f06b start public repo
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
34 <h1>Unsubscribed</h1>
8f4df159f06b start public repo
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
35 <p><%=email%> has been unsubscribed from linkmy.style .</p>
8f4df159f06b start public repo
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
36 <p>Unsubscribed by mistake? <a href="subscribe.html?email=<%=email%>">Subscribe</a></p>
8f4df159f06b start public repo
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
37 </div>
8f4df159f06b start public repo
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
38 <% footer() %>
8f4df159f06b start public repo
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
39 </body>
8f4df159f06b start public repo
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
40 </html>
8f4df159f06b start public repo
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
41 <%
8f4df159f06b start public repo
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
42 end