Posts

Showing posts from March, 2017

How to style your input file in Reagent with Bootstrap

Image
Ok this caused me a lot of headache, hope it will help anyone. In bootstrap the only way to style a input with type file, is to close it in a label. Like this: <label class="btn btn-default btn-file"> Browse <input type="file" style="display: none;"> </label>     Unfortunately, as things are now, the only way to do something like this in Reagent is to set the InnerHhtml and do something like this: (defn ^:export on-click   [event]   (js/alert "Upload Button Clicked") (defn ^:export on-change   [event]   (js/alert "File Changed) (def input-html "<input id='upload-file' name='updload-file' type='file' style='display: none;' onclick='{ns}.table.on_click(event)' onchange='{ns}.table.on_change(event);'></input>") [:label.btn.btn-primary.col-span-1      {:dangerouslySetInnerHTML       {:__html (str (label-input "Select File") input-

How to do an upload using REST (Swagger) and Clojurescript (ajav

Hoping to help someone else that is also struggling with this. I have used Luminus with Reagent to try this. Luminus come with Swagger for REST API, it's a great tool because it gives you the possibility to try the API as soon as you have write it. This is the code to write a REST end-point that accept a file in upload (ns your-clojure-ns   (:require [ring.util.http-response :refer :all]             [compojure.api.sweet :refer :all]             [schema.core :as s]             [ring.swagger.upload :as upload]) (defapi service-routes   {:swagger {:ui "/swagger-ui"              :spec "/swagger.json"              :data {:info {:version "1.0.0"                            :title "Sample API"                            :description "Sample Services"}}}}   (context "/your-context" []     :tags ["Your Context"]     (POST "/upload" []       :multipart-params [file :- upload/TempFileUpload]       :middle

First project with Luminus and Reagent... impressions.

Ok I have started a project for a friend https://github.com/marcomanzi/arcatron, it's web application to charge customers for calls done. I'm using Luminus with Reagent as frontend... how it is going... I will compare this with my experience in doing something similar using Java, with Spring and Vaadin. During this development I had more feeling coming out, these are the things I want to share (not ordered by relevance) Fun: Well, this is a totally new experience, I have Terminator with 3 windows, one with lein test-refreh, one with lein run and one with lein figwheel. I really enjoy that I see happening in my browser while I change them. It's a new experience because with Vaadin every little change I had to restart the application server (it does not take long though) Creativity: Because there is not a clear path written (with Spring a Vaadin you are taken by hand and they guide you to the final result like a parent with a child) I was able to come out with my soluti