Skip to content

Commit

Permalink
Implement initial build script
Browse files Browse the repository at this point in the history
  • Loading branch information
jkrasnay committed Dec 18, 2024
1 parent e895aa4 commit cadd2f7
Show file tree
Hide file tree
Showing 5 changed files with 41 additions and 5 deletions.
4 changes: 4 additions & 0 deletions bb.edn
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{:paths ["src"]
:tasks
{:requires [[linkup.core :as linkup]]
build (linkup/build)}}
5 changes: 3 additions & 2 deletions docs/test.ics → docs/clojureto.ics
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,10 @@ VERSION:2.0
PRODID:-//linkup//linkup//EN
METHOD:PUBLISH
BEGIN:VEVENT
UID:
DTSTAMP:20241218T010628Z
UID:clojureto
DTSTAMP:20241218T015254Z
SUMMARY:Clojure Toronto
RRULE:FREQ=MONTHLY;INTERVAL=1;BYDAY=3TU
DTSTART:20241218T000000Z
DTEND:20241218T020000Z
END:VEVENT
Expand Down
6 changes: 6 additions & 0 deletions docs/events/clojureto.edn
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{:id "clojureto"
:date "2024-12-17"
:rrule "FREQ=MONTHLY;INTERVAL=1;BYDAY=3TU"
:start-time "19:00"
:end-time "21:00"
:summary "Clojure Toronto"}
1 change: 1 addition & 0 deletions docs/index.json
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
["events/clojureto.edn"]
30 changes: 27 additions & 3 deletions src/linkup/core.clj
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
(ns linkup.core
(:require
[babashka.fs :as fs]
[cheshire.core :as json]
[clojure.edn :as edn]
[clojure.string :as string])
(:import
[java.time Instant LocalDate LocalTime ZonedDateTime ZoneId ZoneOffset]
Expand Down Expand Up @@ -51,15 +54,19 @@

(defn print-time-slot
[time-slot timezone]
(let [{:keys [date
(let [{:keys [id
date
start-time
end-time
rrule
summary
location]} time-slot]
(vprintln "BEGIN:VEVENT")
(vprintln (str "UID:" (:id time-slot)))
(vprintln (str "UID:" id))
(vprintln (str "DTSTAMP:" (format-instant (Instant/now))))
(vprintln (str "SUMMARY:" summary))
(when rrule
(vprintln (str "RRULE:" rrule)))
(when location
(vprintln (str "LOCATION:" location)))
(vprintln (str "DTSTART:" (utc-time-string date start-time timezone)))
Expand All @@ -78,11 +85,28 @@
(vprintln "END:VCALENDAR"))


(defn build
[]
(let [event-files (->> (fs/glob "docs/events" "*.edn")
(map str))]
(doseq [file-name event-files]
(let [[_ root] (re-find #"([^/]+).edn" file-name)
edn (-> (slurp file-name)
edn/read-string)]
(spit (str "docs/" root ".ics")
(with-out-str
(print-calendar [edn] "America/Toronto")))))
(spit "docs/index.json"
(json/encode (->> event-files
(map (fn [s] (string/replace s "docs/" ""))))))))

(comment

(re-find #"([^/]+).edn" "foo/bar/baz.edn")

(spit "docs/test.ics" (with-out-str
(print-calendar [{:date "2024-12-17"
(print-calendar [{:id "clojureto"
:date "2024-12-17"
:start-time "19:00"
:end-time "21:00"
:summary "Clojure Toronto"
Expand Down

0 comments on commit cadd2f7

Please sign in to comment.