Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

adding contact page

  • Loading branch information...
commit 2b9a888a58b6126e468649266154ac6b590032c0 1 parent 0f7499b
@swanson swanson authored
View
25 landingpad.rb
@@ -10,6 +10,24 @@ class LandingPad < Sinatra::Base
set :public, 'public'
configure do
+ # Admin settings - used to access contacts
+ $admin_acct_name = 'admin'
+ $admin_acct_passwd = 'admin'
+
+ # 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
+ start collecting contacts immediately!'
+ #your google analyics tracking key, if applicable
+ $google_analyics_key = 'UA-XXXXXX-X'
+
+ $bg_color = '#2B2F3D'
+ $app_title_color = '#FFFFFF'
+ #see http://code.google.com/webfonts for available fonts
+ $app_title_font = 'Philosopher'
+
+ # Database settings - do NOT change these
uri = URI.parse(ENV['MONGOHQ_URL'])
conn = Mongo::Connection.from_uri(ENV['MONGOHQ_URL'])
db = conn.db(uri.path.gsub(/^\//, ''))
@@ -26,7 +44,7 @@ def protected!
def authorized?
@auth ||= Rack::Auth::Basic::Request.new(request.env)
- @auth.provided? && @auth.basic? && @auth.credentials && @auth.credentials == ['admin', 'admin']
+ @auth.provided? && @auth.basic? && @auth.credentials && @auth.credentials == [$admin_acct_name, $admin_acct_passwd]
end
end
@@ -36,6 +54,7 @@ def authorized?
get '/contacts' do
protected!
+ @contacts = $collection.find()
erb :contacts
end
@@ -43,10 +62,10 @@ def authorized?
content_type :json
contact = params[:contact]
contact_type = contact.start_with?("@") ||
- !contact.include?("@") ? "Twitter" : "email"
+ !contact.include?("@") ? "Twitter" : "Email"
doc = {
- "name" => contact,
+ "name" => contact,
"type" => contact_type,
"referer" => params[:referer],
}
View
69 public/css/style.css
@@ -1,11 +1,11 @@
-@font-face { font-family: paola; src: url('paola.ttf'); }
-
#container {
- margin-top: 200px;
+ margin-left: auto;
+ margin-right: auto;
+ margin-top: 100px;
+ width: 960px;
}
h1 {
- font-family: paola, sans-serif;
font-size: 65px;
margin-bottom: 5px;
margin-top: 10px;
@@ -26,15 +26,21 @@ h3 {
}
h4 {
+ font-size: 12px;
}
body {
- background-color: #2B2F3D;
- color: white;
font-family: 'Helvetica Neue', Arial, Helvetica, sans-serif;
+ text-align: center;
+}
+
+a {
+ color:white;
+ font-weight:bold;
}
.box {
+ color: white;
width: 480px;
background-color: black;
margin: 5px auto 0px;
@@ -53,29 +59,20 @@ body {
font-size: 13px;
}
+#form_div {
+ height: 30px;
+}
+
#sign_up {
background: -moz-linear-gradient(0% 100% 90deg,#63A62F, #7FBF4D);
background-image: -webkit-gradient(linear, 0% 0%, 0% 100%, from(#7FBF4D), to(#63A62F));
- border-bottom-color: #5B992B;
- border-bottom-left-radius: 3px;
- border-bottom-right-radius: 3px;
- border-bottom-style: solid;
- border-bottom-width: 1px;
- border-left-color: #63A62F;
- border-left-style: solid;
- border-left-width: 1px;
- border-right-color: #63A62F;
- border-right-style: solid;
- border-right-width: 1px;
- border-top-color: #63A62F;
- border-top-left-radius: 3px;
- border-top-right-radius: 3px;
- border-top-style: solid;
- border-top-width: 1px;
+ border-radius: 3px;
+ -moz-border-radius: 3px;
+ border-style: 1px solid;
+ border-color: #63A62F;
display: block;
float: left;
color: white;
- font-family: 'Lucida Grande', 'Lucida Sans Unicode', 'Lucida Sans', Geneva, Verdana, sans-serif;
font-size: 13px;
font-weight: bold;
height: 30px;
@@ -108,6 +105,9 @@ body {
height: 30px;
z-index: 1;
position:relative;
+ color:white;
+ margin-left: auto;
+ margin-right: auto;
}
.yikes {
@@ -123,4 +123,27 @@ body {
height: 30px;
z-index: 1;
position:relative;
+ color:white
+ margin-left: auto;
+ margin-right: auto;
+}
+
+.odd {
+ background-color:#eaecdc;
+}
+
+.even {
+ background-color:#fbfcf3;
+}
+
+.table-name {
+ width: 50%;
+}
+
+.table-type {
+ width: 10%;
+}
+
+.table-referer {
+ width: 40%;
}
View
29 views/contacts.erb
@@ -1,5 +1,28 @@
<html>
- <% @contacts.each do |contact| %>
- <%= contact.name %> <%= contact.type %> <%= contact.referer %>
- <% %>
+<head>
+ <link rel="stylesheet" href="css/style.css" type="text/css" media="screen">
+</head>
+<body style="background-color:<%= $bg_color %>">
+ <div id="container">
+ <div class="box">
+ <h2>Logged Contacts</h2>
+ <h4>So far, <%= @contacts.count %> people have signed up.</h4>
+ <table cellpadding="10px">
+ <thead class="even">
+ <td class="table-name">Name</td>
+ <td class="table-type">Type</td>
+ <td class="table-referer">Referer URL</td>
+ </thead>
+ <% @contacts.each_with_index do |contact, i| %>
+ <% row_class = i%2 == 0 ? "even" : "odd" %>
+ <tr class="<%= row_class %>">
+ <td class="table-name"><%= contact['name'] %></td>
+ <td class="table-type"><%= contact['type'] %></td>
+ <td class="table-referer"><%= contact['referer'] %></td>
+ </tr>
+ <% end %>
+ </table>
+ </div>
+ </div>
+</body>
</html>
View
128 views/index.erb
@@ -1,65 +1,79 @@
<html>
- <head>
- <title>LandingPad.rb | Just add water landing page</title>
- <script type="text/javascript" src="javascripts/jquery-1.4.4.min.js"></script>
- <script type="text/javascript" src="javascripts/jquery-ui-1.8.9.custom.min.js">
- </script>
- <link rel="stylesheet" href="css/style.css" type="text/css" media="screen">
- <script type="text/javascript">
- $(document).ready(function(){
- $("#sign_up").click(function(e){
- var that = $(this);
- e.preventDefault();
+<head>
+ <title><%= $page_title %></title>
+ <script type="text/javascript" src="javascripts/jquery-1.4.4.min.js"></script>
+ <script type="text/javascript" src="javascripts/jquery-ui-1.8.9.custom.min.js"></script>
+ <link rel="stylesheet" type="text/css" href="http://fonts.googleapis.com/css?family=<%= $app_title_font %>">
+ <link rel="stylesheet" href="css/style.css" type="text/css" media="screen">
+ <script type="text/javascript">
+ $(document).ready(function(){
+ $("#sign_up").click(function(e){
+ var that = $(this);
+ e.preventDefault();
- if ( $('.entry').val().length < 1 ){
- $('#form_div').effect('shake', { times: 4, distance: 3}, 40);
- return;
- }
+ if ( $('#subscribe').attr('submitted') ){
+ return;
+ }
- $.ajax({
- type: 'post',
- url: '/subscribe',
- data: $('#subscribe').serialize(),
- datatype: 'json',
- success: function(data){
- $('.entry').val('');
- $("<div class='thanks'>Thanks! We'll update you through " +
- data.type + "!</div>")
- .hide()
- .appendTo('#container')
- .slideDown('fast');
+ if ( $('.entry').val().length < 1 ){
+ $('#form_div').effect('shake', { times: 4, distance: 3}, 40);
+ return;
+ }
- $('.sign_up').attr('disabled', true);
- that.unbind();
- },
- error: function(data){
- $("<div class='yikes'>Yikes! Something messed up, try again.</div>")
- .hide()
- .appendTo('#container')
- .slideDown('fast');
- },
- });
- });
- });
- </script>
+ $.ajax({
+ type: 'post',
+ url: '/subscribe',
+ data: $('#subscribe').serialize(),
+ datatype: 'json',
+ success: function(data){
+ $("<div class='thanks'>Thanks! We'll update you through " +
+ data.type + "!</div>")
+ .hide()
+ .appendTo('#container')
+ .slideDown('fast');
+ $('.sign_up').attr('disabled', true);
+ $('#subscribe').attr('submitted', true);
+ },
+ error: function(data){
+ $("<div class='yikes'>Yikes! Something messed up, try again.</div>")
+ .hide()
+ .appendTo('#container')
+ .slideDown('fast');
+ },
+ });
+ });
+ });
+</script>
</head>
- <body>
- <center id="container">
- <h1>LandingPad.rb</h1>
- <div class="box">
- <h2>Just add water landing pages. <br />
- Get a page up in running minutes and startcollecting contact information!
- </h2>
- <h3>Enter your email or Twitter and we'll tell you when it's ready.</h3>
- <div id="form_div">
- <form id="subscribe" novalidate>
- <input class="entry" type="email" name="contact" />
- <button id="sign_up">Sign up</button>
- </form>
- </div>
- <h4>Powered by Heroku and MongoHQ</h4>
+<body style="background-color:<%= $bg_color %>;">
+ <div id="container">
+ <h1 style="color:<%= $app_title_color %>; font-family:<%= $app_title_font %>,serif">
+ <%= $app_title %>
+ </h1>
+ <div class="box">
+ <h2><%= $app_summary %></h2>
+ <h3>Enter your email or Twitter and we'll tell you when it's ready.</h3>
+ <div id="form_div">
+ <form id="subscribe" novalidate>
+ <input class="entry" type="email" name="contact" />
+ <button id="sign_up">Sign up</button>
+ </form>
</div>
- </center>
- </body>
+ <h4>Powered by <a href="http://heroku.com/">Heroku</a> and <a href="http://mongohq.com">MongoHQ</a></h4>
+ </div>
+ </div>
+</body>
+
+<script type="text/javascript">
+ var _gaq = _gaq || [];
+ _gaq.push(['_setAccount', <%= $google_analytics_key %>]);
+ _gaq.push(['_trackPageview']);
+
+ (function() {
+ var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
+ ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
+ var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
+ })();
+</script>
</html>
Please sign in to comment.
Something went wrong with that request. Please try again.