<commit_before>(ns ^:figwheel-always bitfondue.core
    (:require [reagent.core :as reagent :refer [atom]]
              [ajax.core :refer [GET]]
              [secretary.core :as secretary :refer-macros [defroute]]
              [goog.events :as events]
              [goog.history.EventType :as EventType])
    (:import goog.History))

;; define your app data so that it doesn't get over-written on reload

(defonce chunks-state (atom '()))

;; ---
;; View Template
;; ---

(defn chunk-card
  [chunk]
  [:div.col-sm-4
   [:div.card.card-block
    [:h4.card-title (let [character-max-length 20]
                      (if (> character-max-length (count (:title chunk)))
                        (:title chunk)
                        (apply str (concat (take character-max-length (:title chunk))
                                           '("...")))))]
    [:p.card-text (:description_summary chunk)]]])

(defn chunks
  []
  [:div.chunks
   (for [chunk-row (->> @chunks-state
                        (sort-by :created_on)
                        (partition-all 3))]
     [:div.row
      (for [item chunk-row]
        [chunk-card item])])])

(defn header
  []
  [:nav.navbar.navbar-light.bg-faded
   [:div.container
    [:a.navbar-brand {:href "#"} "bitfondue"]
    [:ul.nav.navbar-nav
     [:li.nav-item
      [:a.nav-link {:href "#features"} "Features"]]
     [:li.nav-item
      [:a.nav-link {:href "#pricing"} "Pricing"]]
     [:li.nav-item
      [:a.nav-link {:href "#about"} "About"]]]
    [:ul.nav.navbar-nav.pull-right
     [:li.nav-item
      [:a.nav-link {:href "#login"} "Login"]]
     [:li.nav-item
      [:a.nav-link {:href "#register"} "Register"]]]]])

(defn layout
  [content]
  [:div
   [header]
   [:br]
   [:div.container content]])

(defn home-anonymous []
  [layout [:h1 "Home"]])

(defn home-authenticated []
  [layout [chunks]])

(defn features []
  [layout [:h1 "Features"]])

(defn pricing []
  [layout [:h1 "Pricing"]])

(defn about []
  [layout [:h1 "About"]])

(def login-form
  [:div.col-md-6
   [:form
    [:fieldset.form-group
     [:label {:for "usernameInput"} "Username"]
     [:input.form-control {:type "email" :id "usernameInput" :placeholder "Your username please."}]]]])

(defn login []
  [layout [:div.row
           [:h1 "Login"]
           login-form]])

(defn register []
  [layout [:h1 "Register"]])

(defn not-found []
  [layout [:h1 "404 - Page not found"]])

;; ---
;; Load data from the API
;; ---

(defn chunks-success-handler
  [response]
  (reset! chunks-state (:chunks response)))

(defn chunks-error-handler
  [{:keys [status status-text]}]
  nil)

(defn fetch-chunks
  []
  (GET "/chunks" {:response-format :json<commit_msg>moving all the login content into the login-form; adding a password field and submit button<commit_after>(ns ^:figwheel-always bitfondue.core
    (:require [reagent.core :as reagent :refer [atom]]
              [ajax.core :refer [GET]]
              [secretary.core :as secretary :refer-macros [defroute]]
              [goog.events :as events]
              [goog.history.EventType :as EventType])
    (:import goog.History))

;; define your app data so that it doesn't get over-written on reload

(defonce chunks-state (atom '()))

;; ---
;; View Template
;; ---

(defn chunk-card
  [chunk]
  [:div.col-sm-4
   [:div.card.card-block
    [:h4.card-title (let [character-max-length 20]
                      (if (> character-max-length (count (:title chunk)))
                        (:title chunk)
                        (apply str (concat (take character-max-length (:title chunk))
                                           '("...")))))]
    [:p.card-text (:description_summary chunk)]]])

(defn chunks
  []
  [:div.chunks
   (for [chunk-row (->> @chunks-state
                        (sort-by :created_on)
                        (partition-all 3))]
     [:div.row
      (for [item chunk-row]
        [chunk-card item])])])

(defn header
  []
  [:nav.navbar.navbar-light.bg-faded
   [:div.container
    [:a.navbar-brand {:href "#"} "bitfondue"]
    [:ul.nav.navbar-nav
     [:li.nav-item
      [:a.nav-link {:href "#features"} "Features"]]
     [:li.nav-item
      [:a.nav-link {:href "#pricing"} "Pricing"]]
     [:li.nav-item
      [:a.nav-link {:href "#about"} "About"]]]
    [:ul.nav.navbar-nav.pull-right
     [:li.nav-item
      [:a.nav-link {:href "#login"} "Login"]]
     [:li.nav-item
      [:a.nav-link {:href "#register"} "Register"]]]]])

(defn layout
  [content]
  [:div
   [header]
   [:br]
   [:div.container content]])

(defn home-anonymous []
  [layout [:h1 "Home"]])

(defn home-authenticated []
  [layout [chunks]])

(defn features []
  [layout [:h1 "Features"]])

(defn pricing []
  [layout [:h1 "Pricing"]])

(defn about []
  [layout [:h1 "About"]])

(def login-form
  [:div.col-md-6
   [:h1 "Login"]
   [:br]
   [:form
    [:fieldset.form-group
     [:label {:for "usernameInput"} "Username"]
     [:input.form-control {:type "email" :id "usernameInput" :placeholder "Your username please."}]]
    [:fieldset.form-group
     [:label {:for "passwordInput"} "Password"]
     [:input.form-control {:type "password" :id "passwordInput" :placeholder "Password"}]]
    [:button.btn.btn-primary {:type "submit"} "Login"]]])

(defn login []
  [layout [:div.row login-form]])

(defn register []
  [layout [:h1 "Register"]])

(defn not-found []
  [layout [:h1 "404 - Page not found"]])

;; ---
;; Load data from the API
;; ---

(defn chunks-success-handler
  [response]
  (reset! chunks-state (:chunks response)))

(defn chunks-error-handler
  [{:keys [status status-text]}]
  nil)

(defn fetch-chunks
  []
  (GET "/chunks" {:response-format :json
{'fraction_non_alphanumeric': 0.19131205673758866, 'fraction_numerical': 0.005673758865248227, 'mean_word_length': 2.4564950980392157, 'pattern_counts': {'":': 0, '<': 3, '<?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': 4, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '491949', 'n_tokens_mistral': 2043, 'n_tokens_neox': 1917, 'n_words': 454}