diff options
Diffstat (limited to 'src')
| -rw-r--r-- | src/weepinbell/handler.clj | 3 | ||||
| -rw-r--r-- | src/weepinbell/ui.clj | 32 | ||||
| -rw-r--r-- | src/weepinbell/utils.clj | 9 |
3 files changed, 44 insertions, 0 deletions
diff --git a/src/weepinbell/handler.clj b/src/weepinbell/handler.clj index 7194875..056c8f4 100644 --- a/src/weepinbell/handler.clj +++ b/src/weepinbell/handler.clj @@ -8,6 +8,7 @@ [weepinbell.receiver :refer [receive]] [weepinbell.retriever :as retriever] [weepinbell.processor :refer [process-webmention]] + [weepinbell.ui :as ui] [clojure.core.async :refer [chan]])) (def wmc (chan)) @@ -15,6 +16,8 @@ (process-webmention wmc) (defroutes api-routes + (GET "/" [] (ui/home (get-config :allowed-target-domains) + (get-config :endpoint))) ;; receiver endpoint (POST (get-config :endpoint) [source target] (receive {:s source :t target} wmc)) diff --git a/src/weepinbell/ui.clj b/src/weepinbell/ui.clj new file mode 100644 index 0000000..a8abacd --- /dev/null +++ b/src/weepinbell/ui.clj @@ -0,0 +1,32 @@ +(ns weepinbell.ui + (:require [hiccup2.core :as h] + [weepinbell.utils :refer [format-list]])) + +(defn- page-response [page] + {:body page + :headers {"Content-Type" "text/html"} + :status 200}) + +(defn- page-base [slot] + (str (h/html [:html + [:head + [:link {:rel "stylesheet" :href "/main.css"}] + [:title "Weepinbell - Webmention Receiver"]] + [:body slot]]))) + +(defn home [domains endpoint] + (-> + [:main.home + [:img.banner {:src "/weepinbell.avif"}] + [:div + [:p "This is a " [:a {:href "https://codeberg.org/eltrac/weepinbell" :target "_blank"} "Weepinbell"] "."] + [:p "He receives " [:a {:href "https://indieweb.org/webmention" :target "_blank"}] " for " (format-list domains)]] + [:div + [:p "Have him send a Webmention for you."] + [:form {:action endpoint :method "POST"} + [:input {:name "source" :placeholder "source"}] + [:input {:name "target" :placeholder "target"}] + [:button {:type "submit"} "send"]]]] + page-base + page-response)) + diff --git a/src/weepinbell/utils.clj b/src/weepinbell/utils.clj index 8c3a21a..6012a5e 100644 --- a/src/weepinbell/utils.clj +++ b/src/weepinbell/utils.clj @@ -100,3 +100,12 @@ :headers {"Content-Type" "application/json; charset=utf-8"} :body json-string}))) +(defn format-list [coll] + (let [total (count coll)] + (cond + (= total 0) "" + (= total 1) (first coll) + :else (str (clojure.string/join ", " (butlast coll)) + " and " + (last coll))))) + |
