Дмитрий Грошев (@lambdadmitry)
(defroutes user-routes
(context "/user/:id{[0-9]+}" []
(GET "/" [] ...)
(GET "/profile" [] ...)
(GET "/posts" [] ...)))
(defn foobar [...]
[:div.top.container
[:a {:href "/"}
[:img {:src "/img/logo_small.png"
:border "0"}]]
[:div.links
(if is-authorized?
[:a {:href "/logout"} "Выйти"]
[:a {:href "/login"} "Войти в аккаунт"])]
[:div.clear]])
(def stats-graph
{:n (fnk [xs] (count xs))
:m (fnk [xs n] (/ (sum identity xs) n))
:m2 (fnk [xs n] (/ (sum #(* % %) xs) n))
:v (fnk [m m2] (- m2 (* m m)))})
(defnk $entries$:entry-id$GET
"Get the entry at the given id"
{:responses {200 schemas/ClientEntry}}
[[:request [:uri-args entry-id :- Long]]
[:resources guestbook]]
{:body (safe-get @guestbook entry-id)})
NB: data > fn > macro
(p/defnk post
"Adds new foobar"
{:responses {201 s/Any
422 {:message s/Str}}
:path "/"
:method :post
:auth-scope :auth-scopes/foobar-add}
[[:request datomic-val oauth-token
body :- (msext/fresh msext/Foobar)]
[:resources datomic]]
(let [foobar (adapter body)
uuid (:foobar/uuid foobar)
entity-url (mh/handler-var->url #'get-entity {:uuid uuid})]
(case (md/assert-entity datomic foobar oauth-token)
...
:not-an-entity
{:status 422 :body {:message "reference consistency violation"}})))
(defn team [active? arrow-class score-class score]
(let [offset (str (- (* 93 (/ score (:max-score config))) 93) "%")
translation (str "translate3d(" offset ",0,0)")]
[:div.team {:class (when-not active? "inactive")}
[:div.arrow {:class arrow-class}
[:span.icon-arrow-right]]
[:div.score {:class score-class
:style {:-webkit-transform translation
:transform translation}}
[:span.label score]]]))
NB: controlflow DAG vs data DAG
NB: CAP, агенты, криптография
Слайды: si14.github.io/sprug-2015-01-slides
Твиттер: @lambdadmitry
Почта: lambdadmitry@gmail.com