home
readme
diff
tree
note
docs
0commit 1f30f6d83652cd76007c51ceb244ec4547215982
1Author: Mason Wright <mason@lakefox.net>
2Date: Sat Nov 22 11:44:39 2025 -0700
3
4 Added readme
5
6diff --git a/README.txt b/README.txt
7new file mode 100644
8index 0000000..29fb45f
9--- /dev/null
10+++ b/README.txt
11@@ -0,0 +1,14 @@
12+Decode
13+
14+This is the git repo for this website. It includes the git.awk and the mailto.awk files.
15+They are very easy to setup if you are using pighttpd or apache.
16+
17+Git
18+---------------------------------------
19+
20+Add all git repos to /var/git
21+
22+Mailto
23+--------------------------------------
24+
25+All emails will be served out of /var/mailto
26diff --git a/cgi-bin/.mailto.awk.swp b/cgi-bin/.git.awk.swp
27similarity index 50%
28rename from cgi-bin/.mailto.awk.swp
29rename to cgi-bin/.git.awk.swp
30index 10fd033..615176b 100644
31Binary files a/cgi-bin/.mailto.awk.swp and b/cgi-bin/.git.awk.swp differ
32diff --git a/cgi-bin/git.awk b/cgi-bin/git.awk
33index 1d1353d..95c254f 100755
34--- a/cgi-bin/git.awk
35+++ b/cgi-bin/git.awk
36@@ -4,11 +4,7 @@
37
38 BEGIN {
39
40- print "Content-Type: text/html\r\n"
41- print "<!DOCTYPE html>"
42- print "<html>"
43- print "<head>"
44-
45+
46 split(ENVIRON["QUERY_STRING"], pairs, "&")
47 for (i in pairs) {
48 split(pairs[i], kv, "=")
49@@ -24,6 +20,11 @@ BEGIN {
50 }
51 }
52
53+ print "Content-Type: text/html\r\n"
54+ print "<!DOCTYPE html>"
55+ print "<html>"
56+ print "<head>"
57+
58 if (name == "") name = "all"
59 if (hash == "") hash = "HEAD"
60
61@@ -40,6 +41,8 @@ BEGIN {
62 print "<a href='?name=" name "&hash=" hash "&action=tree'>tree</a>"
63 }
64
65+ print "<a href='" clone "'>Clone</a>"
66+
67
68 if (action == "") {
69 if (name == "all") {
70@@ -118,4 +121,5 @@ BEGIN {
71
72 print "</body>"
73 print "</html>"
74+ }
75 }
76diff --git a/cgi-bin/mailto.awk b/cgi-bin/mailto.awk
77index 2316290..a6a4d39 100755
78--- a/cgi-bin/mailto.awk
79+++ b/cgi-bin/mailto.awk
80@@ -1,6 +1,7 @@
81 #!/usr/bin/awk -f
82
83 # A list should be split by a /: grim/patches.txt
84+# todo: https://inbox.sourceware.org/gcc/8f344050-3198-42eb-afe0-3f20cc22339a@redhat.com/
85
86 BEGIN {
87 if (ARGC > 1 && ARGV[1] == "sync") {
88@@ -165,15 +166,14 @@ function openMail(folder, uid) {
89
90 # This function will keep all email's up to date
91 function getThreads(username, password, inbox, query) {
92-# TODO: "(echo 'USER " username "'; echo PASS '" password "'; echo LIST; echo QUIT;) | nc -i 1 " inbox " 110"
93-# RETR 1
94-# . == end of message
95- cmd = "curl -s -u '" username ":" password "' '" inbox "' -X 'UID SEARCH SUBJECT " query "'"
96- while ((cmd | getline res) > 0) { # collect last line
97- split(res, a); # a[1]="*"; a[2]="SEARCH"; rest are UIDs
98- n = 0
99- for (i = 3; i <= length(a); i++) { # skip "* SEARCH"
100- uids[++n] = a[i]
101+ cmd = "(echo 'USER " username "'; echo PASS '" password "'; echo LIST; echo QUIT;) | nc -i 1 " inbox " 110"
102+ n = 0
103+ while (cmd | getline res) {
104+ if (res !~ /^\+/) {
105+ if (res != ".\r") {
106+ split(res, a)
107+ uids[++n] = a[2]
108+ }
109 }
110 }
111 close(cmd)
112@@ -182,7 +182,7 @@ function getThreads(username, password, inbox, query) {
113 files = ""
114
115 while (cmd | getline line) {
116- file = files line
117+ files = files line
118 }
119 close(cmd)
120
121@@ -192,13 +192,16 @@ function getThreads(username, password, inbox, query) {
122 sub("\r", "", uid)
123
124 if (index(files, uid) == 0) {
125- cmd = "curl -s -u '" username ":" password "' '" inbox ";UID=" uid "'"
126+ cmd = "(echo 'USER " username "'; echo PASS '" password "'; echo RETR "i"; echo QUIT;) | nc -i 1 " inbox " 110"
127 subj = ""
128 body = ""
129 from = ""
130 date = ""
131 inBody = 0
132 while ((cmd | getline line) > 0) {
133+ if (line == ".\r") {
134+ break
135+ }
136 if (line == "\r") { # blank line → headers finished
137 inBody = 1
138 continue
139@@ -215,18 +218,20 @@ function getThreads(username, password, inbox, query) {
140 }
141 }
142 close(cmd)
143-
144- cleanSubj = subj
145- gsub("/", "<>", cleanSubj)
146- sub("\r", "", cleanSubj)
147-
148- if (system("test -e \"/var/mailto/.cache/" query "/" cleanSubj "." uid "\"") != 0) {
149- file = "/var/mailto/.cache/" query "/" cleanSubj "." uid
150- gsub("\r","</br>", body)
151- print "<h1>" subj "</h1>" > file
152- print "<h3>From: " from "</h3>" >> file
153- print "<b>Date: " date "</b>" >> file
154- print "<p>" body "</p>" >> file
155+
156+ if (index(subj, query)) {
157+ cleanSubj = subj
158+ gsub("/", "<>", cleanSubj)
159+ sub("\r", "", cleanSubj)
160+
161+ if (system("test -e \"/var/mailto/.cache/" query "/" cleanSubj "." uid "\"") != 0) {
162+ file = "/var/mailto/.cache/" query "/" cleanSubj "." uid
163+ gsub("\r","</br>", body)
164+ print "<h1>" subj "</h1>" > file
165+ print "<h3>From: " from "</h3>" >> file
166+ print "<b>Date: " date "</b>" >> file
167+ print "<p>" body "</p>" >> file
168+ }
169 }
170 }
171 }
172diff --git a/index.html b/index.html
173index d5f477a..68f3da3 100644
174--- a/index.html
175+++ b/index.html
176@@ -37,7 +37,7 @@
177 <td><a href="/cgi-bin/git.awk?name=grim&action=readme">grim/</a></td>
178 <td>HTML/CSS renderer with a C++ DOM API</td>
179 <td><a href="irc.decode.sh/#grim">#grim</a></td>
180- <td>http://git.decode.sh/grim.git</td>
181+ <td><a href="http://decode.sh/git/grim.git">http://decode.sh/git/grim.git</a></td>
182 </tr>
183 <tr>
184 <td><a href="http://lakefox.net/decode/cgi-bin">mailto/</a></td>