blob: 062135021f74cc898bb5bc55d9d7ee54d28a97cf (
plain)
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
|
#!/bin/env ruby
require "cgi"
require "date"
THOUGHTS_DIR = "/srv/thoughts"
heading = <<~END
================================================================================
Welcome to Martin's Sunday Corner! Here you will find some of my random thoughts
from throughout the past week. Available only on Sundays.
You can host your own Sunday Corner by copying my code from
>>> git.m-chrzan.xyz/sunday <<<
================================================================================
END
no_thoughts = <<~END
No thoughts to share this week. Check back next Sunday!
END
not_sunday = <<~END
Corner's closed today. Check back on Sunday!
END
cgi = CGI.new
today = Date::today
thoughts_file = "#{THOUGHTS_DIR}/#{today}"
if today.sunday?
if File.exist? thoughts_file
contents = File.read thoughts_file
else
contents = no_thoughts
end
else
contents = not_sunday
end
cgi.out "type" => "text/plain", "charset" => "utf-8" do
heading + "\n" + contents
end
|