-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Enable figwheel-main for client development - Figwheel will now watch mango.css for changes, speeding up styling development - Remove build/minification process and dependency on asset minification plugin - Remove unnecessary lein plugin "shell" - Delete mango.js and begin to replace it with ClojureScript - Port (pretty much directly) the file uploading JavaScript with ClojureScript and handle multiple file upload - Update README
- Loading branch information
Lee Adams
authored and
Lee Adams
committed
Jul 17, 2019
1 parent
5368dda
commit d5ff6d3
Showing
19 changed files
with
277 additions
and
153 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
^{:open-url "http://localhost:8080"} | ||
^{:css-dirs ["resources/public/css"]} | ||
{:main mango.core | ||
:asset-path "/cljs-out" | ||
:output-to "resources/public/js/dev-main.js" | ||
:output-dir "resources/public/cljs-out" | ||
:source-map true | ||
:source-map-timestamp true | ||
:infer-externs true | ||
:closure-warnings {:externs-validation :off} | ||
;; To console.log CLJS data-structures make sure you enable devtools in Chrome | ||
;; https://github.com/binaryage/cljs-devtools | ||
:preloads [devtools.preload]} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
^{:open-url "http://localhost:8080"} | ||
{:main mango.core | ||
:output-to "resources/public/js/prod-main.js" | ||
:infer-externs true | ||
:closure-warnings {:externs-validation :off} | ||
:optimizations :whitespace} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
File renamed without changes.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,74 @@ | ||
(ns ^:figwheel-hooks mango.core | ||
(:require [mango.media] [mango.xhr])) | ||
|
||
(enable-console-print!) | ||
;(set! *warn-on-infer* true) | ||
|
||
(println " __ ___ | ||
/ |/ /___ _____ ____ _____ | ||
/ /|_/ / __ `/ __ \\/ __ `/ __ \\ | ||
/ / / / /_/ / / / / /_/ / /_/ / | ||
/_/ /_/\\__,_/_/ /_/\\__, /\\____/ | ||
/____/ v1.0") | ||
|
||
;; Initialize Twitter Widgets | ||
(let [fjs (first (array-seq (.getElementsByTagName js/document "script"))) | ||
t (or (.-twttr js/window) (js-obj))] | ||
(if-not (.getElementById js/document "twitter-wjs") | ||
(let [s (.createElement js/document "script")] | ||
(set! (.-id s) "twitter-wjs") | ||
(set! (.-src s) "https://platform.twitter.com/widgets.js") | ||
(.insertBefore (.-parentNode fjs) s fjs) | ||
(set! (.-_e t) #js []) | ||
(set! (.-ready (fn [f] (.push (.-_e t) f)))) | ||
t))) | ||
|
||
;; Highlight code blocks | ||
(.initHighlightingOnLoad js/hljs) | ||
|
||
(defn bind-upload-form | ||
[upload-form] | ||
(println "Binding upload form") | ||
(let [file-select (.getElementById js/document "file-select") | ||
upload-status (.getElementById js/document "upload-status") | ||
anti-forgery (.getElementById js/document "anti-forgery-token") | ||
article-id (.getElementById js/document "article-id") | ||
file-upload (.getElementById js/document "file-upload")] | ||
(set! (.-onsubmit upload-form) (fn [event] | ||
(.preventDefault event) | ||
(set! (.-value file-upload) "Uploading...") | ||
(set! (.-innerHTML upload-status) "Uploading...") | ||
(let [form-data (js/FormData.)] | ||
(.append form-data "__anti-forgery-token" (.-value anti-forgery)) | ||
(.append form-data "article-id" (.-value article-id)) | ||
(doseq [file (array-seq (.-files file-select))] | ||
(.append form-data "files[]" file (.-name file))) | ||
(mango.xhr/send (.-method upload-form) | ||
(.-action upload-form) | ||
form-data | ||
(fn [status message] (set! (.-innerHTML upload-status) message) (set! (.-value file-upload) "Upload")) | ||
(fn [event] (set! (.-innerHTML upload-status) (.-loaded event))))))))) | ||
|
||
(defn unbind-upload-form | ||
[upload-form] | ||
(set! (.-onsubmit upload-form) nil)) | ||
|
||
(defn bind | ||
[] | ||
(when-let [upload-form (.getElementById js/document "upload-form")] | ||
(bind-upload-form upload-form))) | ||
|
||
(defn unbind | ||
[] | ||
(when-let [upload-form (.getElementById js/document "upload-form")] | ||
(unbind-upload-form upload-form))) | ||
|
||
(.addEventListener js/window "DOMContentLoaded" bind) | ||
|
||
(defn ^:after-load setup [] | ||
(println "setup") | ||
(bind)) | ||
|
||
(defn ^:before-load teardown [] | ||
(println "teardown") | ||
(unbind)) |
Oops, something went wrong.