commit 529643581b962f5be401c0050ef8edb606a5859d parent e252c3613d39b01395b4543464ef2c36339479a1 Author: massi <mdsiboldi@gmail.com> Date: Wed, 24 Jul 2024 16:10:49 -0700 add progress on migration to clojure Diffstat:
A | deps.edn | | | 4 | ++++ |
A | make.clj | | | 3 | +++ |
A | src/main.clj | | | 82 | +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ |
3 files changed, 89 insertions(+), 0 deletions(-)
diff --git a/deps.edn b/deps.edn @@ -0,0 +1,4 @@ +{ + :deps + {hiccup/hiccup {:mvn/version "2.0.0-RC3"}} + } diff --git a/make.clj b/make.clj @@ -0,0 +1,3 @@ +#!clj +(load-file "src/main.clj") +(massi-world/mk-site) diff --git a/src/main.clj b/src/main.clj @@ -0,0 +1,82 @@ +(ns massi-world + (:require [hiccup2.core :as h])) + +(defmacro with-page + "wraps body in a nice page with metadata and such" + [{:keys [path title desc img] + :or {img {:src "https://massi.world/static/massi-world-180-180.png" + :desc "an unknown planet. could it be... massi world!?"}}} + & body] + (let [abs-path (str "https://massi.world" path)] + `(h/html [:doctype] + [:html.no-js] + [:head + [:meta {:charset "UTF-8"}] + [:meta {:name "viewport" + :content "width=device-width" + :initial-screen-scale "1"}] + [:title ~title] + [:script {:type "module" :src "/js/js-check.js"}] + [:link {:rel "stylesheet" :href "/static/style.css"}] + [:meta {:name "description" :content ~desc}] + [:meta {:property "og:title" :content ~title}] + [:meta {:property "og:image" :content (get ~img :src)}] + [:meta {:property "og:image:alt" :content (get ~img :desc)}] + [:meta {:property "og:locale" :content "en_US"}] + [:meta {:property "og:type" :content "website"}] + [:meta {:property "og:url" :content ~abs-path}] + [:meta {:name "theme-color" :content "#000033"}] + [:link {:rel "canonical" :href ~abs-path}] + [:link {:rel "shortcut icon" :href "/favicon.ico"}] + [:link {:rel "icon" :type "image/png" :sizes "16x16" :href "/static/massi-world-16-16.png"}] + [:link {:rel "icon" :type "image/png" :sizes "32x32" :href "/static/massi-world-32-32.png"}] + [:link {:rel "icon" :type "image/png" :sizes "48x48" :href "/static/massi-world-48-48.png"}] + [:link {:rel "apple-touch-icon" :href "/static/massi-world-180-180.png"}] + [:link {:rel "manifest" :href "/manifest.json"}]] + [:body ~@body]))) + +(str (with-page {:path "/index.html" + :title "massi world" + :desc "massi world - home page"})) + +(defn header [] + [:header "massi world 🦝"]) +(defn footer [] + [:footer + "Last generated: " + (.format (java.text.SimpleDateFormat. "MM/dd/yyyy hh:mm:ssa z") + (new java.util.Date))]) + +(defn mk-home [path] + (with-page {:path path + :title "massi world" + :desc "home"} + (header) + [:section + [:h1 "projects"] + [:ul + [:li [:a {:href "/projects/color-synth.html"} "color-synth"]]] + (footer)])) + +(defn mk-page [{:keys [path fn]}] + (let* [out-dir "build" + out-file (str out-dir path) + out-str (str (apply fn `(~path)))] + (spit out-file out-str) + (println "wrote" out-file) + out-str)) + +(defn mk-site [] + (println "building site...") + (time + (doseq [spec [{:path "/index.html" :fn mk-home} + {:path "/projects/color-synth.html" + :fn #(with-page {:path % + :title "projects -> color-synth" + :desc "a digital video synthesizer on the web"} + (header) + [:main.color-synth + [:div.samples + [:img {:src "/static/color-synth-sample-1.webp" :alt "a pixelated wobbling smiley face"}]]] + (footer))}]] + (mk-page spec))))