170
170
:date future-date})}
171
171
[:div.day-next " >" ]])]]])
172
172
173
+ (defn slack-url [ctx & parts]
174
+ (apply str
175
+ (get-in ctx [:request :clojurians-log.application/slack-instance ])
176
+ parts))
177
+
173
178
(defn- single-message
174
179
" Returns the hiccup of a single message"
175
180
[{:keys [request]
178
183
{:message/keys [user inst user text thread-ts ts] :as message}]
179
184
180
185
(let [{:user/keys [name slack-id]
181
- :user-profile/keys [display-name real-name image-48]} user
182
- slack-instance (:clojurians-log.application/slack-instance request)]
183
-
186
+ :user-profile/keys [display-name real-name image-48]} user]
184
187
; ; things in the profile
185
188
; ; :image_512 :email :real_name_normalized :image_48 :image_192 :real_name :image_72 :image_24
186
189
; ; :avatar_hash :title :team :image_32 :display_name :display_name_normalized
187
- (list [:div.message
188
- {:id (cl.tu/format-inst-id inst) :class (when (thread-child? message) " thread-msg" )}
189
- [:a.message_profile-pic {:href (str slack-instance " /team/" slack-id) :style (str " background-image: url(" image-48 " );" )}]
190
- [:a.message_username {:href (str slack-instance " /team/" slack-id)}
191
- (some #(when-not (str/blank? %) %) [display-name real-name name])]
192
- [:span.message_timestamp [:a {:rel " nofollow"
193
- :href (path-for context
194
- :clojurians-log.routes/message
195
- {:channel (:channel/name channel)
196
- :date date
197
- :ts ts})}
198
- (cl.tu/format-inst-time inst)]]
199
- [:span.message_star ]
200
- [:span.message_content [:p (slack-messages/message->hiccup text usernames emojis)]]])))
190
+ [:div.message
191
+ {:id (cl.tu/format-inst-id inst) :class (when (thread-child? message) " thread-msg" )}
192
+ [:a.message_profile-pic {:href (slack-url context " /users/x/x/" slack-id)
193
+ :style (str " background-image: url(" image-48 " );" )}]
194
+ ; ;[:a.message_username {:href (str slack-instance "/team/" slack-id)}
195
+ [:a.message_username {:href (str " /_/_/users/" slack-id)}
196
+ (some #(when-not (str/blank? %) %) [display-name real-name name])]
197
+ [:span.message_timestamp [:a {:rel " nofollow"
198
+ :href (path-for context
199
+ :clojurians-log.routes/message
200
+ {:channel (:channel/name channel)
201
+ :date date
202
+ :ts ts})}
203
+ (cl.tu/format-inst-time inst)]]
204
+ [:span.message_star ]
205
+ [:span.message_content [:p (slack-messages/message->hiccup text usernames emojis)]]]))
201
206
202
207
(defn- message-hiccup
203
208
" Returns either a single message hiccup, or if the given message starts a thread,
280
285
[:section#about
281
286
(:data/about-hiccup context)]]]])
282
287
288
+ (defn- user-profile-html [context]
289
+ [:html.user-profile-page
290
+ (page-head context)
291
+ [:body
292
+ [:h2 " User Profile" ]
293
+ [:section
294
+ (let [user-profile (get-in context [:data/user-profile ])
295
+ {:user-profile/keys [display-name real-name image-192]
296
+ :user/keys [slack-id]} user-profile]
297
+ (list
298
+ [:img {:src image-192 :alt (str display-name " avatar" )}]
299
+ [:h1 display-name]
300
+ [:p.real-name real-name]
301
+ [:a.talk-on-slack {:href (slack-url context " /team/" slack-id)} " let's talk on Slack" ]))]]])
302
+
283
303
(defn- sitemap-xml [{:data/keys [channel-day-tuples http-origin] :as context}]
284
304
[:urlset {:xmlns " http://www.sitemaps.org/schemas/sitemap/0.9" }
285
305
(for [[{:channel/keys [name]} channel-days] channel-day-tuples]
312
332
[:body
313
333
[:div
314
334
[:h4 " Slack message stats" ]
315
- [:p
335
+ [:p
316
336
[:strong {:style {:border-bottom " 1px solid black" }} (:day (first message-stats))]
317
337
" to "
318
338
[:strong {:style {:border-bottom " 1px solid black" }} (:day (last message-stats))]]
341
361
(defn about [context]
342
362
(assoc context :response/html (about-html context)))
343
363
364
+ (defn user-profile-route [context]
365
+ (assoc context :response/html (user-profile-html context)))
366
+
344
367
(defn sitemap [context]
345
368
(assoc context :response/xml (sitemap-xml context)))
346
369
347
370
(defn message-stats-page [context]
348
- (assoc context :response/html (message-stats-page-html context)))
371
+ (assoc context :response/html (message-stats-page-html context)))
0 commit comments