PageRenderTime 56ms CodeModel.GetById 27ms RepoModel.GetById 1ms app.codeStats 0ms

/README.mkd

http://github.com/ohpauleez/shoreleave
Unknown | 155 lines | 106 code | 49 blank | 0 comment | 0 complexity | 199142abaff5c11e426397cffea5c989 MD5 | raw file
  1. shoreleave
  2. ==========
  3. A smarter client-side in ClojureScript
  4. ###Shoreleave is a collection of integrated libraries that focuses on:
  5. * Security
  6. * Idiomatic interfaces
  7. * Common client-side strategies
  8. * HTML5 capabilities
  9. * ClojureScript's advantages
  10. Installing and using
  11. --------------------
  12. You can pull all the pieces of Shoreleave into your project by adding the following to your `project.clj`
  13. ```clojure
  14. (defproject ...
  15. :dependencies [[org.clojure/clojure "1.4.0"]
  16. [shoreleave "0.2.2-SNAPSHOT"]
  17. [shoreleave/shoreleave-remote-noir "0.2.2-SNAPSHOT"]
  18. ...
  19. ]
  20. ...
  21. )
  22. ```
  23. Individual utilies can be pulled in with `[shoreleave/UTILITY "0.2.2-SNAPSHOT"]`. See the specific repo/artifact names below.
  24. Overview
  25. ----------
  26. Shoreleave has support for the following:
  27. ### A remotes package
  28. Shoreleave's remotes package includes XHR, Pooled-XHR, JSONP, and HTTP-RPC capabilities.
  29. CSRF protection is built in if your Clojure server is using the [ring-anti-forgery](https://github.com/weavejester/ring-anti-forgery) middleware.
  30. The HTTP-RPC allows for exposing a server-side namespace as a client-side API, via a single server-side call, `remote-ns`.
  31. A typical [Noir](http://www.webnoir.org/) setup might look like:
  32. ```clojure
  33. (ns example
  34. (:require [example.api] ; You don't have to pull this in, but it is suggested
  35. [noir.shoreleave.rpc :as rpc]))
  36. ;; ...
  37. ;; The Base Web Server
  38. ;; ---------------------
  39. ;; Serve every view file found in `src/example/views`
  40. (server/load-views "src/example/views/")
  41. ;; Remote Namespaces
  42. ;; -----------------
  43. (rpc/activate-remotes!)
  44. (rpc/remote-ns 'example.api :as "api")
  45. ;; Middleware
  46. ;;-----------
  47. (server/add-middleware ring.middleware.gzip/wrap-gzip)
  48. (server/add-middleware ring.middleware.file-info/wrap-file-info)
  49. (server/add-middleware ring.middleware.anti-forgery/wrap-anti-forgery)
  50. ```
  51. You can also define single "global" rpc functions:
  52. ```clojure
  53. (defremote ping []
  54. (do
  55. (println "Pinged by client!")
  56. "PONG - from the server"))
  57. ```
  58. ### A pub/sub abstraction (and implementations)
  59. _Why would I ever want to use this?_
  60. Shoreleave's pub/sub system enables you to completely decouple parts of your app and declaratively bind them together.
  61. New features and functionalities can be built by composing pre-existing services/publishables.
  62. Additionally you can express cross-cutting functionality (like logging or metrics reporting) as a service.
  63. _Reactive ClojureScript_
  64. This gives you the heart of Reactive JavaScript (RxJS), without the additional verbs (both a benefit and a tradeoff).
  65. It's often most beneficial to use DOM listeners as entry-points into the pub/sub system.
  66. - - -
  67. Shoreleave's pub/sub system is built upon two protocols: "brokers" and "publishables"
  68. Out of the box, Shoreleave allows you to publish funtions, atoms, web workers, and anything that implements (str ...)/.toString, as topics.
  69. The simple pub/sub bus has little overhead but will only work in single document cases.
  70. (In-progress) The cross document bus has a small amount of overhead, but allows you to publish and subscribe from/to functions that live in other web workers
  71. or windows (in-browser concurrency for "free").
  72. ### Common client-side interactions
  73. * An idiomatic interface to cookies
  74. * An idiomatic interface to browser history (with extended support for HTML5 History API)
  75. * BlobBuilders and on-demand asset building
  76. * (Coming soon) An idiomatic interface to browser storage (Local Storage, Session Storage, and App Cache)
  77. * Common auxiliary functions out-of-the-box to handle query strings, browser-repl, hash strings, and CLJS/JS interop
  78. ### Common external API support
  79. Shoreleave has JSONP-wrapped support for external APIs including:
  80. * Google Maps
  81. * DuckDuckGo Zero-Click
  82. * (Coming soon) Wikipedia and Alpha
  83. ### An enhanced ClojureScript experience
  84. * A `Function` object that supports metadata
  85. * The ability to create embedded web workers
  86. Where's the code?
  87. -----------------
  88. Shoreleave is a big project and has been split up into smaller pieces within the [Shoreleave organization](https://github.com/shoreleave):
  89. * [shoreleave-core](https://github.com/shoreleave/shoreleave-core) - [Marg docs](http://shoreleave.github.com/shoreleave-core/)
  90. * [shoreleave-browser](https://github.com/shoreleave/shoreleave-browser) - [Marg docs](http://shoreleave.github.com/browser/)
  91. * [shoreleave-pubsub](https://github.com/shoreleave/shoreleave-pubsub) - [Marg docs](http://shoreleave.github.com/shoreleave-pubsub/)
  92. * [shoreleave-remote](https://github.com/shoreleave/shoreleave-remote) - [Marg docs](http://shoreleave.github.com/shoreleave-remote/)
  93. * [shoreleave-remote-noir](https://github.com/shoreleave/shoreleave-remote-noir) - Marg docs coming
  94. * [shoreleave-services](https://github.com/shoreleave/shoreleave-services) - Marg docs coming
  95. * [shoreleave-worker](https://github.com/shoreleave/shoreleave-worker) - [Marg docs](http://shoreleave.github.com/shoreleave-worker/)
  96. Plays well with others
  97. ----------------------
  98. Shoreleave makes no assumptions about other libraries you might be using in your app.
  99. I have found it to pair particularly well with [Enfocus](https://github.com/ckirkendall/enfocus)
  100. Examples and usage
  101. ------------------
  102. Please the github wiki for examples of each library feature
  103. License
  104. -------
  105. Copyright (C) 2012 Paul deGrandis
  106. Distributed under the Eclipse Public License, the same as Clojure.