<commit_before>(ns casper.core
  (:gen-class)
  (:use compojure.core)
  (:use ring.adapter.jetty)
  (:require
    [ casper.crypto :refer [encrypt decrypt encrypt-base64 decrypt-base64]] 
    ;[ casper.db-ram :refer [insert-secret select-secret delete-secret]] 
    [ casper.db-ram :refer [insert-secret select-secret delete-secret now-seconds]] 
    [charset-bytes.core :refer [utf8-bytes]]
    [compojure.handler :as handler]
    [compojure.route :as route]
    [digest :as digest]
    [ring.util.response :refer [redirect]]
  )
)

; Content-Type for plain text
(def plain-text {"Content-Type" "text/plain; charset=utf-8"})

; HTML for the create form
(def create-html (str "<form method='post' action='/create'>"
                    "<textarea type='text' name='secret' rows='4' cols='50'>What's your secret</textarea >"
                    "<p><input type='submit' /></p>"
                    "</form>"))
; HTTP response codes
(def http-status-ok 200)
(def http-status-created 201)
(def http-status-bad-request 400)
(def http-status-not-found 404)
(def http-status-gone 410)

; Encryption key - TBD needs improvement
(def encryption-key "<KEY>")

; Create a unique URL consistent id
(defn unique-key [] (digest/md5 (str (java.util.UUID/randomUUID))))

(defroutes casper-routes           
  (GET "/" [] (redirect "/create"))

  (GET "/create" [] create-html)

  (GET "/secret/:id" [id] 
    (let [ record  (first (select-secret id)) ]
      (delete-secret id) 
      (if (= 0 (count record))
        { :status http-status-not-found
          :headers plain-text
          :body "Secret already viewed"<commit_msg>add TTL to the form and placeholders<commit_after>(ns casper.core
  (:gen-class)
  (:use compojure.core)
  (:use ring.adapter.jetty)
  (:require
    [ casper.crypto :refer [encrypt decrypt encrypt-base64 decrypt-base64]] 
    ;[ casper.db-ram :refer [insert-secret select-secret delete-secret]] 
    [ casper.db-ram :refer [insert-secret select-secret delete-secret now-seconds]] 
    [charset-bytes.core :refer [utf8-bytes]]
    [compojure.handler :as handler]
    [compojure.route :as route]
    [digest :as digest]
    [ring.util.response :refer [redirect]]
  )
)

; Content-Type for plain text
(def plain-text {"Content-Type" "text/plain; charset=utf-8"})

; HTML for the create form
(def create-html (str "<form method='post' action='/create'>"
                    "<textarea type='text' name='secret' rows='4' cols='50' placeholder='What is your secret'></textarea >"
                    "<p><input type='text' name='ttl' placeholder='TTL (seconds)'/></p>"
                    "<p><input type='submit' /></p>"
                    "</form>"))
; HTTP response codes
(def http-status-ok 200)
(def http-status-created 201)
(def http-status-bad-request 400)
(def http-status-not-found 404)
(def http-status-gone 410)

; Encryption key - TBD needs improvement
(def encryption-key "<KEY>")

; Create a unique URL consistent id
(defn unique-key [] (digest/md5 (str (java.util.UUID/randomUUID))))

(defroutes casper-routes           
  (GET "/" [] (redirect "/create"))

  (GET "/create" [] create-html)

  (GET "/secret/:id" [id] 
    (let [ record  (first (select-secret id)) ]
      (delete-secret id) 
      (if (= 0 (count record))
        { :status http-status-not-found
          :headers plain-text
          :body "Secret already viewed"
{'fraction_non_alphanumeric': 0.15812983918999404, 'fraction_numerical': 0.015485407980941036, 'mean_word_length': 2.998809523809524, 'pattern_counts': {'":': 0, '<': 22, '<?xml version=': 0, '>': 22, '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': '5353598', 'n_tokens_mistral': 1156, 'n_tokens_neox': 1088, 'n_words': 288}