-
Notifications
You must be signed in to change notification settings - Fork 1
/
index.cgi
executable file
·54 lines (44 loc) · 1.45 KB
/
index.cgi
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
#!/bin/bash
set -e
. ./config
. ./threads.sh
. ./html.sh
. ./bans.sh
echo "Content-Type: text/html"
echo
html_thread_list() {
for th in $(list_threads | sort -rg); do
echo '<div class="thread">'
echo "<h2>Thread $th</h2>"
for post in $(seq 0 5); do
file="$THREAD_DIR/$th/$post"
if [ -f "$file" ]; then
post_html "$th" "$post"
fi
done
echo "<a href=\"$URL_ROOT/thread.cgi?$th\">Full thread</a>"
echo "</div>"
done
}
html_page "$SITE_TITLE" <<EOF
$(ban_notice)
<h2>What is this?</h2>
<p>$SITE_TITLE is a simple clone of 4chan without images (for now) written entirely
in bash. It's not meant to be anything big, just a little toy to see if I could
make a bulletin board type thing using only shell scripts.</p>
<p>To use $SITE_TITLE, you can either start a new thread by typing the initial post
in the box below, or you can post on one of the existing threads (listed
below). All posts are anonymous, although your IP address will be stored along
with your posts for banning purposes.</p>
<p>There aren't really any rules right now, just don't be a dick, don't spam,
etc.</p>
<h2>New Thread</h2>
<form method="POST" action="$URL_ROOT/new-thread.cgi">
Type an initial post below and click create thread to start a new thread.
<br/>
<textarea name="content"></textarea>
<br/>
<input type="submit" value="Create Thread">
</form>
$(html_thread_list)
EOF