Created
July 4, 2011 19:20
Revisions
-
ithayer revised this gist
May 7, 2012 . 1 changed file with 1 addition and 2 deletions.There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -1,6 +1,5 @@ (ns noir-mongo-heroku.views.welcome (:require [noir-mongo-heroku.views.common :as common]) (use noir.core hiccup.core hiccup.page-helpers) -
ithayer revised this gist
Jul 5, 2011 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -1,2 +1,2 @@ # Update welcome.clj to include some simple mongo code. wget https://raw.github.com/gist/1063814/b376a69fc0e6fbaed613eb35bee98ccc72e6be1b/welcome.clj -O src/noir_mongo_heroku/views/welcome.clj -
ithayer revised this gist
Jul 5, 2011 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -33,4 +33,4 @@ {:$inc {:value 1} } ;; Increment it. :return-new true :upsert? true)] ;; Insert if not there. (common/layout [:p (str "Welcome to noir-heroku, you're visitor " (or (:value counter) 0))]))) -
ithayer revised this gist
Jul 5, 2011 . 1 changed file with 4 additions and 0 deletions.There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,4 @@ :dependencies [ [org.clojure/clojure "1.2.1"] [congomongo "0.1.5-SNAPSHOT"] ;; <-- New. [noir "1.1.0-SNAPSHOT"]] -
ithayer revised this gist
Jul 5, 2011 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -1,3 +1,3 @@ # Update Heroku git commit -a -m "Updates" git push heroku master -
ithayer revised this gist
Jul 5, 2011 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -1,2 +1,2 @@ # Update welcome.clj to include some simple mongo code. wget https://raw.github.com/gist/1063814/d5997229e3e1c7643b6324af9b9eca351f8696ec/welcome.clj -O src/noir_mongo_heroku/views/welcome.clj -
ithayer revised this gist
Jul 5, 2011 . 1 changed file with 2 additions and 2 deletions.There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -1,5 +1,5 @@ (ns noir-mongo-heroku.views.welcome (:require [noir-mongo-heroku.views.common :as common] [noir.content.pages :as pages]) (use noir.core hiccup.core -
ithayer revised this gist
Jul 5, 2011 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -1,2 +1,2 @@ # Update welcome.clj to include some simple mongo code. wget https://raw.github.com/gist/1063814/4e2a7b82fd66405776fd897694691b5b4c47fdf2/welcome.clj -O src/noir_mongo_heroku/views/welcome.clj -
ithayer revised this gist
Jul 5, 2011 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -1,2 +1,2 @@ # Update welcome.clj to include some simple mongo code. wget https://gist.github.com/1063814.js?file=welcome.clj -O src/noir_mongo_heroku/views/welcome.clj -
ithayer revised this gist
Jul 5, 2011 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -1,7 +1,7 @@ # Commands to initialize a simple heroku noir app. You can cut and paste them together. # Install latest version of noir. If an older version is installed, remove it first. lein plugin install lein-noir "1.1.0-SNAPSHOT" # Create new noir project. lein noir new noir-mongo-heroku cd noir-mongo-heroku -
ithayer revised this gist
Jul 5, 2011 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -1,6 +1,6 @@ # Commands to initialize a simple heroku noir app. You can cut and paste them together. # Install latest version of noir. If an older version is installed, remove it first. lein plugin install noir "1.1.0-SNAPSHOT" # Create new noir project. lein noir new noir-mongo-heroku -
ithayer revised this gist
Jul 5, 2011 . 1 changed file with 3 additions and 1 deletion.There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -1,5 +1,7 @@ # Commands to initialize a simple heroku noir app. You can cut and paste them together. # Install latest version of noir. lein plugin install noir "1.1.0-SNAPSHOT" # Create new noir project. lein noir new noir-mongo-heroku cd noir-mongo-heroku -
ithayer revised this gist
Jul 4, 2011 . 1 changed file with 2 additions and 2 deletions.There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -11,11 +11,11 @@ "Parses mongodb url from heroku, eg. mongodb://user:pass@localhost:1234/db" (let [matcher (re-matcher #"^.*://(.*?):(.*?)@(.*?):(\d+)/(.*)$" url)] ;; Setup the regex. (when (.find matcher) ;; Check if it matches. (zipmap [:match :user :pass :host :port :db] (re-groups matcher))))) ;; Construct an options map. (defn maybe-init [] "Checks if connection and collection exist, otherwise initialize." (when (not (connection? *mongo-config*)) ;; If global connection doesn't exist yet. (let [mongo-url (get (System/getenv) "MONGOHQ_URL") ;; Heroku puts it here. config (split-mongo-url mongo-url)] ;; Extract options. (println "Initializing mongo @ " mongo-url) -
ithayer revised this gist
Jul 4, 2011 . 1 changed file with 12 additions and 12 deletions.There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -9,28 +9,28 @@ (defn split-mongo-url [url] "Parses mongodb url from heroku, eg. mongodb://user:pass@localhost:1234/db" (let [matcher (re-matcher #"^.*://(.*?):(.*?)@(.*?):(\d+)/(.*)$" url)] ;; Setup the regex. (when (.find matcher) ;; Check if it matches. (zipmap [:match :user :pass :host :port :db] (re-groups matcher))))) ;; Construct a map. (defn maybe-init [] "Checks if connection and collection exist, otherwise initialize." (when (not (connection? *mongo-config*)) (let [mongo-url (get (System/getenv) "MONGOHQ_URL") ;; Heroku puts it here. config (split-mongo-url mongo-url)] ;; Extract options. (println "Initializing mongo @ " mongo-url) (mongo! :db (:db config) :host (:host config) :port (Integer. (:port config))) ;; Setup global mongo. (authenticate (:user config) (:pass config)) ;; Setup u/p. (or (collection-exists? :firstcollection) ;; Create collection named 'firstcollection' if it doesn't exist. (create-collection! :firstcollection))))) (defpage "/welcome" [] (maybe-init) (let [counter (fetch-and-modify :firstcollection ;; In the collection named 'firstcollection', {:_id "counter"} ;; find the counter record. {:$inc {:value 1} } ;; Increment it. :return-new true :upsert? true)] ;; Insert if not there. (common/layout [:p (str "Welcome to noir-heroku, you're visitor " (:value counter))]))) -
ithayer revised this gist
Jul 4, 2011 . 1 changed file with 3 additions and 0 deletions.There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,3 @@ # Update Heroku git commit -a -m "Updates" git push heroku -
ithayer revised this gist
Jul 4, 2011 . 1 changed file with 1 addition and 0 deletions.There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -1 +1,2 @@ # Update welcome.clj to include some simple mongo code. wget https://gist.github.com/1063814.js?file=welcome.clj -O src/noir_heroku/views/welcome.clj -
ithayer revised this gist
Jul 4, 2011 . 1 changed file with 1 addition and 0 deletions.There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1 @@ wget https://gist.github.com/1063814.js?file=welcome.clj -O src/noir_heroku/views/welcome.clj -
ithayer revised this gist
Jul 4, 2011 . 1 changed file with 36 additions and 0 deletions.There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,36 @@ (ns noir-heroku.views.welcome (:require [noir-heroku.views.common :as common] [noir.content.pages :as pages]) (use noir.core hiccup.core hiccup.page-helpers) (:use somnium.congomongo) (:use [somnium.congomongo.config :only [*mongo-config*]])) (defn split-mongo-url [url] "Parses mongodb url from heroku, eg. mongodb://user:pass@localhost:1234/db" (let [matcher (re-matcher #"^.*://(.*?):(.*?)@(.*?):(\d+)/(.*)$" url)] (when (.find matcher) (zipmap [:match :user :pass :host :port :db] (re-groups matcher))))) (defn maybe-init [] "Checks if connection and collection exist, otherwise initialize." (when (not (connection? *mongo-config*)) (let [mongo-url (get (System/getenv) "MONGOHQ_URL") config (split-mongo-url mongo-url)] (println "Initializing mongo @ " mongo-url) (mongo! :db (:db config) :host (:host config) :port (Integer. (:port config))) (authenticate (:user config) (:pass config)) (or (collection-exists? :firstcollection) (create-collection! :firstcollection))))) (defpage "/welcome" [] (maybe-init) (let [counter (fetch-and-modify :firstcollection {:_id "counter"} {:$inc {:value 1} } :return-new true :upsert? true)] (common/layout [:p (str "Welcome to noir-heroku, you're visitor " (:value counter))]))) -
ithayer revised this gist
Jul 4, 2011 . 1 changed file with 1 addition and 0 deletions.There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -1 +1,2 @@ # Configure Heroku to add a small mongo add on for our app. heroku addons:add mongohq:free -
ithayer revised this gist
Jul 4, 2011 . 1 changed file with 1 addition and 0 deletions.There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1 @@ heroku addons:add mongohq:free -
ithayer revised this gist
Jul 4, 2011 . 1 changed file with 15 additions and 0 deletions.There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,15 @@ # Install latest version of noir. lein install noir "1.1.0-SNAPSHOT" # Create new noir project. lein noir new noir-mongo-heroku cd noir-mongo-heroku # Create instructions for heroku. echo 'web: lein run' > Procfile # Create git repository. git init git add . git commit -m "Initial commit" # Initialize heroku app. heroku create --stack cedar # Push to heroku. git push heroku master -
ithayer created this gist
Jul 4, 2011 .There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,5 @@ # 1. Install lein wget https://raw.github.com/technomancy/leiningen/stable/bin/lein sh lein # 2. Install heroku gem gem install heroku