diff --git a/profiles/dev/user.clj b/profiles/dev/user.clj index 8246fcf..cf5f327 100644 --- a/profiles/dev/user.clj +++ b/profiles/dev/user.clj @@ -36,3 +36,11 @@ [:message-page :cache-time] (constantly new-cache-time)) true) + +(comment + (go) + (reset) + (reset-all) + (use 'clojurians-log.repl) + (load-demo-data! "../clojurians-log-demo-data") + #_:end) diff --git a/src/clojurians_log/db/queries.clj b/src/clojurians_log/db/queries.clj index 8ced964..47fdafc 100644 --- a/src/clojurians_log/db/queries.clj +++ b/src/clojurians_log/db/queries.clj @@ -82,7 +82,10 @@ (defn channel-days [db chan-name] (when-let [indexes @!indexes] - (let [{:keys [chan-day-cnt chan-name->id] :as index} @!indexes] + (let [{:keys [chan-day-cnt chan-name->id] :as index} + (if (seq @!indexes) + @!indexes + {:chan-day-cnt {} :chan-name->id {}})] (when index (some->> chan-name chan-name->id diff --git a/src/clojurians_log/routes.clj b/src/clojurians_log/routes.clj index 21becd0..b1b0f09 100644 --- a/src/clojurians_log/routes.clj +++ b/src/clojurians_log/routes.clj @@ -116,9 +116,29 @@ views/channel-page response/render))) +(defn about-route [request] + (-> request + context + views/about + response/render)) + +(defn sitemap-route [{:keys [endpoint] :as request}] + (let [db (db-from-endpoint endpoint)] + (-> request + context + (assoc :data/channel-day-tuples + (for [{:channel/keys [name] :as channel} (queries/channel-list db)] + [channel (queries/channel-days db name)])) + views/sitemap + response/render))) + (def routes [["/" {:name :clojurians-log.routes/index :get index-route}] + ["/x/x/x/about" {:name :clojurians-log.routes/about + :get about-route}] + ["/x/x/x/sitemap" {:name :clojurians-log.routes/sitemap + :get sitemap-route}] ["/x/x/x/healthcheck" {:name :clojurians-log.routes/healthcheck, :get healthcheck-route}] ["/{channel}" {:name :clojurians-log.routes/channel, diff --git a/src/clojurians_log/views.clj b/src/clojurians_log/views.clj index f288bd5..704667d 100644 --- a/src/clojurians_log/views.clj +++ b/src/clojurians_log/views.clj @@ -220,14 +220,22 @@ [:body [:div.main (fork-me-badge) + [:p + [:a {:href (path-for context :clojurians-log.routes/about)} + "About Clojurians Slack Log"]] + [:p + [:a {:href (path-for context :clojurians-log.routes/sitemap)} + "Sitemap"]] [:h1 "Channels"] - [:ul - (for [{:channel/keys [name]} channels] - [:li - [:a {:href (path-for context - :clojurians-log.routes/channel - {:channel name})} - "# " name]])]]]]) + (if (seq channels) + [:ul + (for [{:channel/keys [name]} channels] + [:li + [:a {:href (path-for context + :clojurians-log.routes/channel + {:channel name})} + "# " name]])] + [:p "no data loaded"])]]]) (defn log-page [context] (assoc context :response/html (log-page-html context))) @@ -237,3 +245,43 @@ (defn channel-list-page [context] (assoc context :response/html (channel-list-page-html context))) + +(defn- about-html [context] + [:html + (page-head context) + [:body + [:div.main + (fork-me-badge) + [:h1 "About Clojurians Slack Log"] + [:p "One of the main on-line hangouts for Clojure people is the " + [:a {:href "http://clojurians.net"} "Clojurians Slack community"] + ". Unfortunately it suffers from its popularity. Slack will only retain the last 10,000 messages of history, that is less than two weeks of logs. A lot of valuable information is in that chat history. The Clojureverse team has decided to set up this service so that the logs aren’t lost in time." + [:p "If some channel is not logging, it's probably because @logbot isn't receiving its messages. Feel free to invite @logbot to a channel to start logging"] + [:p "The source code is in " + [:a {:href "https://github.com/clojureverse/clojurians-log-app"} + "this"] " github repo, you are welcome to contribute."]] + [:p "The hosting of Clojurians Slack Log is kindly donated by " [:a {:href "https://www.exoscale.com"} "Exoscale."]]]]]) + +(defn about [context] + (assoc context :response/html (about-html context))) + +(defn- sitemap-html [{:data/keys [channel-day-tuples] :as context}] + [:html + (page-head context) + [:body + [:div.main + (fork-me-badge) + [:h1 "Sitemap"] + (if (seq channel-day-tuples) + [:ul + (for [[{:channel/keys [name]} channel-days] channel-day-tuples] + (for [[day cnt] channel-days] + [:li [:a {:href (path-for context + :clojurians-log.routes/channel-date + {:channel name + :date day})} + "# " name " " day " (" cnt ")"]]))] + [:p "no data loaded"])]]]) + +(defn sitemap [context] + (assoc context :response/html (sitemap-html context)))