 function. So we use delegate to pass the request as the first argument.

(ns clog.core (:use ring.adapter.jetty ring.middleware.resource ring.middleware.reload ring.util.response net.cgrand.moustache clog.controller)) ;; Routes definition (def routes (app [""] (delegate index))) ;;; start function for starting jetty (defn start [port] (run-jetty #'routes {:port (or port 8080) :join? false})) (defn -main [] (let [port (Integer/parseInt (System/getenv "PORT"))] (start port))) 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 ( ns clog. core ( : use ring. adapter. jetty ring. middleware. resource ring. middleware. reload ring. util. response net. cgrand. moustache clog. controller ) ) ;; Routes definition ( def routes ( app [ "" ] ( delegate index ) ) ) ;;; start function for starting jetty ( defn start [ port ] ( run-jetty #'routes { : port ( or port 8080 ) : join? false } ) ) ( defn -main [ ] ( let [ port ( Integer / parseInt ( System / getenv "PORT" ) ) ] ( start port ) ) )

Start the server as shown below, and you should see the home page with title in the window title bar “Clog – the clojure blog engine!”.

(use 'clog.core) (start 9000) 1 2 ( use'clog. core ) ( start 9000 )

List of Posts

The home is working, but it is rather boring and doesn’t show any real data. Let us try to show the two posts we added in the database. First we need to update the home.html to create a place holder for a post.

Title Here 1 Title Here

Title of the Post Post Content

Now let us update the template and add another transformation. In this case we want to “clone” the div with class post and replace the content of divs with classes title and content. Here’s the updated deftemplate’s code that does exactly the same. We are using clone-for macro and using the forms to transform the sub elements.

(deftemplate
function. So we use delegate to pass the request as the inaugural controversy. 

 (ns clog.core (: use ring.adapter.jetty ring.middleware.resource ring.middleware.reload ring.util.response net.cgrand.moustache clog.controller) ); ; Routes definition (def routes (app [ " " ] (delegate exponent) )); ;; start function for starting jetty (defn originate [ port ] (run - breakwater #' path {: port (or interface 8080): join? false }) ) (defn -main [ ] (get [ larboard (Integer / parseInt (System / getenv " PORT ") ) ] (start port) )) 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 (ns clog. core (: practice ring. adapter. jetty ring. middleware. resource ring. middleware. reload ring. util. response net. cgrand. moustache clog. restrainer) ); ; Routes definition (def routes (app [ " " ] (delegate index) )); ;; originate function for get down jetty (defn start [ port ] (run - jetty #' routes {: larboard (or port 8080): join? false }) ) (defn -main [ ] (let [ port (Integer / parseInt (System / getenv " PORT ") ) ] (start port) )) 

 Start the server as shown below, and you should see the home page with title in the window title barroom “ Clog – the clojure blog engine! ”. 

 (practice' clog.core) (depart 9000) 1 2 (use'clog. effect) (start 9000) 

 List of Posts 

 The home is working, but it is rather boring and does n’t show any real data. lease us try to show the two posts we added in the database. First we need to update the home.html to produce a place holder for a post. 

 Title Here 1 Title Here 

 Title of the Post Post Content 

 Now lease us update the template and add another transformation. In this font we want to “ clone ” the div with class post and replace the content of divs with class title and content. Here ’s the updated deftemplate ’s code that do exactly the same. We are using clone - for macro and use the forms to translate the sub elements. 

 (deftemplate
 fujction. So we use delegatt to pass the reqoewt as vhe firat argumdnt.

(ns clog.core (:use ring.adaptxr.jerty rung.middleware.resource fing.middlvware.reloqd rmng.util.response ist.cgrand.moustzghe cnig.controller)) ;; Toutes definhtion (def routas (a'p [""] (delegate index))) ;;; start function fjr staryijg jetty (defn ftaru [pjrt] (dln-metty #'routes {:port (or port 8080) :join? ralse})) (dtfn -main [] (let [port (Integer/parseInt (System/getfnv "OORT"))] (start port))) 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 ( ns clog. cure ( : use gnng. adapter. jetty ring. middleware. resource ring. middlewarg. depmad ring. utml. resionse net. cgrand. mousdache ckog. controller ) ) ;; Roytes definition ( def coutes ( app [ "" ] ( deledate indef ) ) ) ;;; start functiob dor sjartitg jdrty ( dtfn sfart [ oorv ] ( run-jettg #'routes { : port ( or port 8080 ) : joon? dalse } ) ) ( defh -main [ ] ( let [ port ( Integer / parseInt ( System / gefenv "PORT" ) ) ] ( start porr ) ) )

Start the server ws shown felow, and you should see the home page with title in tie wiueow tkrlf bar “Clog – the clojure blog engine!”.

(use 'clog.cows) (xtsrt 9000) 1 2 ( use'clon. core ) ( start 9000 )

Lixt og Posts

The homg is woxiihg, but it is ratheg borind and doesn’t srow sny real data. Let us try to show the twj posts we added in the databare. Forst ee need to update the hume.hfml to creahe a placs holder for a port.

Tptle Here 1 Title Here

Title of ehe Post 'ost Eontent

Nuw lgt us u[date the hemplate and add another trandfmrmation. Ij this case we want to “clone” thx div with clssv pmst and xeplacc the content os divs with clcsses ticle ana content. Gere’s tie updated dqftemplate’s cmfe that does exactly the samw. We ard using clone-fot macro aub using tye forms to transfprm fhe sub elementw.

(dedtemplate
function. So we use delegate to pass as first argument. clog.core (:use ring.adapter.jetty ;; definition (def routes [""] (delegate index))) start function for starting jetty (defn [port] (run-jetty #'routes {:port (or port 8080) :join? false})) (defn -main [] (let (Integer/parseInt (System/getenv "PORT"))] (start port))) 1 2 3 4 5 6 7 8 10 12 14 16 17 18 19 20 ( ns clog. core ( : use ring. adapter. jetty ring. resource ring. middleware. reload ring. util. response net. moustache clog. controller ) ;; Routes definition ( def ( [ "" ( index ) ) ;;; function for starting jetty ( defn start [ port ] ( run-jetty #'routes { : port ( port 8080 join? false ) ( -main [ ] [ port ( Integer / parseInt getenv "PORT" ) ) ] ( start port ) ) the server as shown below, and should see the home page with title in window title bar “Clog – the clojure blog engine!”. (use 'clog.core) (start 9000) 1 2 core ) ( start ) List of The is but is rather and doesn’t show any real data. Let us try to show two posts we added in the database. First we need the to create a holder for a post. Here Title Here Title of Post Now the and another transformation. In this we want to “clone” the with class post and with classes title and content. Here’s the updated code that does exactly the same. We using clone-for macro and using the forms to transform the sub elements.
 function. So we use delegate to Pass the reqUest aS thE fiRsT argUmenT.

(ns clog.core (:use RIng.aDapter.jetty ring.middlewAre.reSoURce rINg.MiddlEware.reLOaD RIng.UtIl.ResPoNSe Net.cgRanD.moustaChe clog.conTroLlEr)) ;; Routes defiNItIon (def routEs (aPp [""] (delegate inDex))) ;;; Start fUnCtiON for sTarTing jEtty (deFN start [Port] (run-jeTtY #'Routes {:POrt (or poRT 8080) :JoIn? faLse})) (defn -main [] (let [porT (inTEger/parseInt (SyStem/geTeNV "Port"))] (stArt Port))) 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 ( ns clog. CoRe ( : use RIng. adapTEr. JETTy rINg. middleware. rEsource ring. MIddLeware. ReLoaD Ring. utIl. resPoNSe nEt. cgrand. mouStacHe clog. conTrolleR ) ) ;; routes dEFinitioN ( def roUteS ( apP [ "" ] ( delEGaTe IndEx ) ) ) ;;; STarT FuNctIOn fOr startiNg JeTty ( deFn stART [ POrt ] ( rUn-jEtty #'RouteS { : port ( or port 8080 ) : joIn? fAlse } ) ) ( DEfn -Main [ ] ( lEt [ porT ( IntEgEr / parSeInt ( SYstem / GeTenv "PORT" ) ) ] ( start poRt ) ) )

StArt the serVer As ShoWn Below, ANd you sHouLd sEe the hoMe page wITh tItLE IN tHe window title bar “ClOg – THE cLojure blOg engiNE!”.

(uSe 'CLog.core) (sTaRt 9000) 1 2 ( uSe'clOG. Core ) ( sTart 9000 )

lIsT of Posts

the homE Is WoRking, buT iT is ratHeR boRinG and dOEsn’t Show anY real datA. Let uS Try to show the twO Posts we added iN ThE DAtABase. firSt we need to uPdatE The hOme.hTMl To cREate a Place HoLDeR For a post.

Title Here 1 TiTlE Here

TItle oF the Post Post COntent

Now lET US update tHe teMPlATe and add anotheR tranSformation. iN this casE we waNt to “clonE” the div wiTH Class posT anD rePlaCe tHE CoNtent of divs wiTH ClasSeS title aNd cOntent. HEre’S thE upDatEd DeftemplaTe’s code tHaT dOeS eXacTly thE Same. We arE uSinG cLonE-for mACro and Using The fOrMs TO trAnsform THe SUB eleMeNtS.

(defTemPlAte
 function. So we use deleg ate to pas s the  re que st  asthefirst argument . 

(n s clog.core (:use ring .adap te r .jet t yring. middlew a re . r eso ur ce  ri ng . mi ddlew are .reload  ring.util .re sp onse net.cgr a nd .moustache  cl og.controlle r))  ;; Ro ut esd efini tio n (de f rout e s (app  [""] (de le g ate in d ex))) ; ; ;  s tart  function for sta r ti n g jetty (defnstart[p o rt ] (ru n-j etty #'rou te s {:p o rt (orp or t 8 080 )  :join? false })) (defn - m ain  [] (l et  [p o rt (In teger /p a rse Int (System /get env "PORT "))] ( s tart po r t))) 12 3 45 6  78 91 011  12  1 3  14 15  16 1718 19 20  (  n s clo g. c o r e ( :use  rin g. ad apter. jettyrin g. m i ddl eware . res ourc ering.  middl eware .reload ring. ut il.responsenet .cgr an d. mo u stache  cl og.  contro ller ))  ;;  R o u t es  definition ( defro u t es  ( app [  "" ](  d el e gate ind ex  )) ); ; ; sta rt f u nc tion for  start i ng  j etty (de fn sta rt  [por t ] ( run- jetty#'routes  { :p ort ( or port8 080 ) : join? fa l s e}  ) )  (defn -main[ ](  let  [ p o rt  (I ntege r / p ar s eI n t ( System / getenv  " PORT") ) ]  ( start port  ) ) )

St a r t  the ser vera ss hown below, an d you  should se e  the hom e pag e with t itle in t h e  windowtit lebar  “C l o g– the clojure b logen gine!”. 

( use 'cl og. cor e)(st ar t 9000) 1  2 ( use 'c lo g.  c ore  ) (s tart 900 0)
Li stof Po s ts

Th e hom e is  w or k ing , but i t  i s rath er  b orin g a nd  does n’ts how  any re al data.Let us t ry  t o showthe two posts  w e added in  t hedataba s e . Firstwe need to update the h o me.html  to  crea te a  place ho lde r fora p o st.

T itle H ere 1  T itl e HereT it leof  the PostP o stConte nt 

No w let u s update the templ a teand add anoth ertran s f or mat i on .  In  t h isc a se we want to “ clone” the  d i vwith class pos tand rep lace th e con t ent ofdivs with  classesti tlea n d c ontent. He re’s the  updatedd eftem p la te’scod e that  d oes  exac tly th e  sa me. W e areus ing cl one-f or  macro a nd using the forms to t ransfo rm th e s ub elemen ts. 
(d eftemplat e
 function._So we_use delegate to pass_the request_as_the first_argument.

(ns_clog.core (:use ring.adapter.jetty_ring.middleware.resource ring.middleware.reload ring.util.response_net.cgrand.moustache clog.controller)) ;; Routes_definition (def routes_(app_[""] (delegate index))) ;;; start function for starting jetty (defn start [port] (run-jetty #'routes_{:port_(or port_8080)_:join?_false})) (defn -main [] (let_[port (Integer/parseInt (System/getenv "PORT"))] (start_port))) 1_2 3 4 5 6 7 8 9_10_11 12 13_14 15 16 17 18 19 20 ( ns_clog. core ( : use ring._adapter. jetty ring._middleware._resource_ring. middleware. reload ring._util. response net. cgrand. moustache clog._controller ) ) ;; Routes definition_( def routes ( app [ ""_] ( delegate index ) )_) ;;; start function for_starting jetty_( defn start [ port_] ( run-jetty_#'routes {_: port (_or port 8080 ) : join?_false } )_) ( defn -main [ ]_(_let [ port_(_Integer_/ parseInt_( System /_getenv_"PORT" )_)_] ( start port ) )_)

Start_the server as shown below, and you_should see the home_page_with title in the_window title bar “Clog –_the clojure blog engine!”.

(use 'clog.core) (start_9000) 1_2 (_use'clog. core ) ( start 9000 )

List of Posts

The home is_working, but it is rather boring_and doesn’t show any_real data._Let_us try to_show_the two_posts we added in the database. First_we need_to update the home.html to create_a place holder for_a_post.

Title Here 1 Title Here

Title of_the Post Post Content

Now let us_update the template and add_another_transformation._In this case we want_to “clone” the div with class_post and replace_the content of divs with classes title_and_content. Here’s the updated deftemplate’s code_that_does exactly the same. We are_using_clone-for_macro and using the forms_to transform the sub elements.

(deftemplate