first try for frontend build

This commit is contained in:
jem 2021-06-05 17:49:05 +02:00
parent a900551a58
commit 43d90ea8eb
2 changed files with 21 additions and 56 deletions

View file

@ -3,7 +3,7 @@
<head> <head>
<meta charset="utf-8" /> <meta charset="utf-8" />
<title>c4k-mastodon-bot</title> <title>c4k-keycloak</title>
<link href="https://domaindrivenarchitecture.org/css/bootstrap.min.css" rel="stylesheet" type="text/css" /> <link href="https://domaindrivenarchitecture.org/css/bootstrap.min.css" rel="stylesheet" type="text/css" />
<link href="https://domaindrivenarchitecture.org/css/fonts/fontawesome/fontawesome.css" rel="stylesheet" type="text/css" /> <link href="https://domaindrivenarchitecture.org/css/fonts/fontawesome/fontawesome.css" rel="stylesheet" type="text/css" />
<link href="https://domaindrivenarchitecture.org/css/custom.css" rel="stylesheet" type="text/css" /> <link href="https://domaindrivenarchitecture.org/css/custom.css" rel="stylesheet" type="text/css" />
@ -12,64 +12,28 @@
<body> <body>
<div class="container jumbotron"> <div class="container jumbotron">
<form class="needs-validation" id="form"> <form class="needs-validation" id="form">
<label for="config" class="form-label">Your config.edn:</label> <label for="config" class="form-label">Your fqdn:</label>
<textarea name="config" id="config" class="form-control" rows="15"> <textarea name="fqdn" id="fqdn" class="form-control" rows="1">
{:transform [{:source {:source-type :twitter your.domain.com
;; optional, defaults to false </textarea>
:include-replies? false <div class="invalid-feedback"><pre id="config-validation"></pre></div>
;; optional, defaults to false <br><br>
:include-rts? false
;; Replace Twitter links by Nitter
:nitter-urls? false
;; accounts you wish to mirror
:accounts ["arstechnica" "WIRED"]}
:target {:target-type :mastodon
;; optional flag specifying wether the name of the account
;; will be appended in the post, defaults to false
:append-screen-name? false
;; optional visibility flag: direct, private, unlisted, public
;; defaults to public
:visibility "unlisted"
;; optional boolean to mark content as sensitive. Defaults to true.
:sensitive? true
;; optional boolean defaults to false
;; only sources containing media will be posted when set to true
:media-only? true
;; optional limit for the post length. Defaults to 300.
:max-post-length 300
;; optional signature for posts. Defaults to "not present".
:signature "#newsbot"}
}]
:auth {}}}
</textarea>
<div class="invalid-feedback"><pre id="config-validation"></pre></div>
<br><br>
<label for="auth" class="form-label">Your auth.edn:</label> <label for="auth" class="form-label">Your auth.edn:</label>
<textarea name="auth" id="auth" class="form-control" rows="15"> <textarea name="auth" id="auth" class="form-control" rows="5">
{:auth {;; add Twitter config to mirror Twitter accounts {:keycloak-admin-user "testuser"
:twitter {:consumer_key "XXXX" :keycloak-admin-password "testpassword"
:consumer_secret "XXXX" :postgres-db-user "keycloakuser"
:access_token_key "XXXX" :postgres-db-password "testdbpassword"}
:access_token_secret "XXXX"}
:mastodon {:access_token "XXXX"
;; account number you see when you log in and go to your profile
;; e.g: https://mastodon.social/web/accounts/294795
:account-id "XXXX"
:api_url "https://botsin.space/api/v1/"}
:tumblr {:consumer_key "XXXX"
:consumer_secret "XXXX"
:token "XXXX"
:token_secret "XXXX"}}}
</textarea> </textarea>
<div class="invalid-feedback"><pre id="auth-validation"></pre></div> <div class="invalid-feedback"><pre id="auth-validation"></pre></div>
<br><br> <br><br>
<button type="button" id="generate-button" class="btn btn-primary"> <button type="button" id="generate-button" class="btn btn-primary">
Generate c4k yaml Generate c4k yaml
</button></form><br><br> </button></form><br><br>
<div id="c4k-mastodon-bot-output"> <div id="c4k-keycloak-output">
<label for="output" class="form-label">Your c4k deployment.yaml:</label> <label for="output" class="form-label">Your c4k deployment.yaml:</label>
<textarea name="output" id="output" class="form-control" rows="15"> <textarea name="output" id="output" class="form-control" rows="25">
</textarea> </textarea>
</div> </div>

View file

@ -9,9 +9,9 @@
(print "debug " sth) (print "debug " sth)
sth) sth)
(defn config [] (defn fqdn []
(-> js/document (-> js/document
(.getElementById "config"))) (.getElementById "fqdn")))
(defn auth [] (defn auth []
(-> js/document (-> js/document
@ -22,8 +22,9 @@
(.getElementById "form"))) (.getElementById "form")))
(defn config-from-document [] (defn config-from-document []
(-> (config) {:fqdn
(.-value))) (-> (fqdn)
(.-value))})
(defn auth-from-document [] (defn auth-from-document []
(-> (auth) (-> (auth)
@ -42,7 +43,7 @@
(.getElementById "config-validation") (.getElementById "config-validation")
(.-innerHTML) (.-innerHTML)
(set! validation-result)) (set! validation-result))
(-> (config) (-> (fqdn)
(.setCustomValidity validation-result)) (.setCustomValidity validation-result))
validation-result) validation-result)
@ -87,7 +88,7 @@
(set-validated!) (set-validated!)
(-> (core/generate (config-from-document) (auth-from-document)) (-> (core/generate (config-from-document) (auth-from-document))
(set-output!))))) (set-output!)))))
(-> (config) (-> (fqdn)
(.addEventListener "blur" (.addEventListener "blur"
#(do (validate-config!) #(do (validate-config!)
(validate-auth!) (validate-auth!)