#!/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