Skip to content

Commit

Permalink
Initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
tiye committed Feb 3, 2020
0 parents commit d0b1de0
Show file tree
Hide file tree
Showing 16 changed files with 2,223 additions and 0 deletions.
4 changes: 4 additions & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@

calcit.edn -diff linguist-generated
calcit.cirru -diff
yarn.lock -diff linguist-generated
8 changes: 8 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@

/target/
/dist
/node_modules
.cpcache/
.shadow-cljs/

.nrepl-port
17 changes: 17 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@

Phlox Workflow(WIP)
----

Workflow based on [phlox](https://github.com/Quamolit/phlox) and Calcit Editor.

### Usage

WIP

### Workflow

Workflow https://github.com/mvc-works/phlox-workflow

### License

MIT
711 changes: 711 additions & 0 deletions calcit.cirru

Large diffs are not rendered by default.

24 changes: 24 additions & 0 deletions cli/build/main.clj
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@

(ns build.main
(:require [shadow.cljs.devtools.api :as shadow]
[clojure.java.shell :refer [sh]]))

(defn sh! [command]
(println command)
(println (:out (sh "bash" "-c" command))))

(defn build-cdn []
(sh! "rm -rf dist/*")
(shadow/release :client)
(shadow/compile :page)
(sh! "release=true cdn=true node target/page.js"))

(defn build []
(sh! "rm -rf dist/*")
(shadow/release :client)
(shadow/compile :page)
(sh! "release=true node target/page.js"))

(defn page []
(shadow/compile :page)
(sh! "node target/page.js"))
11 changes: 11 additions & 0 deletions entry/main.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@

body {
margin: 0;
overscroll-behavior-y: none;
font-family: Josefin Sans, Hind;
}

body * {
box-sizing: border-box;
flex-shrink: 0;
}
30 changes: 30 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
{
"name": "phlox",
"version": "0.1.0",
"description": "a PIXI DSL in ClojureScript",
"main": "index.js",
"scripts": {
"watch": "shadow-cljs watch client test",
"serve": "http-server dist -s",
"build-cdn": "shadow-cljs clj-run build.main/build-cdn",
"build": "shadow-cljs clj-run build.main/build",
"up": "yarn build-cdn && tiye-up",
"page": "shadow-cljs clj-run build.main/page",
"ln": "cd target && rm -f entry && ln -s ../entry"
},
"repository": {
"type": "git",
"url": "git@github.com:mvc-works/calcit-workflow.git"
},
"author": "jiyinyiyong",
"license": "MIT",
"devDependencies": {
"http-server": "^0.12.1",
"shadow-cljs": "^2.8.83"
},
"dependencies": {
"color": "^3.1.2",
"pixi.js": "^5.2.1",
"shortid": "^2.2.15"
}
}
40 changes: 40 additions & 0 deletions shadow-cljs.edn
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
{
:source-paths ["src" "cli"]
:cache-blockers #{cumulo-util.build}
:dependencies [
[mvc-works/hsl "0.1.2"]
[mvc-works/shell-page "0.1.10"]
[cumulo/util "0.1.10"]
[respo "0.11.5"]
[quamolit/phlox "0.0.1-a3"]
[org.clojure/core.incubator "0.1.4"]
]
:repositories {
"central" {:url "https://maven.aliyun.com/nexus/content/groups/public/"}
"clojars" {:url "https://mirrors.ustc.edu.cn/clojars/"}
}
:open-file-command [
"subl"
["%s:%s:%s" :file :line :column]
]
:dev-http {7000 "target/"}
:builds {
:client {
:target :browser, :output-dir "target/", :asset-path "./"
:modules {
:client {:init-fn phlox.main/main!}
}
:devtools {:after-load phlox.main/reload!, :loader-mode :script}
:compiler-options {:infer-externs :auto}
:release {
:output-dir "dist/", :module-hash-names 8
:build-options {:manifest-name "assets.edn"}
}
}
:page {
:target :node-script, :output-to "target/page.js", :main phlox.page/main!
:devtools {:after-load phlox.page/main!}
}
:test {:target :node-test, :output-to "target/test.js", :ns-regexp "test$"}
}
}
23 changes: 23 additions & 0 deletions src/phlox/config.cljs
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@

(ns phlox.config )

(def cdn?
(cond
(exists? js/window) false
(exists? js/process) (= "true" js/process.env.cdn)
:else false))

(def dev?
(let [debug? (do ^boolean js/goog.DEBUG)]
(cond
(exists? js/window) debug?
(exists? js/process) (not= "true" js/process.env.release)
:else true)))

(def site
{:dev-ui "http://localhost:8100/main.css",
:release-ui "http://cdn.tiye.me/favored-fonts/main.css",
:cdn-url "http://cdn.tiye.me/phlox-workflow/",
:title "Phlox",
:icon "http://cdn.tiye.me/logo/quamolit.png",
:storage-key "phlox-workflow"})
11 changes: 11 additions & 0 deletions src/phlox/container.cljs
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@

(ns phlox.container
(:require [phlox.core :refer [defcomp rect circle text container graphics create-list]]
[phlox.util :refer [hslx]]))

(defcomp
comp-container
(store)
(container
{}
(text {:text "DEMO", :style {:fill (hslx 240 80 80), :font-family "Josefin Sans"}})))
28 changes: 28 additions & 0 deletions src/phlox/main.cljs
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@

(ns phlox.main
(:require ["pixi.js" :as PIXI]
[phlox.core :refer [render!]]
[phlox.container :refer [comp-container]]
[phlox.schema :as schema]))

(defonce *store (atom schema/store))

(defn updater [store op op-data]
(case op
:add-x (update store :x (fn [x] (if (> x 10) 0 (+ x 1))))
:tab (assoc store :tab op-data)
(do (println "unknown op" op op-data) store)))

(defn dispatch! [op op-data]
(println "dispatch!" op op-data)
(reset! *store (updater @*store op op-data)))

(defn main! []
(comment js/console.log PIXI)
(render! (comp-container @*store) dispatch! {})
(add-watch *store :change (fn [] (render! (comp-container @*store) dispatch! {})))
(println "App Started"))

(defn reload! []
(println "Code updated")
(render! (comp-container @*store) dispatch! {:swap? true}))
38 changes: 38 additions & 0 deletions src/phlox/page.cljs
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@

(ns phlox.page
(:require [shell-page.core :refer [make-page spit slurp]]
[phlox.schema :as schema]
[cljs.reader :refer [read-string]]
[phlox.config :as config]
[cumulo-util.build :refer [get-ip!]])
(:require-macros [clojure.core.strint :refer [<<]]))

(def base-info
{:title (:title config/site), :icon (:icon config/site), :ssr nil, :inline-html nil})

(defn dev-page []
(make-page
""
(merge
base-info
{:styles [(<< "http://~(get-ip!):8100/main.css")],
:scripts ["/client.js"],
:inline-styles [(slurp "./entry/main.css")]})))

(defn prod-page []
(let [assets (read-string (slurp "dist/assets.edn"))
cdn (if config/cdn? (:cdn-url config/site) "")
prefix-cdn (fn [x] (str cdn x))]
(make-page
""
(merge
base-info
{:styles [(:release-ui config/site)],
:scripts (map #(-> % :output-name prefix-cdn) assets),
:inline-styles [(slurp "./entry/main.css")]}))))

(defn main! []
(println "Running mode:" (if config/dev? "dev" "release"))
(if config/dev?
(spit "target/index.html" (dev-page))
(spit "dist/index.html" (prod-page))))
4 changes: 4 additions & 0 deletions src/phlox/schema.cljs
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@

(ns phlox.schema )

(def store {:tab :drafts, :x 0})
5 changes: 5 additions & 0 deletions src/phlox/updater.cljs
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@

(ns phlox.updater )

(defn updater [store op op-data op-id op-time]
(case op :content (assoc store :content op-data) :hydrate-storage op-data store))
10 changes: 10 additions & 0 deletions upload.cirru
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@

{}
:host |tiye.me
:uploads $ []
{}
:from |dist/*
:to |cdn/phlox-workflow/
{}
:from |dist/index.html
:to |repo/Quamolit/phlox-workflow/
Loading

0 comments on commit d0b1de0

Please sign in to comment.