ad browser integration
This commit is contained in:
parent
3611160388
commit
42a08c3c7f
5 changed files with 107 additions and 6 deletions
1
.gitignore
vendored
1
.gitignore
vendored
|
@ -7,6 +7,7 @@ target/
|
|||
.nrepl-*
|
||||
package-lock.json
|
||||
node_modules/
|
||||
public/js/
|
||||
|
||||
.calva
|
||||
|
||||
|
|
69
public/index.html
Normal file
69
public/index.html
Normal file
|
@ -0,0 +1,69 @@
|
|||
<!doctype html>
|
||||
<html>
|
||||
|
||||
<head>
|
||||
<meta charset="utf-8" />
|
||||
<title>k8s-mastodon-bot</title>
|
||||
</head>
|
||||
|
||||
<body>
|
||||
<div class="container">
|
||||
<label for="config">Your config.edn:</label>
|
||||
<textarea name="config" id="config" rows="40" cols="150">
|
||||
{:transform [{:source {:source-type :twitter
|
||||
;; optional, defaults to false
|
||||
:include-replies? false
|
||||
;; optional, defaults to false
|
||||
: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"}
|
||||
}]}
|
||||
</textarea><br><br>
|
||||
<label for="auth">Your auth.edn:</label>
|
||||
<textarea name="auth" id="auth" rows="40" cols="150">
|
||||
{:auth {;; add Twitter config to mirror Twitter accounts
|
||||
:twitter {:consumer_key "XXXX"
|
||||
:consumer_secret "XXXX"
|
||||
:access_token_key "XXXX"
|
||||
: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><br><br>
|
||||
<button type="button" onclick="generate()">Generate k8s yaml</button>
|
||||
</div>
|
||||
<div id="k8s-mastodon-bot-output">
|
||||
<label for="output">Your k8s deployment.yaml:</label>
|
||||
<textarea name="output" id="output" rows="40" cols="150">
|
||||
</textarea>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
<script src="js/main.js"></script>
|
||||
</body>
|
||||
|
||||
</html>
|
|
@ -4,11 +4,15 @@
|
|||
"src/test/cljc"]
|
||||
:dependencies [[aero "1.1.6"]
|
||||
[expound "0.8.4"]]
|
||||
:builds {:test {:target :node-test
|
||||
:output-to "target/node-tests.js"
|
||||
:autorun true
|
||||
:repl-pprint true}
|
||||
:dev-http {8080 "public"}
|
||||
:builds {:frontend {:target :browser
|
||||
:modules {:main {:init-fn dda.k8s-mastodon-bot.browser/generate}}
|
||||
:release {}}
|
||||
:app {:target :node-script
|
||||
:output-to "target/k8s-mastodon-bot.js"
|
||||
:main dda.k8s-mastodon-bot.core/main
|
||||
:compiler-options {:optimizations :simple}}}}
|
||||
:compiler-options {:optimizations :simple}}
|
||||
:test {:target :node-test
|
||||
:output-to "target/node-tests.js"
|
||||
:autorun true
|
||||
:repl-pprint true}}}
|
||||
|
|
|
@ -22,6 +22,9 @@
|
|||
(assoc-in [ :data :credentials.edn] (str my-auth))
|
||||
))
|
||||
|
||||
(defn generate [my-config my-auth]
|
||||
(yaml/to-string (generate-config my-config my-auth)))
|
||||
|
||||
(def usage
|
||||
"usage:
|
||||
|
||||
|
@ -37,4 +40,4 @@
|
|||
(some #(= "-h" %) options)
|
||||
(print usage)
|
||||
:default
|
||||
(yaml/to-string (generate-config config auth)))))))
|
||||
(generate config auth))))))
|
||||
|
|
24
src/main/cljs/dda/k8s_mastodon_bot/browser.cljs
Normal file
24
src/main/cljs/dda/k8s_mastodon_bot/browser.cljs
Normal file
|
@ -0,0 +1,24 @@
|
|||
(ns dda.k8s-mastodon-bot.browser
|
||||
(:require
|
||||
[dda.k8s-mastodon-bot.core :as core]))
|
||||
|
||||
(defn config-from-document []
|
||||
(-> js/document
|
||||
(.getElementById "config")
|
||||
(.-innerHTML)))
|
||||
|
||||
(defn auth-from-document []
|
||||
(-> js/document
|
||||
(.getElementById "auth")
|
||||
(.-innerHTML)))
|
||||
|
||||
(defn render-to-document
|
||||
[input]
|
||||
(-> js/document
|
||||
(.getElementById "output")
|
||||
(.-innerHTML)
|
||||
(set! input)))
|
||||
|
||||
(defn generate []
|
||||
(-> (dda.k8s-mastodon-bot.core/generate (config-from-document) (auth-from-document))
|
||||
(render-to-document)))
|
Loading…
Reference in a new issue