Permalink
Browse files

preparing for gh-pages site

  • Loading branch information...
1 parent 11fc59e commit 292cf6e84ccd1a9fe26e6ed68aae1cd5d8f8a630 @oliyh committed Jan 4, 2017
View
@@ -12,4 +12,6 @@ pom.xml.asc
.hg/
/figwheel_server.log
/resources/public/js
-/dev-resources/public/*/js
+/dev-resources/public/*/js
+/dist/js
+/dist/css
@@ -376,3 +376,16 @@ html #clear-completed:active {
bottom: 10px;
}
}
+
+.re-learn-controls {
+ border-top: 1px solid lightgray;
+ text-align: center;
+}
+
+.re-learn-controls button {
+ border: 1px solid gray;
+ background-color: hotpink;
+ padding: 8px;
+ border-radius: 2px;
+ color: white;
+}
View
@@ -0,0 +1,28 @@
+(ns pages
+ (:require [clojure.java.io :as io]
+ [leiningen.core.eval :as eval])
+ (:import [java.io File]))
+
+(defn- copy [from to]
+ (let [from (io/file from)]
+ (if (.isDirectory from)
+ (doseq [^File f (file-seq from)]
+ (when-not (.isDirectory f)
+ (let [to (io/file to (.getName f))]
+ (io/make-parents to)
+ (io/copy f to))))
+
+ (let [to (io/file to)]
+ (when-not (.exists to)
+ (io/make-parents to))
+ (io/copy from to)))))
+
+(defn build [& args]
+ (println "Building gh-pages")
+ (copy (io/resource "public/todomvc/css") "dist/css")
+ (copy (io/resource "public/css/re-learn.css") "dist/css/re-learn.css"))
+
+(defn push [& args]
+ (println "Pushing gh-pages")
+ (eval/sh-with-exit-code "Couldn't commit" "git" "commit" "dist" "-m" "deploying gh-pages")
+ (eval/sh-with-exit-code "Couldn't push" "git" "subtree" "push" "--prefix" "dist" "origin" "gh-pages"))
View
@@ -0,0 +1,46 @@
+<!doctype html>
+<html lang="en" data-framework="reagent">
+ <head>
+ <meta charset="utf-8">
+ <title>re-learn</title>
+ <meta name="viewport" content="width=device-width, initial-scale=1">
+ <link rel="stylesheet" href="css/base.css">
+ <link rel="stylesheet" href="css/index.css">
+ <link rel="stylesheet" href="css/re-learn.css">
+ </head>
+ <body>
+ <a href="https://github.com/oliyh/re-learn" target="_blank">
+ <img style="position: absolute; top: 0; right: 0; border: 0;" src="https://camo.githubusercontent.com/652c5b9acfaddf3a9c326fa6bde407b87f7be0f4/68747470733a2f2f73332e616d617a6f6e6177732e636f6d2f6769746875622f726962626f6e732f666f726b6d655f72696768745f6f72616e67655f6666373630302e706e67" alt="Fork me on GitHub" data-canonical-src="https://s3.amazonaws.com/github/ribbons/forkme_right_orange_ff7600.png">
+ </a>
+ <div id="tutorial"></div>
+ <div id="app">Loading...</div>
+ <script src="js/app.js"></script>
+ <script>
+ todomvc.core.run();
+ </script>
+
+ <div style="border: 1px solid gray; border-radius: 8px; padding: 24px; background-color: #eee;">
+ <h3>Hello</h3>
+ <p>
+ This is the re-learn live demo, where re-learn has been used to provide a tutorial for the classic to-do list.
+ </p>
+ <p>
+ When you've worked through the tutorial you can use the controls above to reset the tutorial to try it again or try out help mode.
+ You can also refer to the source code and documentation at
+ <a href="https://github.com/oliyh/re-learn" target="_blank">
+ https://github.com/oliyh/re-learn</a>.
+ </p>
+ <p>
+ re-learn gives you data-driven tutorials for reagent components with no changes required to your dom.
+ </p>
+ <small>
+ The Todo-MVC example was taken from
+ <a href="https://github.com/tastejs/todomvc/tree/master/examples/reagent" target="_blank">
+ tastejs/todomvc</a>, with thanks to
+ <a href="https://twitter.com/gadfly361" target="_blank">Matthew Jaoudi</a>,
+ <a href="https://twitter.com/yogthos" target="_blank">Dmitri Sotnikov</a> and
+ <a href="https://twitter.com/holmsand" target="_blank">Dan Holmsand</a>.
+ </small>
+ </div>
+ </body>
+</html>
File renamed without changes.
@@ -19,10 +19,11 @@
(re-learn/with-lesson
{:id :re-learn-controls-lesson
:description "Use these controls to run the tutorial again or activate help mode"
- :position :left}
+ :position :top}
(fn []
- [:div
- [:p [:button {:on-click re-learn/reset-education!} "Reset"]]
+ [:div.re-learn-controls
+ [:h3 "Tutorial controls"]
+ [:p [:button {:on-click re-learn/reset-education!} "Reset tutorial"]]
[:p [:button {:on-click re-learn/enable-help-mode!} "Help mode"]]])))
(def todo-app
@@ -0,0 +1,32 @@
+(ns todomvc.actions
+ (:require [todomvc.session :as session]
+ [todomvc.helpers :as helpers]))
+
+(defn add-todo [title default]
+ (let [id (helpers/create-todo-id)
+ trimmed-title (helpers/trim-title @title)]
+ (swap! session/todos assoc id {:id id
+ :title trimmed-title
+ :completed false})
+ (reset! title default)))
+
+(defn toggle-todo [id]
+ (swap! session/todos update-in [id :completed] not))
+
+(defn toggle-all-todos [bool]
+ (doseq [todo (helpers/todos-all @session/todos)]
+ (swap! session/todos assoc-in [(:id todo) :completed] (not bool))))
+
+(defn delete-todo [id]
+ (swap! session/todos dissoc id))
+
+(defn save-todo [id title editing]
+ (let [trimmed-title (helpers/trim-title @title)]
+ (if-not (empty? trimmed-title)
+ (swap! session/todos assoc-in [id :title] trimmed-title)
+ (delete-todo id))
+ (reset! editing false)))
+
+(defn clear-completed-todos [todos]
+ (doseq [todo (helpers/todos-completed todos)]
+ (delete-todo (:id todo))))
View
@@ -24,10 +24,16 @@
;; todomvc
[secretary "1.2.2"]
- [alandipert/storage-atom "1.2.4"]]
+ [alandipert/storage-atom "1.2.4"]
+
+ ;; gh-pages deploy
+ [leiningen-core "2.7.1"]]
:repl-options {:init-ns user
:nrepl-middleware [cemerick.piggieback/wrap-cljs-repl]}}}
- :aliases {"test" ["do" ["clean"] ["test"] ["doo" "phantom" "test" "once"]]}
+ :aliases {"test" ["do" ["clean"] ["test"] ["doo" "phantom" "test" "once"]]
+ "build-pages" ["do"
+ ["run" "-m" "pages/build"]
+ ["cljsbuild" "once" "pages"]]}
:figwheel {:css-dirs ["dev-resources/public/css"]}
:cljsbuild {:builds [{:id "checkout"
:source-paths ["src/" "example/checkout"]
@@ -49,6 +55,13 @@
:preloads [devtools.preload]
:parallel-build true}}
+ {:id "pages"
+ :source-paths ["src/" "example/todomvc"]
+ :compiler {:main "todomvc.core"
+ :output-to "dist/js/app.js"
+ :parallel-build true
+ :optimizations :advanced}}
+
{:id "devcards"
:figwheel {:devcards true}
:source-paths ["src" "test"]
@@ -129,7 +129,7 @@
(if (:continue lesson)
(let [{:keys [event selector event-filter]
:or {event-filter identity}} (:continue lesson)
- dom-node (when selector (dom/sel1 selector) (:dom-node lesson))]
+ dom-node (if selector (dom/sel1 selector) (:dom-node lesson))]
{:db db
::on-dom-event [event
dom-node

0 comments on commit 292cf6e

Please sign in to comment.