From 053805d34e1733ed5ece62c7695925b832c03aea Mon Sep 17 00:00:00 2001 From: kloimhardt Date: Thu, 12 Mar 2020 18:56:09 +0100 Subject: [PATCH 1/4] Add about section --- src/clojurians_log/routes.clj | 8 ++++++++ src/clojurians_log/views.clj | 14 ++++++++++++++ 2 files changed, 22 insertions(+) diff --git a/src/clojurians_log/routes.clj b/src/clojurians_log/routes.clj index 21becd0..36453ff 100644 --- a/src/clojurians_log/routes.clj +++ b/src/clojurians_log/routes.clj @@ -116,9 +116,17 @@ views/channel-page response/render))) +(defn about [request] + (-> request + context + views/about + response/render)) + (def routes [["/" {:name :clojurians-log.routes/index :get index-route}] + ["/x/x/x/about" {:name :clojurians-log.routes/about + :get about}] ["/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..daf5363 100644 --- a/src/clojurians_log/views.clj +++ b/src/clojurians_log/views.clj @@ -220,6 +220,8 @@ [:body [:div.main (fork-me-badge) + [:a {:href (path-for context :clojurians-log.routes/about)} + "About Clojurians Slack Log"] [:h1 "Channels"] [:ul (for [{:channel/keys [name]} channels] @@ -237,3 +239,15 @@ (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 "clojurians.net"} "Clojurians Slack community"] ". Unfortunately it suffers from its popularity. Slack will only retain the last 10,000 messages of history, which means that less than two weeks of logs are kept available. A lot of valuable information is in that chat history, and so the Clojureverse team set up a logging service so that these logs aren’t lost in time."]]]]) + +(defn about [context] + (assoc context :response/html (about-html context))) From 4d5630ccb7fa13f9b221da00c8c269da8b75747e Mon Sep 17 00:00:00 2001 From: kloimhardt Date: Fri, 13 Mar 2020 17:51:34 +0100 Subject: [PATCH 2/4] about text --- src/clojurians_log/views.clj | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/src/clojurians_log/views.clj b/src/clojurians_log/views.clj index daf5363..1031753 100644 --- a/src/clojurians_log/views.clj +++ b/src/clojurians_log/views.clj @@ -247,7 +247,15 @@ [: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 "clojurians.net"} "Clojurians Slack community"] ". Unfortunately it suffers from its popularity. Slack will only retain the last 10,000 messages of history, which means that less than two weeks of logs are kept available. A lot of valuable information is in that chat history, and so the Clojureverse team set up a logging service so that these logs aren’t lost in time."]]]]) + [: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))) From 2436f5a612247d1da75ee1eadd21f723c3d4623e Mon Sep 17 00:00:00 2001 From: kloimhardt Date: Fri, 13 Mar 2020 19:43:36 +0100 Subject: [PATCH 3/4] fix the 500 error after calling (go) in repl --- profiles/dev/user.clj | 8 ++++++++ src/clojurians_log/db/queries.clj | 5 ++++- src/clojurians_log/views.clj | 16 +++++++++------- 3 files changed, 21 insertions(+), 8 deletions(-) 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/views.clj b/src/clojurians_log/views.clj index 1031753..55f63d9 100644 --- a/src/clojurians_log/views.clj +++ b/src/clojurians_log/views.clj @@ -223,13 +223,15 @@ [:a {:href (path-for context :clojurians-log.routes/about)} "About Clojurians Slack Log"] [: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))) From a11fdfada343adc5536666a1aac33d1199c682c2 Mon Sep 17 00:00:00 2001 From: kloimhardt Date: Sat, 14 Mar 2020 20:23:20 +0100 Subject: [PATCH 4/4] sitemap --- src/clojurians_log/routes.clj | 16 ++++++++++++++-- src/clojurians_log/views.clj | 30 +++++++++++++++++++++++++++--- 2 files changed, 41 insertions(+), 5 deletions(-) diff --git a/src/clojurians_log/routes.clj b/src/clojurians_log/routes.clj index 36453ff..b1b0f09 100644 --- a/src/clojurians_log/routes.clj +++ b/src/clojurians_log/routes.clj @@ -116,17 +116,29 @@ views/channel-page response/render))) -(defn about [request] +(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}] + :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 55f63d9..704667d 100644 --- a/src/clojurians_log/views.clj +++ b/src/clojurians_log/views.clj @@ -220,8 +220,12 @@ [:body [:div.main (fork-me-badge) - [:a {:href (path-for context :clojurians-log.routes/about)} - "About Clojurians Slack Log"] + [: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"] (if (seq channels) [:ul @@ -258,6 +262,26 @@ "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)))