Initial commit
This commit is contained in:
		
						commit
						a46aa69b7b
					
				|  | @ -0,0 +1,39 @@ | |||
| **/classes | ||||
| **/target | ||||
| **/.artifacts | ||||
| **/.cpcache | ||||
| **/.DS_Store | ||||
| **/.gradle | ||||
| 
 | ||||
| # User-specific stuff | ||||
| .idea/**/workspace.xml | ||||
| .idea/**/tasks.xml | ||||
| .idea/**/usage.statistics.xml | ||||
| .idea/**/shelf | ||||
| .idea/**/statistic.xml | ||||
| .idea/dictionaries/** | ||||
| .idea/libraries/** | ||||
| 
 | ||||
| # File-based project format | ||||
| *.iws | ||||
| *.ipr | ||||
| 
 | ||||
| # Cursive Clojure plugin | ||||
| .idea/replstate.xml | ||||
| *.iml | ||||
| 
 | ||||
| /example/example/** | ||||
| artifacts | ||||
| projects/**/pom.xml | ||||
| 
 | ||||
| # nrepl | ||||
| .nrepl-port | ||||
| 
 | ||||
| # clojure-lsp | ||||
| .lsp/.cache | ||||
| 
 | ||||
| # clj-kondo | ||||
| .clj-kondo/.cache | ||||
| 
 | ||||
| # Calva VS Code Extension | ||||
| .calva/output-window/output.calva-repl | ||||
|  | @ -0,0 +1 @@ | |||
| 
 | ||||
|  | @ -0,0 +1 @@ | |||
| 
 | ||||
|  | @ -0,0 +1,4 @@ | |||
| {:paths ["src" "resources"] | ||||
|  :deps {} | ||||
|  :aliases {:test {:extra-paths ["test"] | ||||
|                   :extra-deps {}}}} | ||||
|  | @ -0,0 +1 @@ | |||
| 
 | ||||
|  | @ -0,0 +1,16 @@ | |||
| (ns org.aplex.helpers.core | ||||
|   (:require | ||||
|    [clojure.string :as s])) | ||||
| 
 | ||||
| (defn map-replace | ||||
|   "Given a string with {:key} strings substitute the matching key in a hash map" | ||||
|   [text m] | ||||
|   (reduce | ||||
|    (fn [acc [k v]] (s/replace acc (str "{" k "}") (str v))) | ||||
|    text m)) | ||||
| 
 | ||||
| (defn build-url [root-url path params] | ||||
|   (str root-url (map-replace path params))) | ||||
| 
 | ||||
| (defn attach-handler [hm fn] | ||||
|   (assoc hm :handler fn)) | ||||
|  | @ -0,0 +1,18 @@ | |||
| (ns org.aplex.helpers.interface | ||||
|   (:require | ||||
|    [org.aplex.helpers.core :as c]) | ||||
|   (:import | ||||
|    (java.lang System))) | ||||
| 
 | ||||
| (defmacro load-default-env [env-var] | ||||
|   (System/getenv env-var)) | ||||
| 
 | ||||
| (defn map-replace [text m] | ||||
|   (c/map-replace text m)) | ||||
| 
 | ||||
| 
 | ||||
| (defn build-url [root-url path params] | ||||
|   (c/build-url root-url path params)) | ||||
| 
 | ||||
| (defn attach-handler [hm fn] | ||||
|   (c/attach-handler hm fn)) | ||||
|  | @ -0,0 +1,6 @@ | |||
| (ns org.aplex.helpers.interface-test | ||||
|   (:require [clojure.test :as test :refer :all] | ||||
|             [org.aplex.helpers.interface :as helpers])) | ||||
| 
 | ||||
| (deftest dummy-test | ||||
|   (is (= 1 1))) | ||||
|  | @ -0,0 +1,4 @@ | |||
| {:paths ["src" "resources"] | ||||
|  :deps {} | ||||
|  :aliases {:test {:extra-paths ["test"] | ||||
|                   :extra-deps {}}}} | ||||
|  | @ -0,0 +1 @@ | |||
| 
 | ||||
|  | @ -0,0 +1 @@ | |||
| (ns org.do.apis.mailchimp.interface) | ||||
|  | @ -0,0 +1 @@ | |||
| oly@avocato.1708108:1668427537 | ||||
|  | @ -0,0 +1,2 @@ | |||
| (ns org.do.apis.mailchimp.v3.malli.core) | ||||
| 
 | ||||
|  | @ -0,0 +1 @@ | |||
| oly@avocato.1708108:1668427537 | ||||
|  | @ -0,0 +1,6 @@ | |||
| (ns org.aplex.rest-mailchimp.interface-test | ||||
|   (:require [clojure.test :as test :refer :all] | ||||
|             [org.aplex.rest-mailchimp.interface :as rest-mailchimp])) | ||||
| 
 | ||||
| (deftest dummy-test | ||||
|   (is (= 1 1))) | ||||
|  | @ -0,0 +1,4 @@ | |||
| {:paths ["src" "resources"] | ||||
|  :deps {} | ||||
|  :aliases {:test {:extra-paths ["test"] | ||||
|                   :extra-deps {}}}} | ||||
|  | @ -0,0 +1 @@ | |||
| 
 | ||||
|  | @ -0,0 +1,38 @@ | |||
| (ns org.aplex.rest-stability-ai.core | ||||
|   (:require [org.aplex.helpers.interface :as h])) | ||||
| 
 | ||||
| (def api-config (atom {:api-host "https://api.stability.ai" | ||||
|                        :api-key "STABILITY_API_KEY"})) | ||||
| 
 | ||||
| (def api-host "https://api.stability.ai") | ||||
| (def api-key "sk-t8dmTcOV2jOAALqJ4yjS8qEOgr4NZHumuHd3ppuMsQn9os2W") | ||||
| 
 | ||||
| (def default-authed-payload {:headers {"Authorization" (str "Bearer " api-key) | ||||
|                                        "content-type" "application/json"}}) | ||||
| 
 | ||||
| (defn init-config [cfg] | ||||
|   (reset! api-config (merge @api-config cfg))) | ||||
| 
 | ||||
| (defn build-url [path] | ||||
|   (str api-host path)) | ||||
| 
 | ||||
| (defn fetch-user-account [] | ||||
|   (merge default-authed-payload  | ||||
|          {:url (build-url "/v1/user/account") | ||||
|           :handler prn})) | ||||
| 
 | ||||
| (defn fetch-user-balance [] | ||||
|   (merge default-authed-payload  | ||||
|          {:url (build-url "/v1/user/balance") | ||||
|           :handler prn})) | ||||
| 
 | ||||
| (defn fetch-generation-text-to-image [] | ||||
|   (merge default-authed-payload  | ||||
|          {:url (build-url "/v1/user/balance") | ||||
|           :format :json | ||||
|           :response-format :json | ||||
|           :params {:text_prompts [{:text "A wooden hand crafted light house" | ||||
|                                    :weight 0.5}]} | ||||
|           :handler prn})) | ||||
| 
 | ||||
| 
 | ||||
|  | @ -0,0 +1,8 @@ | |||
| (ns org.aplex.rest-stability-ai.interface | ||||
|   (:require [org.aplex.stability-ai.core :as c])) | ||||
| 
 | ||||
| 
 | ||||
| (defn init-config [cfg] (c/init-config cfg)) | ||||
| (defn fetch-user-account [] (c/fetch-user-account )) | ||||
| (defn fetch-user-balance [] (c/fetch-user-balance )) | ||||
| (defn fetch-generation-text-to-image [required optional] (c/fetch-generation-text-to-image required optional)) | ||||
|  | @ -0,0 +1,6 @@ | |||
| (ns org.aplex.rest-stability-ai.interface-test | ||||
|   (:require [clojure.test :as test :refer :all] | ||||
|             [org.aplex.rest-stability-ai.interface :as rest-stability-ai])) | ||||
| 
 | ||||
| (deftest dummy-test | ||||
|   (is (= 1 1))) | ||||
|  | @ -0,0 +1,4 @@ | |||
| {:paths ["src" "resources"] | ||||
|  :deps {} | ||||
|  :aliases {:test {:extra-paths ["test"] | ||||
|                   :extra-deps {}}}} | ||||
|  | @ -0,0 +1 @@ | |||
| 
 | ||||
|  | @ -0,0 +1,39 @@ | |||
| (ns org.aplex.stability-ai.core | ||||
|   (:require [org.aplex.helpers.interface :as h]) | ||||
|   ) | ||||
| 
 | ||||
| (def api-config (atom {:api-host "https://api.stability.ai" | ||||
|                        :api-key "STABILITY_API_KEY"})) | ||||
| 
 | ||||
| (def api-host "https://api.stability.ai") | ||||
| (def api-key "sk-t8dmTcOV2jOAALqJ4yjS8qEOgr4NZHumuHd3ppuMsQn9os2W") | ||||
| 
 | ||||
| (def default-authed-payload {:headers {"Authorization" (str "Bearer " api-key) | ||||
|                                        "content-type" "application/json"}}) | ||||
| 
 | ||||
| (defn init-config [cfg] | ||||
|   (reset! api-config (merge @api-config cfg))) | ||||
| 
 | ||||
| (defn build-url [path] | ||||
|   (str api-host path)) | ||||
| 
 | ||||
| (defn fetch-user-account [] | ||||
|   (merge default-authed-payload  | ||||
|          {:url (build-url "/v1/user/account") | ||||
|           :handler prn})) | ||||
| 
 | ||||
| (defn fetch-user-balance [] | ||||
|   (merge default-authed-payload  | ||||
|          {:url (build-url "/v1/user/balance") | ||||
|           :handler prn})) | ||||
| 
 | ||||
| (defn fetch-generation-text-to-image [] | ||||
|   (merge default-authed-payload  | ||||
|          {:url (build-url "/v1/user/balance") | ||||
|           :format :json | ||||
|           :response-format :json | ||||
|           :params {:text_prompts [{:text "A wooden hand crafted light house" | ||||
|                                    :weight 0.5}]} | ||||
|           :handler prn})) | ||||
| 
 | ||||
| 
 | ||||
|  | @ -0,0 +1,8 @@ | |||
| (ns org.aplex.stability-ai.interface | ||||
|   (:require [org.aplex.stability-ai.core :as c])) | ||||
| 
 | ||||
| 
 | ||||
| (defn init-config [cfg] (c/init-config cfg)) | ||||
| (defn fetch-user-account [] (c/fetch-user-account )) | ||||
| (defn fetch-user-balance [] (c/fetch-user-balance )) | ||||
| (defn fetch-generation-text-to-image [required optional] (c/fetch-generation-text-to-image required optional)) | ||||
|  | @ -0,0 +1,6 @@ | |||
| (ns org.aplex.stability-ai.interface-test | ||||
|   (:require [clojure.test :as test :refer :all] | ||||
|             [org.aplex.stability-ai.interface :as stability-ai])) | ||||
| 
 | ||||
| (deftest dummy-test | ||||
|   (is (= 1 1))) | ||||
|  | @ -0,0 +1,34 @@ | |||
| {:paths ["development/src"] | ||||
|  :deps { | ||||
|         org.clojure/clojure {:mvn/version "1.11.1"} | ||||
| 
 | ||||
|         djblue/portal {:mvn/version "0.49.1"} | ||||
|         no.cjohansen/portfolio {:mvn/version "2023.07.15"} | ||||
|         io.github.nextjournal/clerk {:mvn/version "0.15.957"} | ||||
|         refactor-nrepl/refactor-nrepl {:mvn/version "3.9.0"} | ||||
| 
 | ||||
|         } | ||||
|  :aliases  {:dev {:extra-paths ["development/src"] | ||||
|                   :extra-deps {org.clojure/clojure {:mvn/version "1.11.1"} | ||||
| 
 | ||||
|                                djblue/portal {:mvn/version "0.49.1"} | ||||
|                                no.cjohansen/portfolio {:mvn/version "2023.07.15"} | ||||
|                                io.github.nextjournal/clerk {:mvn/version "0.15.957"} | ||||
| 
 | ||||
|                                refactor-nrepl/refactor-nrepl {:mvn/version "3.9.0"} | ||||
| 
 | ||||
|                                }} | ||||
| 
 | ||||
|             :shadow-cljs-run | ||||
|             {:extra-deps {thheller/shadow-cljs {:mvn/version "2.25.2"} | ||||
|                           cider/piggieback {:mvn/version "0.5.3"}} | ||||
|             :extra-paths ["development/src"] | ||||
|             :main-opts ["-m" "shadow.cljs.devtools.cli"]} | ||||
| 
 | ||||
|             :test {:extra-paths []} | ||||
| 
 | ||||
|             :poly {:main-opts ["-m" "polylith.clj.core.poly-cli.core"] | ||||
|                    :extra-deps {polyfy/polylith | ||||
|                                 {:git/url   "https://github.com/polyfy/polylith" | ||||
|                                  :sha       "bddda87d2fb071e2b8488383a800d4a17989e766" | ||||
|                                  :deps/root "projects/poly"}}}}} | ||||
|  | @ -0,0 +1,30 @@ | |||
| <!DOCTYPE html> | ||||
| <html> | ||||
|   <head> | ||||
|     <title>Personal portfolio for olymk2</title> | ||||
|     <meta charset="utf-8" /> | ||||
|     <meta content="#da532c" name="msapplication-TileColor" /> | ||||
|     <meta content="#ffffff" name="theme-color" /> | ||||
|     <link | ||||
|       href="https://cdn.jsdelivr.net/gh/devicons/devicon@v2.15.1/devicon.min.css" | ||||
|       rel="stylesheet" | ||||
|       type="text/css" | ||||
|     /> | ||||
|     <link | ||||
|       href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.1.1/css/all.min.css" | ||||
|       rel="stylesheet" | ||||
|       type="text/css" | ||||
|     /> | ||||
|     <link rel="stylesheet" href="./css/styles.css" type="text/css" /> | ||||
|     <meta content="Personal portfolio" property="og:title" /> | ||||
|     <meta | ||||
|       content="Portfolio of projects worked on past to present" | ||||
|       property="og:description" | ||||
|     /> | ||||
|   </head> | ||||
|   <body> | ||||
|     <div id="app"></div> | ||||
|     <script src="/cljs-out/base.js" type="application/javascript"></script> | ||||
|     <script src="/cljs-out/portfolio.js" type="application/javascript"></script> | ||||
|   </body> | ||||
| </html> | ||||
|  | @ -0,0 +1 @@ | |||
| 
 | ||||
|  | @ -0,0 +1,10 @@ | |||
| (ns frontend.portfolio.core | ||||
|   (:require [portfolio.ui :as ui])) | ||||
| 
 | ||||
| 
 | ||||
| (defn launch [] | ||||
|   (ui/start! | ||||
|    {:config {:css-paths ["/css/styles.css" | ||||
|                          "https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.1.1/css/all.min.css" | ||||
|                          "https://cdn.jsdelivr.net/gh/devicons/devicon@v2.15.1/devicon.min.css"]}})) | ||||
| 
 | ||||
|  | @ -0,0 +1,59 @@ | |||
| (ns src.frontend.portfolio.stability-ai | ||||
|   (:require ;[clj-http.client :as client] | ||||
|             [ajax.core :refer [GET POST]] | ||||
|             [portfolio.ui :as ui] | ||||
|             [portfolio.dumdom :as d] | ||||
|             [portfolio.dom :as r])) | ||||
| 
 | ||||
| ;; api root paths shoudl not end in a slash | ||||
| ;; the payloads should be maps no coupling to http libraries | ||||
| ;; each api should have an init to set the api key and change the host along side any other config | ||||
|   | ||||
| 
 | ||||
| (def api-host "https://api.stability.ai") | ||||
| (def api-key "") | ||||
| 
 | ||||
| (def default-authed-payload {:headers {"Authorization" (str "Bearer " api-key) | ||||
|                                        "content-type" "application/json"}}) | ||||
| 
 | ||||
| (defn build-url [path] | ||||
|   (str api-host path)) | ||||
| 
 | ||||
| 
 | ||||
| 
 | ||||
| (GET (build-url "/v1/user/account") | ||||
|      (merge default-authed-payload | ||||
|             {:handler prn})) | ||||
| 
 | ||||
| (GET (build-url "/v1/user/balance") | ||||
|      (merge default-authed-payload | ||||
|             {:handler prn})) | ||||
| 
 | ||||
| (def temp-response (atom nil)) | ||||
| 
 | ||||
| (POST (build-url "/v1/generation/stable-diffusion-v1-5/text-to-image") | ||||
|      (merge default-authed-payload | ||||
|             {:handler (fn [r] | ||||
|                         (prn r) | ||||
|                         (reset! temp-response r)) | ||||
|              :format :json | ||||
|              :response-format :json | ||||
|              :params {:text_prompts [{:text "A wooden hand crafted light house" | ||||
|                                       :weight 0.5}]} | ||||
|              })) | ||||
| 
 | ||||
| 
 | ||||
| 
 | ||||
| (d/defscene image | ||||
|   [:div | ||||
|    [:img {:src (str "data:image/png;base64," (get (first (get @temp-response "artifacts")) "base64")) }]]) | ||||
| 
 | ||||
| (d/defscene card | ||||
|   [:div.h-96.w-48.flex.justify-center.flex.col.rounded-full.border | ||||
|    [:div.w-48.h-48 | ||||
|     [:img.object-contain.w-48.h-48.rounded-md | ||||
|      {:src (str "data:image/png;base64," (get (first (get @temp-response "artifacts")) "base64")) }]] | ||||
|    [:div "some text"]]) | ||||
| 
 | ||||
| @temp-response | ||||
| 
 | ||||
|  | @ -0,0 +1,7 @@ | |||
| npx shadow-cljs server | ||||
| 
 | ||||
| npx tailwindcss -i ./development/resources/public/css/tailwind-styles.css -o ./development/resources/public/css/styles.css --watch | ||||
| 
 | ||||
| clj -Mshadow-cljs watch app | ||||
| 
 | ||||
| clj -Mshadow-cljs-run watch app | ||||
|  | @ -0,0 +1,2 @@ | |||
| (ns src.user) | ||||
| 
 | ||||
|  | @ -0,0 +1,12 @@ | |||
| { | ||||
|   "dependencies": { | ||||
|     "axe-core": "4.7.0", | ||||
|     "katex": "0.12.0", | ||||
|     "markdown-it": "12.3.2", | ||||
|     "markdown-it-block-image": "0.0.3", | ||||
|     "markdown-it-footnote": "3.0.3", | ||||
|     "markdown-it-texmath": "0.9.7", | ||||
|     "markdown-it-toc-done-right": "4.2.0", | ||||
|     "punycode": "2.1.1" | ||||
|   } | ||||
| } | ||||
|  | @ -0,0 +1 @@ | |||
| 
 | ||||
|  | @ -0,0 +1,7 @@ | |||
| #+TITLE: aplex Api's | ||||
| 
 | ||||
| * Each library should have an init function to configur url tokens or anything else specific users | ||||
| * Library's do not need to be complete as they can be expanded as sneeded | ||||
| * There should be one function for each api route | ||||
| * API libraries should just build the requests as maps. | ||||
| * Validation should be seperate to the requests making it optional and written in a way to pipe the request into the validation. | ||||
|  | @ -0,0 +1,15 @@ | |||
| {:deps {:aliases [:dev]} | ||||
|  :dev-http {8080 ["development/resources/public/" "classpath:public"]} | ||||
|  :nrepl {:middleware [refactor-nrepl.middleware/wrap-refactor]} | ||||
|  :source ["development/src"] | ||||
|  :builds {:app {:output-dir "development/resources/public/cljs-out" | ||||
|                 :asset-path "cljs-out" | ||||
|                 :target :browser | ||||
|                 :compiler-options {:infer-externs :auto :output-feature-set :es6} | ||||
|                 :modules {:base {:entries []} | ||||
|                           ;; :app {:init-fn src.frontend.portfolio.core/launch | ||||
|                           ;;       :depends-on #{:base}} | ||||
|                           :portfolio {:init-fn frontend.portfolio.core/launch | ||||
|                                       :depends-on #{:base}} | ||||
|                           } | ||||
|                 :devtools {:after-load app.main/reload!}}}} | ||||
|  | @ -0,0 +1,9 @@ | |||
| {:top-namespace "org.aplex" | ||||
|  :interface-ns "interface" | ||||
|  :default-profile-name "default" | ||||
|  :compact-views #{} | ||||
|  :vcs {:name "git" | ||||
|        :auto-add false} | ||||
|  :tag-patterns {:stable "stable-*" | ||||
|                 :release "v[0-9]*"} | ||||
|  :projects {"development" {:alias "dev"}}} | ||||
		Loading…
	
		Reference in New Issue