This file contains hidden or 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
(ns wl.core | |
(:use compojure.core, aleph.core, aleph.http, hiccup.core, hiccup.page-helpers) | |
(:require [compojure.route :as route]) | |
(:gen-class)) | |
(def broadcast-channel (channel)) | |
(defn chat-handler [ch handshake] | |
(receive ch | |
(fn [name] |
This file contains hidden or 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
(def ducky {}) | |
(nil? (ducky :excitement)) |
This file contains hidden or 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
(ns wl.simple | |
(:use compojure.core, aleph.http, hiccup.core, hiccup.form-helpers, ring.adapter.jetty) | |
(:gen-class)) | |
(defn show-params [values] | |
(println (str values)) | |
(html [:p (str values)])) | |
(defroutes myroutes | |
(GET "/" [] (html (form-to [:post "/"] |
This file contains hidden or 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
import com.ibdknox.socket_io_netty.INSIOClient; | |
import com.ibdknox.socket_io_netty.INSIOHandler; | |
public class EchoHandler implements INSIOHandler { | |
@Override | |
public void OnConnect(INSIOClient client) { | |
System.out.println("A user connected :: " + client.getSessionID()); | |
} |
This file contains hidden or 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
(defpartial layout [& content] | |
(html5 | |
[:head | |
[:title "Noir"]] | |
[:body | |
content])) | |
(defpage "/welcome" [] | |
(layout | |
[:h1 "Welcome to Noir!"])) |
This file contains hidden or 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
lein plugin install lein-noir 1.2.1 | |
lein noir new my-website | |
cd my-website | |
lein run |
This file contains hidden or 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
(defpartial todo-item [{:keys [id title due]}] | |
[:li {:id id} ;; maps define HTML attributes | |
[:h3 title] | |
[:span.due due]]) ;; add a class | |
(defpartial todos-list [items] | |
[:ul#todoItems ;; set the id attribute | |
(map todo-item items)]) | |
(todos-list [{:id "todo1" |
This file contains hidden or 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
;;Create a page that lists out all our todos | |
(defpage "/todos" {} | |
(let [items (all-todos)] | |
(layout | |
[:h1 "Todo list!"] | |
(todos-list items)))) | |
;; Handle an HTTP POST to /todos, returning a | |
;; json object if successful | |
(defpage [:post "/todos"] {:keys [title due]} |
This file contains hidden or 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
;; add a value to the session | |
(defpage "/login" {} | |
(session/put! :admin true) | |
(layout | |
[:p "Are you loggedin? "] | |
[:p (session/get :admin)])) | |
;; set a cookie and get its value | |
(defpage "/cookie" [] | |
(cookie/put! :noir "stuff") |
This file contains hidden or 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
(ns my-app | |
(:use noir.core) | |
(:require [noir.server :as server])) | |
(defpage "/welcome" [] | |
"Welcome to Noir!") | |
(server/start 8080) |
OlderNewer