Created
August 23, 2013 19:05
-
-
Save aamedina/6322861 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| (def ads-api "http://192.241.130.213:8080/user/15/ads-api/") | |
| (defmodel account | |
| {:url "accounts/:id" :api ads-api}) | |
| (defcollection accounts | |
| {:url "accounts" :model account :api ads-api}) | |
| (defmodel campaign | |
| {:url "accounts/:account-id/campaigns/:id" :api ads-api}) | |
| (defcollection campaigns | |
| {:url "accounts/:id/campaigns" :model campaign :api ads-api}) | |
| (defn collection | |
| [{:keys [url model api]} | |
| & {:keys [for models channels] :or {models #{}}}] | |
| (let [chans (reduce #(into %1 {%2 (broadcasting-port)}) {} [:sync :update :destroy :sort]) | |
| coll (with-meta models {:url url :api api :channels chans :type :collection :model model :for for})] | |
| (sub! [coll :sync] (pub! coll :update coll)) | |
| coll)) | |
| (defview account-view | |
| [account campaigns] | |
| [:h1.page-header (:name account)] | |
| (account-stats account) | |
| (campaign-collection-view account campaigns)) | |
| (defn bootstrap | |
| [& args] | |
| (go (let [accounts (<! (accounts)) account (first accounts) campaigns (<! (campaigns :for account))] | |
| (append! :div#content (account-view account campaigns))))) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment