45
The The really frakking really frakking simple guide simple guide to (Noir) to (Noir) - or how I learned to stop worrying about MVC and love the (function)

Getting startedwith noir-clojureexchange-2011

  • View
    1.487

  • Download
    0

Embed Size (px)

DESCRIPTION

Really simple guide to Noir, a web framework written in Clojure. Get going with Noir in minutes.

Citation preview

Page 1: Getting startedwith noir-clojureexchange-2011

TheThereally frakking really frakking simple guide simple guide

to (Noir)to (Noir)

- or how I learned to stop worrying about

MVC and love the (function)

Page 2: Getting startedwith noir-clojureexchange-2011

@jr0cket

john.jr0cket.co.uk

clojure.jr0cket.co.uk

Page 3: Getting startedwith noir-clojureexchange-2011

Clojure.jr0cket.co.uk

Page 4: Getting startedwith noir-clojureexchange-2011

Why use Noir

Functional programming web framework

Simplicity over design patters

Micro framework built on others

Page 5: Getting startedwith noir-clojureexchange-2011

Functional for the web

Big blog of stuff in > Big blob of stuff out

Encourages modularising responsibilities

Good at processing data in parallel

Page 6: Getting startedwith noir-clojureexchange-2011
Page 7: Getting startedwith noir-clojureexchange-2011

What does Noir look like?

Page 8: Getting startedwith noir-clojureexchange-2011

Noir uses other components

Page 9: Getting startedwith noir-clojureexchange-2011

Hiccup [hiccup "0.3.7"]

Representing HTML in Clojure. It uses ● vectors to represent tags● maps to represent a tag's attributes

user=> (use 'hiccup.core)

user=> (html [:span {:class "foo"} "bar"])

"<span class=\"foo\">bar</span>"

user=> (html [:div#foo.bar.baz "bang"])

"<div id=\"foo\" class=\"bar baz\">bang</div>"

user=> (html [:ul (for [x (range 1 4)] [:li x])])

"<ul><li>1</li><li>2</li><li>3</li></ul>"

Page 10: Getting startedwith noir-clojureexchange-2011

Ring

Modular web applications

applications, web servers, and web frameworks.

Page 11: Getting startedwith noir-clojureexchange-2011

Compojure

Maps requests to handlers

(defpage "/" [ ] "hello")

Page 12: Getting startedwith noir-clojureexchange-2011

Getting Started

Page 13: Getting startedwith noir-clojureexchange-2011

Download

webnoir.org

Or via build tool

Leiningen

Cake

Requirements

Java 5

Java 6 (better performance)

Page 14: Getting startedwith noir-clojureexchange-2011
Page 15: Getting startedwith noir-clojureexchange-2011

Leiningen Build tool

Get Leiningen (Line – ing – en):

github.com/technomancy/leiningen

lein

Tesing Leiningen

lein repl

Page 16: Getting startedwith noir-clojureexchange-2011

Leiningen REPL in action

Page 17: Getting startedwith noir-clojureexchange-2011

Use the Leiningen Noir plugin you must

lein plugin install lein-noir 1.2.1

For easy project creation, use lein noir plugin you must

Page 18: Getting startedwith noir-clojureexchange-2011

My first Noir project

Page 19: Getting startedwith noir-clojureexchange-2011

Create a new Noir project

lein noir new my-website

Choose wisely your website name, you must!

Page 20: Getting startedwith noir-clojureexchange-2011

Running your website

lein run

lein repl

(server/start 3000)

Modify your server dynamically you should,

Using lein repl you must!

Choose your port wisely young jedi

Page 21: Getting startedwith noir-clojureexchange-2011

Noir project definition

project.clj

Page 22: Getting startedwith noir-clojureexchange-2011

Noir server definition

server.clj

Page 23: Getting startedwith noir-clojureexchange-2011

Noir server definition

View/welcome.clj

Page 24: Getting startedwith noir-clojureexchange-2011

Noir View common definitions

view/common.clj

Page 25: Getting startedwith noir-clojureexchange-2011

Simple todo list

Page 26: Getting startedwith noir-clojureexchange-2011

Simple todo list - Output

Page 27: Getting startedwith noir-clojureexchange-2011

Using forms

Page 28: Getting startedwith noir-clojureexchange-2011

A bigger example

Page 29: Getting startedwith noir-clojureexchange-2011

All hail ...

An interactive shell for clojure

Experiment with clojure in a safe and easy way

Page 30: Getting startedwith noir-clojureexchange-2011
Page 31: Getting startedwith noir-clojureexchange-2011
Page 32: Getting startedwith noir-clojureexchange-2011

Try Clojure - project.clj

Page 33: Getting startedwith noir-clojureexchange-2011

Try Clojure - core.clj

Page 34: Getting startedwith noir-clojureexchange-2011

Try Clojure lists - core.clj

Page 35: Getting startedwith noir-clojureexchange-2011

Try Clojure text – core.clj

Page 36: Getting startedwith noir-clojureexchange-2011

Try Clojure – CSS & JS – core.clj

Page 37: Getting startedwith noir-clojureexchange-2011

Getting Data

Page 38: Getting startedwith noir-clojureexchange-2011
Page 39: Getting startedwith noir-clojureexchange-2011

Where to find out more

Page 40: Getting startedwith noir-clojureexchange-2011

Where to find out more...

http://webnoir.org/

https://github.com/ibdknox/noir

Page 41: Getting startedwith noir-clojureexchange-2011

Where to find out more...

Extreme Startup Workshop

Use Noir to build your product and compete against others

Page 42: Getting startedwith noir-clojureexchange-2011

Thank you

No (parentheses) were harmed in the making of this

presentation....

@jr0cketjohn.jr0cket.co.uk

clojure.jr0cket.co.uk

Page 43: Getting startedwith noir-clojureexchange-2011
Page 44: Getting startedwith noir-clojureexchange-2011
Page 45: Getting startedwith noir-clojureexchange-2011