2 次代码提交 0e7b90d7b0 ... 7fcf8df16e

作者 SHA1 备注 提交日期
  Brandon Wong 7fcf8df16e expanding image library 2 年之前
  Brandon Wong 46d51cad3d wrote script to facilitate building up a library of images 2 年之前

+ 4 - 6
README.md

@@ -3,18 +3,16 @@
 A visual schedule builder for kids.
 A visual schedule builder for kids.
 
 
 TODO:
 TODO:
-- edit schedule
-  - make a list, choosing from a (text-searchable) library of images/tasks
-    - use modal-panel component and typeahead component
 - name the schedule/track
 - name the schedule/track
-- add little numbers to each box
-- green outline + check mark
 - save state (preserve across refresh)
 - save state (preserve across refresh)
+  - need server
+  - use localstorage ??
 - (saveable) preset schedules (in edit menu)
 - (saveable) preset schedules (in edit menu)
 - (optional) multiple simultaneous schedules (ex: one for each kid, or general vs specific)
 - (optional) multiple simultaneous schedules (ex: one for each kid, or general vs specific)
 - (optional) split decision tracks (conditions)
 - (optional) split decision tracks (conditions)
 - (saveable) make-your-own tasks
 - (saveable) make-your-own tasks
-- use localstorage ??
+  - incorporate an internet search in the editor?
+  - crowdsource images??
 
 
 library (each category has a representative picture/task, as does each sub-item):
 library (each category has a representative picture/task, as does each sub-item):
 - bedtime routine
 - bedtime routine

+ 50 - 0
curator.clj

@@ -0,0 +1,50 @@
+#!/usr/bin/env bb
+
+(require '[clojure.java.io :as io]
+         '[clojure.string :as string]
+         '[clojure.pprint :refer [pprint]])
+
+(def exceptions
+  #{"index.html"
+    "styles.css"
+    "js"
+    "clapping.gif"
+    "go.png"
+    "clapping.png"
+    "vendor"})
+
+(let [foldername "./resources/public"
+      folder (io/file foldername)
+      existing-filename "./library.edn"
+      existing (try
+                 (-> existing-filename
+                     (slurp)
+                     (read-string))
+                 (catch Exception _ []))
+      existing-files (->> existing
+                          (map :image)
+                          (set))
+      highest-index (or (some->> existing
+                                 (map :id)
+                                 (not-empty)
+                                 (apply max)
+                                 (inc))
+                        1)]
+  (if (.isDirectory folder)
+    (->> (.list folder)
+         (remove exceptions)
+         (remove existing-files)
+         (map-indexed (fn [ind file]
+                        {:id (+ highest-index ind)
+                         :name (-> file
+                                   (string/replace #"\.[^\.]*$" "")
+                                   (string/replace #"[-\._]" " "))
+                         :image file}))
+         (concat existing)
+         (vec)
+         ((fn [new-data]
+            (with-open [writer (io/writer existing-filename)]
+              (pprint new-data writer))
+            (println "wrote to" existing-filename))))
+    (println "Folder not found. Make sure to run this script from its containing folder.")))
+

+ 55 - 0
library.edn

@@ -0,0 +1,55 @@
+[{:id 1,
+  :name "sleep",
+  :categories ["bedtime" "naping"],
+  :keywords ["bed" "nap"],
+  :image "sleep.png"}
+ {:id 2,
+  :name "eat",
+  :categories ["eating"],
+  :keywords ["meal" "food" "chopsticks"],
+  :image "eating1.png"}
+ {:id 3,
+  :name "eat",
+  :categories ["eating"],
+  :keywords ["meal" "food" "spaghetti"],
+  :image "eating2.png"}
+ {:id 4,
+  :name "go to school",
+  :categories ["school"],
+  :keywords ["class"],
+  :image "school.png"}
+ {:id 5,
+  :name "brush teeth",
+  :categories ["bedtime"],
+  :keywords ["bedtime" "routine"],
+  :image "teeth-brushing.png"}
+ {:id 6, :name "ten second tidy", :image "ten-second-tidy.jpg"}
+ {:id 7, :name "sing", :image "sing.jpg"}
+ {:id 8, :name "blessing", :image "blessing.jpeg"}
+ {:id 9,
+  :name "family home evening",
+  :image "family-home-evening.jpeg"}
+ {:id 11, :name "bath", :image "bath.png"}
+ {:id 12, :name "ice cream cone", :image "ice-cream-cone.png"}
+ {:id 13, :name "sacrament", :image "sacrament.jpeg"}
+ {:id 14, :name "potty", :image "potty.jpg"}
+ {:id 15, :name "temple", :image "temple.jpeg"}
+ {:id 16, :name "church", :image "church.jpg"}
+ {:id 17, :name "clean up", :image "clean-up.jpg"}
+ {:id 18, :name "numbers", :image "numbers.png"}
+ {:id 19, :name "cleaning", :image "cleaning.png"}
+ {:id 20, :name "read", :image "read.png"}
+ {:id 21, :name "walk", :image "walk.jpg"}
+ {:id 22, :name "shoes", :image "shoes.png"}
+ {:id 23, :name "flush", :image "flush.jpg"}
+ {:id 24, :name "video", :image "video.png"}
+ {:id 25, :name "car", :image "car.png"}
+ {:id 26, :name "get dressed", :image "get-dressed.png"}
+ {:id 27, :name "scriptures", :image "scriptures.jpg"}
+ {:id 28, :name "letters", :image "letters.png"}
+ {:id 30, :name "wash hands", :image "wash-hands.png"}
+ {:id 31, :name "typing2", :image "typing2.png"}
+ {:id 32, :name "writing", :image "writing.jpg"}
+ {:id 33, :name "wait", :image "wait.png"}
+ {:id 34, :name "typing1", :image "typing1.png"}
+ {:id 35, :name "pray", :image "pray.jpeg"}]

二进制
resources/public/bath.png


二进制
resources/public/blessing.jpeg


二进制
resources/public/car.png


二进制
resources/public/church.jpg


二进制
resources/public/clean-up.jpg


二进制
resources/public/cleaning.png


二进制
resources/public/family-home-evening.jpeg


二进制
resources/public/flush.jpg


二进制
resources/public/get-dressed.png


二进制
resources/public/ice-cream-cone.png


二进制
resources/public/letters.png


二进制
resources/public/numbers.png


二进制
resources/public/potty.jpg


二进制
resources/public/pray.jpeg


二进制
resources/public/read.png


二进制
resources/public/sacrament.jpeg


二进制
resources/public/scriptures.jpg


二进制
resources/public/shoes.png


二进制
resources/public/sing.jpg


二进制
resources/public/temple.jpeg


二进制
resources/public/ten-second-tidy.jpg


二进制
resources/public/typing1.png


二进制
resources/public/typing2.png


二进制
resources/public/video.png


二进制
resources/public/wait.png


二进制
resources/public/walk.jpg


二进制
resources/public/wash-hands.png


二进制
resources/public/writing.jpg


+ 38 - 33
src/lineup/components/edit/selector.cljs

@@ -10,36 +10,41 @@
     [re-com/modal-panel
     [re-com/modal-panel
      :backdrop-on-click #(re-frame/dispatch [::events/select-selecting nil])
      :backdrop-on-click #(re-frame/dispatch [::events/select-selecting nil])
      :child
      :child
-     [re-com/v-box
-      :gap "10px"
-      :align :center
-      :children
-      (concat
-       [[re-com/title
-         :label "Select an Activity"
-         :level :level3]
-        [:div "(TODO: search box here)"]]
-       (map
-        (fn [library-item]
-          [re-com/h-box
-           :gap "20px"
-           :align :center
-           :align-self :start
-           :attr {:on-click #(re-frame/dispatch [::events/select-task which (:id library-item)])}
-           :class "task-selector"
-           :children
-           [[re-com/box
-             :width "50px"
-             :height "50px"
-             :max-width "50px"
-             :max-height "50px"
-             :justify :center
-             :child
-             [:img
-              {:src (:image library-item)}]]
-            [re-com/box
-             :child
-             [re-com/title
-              :label (:name library-item)
-              :level :level3]]]])
-        @library-data))]]))
+     [re-com/scroller
+      :v-scroll :auto
+      :h-scroll :off
+      :height "80vh"
+      :child
+      [re-com/v-box
+       :gap "10px"
+       :align :center
+       :children
+       (concat
+        [[re-com/title
+          :label "Select an Activity"
+          :level :level3]
+         [:div "(TODO: search box here)"]]
+        (map
+         (fn [library-item]
+           [re-com/h-box
+            :gap "20px"
+            :align :center
+            :align-self :start
+            :attr {:on-click #(re-frame/dispatch [::events/select-task which (:id library-item)])}
+            :class "task-selector"
+            :children
+            [[re-com/box
+              :width "50px"
+              :height "50px"
+              :max-width "50px"
+              :max-height "50px"
+              :justify :center
+              :child
+              [:img
+               {:src (:image library-item)}]]
+             [re-com/box
+              :child
+              [re-com/title
+               :label (:name library-item)
+               :level :level3]]]])
+         @library-data))]]]))

+ 56 - 25
src/lineup/db.cljs

@@ -5,28 +5,59 @@
    :selecting nil
    :selecting nil
    :schedule {:tasks [{:ref 2} {:ref 5} {:ref 4} {:ref 5} {:ref 1}]}
    :schedule {:tasks [{:ref 2} {:ref 5} {:ref 4} {:ref 5} {:ref 1}]}
 
 
-   :library [{:id 1
-              :name "sleep"
-              :categories ["bedtime" "naping"]
-              :keywords ["bed" "nap"]
-              :image "sleep.png"}
-             {:id 2
-              :name "eat"
-              :categories ["eating"]
-              :keywords ["meal" "food" "chopsticks"]
-              :image "eating1.png"}
-             {:id 3
-              :name "eat"
-              :categories ["eating"]
-              :keywords ["meal" "food" "spaghetti"]
-              :image "eating2.png"}
-             {:id 4
-              :name "go to school"
-              :categories ["school"]
-              :keywords ["class"]
-              :image "school.png"}
-             {:id 5
-              :name "brush teeth"
-              :categories ["bedtime"]
-              :keywords ["bedtime" "routine"]
-              :image "teeth-brushing.png"}]})
+   :library
+   [{:id 1,
+     :name "sleep",
+     :categories ["bedtime" "naping"],
+     :keywords ["bed" "nap"],
+     :image "sleep.png"}
+    {:id 2,
+     :name "eat",
+     :categories ["eating"],
+     :keywords ["meal" "food" "chopsticks"],
+     :image "eating1.png"}
+    {:id 3,
+     :name "eat",
+     :categories ["eating"],
+     :keywords ["meal" "food" "spaghetti"],
+     :image "eating2.png"}
+    {:id 4,
+     :name "go to school",
+     :categories ["school"],
+     :keywords ["class"],
+     :image "school.png"}
+    {:id 5,
+     :name "brush teeth",
+     :categories ["bedtime"],
+     :keywords ["bedtime" "routine"],
+     :image "teeth-brushing.png"}
+    {:id 6, :name "ten second tidy", :image "ten-second-tidy.jpg"}
+    {:id 7, :name "sing", :image "sing.jpg"}
+    {:id 8, :name "blessing", :image "blessing.jpeg"}
+    {:id 9,
+     :name "family home evening",
+     :image "family-home-evening.jpeg"}
+    {:id 11, :name "bath", :image "bath.png"}
+    {:id 12, :name "ice cream cone", :image "ice-cream-cone.png"}
+    {:id 13, :name "sacrament", :image "sacrament.jpeg"}
+    {:id 14, :name "potty", :image "potty.jpg"}
+    {:id 15, :name "temple", :image "temple.jpeg"}
+    {:id 16, :name "church", :image "church.jpg"}
+    {:id 17, :name "clean up", :image "clean-up.jpg"}
+    {:id 18, :name "numbers", :image "numbers.png"}
+    {:id 19, :name "cleaning", :image "cleaning.png"}
+    {:id 20, :name "read", :image "read.png"}
+    {:id 21, :name "walk", :image "walk.jpg"}
+    {:id 22, :name "shoes", :image "shoes.png"}
+    {:id 23, :name "flush", :image "flush.jpg"}
+    {:id 24, :name "video", :image "video.png"}
+    {:id 25, :name "car", :image "car.png"}
+    {:id 26, :name "get dressed", :image "get-dressed.png"}
+    {:id 27, :name "scriptures", :image "scriptures.jpg"}
+    {:id 28, :name "letters", :image "letters.png"}
+    {:id 30, :name "wash hands", :image "wash-hands.png"}
+    {:id 31, :name "typing2", :image "typing2.png"}
+    {:id 32, :name "writing", :image "writing.jpg"}
+    {:id 33, :name "wait", :image "wait.png"}
+    {:id 34, :name "typing1", :image "typing1.png"}
+    {:id 35, :name "pray", :image "pray.jpeg"}]})