<commit_before>(ns moodseer-clj.core
  (:use [noir.core]
        [hiccup.page]
        [net.cgrand.enlive-html :as html :only [deftemplate at content set-attr attr? strict-mode defsnippet]])
  (:require [noir.server :as server])
  (:require [moodseer-clj.ajax])
  (:require [cheshire.core :as json])
  (:import (java.io StringReader BufferedReader)))

(def starting-links [{:desc "Escape to the mothership" :url "http://www.google.com" :important true}
                     {:desc "First test page GORT" :url "/gort"}
                     {:desc "Moodseer HTML5 Clojure" :url "/zoneplayer" :important true}])

(defpage "/" []
  (html5 [:h1 "Hello World"]
         (include-css "/css/standard.css")
         [:h2 "First sub-section header"]
         [:ul
          (for [link starting-links]
          [:li [:a {:href (:url link)} (:desc link)]])
          ]))

(deftemplate index "html/gort.html"
  [ctxt]
  [:div#preamble] (html/content (:message ctxt))
  )

(defpartial layout [& content]
  (html5
   [:head
    [:title "My Moodseer Pang"]
    (include-css "/css/standard.css")]
   [:body
    [:div#wrapper
    content]]))

(defpartial api [params & [content]]
  (let [params (into {} params)
        cmd (:cmd params)
        resp
        (cond
          (= "play" cmd) (moodseer-clj.process/start-player "-shuffle -playlist /home/gregj/work/all.m3u")
          (= "pause" cmd) (moodseer-clj.process/pause-player)
          (= "stop" cmd) (moodseer-clj.process/pause-player)
          (= "next" cmd) (moodseer-clj.process/next-player)
          (= "prev" cmd) (moodseer-clj.process/prev-player)
          (= "quit" cmd) (moodseer-clj.process/quit-player)
          (= "nowplaying" cmd) (moodseer-clj.process/mplayer-pairs->map (moodseer-clj.process/get-player-track-info)))]
    (if (= "nowplaying" cmd)
      (cheshire.core/generate-string {:status true :message "Hello" :nowplaying resp})
      (cheshire.core/generate-string {:testresponse {:message "WTF honey" :muted false :command  cmd}}))))

(defpage "/api:cmd" {:as params}
  (api params))

(deftemplate zone-player "html/tsplayer.html"
  [& payload]
  )

;; (deftemplate footer "html/footer.html" [& payload])

(defpage "/zoneplayer" []
  (zone-player))<commit_msg>Change to defpartial api - for use with mpc/mpd<commit_after>(ns moodseer-clj.core
  (:use [noir.core]
        [hiccup.page]
        [net.cgrand.enlive-html :as html :only [deftemplate at content set-attr attr? strict-mode defsnippet]])
  (:require [noir.server :as server])
  (:require [moodseer-clj.ajax])
  (:require [cheshire.core :as json])
  (:import (java.io StringReader BufferedReader)))

(def starting-links [{:desc "Escape to the mothership" :url "http://www.google.com" :important true}
                     {:desc "First test page GORT" :url "/gort"}
                     {:desc "Moodseer HTML5 Clojure" :url "/zoneplayer" :important true}])

(defpage "/" []
  (html5 [:h1 "Hello World"]
         (include-css "/css/standard.css")
         [:h2 "First sub-section header"]
         [:ul
          (for [link starting-links]
          [:li [:a {:href (:url link)} (:desc link)]])
          ]))

(deftemplate index "html/gort.html"
  [ctxt]
  [:div#preamble] (html/content (:message ctxt))
  )

(defpartial layout [& content]
  (html5
   [:head
    [:title "My Moodseer Pang"]
    (include-css "/css/standard.css")]
   [:body
    [:div#wrapper
    content]]))

;; (defpartial api [params & [content]]
;;   (let [params (into {} params)
;;         cmd (:cmd params)
;;         resp
;;         (cond
;;           (= "play" cmd) (moodseer-clj.process/start-player "-shuffle -playlist /home/gregj/work/all.m3u")
;;           (= "pause" cmd) (moodseer-clj.process/pause-player)
;;           (= "stop" cmd) (moodseer-clj.process/pause-player)
;;           (= "next" cmd) (moodseer-clj.process/next-player)
;;           (= "prev" cmd) (moodseer-clj.process/prev-player)
;;           (= "quit" cmd) (moodseer-clj.process/quit-player)
;;           (= "nowplaying" cmd) (moodseer-clj.process/mplayer-pairs->map (moodseer-clj.process/get-player-track-info)))]
;;     (if (= "nowplaying" cmd)
;;       (cheshire.core/generate-string {:status true :message "Hello" :nowplaying resp})
;;       (cheshire.core/generate-string {:testresponse {:message "WTF honey" :muted false :command  cmd}}))))

(defpartial api [params & [content]]
  (let [params (into {} params)
        cmd (:cmd params)
        resp
        (cond
          (= "play" cmd) (moodseer-clj.process/play-player)
          (= "pause" cmd) (moodseer-clj.process/pause-player)
          (= "stop" cmd) (moodseer-clj.process/pause-player)
          (= "next" cmd) (moodseer-clj.process/next-player)
          (= "prev" cmd) (moodseer-clj.process/prev-player)
          (= "quit" cmd) nil
          (= "nowplaying" cmd) (moodseer-clj.process/player-nowplaying)
          (= "upcoming"   cmd) (moodseer-clj.process/get-player-upcoming))
        ]
    (cond
      (= "nowplaying" cmd) (cheshire.core/generate-string {:status true :message "Hello" :nowplaying resp})
      (= "upcoming" cmd) (cheshire.core/generate-string {:status true :message "Hello" :upcoming {:songlist resp}})
      true      (cheshire.core/generate-string {:testresponse {:message "WTF honey" :muted false :command  cmd}}))))

(defpage "/api:cmd" {:as params}
  (api params))

(deftemplate zone-player "html/tsplayer.html"
  [& payload]
  )

;; (deftemplate footer "html/footer.html" [& payload])

(defpage "/zoneplayer" []
  (zone-player))
{'fraction_non_alphanumeric': 0.17412663755458516, 'fraction_numerical': 0.002183406113537118, 'mean_word_length': 2.841369671558351, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, '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': '4408481', 'n_tokens_mistral': 2002, 'n_tokens_neox': 1931, 'n_words': 421}