<commit_before>(ns db-quiz.core
  (:require [db-quiz.components :as components]
            [reagent.core :as reagent]
            [reagent.session :as session]
            [secretary.core :as secretary :refer-macros [defroute]]
            [goog.events :as events]
            [goog.history.EventType :as EventType])
  (:import goog.History))

(enable-console-print!)
(.initializeTouchEvents js/React true)

;; -------------------------
;; Views

(secretary/set-config! :prefix "#")

(defn current-page []
  [:div [(session/get :current-page)]])

;; -------------------------
;; Routes

(defroute "/" []
  (session/put! :current-page components/home-page))

(defroute "/end" []
  (session/put! :current-page components/end-page))

(defroute "/play" []
  (session/put! :current-page components/play-page))

(defroute "*" []
  (session/put! :current-page components/not-found))

;; -------------------------
;; History
;; must be called after routes have been defined
(defn hook-browser-navigation! []
  (doto (History.)
    (events/listen
     EventType/NAVIGATE
     (fn [event]
       (secretary/dispatch! (.-token event))))
    (.setEnabled true)))

;; -------------------------
;; Initialize app
(defn mount-root []
  (reagent/render [current-page] (.getElementById js/document "app")))

(defn init! []
  (hook-browser-navigation!)
  (mount-root))

(defn on-js-reload []
  ;; optionally touch your app-state to force rerendering depending on
  ;; your application
  ;; (swap! app-state update-in [:__figwheel_counter] inc)
  )<commit_msg>Handle Facebook's appending junk to URL<commit_after>(ns db-quiz.core
  (:require [db-quiz.components :as components]
            [reagent.core :as reagent]
            [reagent.session :as session]
            [secretary.core :as secretary :refer-macros [defroute]]
            [goog.events :as events]
            [goog.history.EventType :as EventType])
  (:import goog.History))

(enable-console-print!)
(.initializeTouchEvents js/React true)

;; -------------------------
;; Views

(secretary/set-config! :prefix "#")

(defn current-page []
  [:div [(session/get :current-page)]])

;; -------------------------
;; Routes

(defroute "/" []
  (session/put! :current-page components/home-page))

(defroute "/end" []
  (session/put! :current-page components/end-page))

(defroute "/play" []
  (session/put! :current-page components/play-page))

; Handle Facebook's appending junk to URL.
(defroute "/_=_" []
  (session/put! :current-page components/home-page))

(defroute "*" []
  (session/put! :current-page components/not-found))

;; -------------------------
;; History
;; must be called after routes have been defined
(defn hook-browser-navigation! []
  (doto (History.)
    (events/listen
     EventType/NAVIGATE
     (fn [event]
       (secretary/dispatch! (.-token event))))
    (.setEnabled true)))

;; -------------------------
;; Initialize app
(defn mount-root []
  (reagent/render [current-page] (.getElementById js/document "app")))

(defn init! []
  (hook-browser-navigation!)
  (mount-root))

(defn on-js-reload []
  ;; optionally touch your app-state to force rerendering depending on
  ;; your application
  ;; (swap! app-state update-in [:__figwheel_counter] inc)
  )
{'fraction_non_alphanumeric': 0.21506042764177255, 'fraction_numerical': 0.0, 'mean_word_length': 2.6598639455782314, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 2, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1751336', 'n_tokens_mistral': 1035, 'n_tokens_neox': 1003, 'n_words': 233}