<commit_before>(ns {{name}}.website
  (:require
   [modular.ring :refer (RingHandler)]
   [modular.bidi :refer (WebService as-ring-handler)]
   [hiccup.core :refer (html)]
   [liberator.core :refer (resource)]
   [bidi.bidi :refer (path-for)]))

{{! "We change the delimiters to avoid conflicting with nested destructuring in the code below" }}
{{=<% %>=}}

(defn index
  "Define a Liberator resource map for the index (home) page of the website"
  []
  {:available-media-types #{"text/html"}
   :handle-ok
   (fn [{{routes :modular.bidi/routes} ; it is common to destructure the
                                       ; bidi route structure from the
                                       ; request
         :request}]
     (html
      [:head
       [:title "Welcome"]]
      [:body
       [:h1 "Hello World! from <% name %>"]
       [:h2 "Links"]
       [:p [:a {:href (path-for routes ::main)} "Home"]]
       ]))})

;; Consider the component below. It is defined by defrecord.
;; It satisfies 2 protocols: modular.bidi.WebService and modular.ring.RingHandler

;; To satisfy modular.bidi.WebSerivce a component must provide the following:
;;   ring-handler-map: A map between keywords and Ring handlers
;;   routes: A bidi route structure, where terminals are keywords
;;              - these keywords correspond to the keys in ring-handler-map
;;   uri-context: Usually an empty string, but acts as a prefix to the route structure

;; By also satisfying the RingHandler protocol, this component can be
;; made a direct dependency of a Ring-compatible web server like
;; http-kit or Jetty. Whether this is the only web-serving component in
;; an application, or one of many (composed together by a router),
;; depends on the system's dependency map defined in system.clj

;; Finally there is the constructor, a function which creates an
;; instance of the component record.

(defrecord Website []
  WebService<commit_msg>Further comments<commit_after>(ns {{name}}.website
  (:require
   [modular.ring :refer (RingHandler)]
   [modular.bidi :refer (WebService as-ring-handler)]
   [hiccup.core :refer (html)]
   [liberator.core :refer (resource)]
   [bidi.bidi :refer (path-for)]))

{{! "We change the delimiters to avoid conflicting with nested destructuring in the code below" }}
{{=<% %>=}}

(defn index
  "Define a Liberator resource map for the index (home) page of the website"
  []
  {:available-media-types #{"text/html"}
   :handle-ok
   (fn [{{routes :modular.bidi/routes} ; it is common to destructure the
                                       ; bidi route structure from the
                                       ; request
         :request}]
     (html
      [:head
       [:title "Welcome"]]
      [:body
       [:h1 "Hello World! from <% name %>"]
       [:h2 "Links"]
       [:p [:a {:href (path-for routes ::main)} "Home"]]
       ]))})

;; Consider the component below. It is defined by defrecord.
;; It satisfies 2 protocols: modular.bidi.WebService and modular.ring.RingHandler

;; To satisfy modular.bidi.WebSerivce a component must provide the following:
;;   ring-handler-map: A map between keywords and Ring handlers
;;   routes: A bidi route structure, where terminals are keywords
;;              - these keywords correspond to the keys in ring-handler-map
;;   uri-context: Usually an empty string, but acts as a prefix to the route structure

;; The use of keywords is to allow looser coupling between generated
;; hyperlinks and the Ring handlers they route to. Every handler can be
;; targeted by using a keyword in bidi's path-for function. This
;; eliminates string-munging code that would otherwise be written to
;; form URIs, with the implicit coupling between this logic and the
;; route structure that would result. Note it is idiomatic to use
;; namespaced keywords so that there is less chance of conflict with
;; other keywords used by other components.

;; By also satisfying the RingHandler protocol, this component can be
;; made a direct dependency of a Ring-compatible web server like
;; http-kit or Jetty. Whether this is the only web-serving component in
;; an application, or one of many (composed together by a router),
;; depends on the system's dependency map defined in system.clj

;; Finally there is the constructor, a function which creates an
;; instance of the component record.

(defrecord Website []
  WebService
{'fraction_non_alphanumeric': 0.1005944215820759, 'fraction_numerical': 0.0013717421124828531, 'mean_word_length': 3.158745247148289, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 7, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 8, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5211515', 'n_tokens_mistral': 1228, 'n_tokens_neox': 1176, 'n_words': 519}