<commit_before>(ns smgui.main
  (:require-macros [cljs.core.async.macros :refer [go go-loop]])
  (:require [om.core :as om]
            [om.dom :as dom]
            [smgui.components :refer [external-link pd]]
            [smgui.search :refer [render-search]]
            [smgui.settings :as settings]
            [smgui.organize :refer [render-organize]]
            [smgui.gui :as gui]
            [smgui.track :as track]
            [smgui.core :refer [app-state flux-channel]]
            [cljs.core.async :refer [put! chan <! >! timeout close!]]
            [clojure.data :as data]
            [clojure.string :as string]
            [weasel.repl :as ws-repl]))

(defn render-not-found []
  (dom/div nil "Página não encontrada"))

(defn render-page [cursor]
  (case (:page cursor)
    :search (render-search (-> cursor :searches))
    :organize (render-organize cursor)
    :settings (settings/render-page cursor)
    (render-not-found)))

(defn change-page [cursor new-page]
  (track/screen (name new-page))
  (om/update! cursor [:page] new-page))

(defn page-link [page cursor view]
  (let [class (if (= (:page cursor) page) "button selected" "button")]
    (dom/a #js {:href "#" :className class :onClick (pd #(change-page cursor page))} view)))

(defn main-view [cursor _]
  (reify
    om/IWillMount
    (will-mount [_]
      (track/screen (-> cursor :page name)))

    om/IRender
    (render [_]
      (dom/div #js {:className "app-container flex-column"}
        (dom/hr #js {:className "filmstrip shadow-down"})
        (render-page cursor)
        (dom/hr #js {:className "filmstrip shadow-up"})
        (dom/div #js {:className "app-menu flex-row"}
          (page-link :search cursor (dom/img #js {:src "images/icons/magnify.png"}))
          (page-link :organize cursor (dom/img #js {:src "images/icons/grid-1.png"}))
          (dom/div #js {:className "flex"})
          (external-link "https://www.facebook.com/subtitlemaster" (dom/img #js {:src "images/icons/facebook.png"}))
          (page-link :settings cursor (dom/img #js {:src "images/icons/gear.png"})))))))

(defn reset-app-to [state]
  (reset! app-state state)
  (om/root main-view app-state {:target (.-body js/document)}))

(defn init []
  (ws-repl/connect "ws://localhost:9001")<commit_msg>helper for rendering icons on main<commit_after>(ns smgui.main
  (:require-macros [cljs.core.async.macros :refer [go go-loop]])
  (:require [om.core :as om]
            [om.dom :as dom]
            [smgui.components :refer [external-link pd]]
            [smgui.search :refer [render-search]]
            [smgui.settings :as settings]
            [smgui.organize :refer [render-organize]]
            [smgui.gui :as gui]
            [smgui.track :as track]
            [smgui.core :refer [app-state flux-channel]]
            [cljs.core.async :refer [put! chan <! >! timeout close!]]
            [clojure.data :as data]
            [clojure.string :as string]
            [weasel.repl :as ws-repl]))

(defn render-not-found []
  (dom/div nil "Página não encontrada"))

(defn render-page [cursor]
  (case (:page cursor)
    :search (render-search (-> cursor :searches))
    :organize (render-organize cursor)
    :settings (settings/render-page cursor)
    (render-not-found)))

(defn change-page [cursor new-page]
  (track/screen (name new-page))
  (om/update! cursor [:page] new-page))

(defn page-link [page cursor view]
  (let [class (if (= (:page cursor) page) "button selected" "button")]
    (dom/a #js {:href "#" :className class :onClick (pd #(change-page cursor page))} view)))

(defn icon [name] (dom/img #js {:src (str "images/icons/" name ".png")}))

(defn main-view [cursor _]
  (reify
    om/IWillMount
    (will-mount [_]
      (track/screen (-> cursor :page name)))

    om/IRender
    (render [_]
      (dom/div #js {:className "app-container flex-column"}
        (dom/hr #js {:className "filmstrip shadow-down"})
        (render-page cursor)
        (dom/hr #js {:className "filmstrip shadow-up"})
        (dom/div #js {:className "app-menu flex-row"}
          (page-link :search cursor (icon "magnify"))
          (page-link :organize cursor (icon "grid-1"))
          (dom/div #js {:className "flex"})
          (external-link "https://www.facebook.com/subtitlemaster" (icon "facebook"))
          (page-link :settings cursor (icon "gear")))))))

(defn reset-app-to [state]
  (reset! app-state state)
  (om/root main-view app-state {:target (.-body js/document)}))

(defn init []
  (ws-repl/connect "ws://localhost:9001")
{'fraction_non_alphanumeric': 0.16880815241470978, 'fraction_numerical': 0.002215330084182543, 'mean_word_length': 2.7099424815119146, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 9, 'https://': 2, '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': '4087400', 'n_tokens_mistral': 1560, 'n_tokens_neox': 1519, 'n_words': 392}