home
readme
diff
tree
note
docs
0commit 9f3fadc08cdaa05790b36d94390640f4ab28cd7a
1Author: lakefox <mason@lakefox.net>
2Date: Sat Jan 24 12:32:00 2026 -0700
3
4 Cleaned up mailto
5
6diff --git a/cgi-bin/git.awk b/cgi-bin/git.awk
7index 4969a24..6175b18 100755
8--- a/cgi-bin/git.awk
9+++ b/cgi-bin/git.awk
10@@ -92,9 +92,11 @@ BEGIN {
11 } if (action == "diff") {
12 cmd = "git --git-dir=/var/git/" name ".git/ show " hash
13 print "<pre><code>"
14- while (cmd | getline line) {
15- print escape_html(line)
16- }
17+ counter = 0
18+ while (cmd | getline line) {
19+ print "<span id='" counter "'><a href='#" counter "' style='user-select:none;'>" counter "</a></span>" escape_html(line)
20+ counter += 1
21+ }
22 close(cmd)
23 print "</code></pre>"
24
25diff --git a/cgi-bin/mailto.awk b/cgi-bin/mailto.awk
26index e6e71ad..b86f39f 100755
27--- a/cgi-bin/mailto.awk
28+++ b/cgi-bin/mailto.awk
29@@ -5,8 +5,37 @@
30
31 BEGIN {
32 if (ARGC > 1 && ARGV[1] == "sync") {
33- # getThreads( user, pass, imap-url, query )
34- getThreads(ARGV[2], ARGV[3], ARGV[4], ARGV[5])
35+ # getThreads( user, pass, imap-url)
36+ getThreads(ARGV[2], ARGV[3], ARGV[4])
37+ exit
38+ } else if (ARGC > 1 && ARGV[1] == "init") {
39+ // --init site page (grim issues)
40+ system("mkdir -p /var/mailto/" ARGV[2])
41+ system("mkdir -p /var/mailto/.cache/" ARGV[2] "/" ARGV[3])
42+ system("touch /var/mailto/" ARGV[2] "/" ARGV[3] ".txt")
43+ exit
44+ } else if (ARGC > 1 && ARGV[1] == "help") {
45+ print "Mailto a stateless email mailing list manager and archiver."
46+ print "Required dependencies:"
47+ print " mkdir touch mv ls nc cat echo test grep"
48+ print "General Usage:"
49+ print " Add this script to your sites cgi-bin folder and mark it as executable."
50+ print " To add a new site/page run mailto.awk init project docs. This will create"
51+ print " /var/mailto/project/docs.txt -- This stores the email addresses"
52+ print " /var/mailto/.cache/project/docs/ -- All messages send will be saved here"
53+ print " if using sync"
54+ print ""
55+ print " Sync allows you to automatically create a archive of all messages send. It"
56+ print " can be ran from any email account as there isn't a need for a central mail"
57+ print " server. The one requirement is the mail server must support pop3."
58+ print " Sync usage:"
59+ print " mailto.awk sync username password inbox"
60+ print " Most mail servers use an email for the username. The inbox should be the domain"
61+ print " of the mail server."
62+ print " mailto.awk sync mail@example.com password mail.email.com"
63+ print " Sync will query the mail accounts inbox, download all mail that doesn't exist on"
64+ print " the server the check to see if they start with the slug \"project/list:\" if it"
65+ print " does then it will save it to the respective .cache folder."
66 exit
67 }
68
69@@ -165,7 +194,7 @@ function openMail(folder, uid) {
70 }
71
72 # This function will keep all email's up to date
73-function getThreads(username, password, inbox, query) {
74+function getThreads(username, password, inbox) {
75 cmd = "(echo 'USER " username "'; echo PASS '" password "'; echo LIST; echo QUIT;) | nc -i 1 " inbox " 110"
76 n = 0
77 while (cmd | getline res) {
78@@ -178,7 +207,7 @@ function getThreads(username, password, inbox, query) {
79 }
80 close(cmd)
81
82- cmd = "ls /var/mailto/.cache/" query
83+ cmd = "ls /var/mailto/.cache/*/* | grep '<>'"
84 files = ""
85
86 while (cmd | getline line) {
87@@ -219,13 +248,15 @@ function getThreads(username, password, inbox, query) {
88 }
89 close(cmd)
90
91- if (index(subj, query)) {
92+ if (match(subj, /^[a-z0-9_-]+\/[a-z0-9_-]+:/)) {
93 cleanSubj = subj
94 gsub("/", "<>", cleanSubj)
95 sub("\r", "", cleanSubj)
96
97- if (system("test -e \"/var/mailto/.cache/" query "/" cleanSubj "." uid "\"") != 0) {
98- file = "/var/mailto/.cache/" query "/" cleanSubj "." uid
99+ slug = substr(subj, 1, RLENGTH-1)
100+
101+ if (system("test -e \"/var/mailto/.cache/" slug "/" cleanSubj "." uid "\"") != 0) {
102+ file = "/var/mailto/.cache/" slug "/" cleanSubj "." uid
103 gsub("\r","</br>", body)
104 print "<h1>" subj "</h1>" > file
105 print "<h3>From: " from "</h3>" >> file
106diff --git a/index.html b/index.html
107index 55e8212..8c459d1 100644
108--- a/index.html
109+++ b/index.html
110@@ -37,19 +37,19 @@
111 <td><a href="http://git.ws/cgi-bin/git.awk?name=grim&hash=HEAD&action=readme">grim/</a></td>
112 <td>HTML/CSS renderer with a C++ DOM API</td>
113 <td><a target="_blank" href="https://web.libera.chat/gamja/?autojoin=#grim">#grim</a></td>
114- <td><a href="http://git.ws/repo/grim.git">http://git.ws/repo/grim.git</a></td>
115+ <td><a href="http://git.ws/cgi-bin/repo/grim.git">http://git.ws/cgi-bin/repo/grim.git</a></td>
116 </tr>
117 <tr>
118 <td><a href="http://git.ws/cgi-bin/git.awk?name=gitws&hash=HEAD&action=readme">git.ws/</a></td>
119 <td>All the scripts that run git.ws (mailto.awk/git.awk)</td>
120 <td><a target="_blank" href="https://web.libera.chat/gamja/?autojoin=#gitws">#gitws</a></td>
121- <td><a href="http://git.ws/repo/gitws.git">http://git.ws/repo/gitws.git</a></td>
122+ <td><a href="http://git.ws/cgi-bin/repo/gitws.git">http://git.ws/cgi-bin/repo/gitws.git</a></td>
123 </tr>
124 <tr>
125 <td><a href="http://git.ws/cgi-bin/git.awk?name=spectre&hash=HEAD&action=readme">spectre/</a></td>
126 <td>Fast router OS</td>
127 <td><a target="_blank" href="https://web.libera.chat/gamja/?autojoin=#spectre">#spectre</a></td>
128- <td><a href="http://git.ws/repo/gitws.git">http://git.ws/repo/spectre.git</a></td>
129+ <td><a href="http://git.ws/cgi-bin/repo/gitws.git">http://git.ws/cgi-bin/repo/spectre.git</a></td>
130 </tr>
131 </tbody>
132 </table>