(ns com.oly.static-sites.clojure-demos.routes
  (:require [spec-tools.data-spec :as ds]))


;; put constant data here
(def site-data
  {:homepage {:intro "Clojure tutorials examples and exploration"}
   :dslpage {:intro "A domain-specific language (DSL) is a language designed to be used for a specific task or domain, clojure has a rich set of DSL some popular DSL's are listed on this page with example's on usage. "}
   :lorem "Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum."
   :pages {:dialects {:title "Dialects & Interop"
                      :intro "Clojure has the ability to run on multiple technology stacks, this allows code reuse and consistency regardless of which eco system you want to make use of."
                      :key :dialects
                      :demos [{:title "Clojure"
                               :description "The original language running on the jvm with access to the java eco system"
                               :icon-image "https://clojure.org/images/clojure-logo-120b.png"
                               :page "clojure-basics"}
                              {:title "Clojurescript"
                               :description "Clojure running in the browser or on top of node, with access to the js eco system."
                               :icon-image "https://clojurescript.org/images/cljs-logo-60b.png"
                               :page "clojurescript-basics"}
                              {:title "ClojureCLR"
                               :description "Clojure running on microsofts CLR with access to .net ecosystem"
                               :icon-image "https://clojure.org/images/clojure-logo-120b.png"
                               :page "clojureclr-basics"}
                              {:title "ClojureDart"
                               :description "Clojure for dart, use clojure to build apps using flutter"
                               :page "clojuredart-info"}
                              {:title "LetGO"
                               :description "Clojure for go, use clojure to build apps using go runtime"
                               :page "clojureletgo-info"}

                              ]

                      }
           :dsl {:title "DSL's"
                 :key :dsl
                 :intro "A domain-specific language (DSL) is a language designed to be used for a specific task or domain, clojure has a rich set of DSL some popular DSL's are listed on this page with example's on usage. "
                 :demos [{:title "Hiccup HTML Demo"
                          :page "hiccup-dsl-demo"
                          :description "Hiccup is a DSL for generating HTML it uses data structures over strings to generate html, this makes it far easier to dynamically generate html by using the language constructs to manipulate the tree."
                         ; :link (rfe/href ::demo {:page "hiccup-dsl-demo"})
                          :icon-image "https://miro.medium.com/max/1400/1*CEYFj5R57UFyCXts2nsBqA.png"}
                         {:title "Honey SQL Demo"
                          :page "honey-sql-demo"
                          :description "Similar to honey but for SQL allows you to split apart your complex queries into parts and compose them together."
                       ;   :link (rfe/href ::demo {:page "honey-dsl-demo"})
                          :icon-image "https://miro.medium.com/max/1400/1*CEYFj5R57UFyCXts2nsBqA.png"}
                         {:title "Datalog Demo"
                          :page "datalog-demo"
                          :description "Datalog is a popular DSL with in the clojure for querying deductive database system's"
                       ;   :link (rfe/href ::demo {:page "datalog-demo"})
                          :icon-image "https://raw.githubusercontent.com/tonsky/datascript/master/extras/logo.svg"}]}
           :devops {:title "Deployment & testing"
                    :intro "Running, Testing and deploying your software in a CI pipeline"
                    :key :devops
                    :demos [{:title "CI Demo"
                             :description "Clojure in a CI pipeline, building artifacts running tests & deploying"
                             :page "ci-demo"
                             ;;:link (rfe/href ::demo {:page "ci-demo"})
                             :icon-image "https://avatars.githubusercontent.com/u/2181346?s=200&v=4"}]}
           :examples {:title "Examples"
                      :intro "Some example applications"
                      :key :examples
                      :demos [{:title "Maps"
                               :description "Some quick examples using frontend map api's like google maps."
                               :page "example-maps"
                               :icon-image "https://avatars.githubusercontent.com/u/2181346?s=200&v=4"}
                              {:title "XML sitemap"
                               :description "Using data.xml to generate a sitemap"
                               :page "example-xml-sitemap"
                               :icon-image "https://avatars.githubusercontent.com/u/2181346?s=200&v=4"}]}
           #_#_:terminology {:title "Terminology"
                         :intro ""
                         :key :terminology}}
   :demos
   {:hiccup-dsl-demo
    {:file "documents/hiccup-dsl-demo.org" :git-link "https://github.com/atomjuice/dsl-demo"}
    :datalog-demo
    {:file "documents/datalog-demo.org" :git-link "https://github.com/atomjuice/dsl-demo"}
    :honey-sql-demo
    {:file "documents/honey-sql-demo.org" :git-link "https://github.com/atomjuice/dsl-demo"}
    :reagent-demo
    {:file "documents/reagent-reitit.org" :git-link "https://github.com/atomjuice/dsl-demo"}
    :clojure-basics
    {:file "documents/clojure-basics.org" :git-link "https://github.com/atomjuice/dsl-demo"}
    :ci-demo
    {:file "documents/ci-demo.org" :git-link "https://github.com/atomjuice/dsl-demo"}
    :example-maps
    {:file "documents/examples-maps.org" :git-link ""}
    :example-xml-sitemap
    {:file "documents/examples-xml-sitemap.org" :git-link "https://github.com/atomjuice/dsl-demo"}
    :containers
    {:file "documents/containers.org" :git-link "https://github.com/atomjuice/containers"}
    :about
    {:file "documents/about.org" :git-link "https://github.com/atomjuice/containers"}}})


(defn get-pages
  "Get pages from site-data map"
  []
  (->> site-data
       :pages
       (map second)
       (map :demos)
       (map (fn cat [c] (map (fn build-url [page] (str "/page/" (:page page))) c)))
       flatten))


;; define our page routes passed into reitit later on
(def routes
  [["/"
    {:name :frontpage
     :view :homepage}]

   ["/page/{page}"
    {:name :page
     :sitemap {:vec get-pages}
     :view :default-page-header
     :parameters {:path {:page string?}
                  :query {(ds/opt :foo) keyword?}}}]

   ["/terminology/"
    {:name :terminology
     :view :list}]

   ["/dialects/"
    {:name :dialects
     :view :list}]

   ["/examples/"
    {:name :examples
     :view :list}]

   ["/devops/"
    {:name :devops
     :view :list}]

   ["/dsl/"
    {:name :dsl
     :view :list}]

   ["/about/"
    {:name :about
     :view :about-page}]])
