#!/usr/bin/env ruby require 'cgi' def link(href, text, remote = false) if remote $cgi.a(href: href, target: "_blank") { "[ #{text} ⇗ ] " } else $cgi.a(href: href) { "[ #{text} ] " } end end def toplinks $cgi.ul(class: "toplinks") { $cgi.li { link("/" , "Home" ) } + $cgi.li { link("/bins" , "Bins" ) } + $cgi.li { link("/shelf" , "Shelf" ) } + $cgi.li { link("/eamit.html" , "eamit" , true) } + $cgi.li { link("https://git.4574.co.uk/", "Git" , true) } + $cgi.li { link("/stuff-i-want" , "Stuff I Want" ) } } end def rquote File.readlines("../inc/quotes.txt").sample.strip end def page(title, jumbotitle = title) load "#{title.downcase.gsub(?\s, ?-)}.cgi" $cgi.out { $cgi.html(lang: "en") { $cgi.head { $cgi.title { "User_4574's Lair / #{title}" } + $cgi.link(rel: "stylesheet", href: "styles.css") } + $cgi.body { $cgi.div(class: "pagetop") { $cgi.h1(class: "jumbo") { jumbotitle } + toplinks } + $cgi.div { $page } + $cgi.div(id: "quote") { rquote } } } } end $cgi = CGI.new("html5") case $cgi.path_info when "/" page("Home", "User_4574's Lair") when "/bins" page("Bins") when "/shelf" page("Whisky Shelf") when /^\/stuff-i-want/ page("Stuff I Want") when /^\/bv/ $cgi.out("status" => "MOVED", "Location" => "https://bv.miller.cm/") {""} end