headstart 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (105) hide show
  1. data/LICENSE +20 -0
  2. data/README.rdoc +117 -0
  3. data/Rakefile +95 -0
  4. data/VERSION +1 -0
  5. data/app/controllers/headstart/confirmations_controller.rb +76 -0
  6. data/app/controllers/headstart/impersonations_controller.rb +44 -0
  7. data/app/controllers/headstart/passwords_controller.rb +93 -0
  8. data/app/controllers/headstart/sessions_controller.rb +76 -0
  9. data/app/controllers/headstart/users_controller.rb +85 -0
  10. data/app/models/deliver_change_password_job.rb +19 -0
  11. data/app/models/deliver_welcome_job.rb +17 -0
  12. data/app/models/generic_mailer.rb +31 -0
  13. data/app/models/headstart_mailer.rb +28 -0
  14. data/app/models/impersonation.rb +26 -0
  15. data/app/models/mimi_mailer.rb +30 -0
  16. data/app/views/generic_mailer/change_password.html.erb +9 -0
  17. data/app/views/generic_mailer/confirmation.html.erb +5 -0
  18. data/app/views/generic_mailer/welcome.html.erb +1 -0
  19. data/app/views/impersonations/index.html.erb +5 -0
  20. data/app/views/passwords/edit.html.erb +23 -0
  21. data/app/views/passwords/new.html.erb +15 -0
  22. data/app/views/sessions/new.html.erb +48 -0
  23. data/app/views/users/_form.html.erb +21 -0
  24. data/app/views/users/edit.html.erb +6 -0
  25. data/app/views/users/new.html.erb +6 -0
  26. data/app/views/users/show.html.erb +8 -0
  27. data/generators/headstart/USAGE +1 -0
  28. data/generators/headstart/headstart_generator.rb +86 -0
  29. data/generators/headstart/lib/insert_commands.rb +33 -0
  30. data/generators/headstart/lib/rake_commands.rb +22 -0
  31. data/generators/headstart/templates/README +20 -0
  32. data/generators/headstart/templates/app/controllers/sessions_controller.rb +6 -0
  33. data/generators/headstart/templates/app/views/sessions/index.html.erb +1 -0
  34. data/generators/headstart/templates/application.html.erb +75 -0
  35. data/generators/headstart/templates/factories.rb +23 -0
  36. data/generators/headstart/templates/headstart.rb +25 -0
  37. data/generators/headstart/templates/headstart.yml +45 -0
  38. data/generators/headstart/templates/layout.css +353 -0
  39. data/generators/headstart/templates/migrations/create_users.rb +26 -0
  40. data/generators/headstart/templates/migrations/update_users.rb +44 -0
  41. data/generators/headstart/templates/report.css +69 -0
  42. data/generators/headstart/templates/reset.css +1 -0
  43. data/generators/headstart/templates/style.css +31 -0
  44. data/generators/headstart/templates/text.css +1 -0
  45. data/generators/headstart/templates/user.rb +3 -0
  46. data/generators/headstart/templates/xd_receiver.html +10 -0
  47. data/generators/headstart/templates/xd_receiver_ssl.html +10 -0
  48. data/generators/headstart_admin/USAGE +1 -0
  49. data/generators/headstart_admin/headstart_admin_generator.rb +32 -0
  50. data/generators/headstart_admin/lib/insert_commands.rb +33 -0
  51. data/generators/headstart_admin/templates/README +16 -0
  52. data/generators/headstart_admin/templates/app/controllers/admin/admin_controller.rb +17 -0
  53. data/generators/headstart_admin/templates/app/controllers/admin/users_controller.rb +52 -0
  54. data/generators/headstart_admin/templates/app/views/admin/admin/index.html.erb +2 -0
  55. data/generators/headstart_admin/templates/app/views/admin/users/_form.html.erb +25 -0
  56. data/generators/headstart_admin/templates/app/views/admin/users/edit.html.erb +6 -0
  57. data/generators/headstart_admin/templates/app/views/admin/users/index.html.erb +7 -0
  58. data/generators/headstart_admin/templates/app/views/admin/users/new.html.erb +6 -0
  59. data/generators/headstart_admin/templates/app/views/admin/users/show.html.erb +10 -0
  60. data/generators/headstart_admin/templates/test/integration/admin/users_test.rb +201 -0
  61. data/generators/headstart_tests/USAGE +1 -0
  62. data/generators/headstart_tests/headstart_tests_generator.rb +21 -0
  63. data/generators/headstart_tests/templates/README +58 -0
  64. data/generators/headstart_tests/templates/test/integration/edit_profile_test.rb +35 -0
  65. data/generators/headstart_tests/templates/test/integration/facebook_test.rb +61 -0
  66. data/generators/headstart_tests/templates/test/integration/impersonation_test.rb +39 -0
  67. data/generators/headstart_tests/templates/test/integration/password_reset_test.rb +128 -0
  68. data/generators/headstart_tests/templates/test/integration/sign_in_test.rb +66 -0
  69. data/generators/headstart_tests/templates/test/integration/sign_out_test.rb +28 -0
  70. data/generators/headstart_tests/templates/test/integration/sign_up_test.rb +47 -0
  71. data/lib/headstart/authentication.rb +138 -0
  72. data/lib/headstart/configuration.rb +34 -0
  73. data/lib/headstart/extensions/errors.rb +6 -0
  74. data/lib/headstart/extensions/rescue.rb +5 -0
  75. data/lib/headstart/routes.rb +67 -0
  76. data/lib/headstart/user.rb +279 -0
  77. data/lib/headstart.rb +7 -0
  78. data/rails/init.rb +4 -0
  79. data/shoulda_macros/headstart.rb +244 -0
  80. data/test/controllers/passwords_controller_test.rb +184 -0
  81. data/test/controllers/sessions_controller_test.rb +129 -0
  82. data/test/controllers/users_controller_test.rb +57 -0
  83. data/test/models/headstart_mailer_test.rb +52 -0
  84. data/test/models/impersonation_test.rb +25 -0
  85. data/test/models/user_test.rb +213 -0
  86. data/test/rails_root/app/controllers/accounts_controller.rb +10 -0
  87. data/test/rails_root/app/controllers/application_controller.rb +6 -0
  88. data/test/rails_root/app/helpers/application_helper.rb +5 -0
  89. data/test/rails_root/app/helpers/confirmations_helper.rb +2 -0
  90. data/test/rails_root/app/helpers/passwords_helper.rb +2 -0
  91. data/test/rails_root/config/boot.rb +110 -0
  92. data/test/rails_root/config/environment.rb +22 -0
  93. data/test/rails_root/config/environments/development.rb +19 -0
  94. data/test/rails_root/config/environments/production.rb +1 -0
  95. data/test/rails_root/config/environments/test.rb +37 -0
  96. data/test/rails_root/config/initializers/inflections.rb +10 -0
  97. data/test/rails_root/config/initializers/mime_types.rb +5 -0
  98. data/test/rails_root/config/initializers/requires.rb +13 -0
  99. data/test/rails_root/config/initializers/time_formats.rb +4 -0
  100. data/test/rails_root/config/routes.rb +9 -0
  101. data/test/rails_root/public/dispatch.rb +10 -0
  102. data/test/rails_root/script/create_project.rb +52 -0
  103. data/test/rails_root/test/functional/accounts_controller_test.rb +23 -0
  104. data/test/test_helper.rb +21 -0
  105. metadata +232 -0
@@ -0,0 +1,28 @@
1
+ class HeadstartMailer
2
+
3
+ def self.deliver_change_password(user)
4
+ if MadMimiMailer.api_settings.present? && MadMimiMailer.api_settings[:username].present? && MadMimiMailer.api_settings[:api_key].present?
5
+ MimiMailer.deliver_mimi_change_password(user)
6
+ else
7
+ GenericMailer.deliver_change_password(user)
8
+ end
9
+ end
10
+
11
+ def self.deliver_welcome(user)
12
+ if MadMimiMailer.api_settings.present? && MadMimiMailer.api_settings[:username].present? && MadMimiMailer.api_settings[:api_key].present?
13
+ MimiMailer.deliver_welcome(user)
14
+ else
15
+ GenericMailer.deliver_welcome(user)
16
+ end
17
+ end
18
+
19
+ def self.deliver_confirmation(user)
20
+ if MadMimiMailer.api_settings.present? && MadMimiMailer.api_settings[:username].present? && MadMimiMailer.api_settings[:api_key].present?
21
+ MimiMailer.deliver_confirmation(user)
22
+ else
23
+ GenericMailer.deliver_confirmation(user)
24
+ end
25
+ end
26
+
27
+
28
+ end
@@ -0,0 +1,26 @@
1
+ module Impersonation
2
+
3
+ ##
4
+ # Returns a hash based on the given id.
5
+ #
6
+ def self.hash_for(id)
7
+ raise(ArgumentError, "Must provide an id") unless id
8
+ generate_hash(id)
9
+ end
10
+
11
+ ##
12
+ # Returns +true+ if the given hash is valid for the given id.
13
+ #
14
+ def self.valid_hash?(id, hash)
15
+ hash == generate_hash(id)
16
+ end
17
+
18
+
19
+ private
20
+
21
+
22
+ def self.generate_hash(id)
23
+ Digest::MD5.hexdigest("----#{id}-----#{Headstart.configuration.impersonation_hash}-----")
24
+ end
25
+
26
+ end
@@ -0,0 +1,30 @@
1
+ class MimiMailer < MadMimiMailer
2
+
3
+ def mimi_change_password(user)
4
+ from Headstart.configuration.mailer_sender
5
+ recipients user.email
6
+ subject I18n.t(:change_password,
7
+ :scope => [:headstart, :models, :headstart_mailer],
8
+ :default => "Change your password")
9
+ body :url => edit_user_password_url(user,
10
+ :token => user.password_reset_token,
11
+ :escape => false)
12
+ end
13
+
14
+ def mimi_welcome(user)
15
+ from Headstart.configuration.mailer_sender
16
+ recipients user.email
17
+ subject I18n.t(:welcome,
18
+ :scope => [:headstart, :models, :headstart_mailer],
19
+ :default => "Welcome")
20
+ end
21
+
22
+ def confirmation(user)
23
+ from Headstart.configuration.mailer_sender
24
+ recipients user.email
25
+ subject I18n.t(:confirmation,
26
+ :scope => [:headstart, :models, :headstart_mailer],
27
+ :default => "Account confirmation")
28
+ body :user => user
29
+ end
30
+ end
@@ -0,0 +1,9 @@
1
+ Someone, hopefully you, has requested that we send you a link to change your password.
2
+
3
+ Here's the link:
4
+
5
+ <%= edit_user_password_url(@user,
6
+ :token => @user.confirmation_token,
7
+ :escape => false) %>
8
+
9
+ If you didn't request this, ignore this email. Don't worry. Your password hasn't been changed.
@@ -0,0 +1,5 @@
1
+
2
+ <%= new_user_confirmation_url(
3
+ :user_id => @user,
4
+ :token => @user.confirmation_token,
5
+ :encode => false) %>
@@ -0,0 +1 @@
1
+ Welcome
@@ -0,0 +1,5 @@
1
+ <ul>
2
+ <%- @users.each do |user| -%>
3
+ <li><%=h user.name %> <%= link_to 'Impersonate', impersonation_path(:user_id => user.id), :method => :post, :id => "impersonate_#{user.id}" %></li>
4
+ <%- end -%>
5
+ </ul>
@@ -0,0 +1,23 @@
1
+ <h2>Change your password</h2>
2
+
3
+ <p>
4
+ Your password has been reset. Choose a new password below.
5
+ </p>
6
+
7
+ <%= error_messages_for :user %>
8
+
9
+ <% form_for(:user,
10
+ :url => user_password_path(@user, :token => @user.password_reset_token),
11
+ :html => { :method => :put }) do |form| %>
12
+ <div class="password_field">
13
+ <%= form.label :password, "Choose password" %>
14
+ <%= form.password_field :password %>
15
+ </div>
16
+ <div class="password_field">
17
+ <%= form.label :password_confirmation, "Confirm password" %>
18
+ <%= form.password_field :password_confirmation %>
19
+ </div>
20
+ <div class="submit_field">
21
+ <%= form.submit "Save this password", :disable_with => "Please wait..." %>
22
+ </div>
23
+ <% end %>
@@ -0,0 +1,15 @@
1
+ <h2>Change your password</h2>
2
+
3
+ <p>
4
+ We will email you a link to change your password.
5
+ </p>
6
+
7
+ <% form_for :password, :url => passwords_path do |form| %>
8
+ <div class="text_field">
9
+ <%= form.label :email, "Email address" %>
10
+ <%= form.text_field :email %>
11
+ </div>
12
+ <div class="submit_field">
13
+ <%= form.submit "Reset password", :disable_with => "Please wait..." %>
14
+ </div>
15
+ <% end %>
@@ -0,0 +1,48 @@
1
+ <%- if Headstart.configuration.use_facebook_connect -%>
2
+ <%- if request.ssl? -%>
3
+ <%= javascript_include_tag 'https://ssl.connect.facebook.com/js/api_lib/v0.4/FeatureLoader.js.php/en_US' %>
4
+ <%- else -%>
5
+ <%= javascript_include_tag 'http://static.ak.connect.facebook.com/js/api_lib/v0.4/FeatureLoader.js.php/en_US' %>
6
+ <%- end -%>
7
+ <script>
8
+ function facebook_onlogin() {
9
+ document.location.href = "<%= fb_connect_path %>";
10
+ }
11
+ </script>
12
+ <%- end -%>
13
+
14
+ <h2>Sign in</h2>
15
+
16
+ <% form_for :session, :url => session_path do |form| %>
17
+ <div class="text_field">
18
+ <%= form.label :email %>
19
+ <%= form.text_field :email %>
20
+ </div>
21
+ <div class="text_field">
22
+ <%= form.label :password %>
23
+ <%= form.password_field :password %>
24
+ </div>
25
+ <div class="submit_field">
26
+ <%= form.submit "Sign in", :disable_with => "Please wait..." %>
27
+ <%- if Headstart.configuration.use_facebook_connect -%>
28
+ or <fb:login-button onlogin="facebook_onlogin();" length="long" v="2" size="large"></fb:login-button>
29
+ <%- end -%>
30
+ </div>
31
+ <% end %>
32
+
33
+ <ul>
34
+ <li>
35
+ <%= link_to "Sign up", sign_up_path %>
36
+ </li>
37
+ <li>
38
+ <%= link_to "Forgot password?", new_password_path %>
39
+ </li>
40
+ </ul>
41
+
42
+ <%- if Headstart.configuration.use_facebook_connect -%>
43
+ <script type="text/javascript">
44
+ FB.init("<%= Headstart.configuration.facebook_api_key %>", "xd_receiver.html", {
45
+ permsToRequestOnConnect : "email",
46
+ });
47
+ </script>
48
+ <%- end -%>
@@ -0,0 +1,21 @@
1
+ <%= form.error_messages %>
2
+ <p class="text_field">
3
+ <%= form.label :email %>
4
+ <%= form.text_field :email %>
5
+ </p>
6
+ <p class="text_field">
7
+ <%= form.label :first_name %>
8
+ <%= form.text_field :first_name %>
9
+ </p>
10
+ <p class="text_field">
11
+ <%= form.label :last_name %>
12
+ <%= form.text_field :last_name %>
13
+ </p>
14
+ <p class="password_field">
15
+ <%= form.label :password %>
16
+ <%= form.password_field :password %>
17
+ </p>
18
+ <p class="password_field">
19
+ <%= form.label :password_confirmation, "Confirm password" %>
20
+ <%= form.password_field :password_confirmation %>
21
+ </p>
@@ -0,0 +1,6 @@
1
+ <h2>Edit My Profile</h2>
2
+
3
+ <% form_for @user do |form| %>
4
+ <%= render :partial => '/users/form', :object => form %>
5
+ <%= form.submit 'Save', :disable_with => 'Please wait...' %>
6
+ <% end %>
@@ -0,0 +1,6 @@
1
+ <h2>Sign up</h2>
2
+
3
+ <% form_for @user do |form| %>
4
+ <%= render :partial => '/users/form', :object => form %>
5
+ <%= form.submit 'Sign up', :disable_with => 'Please wait...' %>
6
+ <% end %>
@@ -0,0 +1,8 @@
1
+ <h2>My Profile</h2>
2
+
3
+ <div id="user_profile">
4
+ <b>First Name:</b> <%=h @user.first_name %><br/>
5
+ <b>Last Name:</b> <%=h @user.last_name %><br/>
6
+ <b>Email:</b> <%=h @user.email %><br/>
7
+ <%= link_to 'Edit', edit_user_path(@user) %>
8
+ </div>
@@ -0,0 +1 @@
1
+ script/generate headstart
@@ -0,0 +1,86 @@
1
+ require File.expand_path(File.dirname(__FILE__) + "/lib/insert_commands.rb")
2
+ require File.expand_path(File.dirname(__FILE__) + "/lib/rake_commands.rb")
3
+
4
+ class HeadstartGenerator < Rails::Generator::Base
5
+
6
+ def manifest
7
+ record do |m|
8
+ app_name = File.expand_path(File.dirname(__FILE__)).split("/").last
9
+ m.directory File.join("config", "initializers")
10
+ m.file "headstart.rb", "config/initializers/headstart.rb"
11
+ m.file "headstart.yml", "config/headstart.yml"
12
+
13
+ m.directory File.join("app", "views", "layouts")
14
+ m.directory File.join("app", "views", "sessions")
15
+ m.file "application.html.erb", "app/views/layouts/application.html.erb"
16
+ m.file "app/views/sessions/index.html.erb", "app/views/sessions/index.html.erb"
17
+
18
+ m.directory File.join("public", "stylesheets")
19
+ m.file "style.css", "public/stylesheets/style.css"
20
+ m.file "reports.css", "public/stylesheets/report.css"
21
+ m.file "reset.css", "public/stylesheets/reset.css"
22
+ m.file "text.css", "public/stylesheets/text.css"
23
+ m.file "layout.css", "public/stylesheets/layout.css"
24
+
25
+ m.file "xd_receiver.html", "public/xd_receiver.html"
26
+ m.file "xd_receiver_ssl.html", "public/xd_receiver_ssl.html"
27
+
28
+ m.file "app/controllers/sessions_controller.rb", "app/controllers/sessions_controller.rb"
29
+ m.insert_into "app/controllers/application_controller.rb",
30
+ "include Headstart::Authentication"
31
+
32
+ user_model = "app/models/user.rb"
33
+ if File.exists?(user_model)
34
+ m.insert_into user_model, "include Headstart::User"
35
+ else
36
+ m.directory File.join("app", "models")
37
+ m.file "user.rb", user_model
38
+ end
39
+
40
+ m.insert_into "config/routes.rb",
41
+ "Headstart::Routes.draw(map)"
42
+
43
+ m.directory File.join("test", "factories")
44
+ m.file "factories.rb", "test/factories/user.rb"
45
+
46
+ m.migration_template "migrations/#{migration_source_name}.rb",
47
+ 'db/migrate',
48
+ :migration_file_name => "headstart_#{migration_target_name}"
49
+
50
+ m.readme "README"
51
+ end
52
+ end
53
+
54
+ def schema_version_constant
55
+ if upgrading_headstart_again?
56
+ "To#{schema_version.gsub('_', '')}"
57
+ end
58
+ end
59
+
60
+ private
61
+
62
+ def migration_source_name
63
+ if ActiveRecord::Base.connection.table_exists?(:users)
64
+ 'update_users'
65
+ else
66
+ 'create_users'
67
+ end
68
+ end
69
+
70
+ def migration_target_name
71
+ if upgrading_headstart_again?
72
+ "update_users_to_#{schema_version}"
73
+ else
74
+ 'create_users'
75
+ end
76
+ end
77
+
78
+ def schema_version
79
+ IO.read(File.join(File.dirname(__FILE__), '..', '..', 'VERSION')).strip.gsub(/[^\d]/, '_')
80
+ end
81
+
82
+ def upgrading_headstart_again?
83
+ ActiveRecord::Base.connection.table_exists?(:users)
84
+ end
85
+
86
+ end
@@ -0,0 +1,33 @@
1
+ # Mostly pinched from http://github.com/ryanb/nifty-generators/tree/master
2
+
3
+ Rails::Generator::Commands::Base.class_eval do
4
+ def file_contains?(relative_destination, line)
5
+ File.read(destination_path(relative_destination)).include?(line)
6
+ end
7
+ end
8
+
9
+ Rails::Generator::Commands::Create.class_eval do
10
+ def insert_into(file, line)
11
+ logger.insert "#{line} into #{file}"
12
+ unless options[:pretend] || file_contains?(file, line)
13
+ gsub_file file, /^(class|module|.*Routes).*$/ do |match|
14
+ "#{match}\n #{line}"
15
+ end
16
+ end
17
+ end
18
+ end
19
+
20
+ Rails::Generator::Commands::Destroy.class_eval do
21
+ def insert_into(file, line)
22
+ logger.remove "#{line} from #{file}"
23
+ unless options[:pretend]
24
+ gsub_file file, "\n #{line}", ''
25
+ end
26
+ end
27
+ end
28
+
29
+ Rails::Generator::Commands::List.class_eval do
30
+ def insert_into(file, line)
31
+ logger.insert "#{line} into #{file}"
32
+ end
33
+ end
@@ -0,0 +1,22 @@
1
+ Rails::Generator::Commands::Create.class_eval do
2
+ def rake_db_migrate
3
+ logger.rake "db:migrate"
4
+ unless system("rake db:migrate")
5
+ logger.rake "db:migrate failed. Rolling back"
6
+ command(:destroy).invoke!
7
+ end
8
+ end
9
+ end
10
+
11
+ Rails::Generator::Commands::Destroy.class_eval do
12
+ def rake_db_migrate
13
+ logger.rake "db:rollback"
14
+ system "rake db:rollback"
15
+ end
16
+ end
17
+
18
+ Rails::Generator::Commands::List.class_eval do
19
+ def rake_db_migrate
20
+ logger.rake "db:migrate"
21
+ end
22
+ end
@@ -0,0 +1,20 @@
1
+
2
+ *******************************************************************************
3
+
4
+ Next:
5
+
6
+ 1. Configure default url options for the mailer to generate URLs in emails.
7
+ In production.rb it must be the actual host your application is deployed to.
8
+ In config/environments/test.rb and config/environments/development.rb:
9
+
10
+ config.action_mailer.default_url_options = { :host => 'localhost:3000' }
11
+
12
+ 2. If you haven't already, be sure you have delayed_jobs setup and configured:
13
+
14
+ ./script/generate delayed_job
15
+
16
+ 3. Migrate:
17
+
18
+ rake db:migrate
19
+
20
+ *******************************************************************************
@@ -0,0 +1,6 @@
1
+ class SessionsController < Headstart::SessionsController
2
+
3
+ def index
4
+
5
+ end
6
+ end
@@ -0,0 +1,75 @@
1
+ <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
2
+ <html xmlns="http://www.w3.org/1999/xhtml" dir="ltr" xml:lang="en-US" lang="en-US" xmlns:fb="http://www.facebook.com/2008/fbml">
3
+ <head>
4
+ <meta http-equiv="Content-type" content="text/html; charset=utf-8" />
5
+ <title><%= yield(:title) %></title>
6
+ <meta name="description" content="<%= yield(:description) %>" />
7
+ <meta name="keywords" content="<%= yield(:keywords) %>" />
8
+ <meta name="robots" content="INDEX,FOLLOW" />
9
+
10
+ <%= stylesheet_link_tag "reset", "layout", "text", "style", "report" %>
11
+
12
+ <%- if request.ssl? -%>
13
+ <%= javascript_include_tag 'https://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js' %>
14
+ <%- else -%>
15
+ <%= javascript_include_tag 'http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js' %>
16
+ <%- end -%>
17
+ <%= javascript_include_tag 'application' %>
18
+ </head>
19
+ <body>
20
+
21
+ <div id="header" class="container_12">
22
+
23
+ <div id="title" class="grid_6 ">
24
+ Default Web App
25
+ </div>
26
+
27
+ <div id="nav" class="grid_6 ">
28
+ <% if signed_in? %>
29
+ <% if impersonating? %>
30
+ Impersonating <%= current_user.name %>
31
+ | <%= link_to 'Stop impersonating', impersonation_path, :method => :delete %>
32
+ <% else %>
33
+ Welcome, <%= current_user.name %>
34
+ | <%= link_to 'Sign out', sign_out_path %>
35
+ <% end %>
36
+
37
+ <% if current_user.admin? %>
38
+ | <%= link_to 'Admin', "/admin" %>
39
+ <% end %>
40
+
41
+ | <%= link_to 'My Profile', user_path(current_user) %>
42
+ <% else %>
43
+ <%= link_to 'Sign in', sign_in_path %> |
44
+ <%= link_to 'Sign up', sign_up_path %>
45
+ <% end %>
46
+ </div>
47
+
48
+ </div>
49
+
50
+ <div id="content" class="container_12">
51
+ <div id="flash">
52
+ <%- flash.each do |key, value| -%>
53
+ <div class="<%= key %>_flash"><%=h value %></div>
54
+ <%- end -%>
55
+ </div>
56
+ <%= yield %>
57
+ </div>
58
+
59
+
60
+ <div id="footer" class="container_12">
61
+
62
+ <div id="built-by" class="grid_6 ">
63
+ Built by Brian Burridge, Agile Nomads LLC
64
+ </div>
65
+
66
+ <div id="meta" class="grid_6 ">
67
+ <% if ENV["RAILS_ENV"] != "production" %><%= ENV["RAILS_ENV"]%><% end %>
68
+ </div>
69
+
70
+ </div>
71
+
72
+
73
+
74
+ </body>
75
+ </html>
@@ -0,0 +1,23 @@
1
+ Factory.sequence :email do |n|
2
+ "user#{n}@example.com"
3
+ end
4
+
5
+ Factory.sequence :facebook_id do |n|
6
+ n
7
+ end
8
+
9
+ Factory.define :user do |user|
10
+ user.email { Factory.next :email }
11
+ user.first_name { "Factory" }
12
+ user.last_name { "User" }
13
+ user.password { "password" }
14
+ user.password_confirmation { "password" }
15
+ end
16
+
17
+ Factory.define :admin_user, :parent => :user do |admin|
18
+ admin.role 'admin'
19
+ end
20
+
21
+ Factory.define :facebook_user, :parent => :user do |user|
22
+ user.facebook_uid { Factory.next :facebook_id }
23
+ end
@@ -0,0 +1,25 @@
1
+ require 'yaml'
2
+
3
+ begin
4
+ configuration = YAML.load_file("#{Rails.root}/config/headstart.yml")[Rails.env]
5
+ configuration = HashWithIndifferentAccess.new(configuration)
6
+
7
+ Headstart.configure do |config|
8
+ config.mailer_sender = configuration[:mailer_sender]
9
+ config.impersonation_hash = configuration[:impersonation_hash]
10
+ config.use_facebook_connect = configuration[:use_facebook_connect]
11
+ config.use_delayed_job = configuration[:use_delayed_job]
12
+ config.facebook_api_key = configuration[:facebook_api_key]
13
+ config.facebook_secret_key = configuration[:facebook_secret_key]
14
+ end
15
+
16
+ if configuration[:madmimi_username].present? && configuration[:madmimi_api_key].present?
17
+ MadMimiMailer.api_settings = {
18
+ :username => configuration[:madmimi_username],
19
+ :api_key => configuration[:madmimi_api_key]
20
+ }
21
+ else
22
+ end
23
+ rescue LoadError
24
+ puts "The /config/headstart.yml file is missing or broken."
25
+ end
@@ -0,0 +1,45 @@
1
+ #
2
+ # The mailer_sender is set as the reply address for all notification emails.
3
+ #
4
+ # Set madmimi_username and madmimi_api_key to your MadMimi account username
5
+ # and API key.
6
+ #
7
+ # The impersonation_hash is used to secure user impersonations. Set it to
8
+ # a long, random hash.
9
+ #
10
+ # To turn on Facebook Connect, set use_facebook_connect to true.
11
+ #
12
+ # If you are using Facebook Connect, you'll need to provide your
13
+ # application's API and secret keys from your Facebook application
14
+ # settings at http://facebook.com/developers.
15
+ #
16
+
17
+ development:
18
+ mailer_sender: donotreply@example.com
19
+ madmimi_username:
20
+ madmimi_api_key:
21
+ impersonation_hash:
22
+ use_facebook_connect: false
23
+ use_delayed_job: $delayed_job
24
+ facebook_api_key:
25
+ facebook_secret_key:
26
+
27
+ test:
28
+ mailer_sender: donotreply@example.com
29
+ madmimi_username:
30
+ madmimi_api_key:
31
+ impersonation_hash:
32
+ use_facebook_connect: false
33
+ use_delayed_job: $delayed_job
34
+ facebook_api_key:
35
+ facebook_secret_key:
36
+
37
+ production:
38
+ mailer_sender: donotreply@example.com
39
+ madmimi_username:
40
+ madmimi_api_key:
41
+ impersonation_hash:
42
+ use_facebook_connect: false
43
+ use_delayed_job: $delayed_job
44
+ facebook_api_key:
45
+ facebook_secret_key: