<commit_before>(ns omchaya.components.sidebar
  (:require [cljs.core.async :as async :refer [>! <! alts! chan sliding-buffer put! close!]]
            [clojure.string :as string]
            [goog.string :as gstring]
            [om.core :as om]
            [omchaya.utils :as utils]
            [sablono.core :as html :refer-macros [html]]))

(def icon-map
  {"png" "img"
   "jpg" "img"
   "jpeg" "img"})

(defn media-entry [comm media]
  (let [extension (-> (string/split (:src media) #"\?")
                      first
                      (string/split #"\.")
                      last)]
    [:li.file_item {:key (:src media)}
     [:a
      {:href "#"
       :on-click (constantly false)
       :target "_blank"}
      [:img {:src (str "/assets/images/" (get icon-map extension "file") "_icon.png")}]
      [:span (:name media)]]]))

(defn people-entry [comm person]
  [:li.user
   {:title (or (:full-name person)
               (:username person)
               (:email person))
    :key (:email person)}
   (utils/gravatar-for (:email person))
   (or (:full-name person)
       (:username person))])

(defn current-user [comm user]
  [:a.user-menu-toggle
   {:href "#"
    :on-click (comp (constantly false)
                    #(put! comm [:user-menu-toggled]))}
   (utils/gravatar-for (:email user))
   [:i.icon-angle.button.right {:style #js {:height "inherit"}}]
   (:full-name user)])

(defn playlist-entry [comm opts entry]
  (let [src (:src entry)
        name (-> (:src entry)
                 (string/split #"/")
                 last
                 (string/split #"\?")
                 first
                 gstring/urlDecode)]
    [:li.user
     (merge {:title (:src entry)
             :key (str (:order entry) src)}
            (when (= (:order entry) (get-in opts [:channels (:selected-channel opts) :player :playing-order]))
              {:style #js {:background-color "#ccc"}}))
     [:a
      {:style #js {:cursor "pointer"}
       :on-click (comp (constantly false)
                       #(put! comm [:playlist-entry-played [(:order entry) (:selected-channel opts)]]))}
      (:order entry) ". " name]]))

(defn playlist-widget [player-data owner opts]
  (reify
    om/IRender
    (render [_]
      (html/html
       (let [comm (get-in opts [:comms :controls])]
         [:div.widget-content<commit_msg>Don't read from cursor outside render<commit_after>(ns omchaya.components.sidebar
  (:require [cljs.core.async :as async :refer [>! <! alts! chan sliding-buffer put! close!]]
            [clojure.string :as string]
            [goog.string :as gstring]
            [om.core :as om]
            [omchaya.utils :as utils]
            [sablono.core :as html :refer-macros [html]]))

(def icon-map
  {"png" "img"
   "jpg" "img"
   "jpeg" "img"})

(defn media-entry [comm media]
  (let [extension (-> (string/split (:src media) #"\?")
                      first
                      (string/split #"\.")
                      last)]
    [:li.file_item {:key (:src media)}
     [:a
      {:href "#"
       :on-click (constantly false)
       :target "_blank"}
      [:img {:src (str "/assets/images/" (get icon-map extension "file") "_icon.png")}]
      [:span (:name media)]]]))

(defn people-entry [comm person]
  [:li.user
   {:title (or (:full-name person)
               (:username person)
               (:email person))
    :key (:email person)}
   (utils/gravatar-for (:email person))
   (or (:full-name person)
       (:username person))])

(defn current-user [comm user]
  [:a.user-menu-toggle
   {:href "#"
    :on-click (comp (constantly false)
                    #(put! comm [:user-menu-toggled]))}
   (utils/gravatar-for (:email user))
   [:i.icon-angle.button.right {:style #js {:height "inherit"}}]
   (:full-name user)])

(defn playlist-entry [comm opts entry]
  (let [src (:src entry)
        order (:order entry)
        name (-> (:src entry)
                 (string/split #"/")
                 last
                 (string/split #"\?")
                 first
                 gstring/urlDecode)]
    [:li.user
     (merge {:title src
             :key (str (:order entry) src)}
            (when (= (:order entry) (get-in opts [:channels (:selected-channel opts) :player :playing-order]))
              {:style #js {:background-color "#ccc"}}))
     [:a
      {:style #js {:cursor "pointer"}
       :on-click (comp (constantly false)
                       #(put! comm [:playlist-entry-played [order (:selected-channel opts)]]))}
      (:order entry) ". " name]]))

(defn playlist-widget [player-data owner opts]
  (reify
    om/IRender
    (render [_]
      (html/html
       (let [comm (get-in opts [:comms :controls])]
         [:div.widget-content
{'fraction_non_alphanumeric': 0.1729339281920544, 'fraction_numerical': 0.0, 'mean_word_length': 2.0083067092651756, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 9, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4805647', 'n_tokens_mistral': 1583, 'n_tokens_neox': 1479, 'n_words': 395}