Permalink
Browse files

Merge pull request #2 from leereilly/json-export

Add ability to export contacts in JSON
  • Loading branch information...
2 parents af6a570 + 0c27ae1 commit 0cbf161543b7f47e793627e3361cd3b3d354eb81 @swanson committed Apr 26, 2012
Showing with 9 additions and 1 deletion.
  1. +9 −1 landingpad.rb
View
@@ -17,7 +17,7 @@ class LandingPad < Sinatra::Base
# Page settings - used to configure your landing page
$page_title = 'LandingPad.rb | Just add water landing pages'
$app_title = 'LandingPad.rb'
- $app_summary = 'Get a page up and running in minutes and
+ $app_summary = 'Get a page up and running in minutes and
start collecting contacts immediately!'
#your google analyics tracking key, if applicable
$google_analytics_key = 'UA-XXXXXX-X'
@@ -58,6 +58,14 @@ def authorized?
erb :contacts
end
+ get '/contacts.json' do
+ protected!
+ content_type :json
+ @contacts = $collection.find()
+ @results = @contacts.to_a();
+ JSON.dump(@results)
+ end
+
post '/subscribe' do
content_type :json
contact = params[:contact]

0 comments on commit 0cbf161

Please sign in to comment.