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]
179
184
180
185
(let [{:user/keys [name slack-id]
181
186
:user-profile/keys [display-name real-name image-48]} user]
182
- (def slack-instance (:clojurians-log.application/slack-instance request))
183
-
184
-
185
187
; ; things in the profile
186
188
; ; :image_512 :email :real_name_normalized :image_48 :image_192 :real_name :image_72 :image_24
187
189
; ; :avatar_hash :title :team :image_32 :display_name :display_name_normalized
188
- (list [:div.message
189
- {:id (cl.tu/format-inst-id inst) :class (when (thread-child? message) " thread-msg" )}
190
- [:a.message_profile-pic {:href (str slack-instance " /users/x/x/" slack-id) :style (str " background-image: url(" image-48 " );" )}]
191
- ; ;[:a.message_username {:href (str slack-instance "/team/" slack-id)}
192
- [:a.message_username {:href (str " /_/_/users/" slack-id)}
193
- (some #(when-not (str/blank? %) %) [display-name real-name name])]
194
- [:span.message_timestamp [:a {:rel " nofollow"
195
- :href (path-for context
196
- :clojurians-log.routes/message
197
- {:channel (:channel/name channel)
198
- :date date
199
- :ts ts})}
200
- (cl.tu/format-inst-time inst)]]
201
- [:span.message_star ]
202
- [: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)]]]))
203
206
204
207
(defn- message-hiccup
205
208
" Returns either a single message hiccup, or if the given message starts a thread,
284
287
285
288
(defn- user-profile-html [context]
286
289
[:html.user-profile-page
287
- [:body
288
- [:h2 {:style " text-align:center; margin-top: 20px; font-family: sans-serif;" } " User Profile" ]
289
- [:div {:style " box-shadow: 0 4px 8px 0 rgba(0, 0, 0, 0.2); max-width: 350px;
290
- margin: auto; text-align: center; font-family: sans-serif;" }
291
-
292
- (for [[k v] (select-keys (get-in context [:data/user-profile 0 ])
293
- [:user-profile/display-name :user-profile/real-name :user-profile/image-192 :user/slack-id ])
294
- :when (-> k)]
295
- (case k
296
- :user-profile/image-192 [:img {:src v, :style " width:95%; border-radius:80%; padding: 8px 0px;" }]
297
- :user-profile/display-name [:h1 v]
298
- :user-profile/real-name [:p {:style " color: grey; font-size: 18px;" } v]
299
- :user/slack-id [:a {:style " border: none; outline: 0; display: inline-block; padding: 8px 0px;
300
- color: white; background-color: #000; text-align: center; cursor: pointer;
301
- width: 100%; font-size: 18px;"
302
- :href (str slack-instance " /team/" v )} " let's talk on Slack" ]))]]])
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" ]))]]])
303
302
304
303
(defn- sitemap-xml [{:data/keys [channel-day-tuples http-origin] :as context}]
305
304
[:urlset {:xmlns " http://www.sitemaps.org/schemas/sitemap/0.9" }
333
332
[:body
334
333
[:div
335
334
[:h4 " Slack message stats" ]
336
- [:p
335
+ [:p
337
336
[:strong {:style {:border-bottom " 1px solid black" }} (:day (first message-stats))]
338
337
" to "
339
338
[:strong {:style {:border-bottom " 1px solid black" }} (:day (last message-stats))]]
369
368
(assoc context :response/xml (sitemap-xml context)))
370
369
371
370
(defn message-stats-page [context]
372
- (assoc context :response/html (message-stats-page-html context)))
371
+ (assoc context :response/html (message-stats-page-html context)))
0 commit comments