More Related Content More from Howard Lewis Ship (17) Cascade1. Cascade
Howard M. Lewis Ship
Director of Open Source Technology, Formos
howard.lewis.ship@formos.com
© 2009 Formos Software Development
3. Cascade Web Framework
• Pure Clojure
• Functional
• Share Nothing
• Action Oriented (not component based)
• Tapestry-style Templates
• Status: alpha, incomplete
© 2009 Formos Software Development
4. Views and Fragments
app/views/index.cml
<html xmlns:c="cascade">
<body>
The current time is:
<c:format-date c:date="(env :current-time)"/>
</body>
</html>
app/fragments.clj
(ns app.fragments
(:import (java.util Date)
(java.text DateFormat)))
(defn format-date
[env params]
(let [#^Date date (params :date)
#^DateFormat fmt (DateFormat/getDateTimeInstance
DateFormat/MEDIUM DateFormat/MEDIUM)]
(.format fmt date)))
© 2009 Formos Software Development
5. Expansions
app/views/index.cml
<html xmlns:c="cascade">
<c:loop c:source="(range 5 0 -1)" c:value=":i">
$(env :i) ...
</c:loop>
</html>
Output
<html xmlns:c="cascade">
5 ... 4 ... 3 ... 2 ... 1 ...
</html>
• In text
• In attribute values
© 2009 Formos Software Development
6. Fragments can be Templates
A bit awkward ...
app/views/index.cml
1
<c:layout xmlns:c="cascade" c:title='"Current Date"'>
The current time is: 4
<c:format-date c:date="(env :current-time)"/>
</c:layout> 6
fragments/layout.cml
2
<html xmlns:c="cascade">
<head>
<title>$(params :title)</title>
</head>
<body>
<h1>$(params :title)</h1>
3
<c:render-body/>
</html> 5
© 2009 Formos Software Development
7. Actions
© 2009 Formos Software Development
8. Actions
• Coming Soon! :-)
• Functional:
•env in (:request, :response, etc.)
•result:
•keyword ➠ render this view
•URL ➠ send redirect for URL
•false ➠ didn't handle request after all
•true ➠ sent response directly
© 2009 Formos Software Development
9. Actions
• Functions to generate callback URLs
• To an action
• To a view
• Pass query parameters
• Extra data in path
• Built-in fragments to generate URLs
© 2009 Formos Software Development
10. URLs
• Actions
• /action/name
• Views
• /name
• Configurable?
© 2009 Formos Software Development
12. Servlet Integration
• Run Cascade as servlet
• Embedded mode: Start Jetty up with Cascade configured
© 2009 Formos Software Development
13. Document Generation
• DOCTYPEs not supported yet
• <![CDATA[]]> not supported yet
• Control: HTML(SGML) vs. XML output
• Filtering characters to entities (i.e., < ➠ <)
• Output namespace support
© 2009 Formos Software Development
14. Template Features
• Server-side Comments
• Root <c:fragment> element (for templates that render
multiple elements)
• Better way to pass literal strings as parameters
• Tapestry-style blocks:
• Encapsulate a section of template as a closure
• Pass as parameter to a fragment
© 2009 Formos Software Development
15. Unimplemented Ideas
• Parallelization
• Render fragments in parallel across threads
• Multiple simultaneous database queries
• Pipelines
• Declarative command chains around views and actions
• Meta-data
• Declare pipelines, required parameters, etc.
© 2009 Formos Software Development
16. (use 'tapestry)
• Libraries of fragments & views
• JAR-packaged resources
• 1st class exception reporting
• JavaScript aggregation / minimization
• Version asset URLs
• Automatic GZIP compression
• Localization
• Live "class" reloading
© 2009 Formos Software Development
17. Wrap Up
© 2009 Formos Software Development
20. Photo Credits
© 2008 Danny Barron
http://www.flickr.com/photos/dbarronoss/2454432792/
© 2006 Chris Walton
http://www.flickr.com/photos/philocrites/245011706/
© 2009 Formos Software Development