finish creating html

This commit is contained in:
bom 2021-08-30 16:29:00 +02:00
parent a9bb71c88d
commit bc5950cc38

View file

@ -9,9 +9,8 @@
[dda.c4k-jira.jira :as jira] [dda.c4k-jira.jira :as jira]
[dda.c4k-jira.backup :as backup] [dda.c4k-jira.backup :as backup]
[clojure.walk :refer [postwalk]] [clojure.walk :refer [postwalk]]
[clojure.zip :as zip]
[hickory.core :as hc] [hickory.core :as hc]
[hickory.zip :as hz])) [hickory.render :as hr]))
(def config-defaults {:issuer :staging}) (def config-defaults {:issuer :staging})
@ -53,60 +52,57 @@
(defn generate-feedback-tag (defn generate-feedback-tag
[id] [id]
{:type :element :attrs {:class "invalid-feedback"} :tag :div :content [{:type :element :attrs {:id (str id "-validation")} :tag :pre :content "nil"}]}) [{:type :element :attrs {:class "invalid-feedback"} :tag :div :content [{:type :element :attrs {:id (str id "-validation")} :tag :pre :content nil}]}])
(defn generate-label (defn generate-label
[id-for [id-for
label] label]
{:type :element :attrs {:for id-for :class "form-label"} :tag :label :content [label]}) [{:type :element :attrs {:for id-for :class "form-label"} :tag :label :content [label]}])
(defn generate-input-field (defn generate-input-field
[id [id
label label
default-value] default-value]
[(generate-label id label) (concat (generate-label id label)
{:type :element :attrs {:class "form-control" :type "text" :name id :value default-value} :tag :input :content "nil"} [{:type :element :attrs {:class "form-control" :type "text" :name id :value default-value} :tag :input :content nil}]
(generate-feedback-tag id)]) (generate-feedback-tag id)))
(defn generate-text-area (defn generate-text-area
[id [id
label label
default-value default-value
rows] rows]
[(generate-label id label) (concat (generate-label id label)
{:type :element :attrs {:name id :id id :class "form-control" :rows rows} :tag :textarea :content default-value} [{:type :element :attrs {:name id :id id :class "form-control" :rows rows} :tag :textarea :content [default-value]}]
(generate-feedback-tag id)]) (generate-feedback-tag id)))
(defn generate-button (defn generate-button
[id [id
label] label]
{:type :element [{:type :element
:attrs {:type "button", :id id, :class "btn btn-primary"} :attrs {:type "button", :id id, :class "btn btn-primary"}
:tag :button :tag :button
:content [label]}) :content [label]}])
(defn generate-br (defn generate-br
[] []
{:type :element, :attrs nil, :tag :br, :content nil}) [{:type :element, :attrs nil, :tag :br, :content nil}])
(defn generate-output (defn generate-output
[id [id
label label
rows] rows]
{:type :element, :attrs {:id id}, :tag :div, :content [ [{:type :element, :attrs {:id id}, :tag :div, :content [{:type :element, :attrs {:for "output", :class "form-label"}, :tag :label, :content [label]}
{:type :element, :attrs {:for "output", :class "form-label"}, :tag :label, :content [label]} {:type :element, :attrs {:name "output", :id "output", :class "form-control", :rows rows}, :tag :textarea, :content []}]}])
{:type :element, :attrs {:name "output", :id "output", :class "form-control", :rows rows}, :tag :textarea, :content []}
]})
(defn generate-needs-validation (defn generate-needs-validation
[] []
{:type :element, :attrs {:class :needs-validation, :id :form}, :tag :form, :content []}) {:type :element, :attrs {:class "needs-validation", :id "form"}, :tag :form, :content []})
(defn generate-content (defn generate-content
[] []
(conj (into [] (concat [(assoc (generate-needs-validation) :content
[(assoc (generate-needs-validation) :content (into [] (concat (generate-input-field "fqdn" "Your fqdn:" "jira-neu.prod.meissa-gmbh.de")
(conj (generate-input-field "fqdn" "Your fqdn:" "jira-neu.prod.meissa-gmbh.de")
(generate-input-field "jira-data-volume-path" "(Optional) Your jira-data-volume-path:" "/var/jira") (generate-input-field "jira-data-volume-path" "(Optional) Your jira-data-volume-path:" "/var/jira")
(generate-input-field "postgres-data-volume-path" "(Optional) Your postgres-data-volume-path:" "/var/postgres") (generate-input-field "postgres-data-volume-path" "(Optional) Your postgres-data-volume-path:" "/var/postgres")
(generate-input-field "restic-repository" "(Optional) Your restic-repository:" "restic-repository") (generate-input-field "restic-repository" "(Optional) Your restic-repository:" "restic-repository")
@ -119,22 +115,27 @@
:aws-access-key-id \" aws-id \" :aws-access-key-id \" aws-id \"
:aws-secret-access-key \" aws-secret \" :aws-secret-access-key \" aws-secret \"
:restic-password \" restic-password \"}" :restic-password \" restic-password \"}"
5) "5")
(generate-br) (generate-br)
(generate-br) (generate-br)
(generate-button "generate-button" "Generate c4k yaml")))] (generate-button "generate-button" "Generate c4k yaml"))))]
[(generate-br)
(generate-br) (generate-br)
(generate-output "c4k-keycloak-output" "Your c4k deployment.yaml:" 25)])) (generate-br)
(generate-output "c4k-keycloak-output" "Your c4k deployment.yaml:" "25"))))
(defn find-map (defn find-map
[coll] [coll]
(postwalk #(if (and (map? %) (postwalk #(if (and (map? %)
(= (:class (:attrs %)) "container jumbotron")) (= (:class (:attrs %)) "container jumbotron"))
(assoc coll :content (generate-content)) {:type :element
:attrs {:class "container jumbotron"}
:tag :div
:content (generate-content)}
%) %)
coll)) coll))
(def htest2 (hr/hickory-to-html (find-map htest)))
; END REFACTOR ; END REFACTOR
(defn-spec generate any? (defn-spec generate any?