frame 0.1.1 → 0.1.2

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 (38) hide show
  1. data/Gemfile.lock +1 -1
  2. data/lib/generators/frame.rb +2 -2
  3. data/lib/generators/frame/admin/admin_generator.rb +6 -6
  4. data/lib/generators/frame/devise/devise_generator.rb +26 -15
  5. data/lib/generators/frame/devise_omniauth/USAGE +11 -0
  6. data/lib/generators/frame/devise_omniauth/devise_omniauth_generator.rb +89 -0
  7. data/lib/generators/frame/devise_omniauth/templates/app/controllers/omniauth_callbacks_controller.rb +16 -0
  8. data/lib/generators/frame/devise_omniauth/templates/app/models/user.rb +40 -0
  9. data/lib/generators/frame/devise_omniauth/templates/app/views/devise/registrations/edit.html.erb +28 -0
  10. data/lib/generators/frame/devise_omniauth/templates/app/views/devise/registrations/new.html.erb +21 -0
  11. data/lib/generators/frame/devise_omniauth/templates/app/views/devise/sessions/new.html.erb +17 -0
  12. data/lib/generators/frame/devise_omniauth/templates/app/views/layouts/defaults.html.erb +48 -0
  13. data/lib/generators/frame/devise_omniauth/templates/config/routes.rb +7 -0
  14. data/lib/generators/frame/gitignore/gitignore_generator.rb +1 -1
  15. data/lib/generators/frame/layout/layout_generator.rb +2 -2
  16. data/lib/generators/frame/layout/templates/app/{stylesheets → assets/stylesheets}/frame.css +0 -0
  17. data/lib/generators/frame/layout/templates/app/helpers/application_helper.rb +5 -0
  18. data/lib/generators/frame/layout/templates/app/views/layouts/application.html.erb +1 -1
  19. data/lib/generators/frame/mysql/mysql_generator.rb +5 -4
  20. data/lib/generators/frame/omniauth/omniauth_generator.rb +15 -9
  21. data/lib/generators/frame/omniauth/templates/app/models/user.rb +8 -4
  22. data/lib/generators/frame/omniauth/templates/app/views/authentications/index.html.erb +1 -1
  23. data/lib/generators/frame/omniauth/templates/app/views/devise/sessions/new.html.erb +5 -5
  24. data/lib/generators/frame/omniauth/templates/app/views/registrations/edit.html.erb +1 -1
  25. data/lib/generators/frame/omniauth/templates/app/views/registrations/new.html.erb +21 -17
  26. data/lib/generators/frame/omniauth/templates/config/initializers/omniauth.rb +6 -3
  27. data/lib/generators/frame/pages/pages_generator.rb +14 -14
  28. data/lib/generators/frame/pages/templates/{pages.html.erb → app/views/layouts/pages.html.erb} +0 -0
  29. data/lib/generators/frame/pages/templates/{_form.html.erb → app/views/pages/_form.html.erb} +0 -0
  30. data/lib/generators/frame/pages/templates/{_links.html.erb → app/views/pages/_links.html.erb} +0 -0
  31. data/lib/generators/frame/pages/templates/{_page.html.erb → app/views/pages/_page.html.erb} +0 -0
  32. data/lib/generators/frame/pages/templates/{index.html.erb → app/views/pages/index.html.erb} +0 -0
  33. data/lib/generators/frame/pages/templates/{show.html.erb → app/views/pages/show.html.erb} +0 -0
  34. data/lib/generators/frame/pages/templates/{_error_messages.html.erb → app/views/shared/_error_messages.html.erb} +0 -0
  35. data/lib/generators/frame/pages/templates/{_sidebar.html.erb → app/views/shared/_sidebar.html.erb} +0 -0
  36. data/lib/generators/frame/secret/secret_generator.rb +1 -0
  37. data/lib/generators/frame/secret/templates/Rakefile +3 -5
  38. metadata +20 -11
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- frame (0.1.1)
4
+ frame (0.1.2)
5
5
 
6
6
  GEM
7
7
  remote: http://rubygems.org/
@@ -14,14 +14,14 @@ module Frame
14
14
  private
15
15
 
16
16
  def add_if_missing(file, string, options = {}, unless_match = string)
17
- puts "\n\n==> Adding the following to '#{file}' file:\n'#{string}' unless it already exists"
17
+ #puts "\n\n==> Adding the following to '#{file}' file:\n'#{string}' unless it already exists"
18
18
  file_content = File.read(file)
19
19
  #File.open(file, 'a') { |f| f.write("\n") } unless file_content =~ /\n\Z/
20
20
  insert_into_file file, string, options unless file_content.include? unless_match
21
21
  end
22
22
 
23
23
  def add_gem(name, options = {})
24
- #add_if_missing(destination_path("Gemfile"),)
24
+ #add_if_missing(destination_path("Gemfile"), name, options)
25
25
  gemfile_content = File.read(destination_path("Gemfile"))
26
26
  File.open(destination_path("Gemfile"), 'a') { |f| f.write("\n") } unless gemfile_content =~ /\n\Z/
27
27
  gem name, options unless gemfile_content.include? name
@@ -17,7 +17,7 @@ module Frame
17
17
  end
18
18
 
19
19
  def install_active_admin
20
- if yes?("Would you like to install Active Admin?")
20
+ #if yes?("Would you like to install Active Admin?")
21
21
  gem("activeadmin")
22
22
  Bundler.with_clean_env do
23
23
  run "bundle install"
@@ -25,13 +25,13 @@ module Frame
25
25
  generate("active_admin:install")
26
26
  default_model = "page"
27
27
  generate("active_admin:resource #{default_model}")
28
- end
28
+ #end
29
29
  end
30
30
 
31
31
  def update_db
32
- if yes?("Would you like to migrate the database?")
32
+ #if yes?("Would you like to migrate the database?")
33
33
  rake("db:migrate")
34
- end
34
+ #end
35
35
  end
36
36
 
37
37
  def update_admin_form
@@ -51,9 +51,9 @@ module Frame
51
51
  def remove_pages_cud
52
52
  filenames = ["app/views/pages/new.html.erb", "app/views/pages/edit.html.erb", "app/views/pages/index.html.erb", "app/views/pages/_form.html.erb"]
53
53
  filenames.each { |filename|
54
- if File.exists?(filename) and yes?("Would you like to remove '#{filename}'?")
54
+ #if File.exists?(filename) and yes?("Would you like to remove '#{filename}'?")
55
55
  remove_file filename
56
- end
56
+ #end
57
57
  }
58
58
  template('app/views/pages/show.html.erb')
59
59
  end
@@ -12,31 +12,39 @@ module Frame
12
12
  gem("rspec-rails", :group => "test, development")
13
13
  gem("cucumber-rails", :group => "test, development")
14
14
 
15
- if yes?("Would you like to install Devise?")
15
+ #if yes?("Would you like to install Devise?")
16
16
  gem("devise")
17
17
  Bundler.with_clean_env do
18
18
  run "bundle"
19
19
  end
20
20
  generate("devise:install")
21
21
  default_model = "User"
22
- model_name = ask("What would you like the user model to be called? [#{default_model}]")
23
- model_name = default_model if model_name.blank?
22
+ #model_name = ask("What would you like the user model to be called? [#{default_model}]")
23
+ #model_name = default_model if model_name.blank?
24
+ model_name = default_model
24
25
  generate("devise", model_name)
25
26
  generate("devise:views")
26
- end
27
+ #end
27
28
  end
28
29
 
29
30
  def update_initializers
30
31
  gsub_file 'config/initializers/devise.rb', /config.mailer_sender = "please-change-me-at-config-initializers-devise@example.com"/ do
31
32
  default_mailer = "webmaster@econtriver.com"
32
- mailer_sender = ask("What is the mail sender address? [#{default_mailer}]")
33
- mailer_sender = default_mailer if mailer_sender.blank?
33
+ #mailer_sender = ask("What is the mail sender address? [#{default_mailer}]")
34
+ #mailer_sender = default_mailer if mailer_sender.blank?
35
+ mailer_sender = default_mailer
34
36
  "config.mailer_sender = \"#{mailer_sender}\""
35
37
  end
36
38
  end
37
39
 
38
40
  def add_default_layout
39
- template 'defaults.html.erb', 'app/views/layouts/defaults.html.erb'
41
+ template('app/views/layouts/defaults.html.erb')
42
+ end
43
+
44
+ def add_routes
45
+ add_if_missing('config/routes.rb', "
46
+ resources :authentications
47
+ ", :after => "devise_for :admin_users, ActiveAdmin::Devise.config\n")
40
48
  end
41
49
 
42
50
 
@@ -45,23 +53,26 @@ module Frame
45
53
 
46
54
  def update_environments
47
55
  default_mailer = "econtriver.com"
48
- action_mailer = ask("What is the action mailer domain (normally just the domain)? [#{default_mailer}]")
49
- action_mailer = default_mailer if action_mailer.blank?
50
- application(nil, :env => "production") do
51
- "config.action_mailer.default_url_options = { :host => #{action_mailer} }"
56
+ #action_mailer = ask("What is the action mailer domain (normally just the domain)? [#{default_mailer}]")
57
+ #action_mailer = default_mailer if action_mailer.blank?
58
+ action_mailer = default_mailer
59
+ application(nil, :env => "production") do "
60
+ config.action_mailer.default_url_options = { :host => \"#{action_mailer}\" }
61
+ config.action_mailer.smtp_settings = { :openssl_verify_mode => 'none' }"
52
62
  end
53
63
  application(nil, :env => "test") do
54
64
  "config.action_mailer.default_url_options = { :host => 'localhost:3000' }"
55
65
  end
56
- application(nil, :env => "development") do
57
- "config.action_mailer.default_url_options = { :host => 'localhost:3000' }"
66
+ application(nil, :env => "development") do "
67
+ config.action_mailer.default_url_options = { :host => 'localhost:3000' }
68
+ config.assets.debug = false"
58
69
  end
59
70
  end
60
71
 
61
72
  def update_db
62
- if yes?("Would you like to migrate the database?")
73
+ #if yes?("Would you like to migrate the database?")
63
74
  rake("db:migrate")
64
- end
75
+ #end
65
76
  end
66
77
 
67
78
  end
@@ -0,0 +1,11 @@
1
+ Description:
2
+ Generates devise omniauthable installation.
3
+
4
+ Usage:
5
+ Use to generate install and setup omniauthable devise for a project.
6
+
7
+ Examples:
8
+ rails generate frame:devise_omniauth
9
+
10
+ Methods:
11
+ There are several methods generated which you can use in your application.
@@ -0,0 +1,89 @@
1
+ require 'generators/frame'
2
+ require 'rails/generators/migration'
3
+
4
+ module Frame
5
+ module Generators
6
+ class DeviseOmniauthGenerator < Base
7
+ include Rails::Generators::Migration
8
+
9
+ desc "Installs Devise and makes it Omniauthable."
10
+
11
+ def install_devise
12
+ gem("rspec-rails", :group => "test, development")
13
+ gem("cucumber-rails", :group => "test, development")
14
+ gem("devise")
15
+ gem("omniauth-twitter")
16
+ gem("omniauth-facebook")
17
+ gem("omniauth-github")
18
+ gem("omniauth-google-oauth2")
19
+ Bundler.with_clean_env do
20
+ run "bundle"
21
+ end
22
+ generate("devise:install")
23
+ generate("devise", "User")
24
+ generate("devise:views")
25
+ end
26
+
27
+ def add_callback_controller
28
+ template('app/controllers/omniauth_callbacks_controller.rb')
29
+ end
30
+
31
+ def make_omniauthable
32
+ template('app/models/user.rb')
33
+ end
34
+
35
+ def add_do_routes
36
+ template('config/routes.rb')
37
+ end
38
+
39
+ def add_omni_services
40
+ add_if_missing('config/initializers/devise.rb', "\n config.omniauth :twitter, 'APP_ID', 'APP_SECRET'", :after => "# config.omniauth :github, 'APP_ID', 'APP_SECRET', :scope => 'user,public_repo'")
41
+ add_if_missing('config/initializers/devise.rb', "\n config.omniauth :google_oauth2, 'APP_ID', 'APP_SECRET'", :after => "# config.omniauth :github, 'APP_ID', 'APP_SECRET', :scope => 'user,public_repo'")
42
+ add_if_missing('config/initializers/devise.rb', "\n config.omniauth :facebook, 'APP_ID', 'APP_SECRET'", :after => "# config.omniauth :github, 'APP_ID', 'APP_SECRET', :scope => 'user,public_repo'")
43
+ uncomment_lines('config/initializers/devise.rb', "config.omniauth :github, 'APP_ID', 'APP_SECRET', :scope => 'user,public_repo'")
44
+ end
45
+
46
+ def add_default_layout
47
+ template('app/views/layouts/defaults.html.erb')
48
+ end
49
+
50
+ def update_initializers
51
+ gsub_file 'config/initializers/devise.rb', /config.mailer_sender = "please-change-me-at-config-initializers-devise@example.com"/ do
52
+ "config.mailer_sender = \"webmaster@econtriver.com\""
53
+ end
54
+ end
55
+
56
+ def update_environments
57
+ application(nil, :env => "production") do "
58
+ config.action_mailer.default_url_options = { :host => \"econtriver.com\" }
59
+ config.action_mailer.smtp_settings = { :openssl_verify_mode => 'none' }"
60
+ end
61
+ application(nil, :env => "test") do
62
+ "config.action_mailer.default_url_options = { :host => 'localhost:3000' }"
63
+ end
64
+ application(nil, :env => "development") do
65
+ "config.action_mailer.default_url_options = { :host => 'localhost:3000' }"
66
+ end
67
+ end
68
+
69
+ def replace_email_username
70
+ template("app/views/devise/sessions/new.html.erb")
71
+ template("app/views/devise/registrations/new.html.erb")
72
+ template("app/views/devise/registrations/edit.html.erb")
73
+ end
74
+
75
+ def add_omniauth_to_users
76
+ generate("migration AddOmniauthToUsers provider:string uid:string")
77
+ end
78
+
79
+ def add_username_to_users
80
+ generate("migration AddUsernameToUsers username:string")
81
+ end
82
+
83
+ def update_db
84
+ rake("db:migrate")
85
+ end
86
+
87
+ end
88
+ end
89
+ end
@@ -0,0 +1,16 @@
1
+ class OmniauthCallbacksController < Devise::OmniauthCallbacksController
2
+ def all
3
+ user = User.from_omniauth(request.env["omniauth.auth"])
4
+ if user.persisted?
5
+ flash.notice = "Signed in!"
6
+ sign_in_and_redirect user
7
+ else
8
+ session["devise.user_attributes"] = user.attributes
9
+ redirect_to new_user_registration_url
10
+ end
11
+ end
12
+ alias_method :facebook, :all
13
+ alias_method :twitter, :all
14
+ alias_method :github, :all
15
+ alias_method :google_oauth2, :all
16
+ end
@@ -0,0 +1,40 @@
1
+ class User < ActiveRecord::Base
2
+ devise :database_authenticatable, :registerable, :omniauthable,
3
+ :recoverable, :rememberable, :trackable, :validatable
4
+
5
+ attr_accessible :email, :password, :password_confirmation, :remember_me, :username
6
+
7
+ validates_presence_of :username
8
+ validates_uniqueness_of :username
9
+
10
+ def self.from_omniauth(auth)
11
+ where(auth.slice(:provider, :uid)).first_or_create do |user|
12
+ user.provider = auth.provider
13
+ user.uid = auth.uid
14
+ user.username = auth.info.nickname
15
+ end
16
+ end
17
+
18
+ def self.new_with_session(params, session)
19
+ if session["devise.user_attributes"]
20
+ new(session["devise.user_attributes"], without_protection: true) do |user|
21
+ user.attributes = params
22
+ user.valid?
23
+ end
24
+ else
25
+ super
26
+ end
27
+ end
28
+
29
+ def password_required?
30
+ super && provider.blank?
31
+ end
32
+
33
+ def update_with_password(params, *options)
34
+ if encrypted_password.blank?
35
+ update_attributes(params, *options)
36
+ else
37
+ super
38
+ end
39
+ end
40
+ end
@@ -0,0 +1,28 @@
1
+ <h2>Edit <%%= resource_name.to_s.humanize %></h2>
2
+
3
+ <%%= form_for(resource, :as => resource_name, :url => registration_path(resource_name), :html => { :method => :put }) do |f| %>
4
+ <%%= devise_error_messages! %>
5
+
6
+ <div><%%= f.label :email %><br />
7
+ <%%= f.email_field :email, :class => "text" %></div>
8
+
9
+ <div><%%= f.label :username %><br />
10
+ <%%= f.text_field :username, :class => "text" %></div>
11
+
12
+ <div><%%= f.label :password %> <i>(leave blank if you don't want to change it)</i><br />
13
+ <%%= f.password_field :password, :autocomplete => "off", :class => "text" %></div>
14
+
15
+ <div><%%= f.label :password_confirmation %><br />
16
+ <%%= f.password_field :password_confirmation, :class => "text" %></div>
17
+
18
+ <div><%%= f.label :current_password %> <i>(we need your current password to confirm your changes)</i><br />
19
+ <%%= f.password_field :current_password, :class => "text" %></div>
20
+
21
+ <div><%%= f.submit "Update" %></div>
22
+ <%% end %>
23
+
24
+ <h3>Cancel my account</h3>
25
+
26
+ <p>Unhappy? <%%= link_to "Cancel my account", registration_path(resource_name), :data => { :confirm => "Are you sure?" }, :method => :delete %>.</p>
27
+
28
+ <%%= link_to "Back", :back %>
@@ -0,0 +1,21 @@
1
+ <h2>Sign up</h2>
2
+
3
+ <%%= form_for(resource, :as => resource_name, :url => registration_path(resource_name)) do |f| %>
4
+ <%%= devise_error_messages! %>
5
+
6
+ <div><%%= f.label :email %><br />
7
+ <%%= f.email_field :email, :class => "text" %></div>
8
+
9
+ <div><%%= f.label :username %><br />
10
+ <%%= f.text_field :username, :class => "text" %></div>
11
+
12
+ <div><%%= f.label :password %><br />
13
+ <%%= f.password_field :password, :class => "text" %></div>
14
+
15
+ <div><%%= f.label :password_confirmation %><br />
16
+ <%%= f.password_field :password_confirmation, :class => "text" %></div>
17
+
18
+ <div><%%= f.submit "Sign up" %></div>
19
+ <%% end %>
20
+
21
+ <%%= render "devise/shared/links" %>
@@ -0,0 +1,17 @@
1
+ <h2>Sign in</h2>
2
+
3
+ <%%= form_for(resource, :as => resource_name, :url => session_path(resource_name)) do |f| %>
4
+ <div><%%= f.label :username %><br />
5
+ <%%= f.text_field :username, :class => "text" %></div>
6
+
7
+ <div><%%= f.label :password %><br />
8
+ <%%= f.password_field :password, :class => "text" %></div>
9
+
10
+ <%% if devise_mapping.rememberable? -%>
11
+ <div><%%= f.check_box :remember_me %> <%%= f.label :remember_me %></div>
12
+ <%% end -%>
13
+
14
+ <div><%%= f.submit "Sign in" %></div>
15
+ <%% end %>
16
+
17
+ <%%= render "devise/shared/links" %>
@@ -0,0 +1,48 @@
1
+ <%% content_for :head do %>
2
+ <%%= favicon_link_tag('/assets/favicon.ico') %>
3
+ <%%= stylesheet_link_tag "application" %>
4
+ <%%= javascript_include_tag "application" %>
5
+ <%%= csrf_meta_tag %>
6
+ <%% end %>
7
+
8
+ <%% content_for :header do %>
9
+ <nav class="span-24 append-bottom">
10
+ <ul>
11
+ <%%= render :partial => "pages/links", :collection => @display_pages.topbar, :as => :page, :locals => {:classes => "left hover"} %>
12
+ <%% if user_signed_in? %>
13
+ <%%= link_to '<li class="left hover">Account</li>'.html_safe, edit_user_registration_path %>
14
+ <%%= link_to '<li class="right hover">Sign out</li>'.html_safe, destroy_user_session_path, :method => :delete %>
15
+ <li class="right last lighter"><%%= current_user.email %></li>
16
+ <%% else %>
17
+ <%%= link_to '<li class="right hover">Sign in</li>'.html_safe, user_session_path %>
18
+ <%%= link_to '<li class="right hover">Sign up</li>'.html_safe, new_user_registration_path %>
19
+ <%% end %>
20
+ </ul>
21
+ </nav>
22
+ <banner>
23
+ <%%= link_to logo, root_path, {:class => "right prepend-1"} %>
24
+ <h1 class="left alt append-1"><%%= yield(:title) %></h1>
25
+ <%% flash.each do |key, value| %>
26
+ <div id="notice" class="left flash <%%= key %>"><%%= value %></div>
27
+ <%% end %>
28
+ </banner>
29
+ <hr/>
30
+ <%% end %>
31
+
32
+ <%% content_for :sidebar do %>
33
+ <%%= render 'shared/sidebar', :sidebar => @display_pages.sidebar %>
34
+ <%% end %>
35
+
36
+ <%% content_for :userbar do %>
37
+ <%% if user_signed_in? %>
38
+ <%%= render 'shared/sidebar', :sidebar => @display_pages.userbar %>
39
+ <%% end %>
40
+ <%% end %>
41
+
42
+ <%% content_for :footer do %>
43
+ <nav class="span-24 prepend-top last">
44
+ <ul>
45
+ <%%= render :partial => "pages/links", :collection => @display_pages.bottombar, :as => :page, :locals => {:classes => "left hover"} %>
46
+ </ul>
47
+ </nav>
48
+ <%% end %>
@@ -0,0 +1,7 @@
1
+ Deom::Application.routes.draw do
2
+ devise_for :users, path_names: {sign_in: "login", sign_out: "logout"},
3
+ controllers: {omniauth_callbacks: "omniauth_callbacks"}
4
+ resources :pages
5
+ get 'sessions/new'
6
+ root :to => 'pages#show', :id => 0
7
+ end
@@ -9,7 +9,7 @@ module Frame
9
9
  desc "Installs Gitignore if it doesn't already exist."
10
10
 
11
11
  def create_gitignore
12
- template ".gitignore", ".gitignore"
12
+ template ".gitignore"
13
13
  end
14
14
 
15
15
  end
@@ -12,9 +12,9 @@ module Frame
12
12
 
13
13
  def remove_index
14
14
  filename="public/index.html"
15
- if File.exists?(filename) and yes?("Would you like to remove '#{filename}'?")
15
+ #if File.exists?(filename) and yes?("Would you like to remove '#{filename}'?")
16
16
  remove_file filename
17
- end
17
+ #end
18
18
  end
19
19
 
20
20
  def add_default_layout
@@ -1,11 +1,16 @@
1
1
  module ApplicationHelper
2
2
  def title(page_title)
3
+ view_flow.content.delete(:title)
3
4
  content_for :title do
4
5
  page_title
5
6
  end
6
7
  page_title
7
8
  end
8
9
 
10
+ def default_title(page_title)
11
+ title page_title unless content_for?(:title)
12
+ end
13
+
9
14
  def logo
10
15
  image_tag("econ_f_64.gif", {:alt => "eContriver", :class => "round", :style => "width: 64px; height: 64px"})
11
16
  end
@@ -1,3 +1,3 @@
1
- <%% title '<%= @title %>' %>
1
+ <%% default_title '<%= @title %>' %>
2
2
  <%%= render :template => 'layouts/defaults' %>
3
3
  <%%= render :template => 'layouts/default_layout' %>
@@ -6,7 +6,7 @@ module Frame
6
6
  class MysqlGenerator < Base
7
7
  include Rails::Generators::Migration
8
8
 
9
- desc "Update MySQL with user priveleges."
9
+ desc "Update MySQL with user privileges."
10
10
 
11
11
  def add_gems
12
12
  gem("mysql2")
@@ -22,7 +22,7 @@ module Frame
22
22
  puts "database: #{db}"
23
23
  output = create_file 'tmp/drop_db.sql', "DROP DATABASE IF EXISTS #{db};"
24
24
  puts "output: #{output}\nEnter mysql root password"
25
- system "mysql -u root -p < #{output}"
25
+ system "mysql -u root < #{output}"
26
26
  end
27
27
 
28
28
  def add_user
@@ -33,7 +33,7 @@ module Frame
33
33
  puts "using pw: #{pw}"
34
34
  output = create_file 'tmp/create_user.sql', "CREATE USER '#{user}'@localhost IDENTIFIED BY '#{pw}';"
35
35
  puts "output: #{output}\nEnter mysql root password"
36
- system "mysql -u root -p < #{output}"
36
+ system "mysql -u root < #{output}"
37
37
  end
38
38
 
39
39
  def grant_user
@@ -44,10 +44,11 @@ module Frame
44
44
  puts "all on db: #{db}"
45
45
  output = create_file 'tmp/grant_user.sql', "GRANT ALL PRIVILEGES ON #{db}.* TO '#{user}'@localhost;"
46
46
  puts "output: #{output}\nEnter mysql root password"
47
- system "mysql -u root -p < #{output}"
47
+ system "mysql -u root < #{output}"
48
48
  end
49
49
 
50
50
  def create_db
51
+ rake("db:reset")
51
52
  rake("db:setup")
52
53
  end
53
54
 
@@ -8,12 +8,17 @@ module Frame
8
8
 
9
9
  desc "Installs Omniauth."
10
10
 
11
+ def add_omniauth_secret
12
+ template('config/initializers/omniauth.rb')
13
+ end
14
+
11
15
  def install_omniauth
12
16
 
13
17
  gem 'omniauth'
18
+ gem 'omniauth-github'
19
+ gem 'omniauth-facebook'
14
20
  gem 'omniauth-twitter'
15
21
  gem 'omniauth-google-oauth2'
16
- gem 'omniauth-github'
17
22
 
18
23
  Bundler.with_clean_env do
19
24
  run "bundle"
@@ -41,17 +46,18 @@ module Frame
41
46
  end
42
47
 
43
48
  # Leave the routes?
44
- def generate_authentication_controller
49
+ def g_authentication_controller
45
50
  generate('controller Authentications index create destroy')
46
51
  template('app/controllers/authentications_controller.rb')
47
52
  remove_file('app/views/authentications/index.html.erb')
48
53
  remove_file('app/views/authentications/create.html.erb')
49
54
  remove_file('app/views/authentications/destroy.html.erb')
50
55
  # Need this index?
51
- template('app/views/authentications/index.html.erb')
56
+ #template('app/views/authentications/index.html.erb')
57
+ #remove_file('app/views/authentications')
52
58
  end
53
59
 
54
- def generate_registration_controller
60
+ def g_registration_controller
55
61
  generate('controller Registrations edit new')
56
62
  template('app/views/registrations/edit.html.erb')
57
63
  template('app/views/registrations/new.html.erb')
@@ -75,12 +81,12 @@ module Frame
75
81
 
76
82
  def copy_images
77
83
  template('app/assets/images/facebook_32.png')
78
- template('app/assets/images/github_32.png')
79
- template('app/assets/images/google_32.png')
80
- template('app/assets/images/twitter_32.png')
81
84
  template('app/assets/images/facebook_64.png')
85
+ template('app/assets/images/github_32.png')
82
86
  template('app/assets/images/github_64.png')
87
+ template('app/assets/images/google_32.png')
83
88
  template('app/assets/images/google_64.png')
89
+ template('app/assets/images/twitter_32.png')
84
90
  template('app/assets/images/twitter_64.png')
85
91
  end
86
92
 
@@ -91,9 +97,9 @@ module Frame
91
97
  end
92
98
 
93
99
  def update_db
94
- if yes?("Would you like to migrate the database?")
100
+ #if yes?("Would you like to migrate the database?")
95
101
  rake("db:migrate")
96
- end
102
+ #end
97
103
  end
98
104
 
99
105
  end
@@ -4,17 +4,21 @@ class User < ActiveRecord::Base
4
4
  # Include default devise modules. Others available are:
5
5
  # :token_authenticatable, :lockable, :timeoutable, :confirmable and :activatable
6
6
  devise :database_authenticatable, :registerable,
7
- :recoverable, :rememberable, :trackable, :validatable
7
+ :recoverable, :rememberable, :trackable, :validatable,
8
+ :authentication_keys => [:login]
8
9
 
9
10
  has_many :authentications, :dependent => :destroy
10
11
 
11
12
  attr_accessor :login
12
13
  attr_accessible :email, :password, :password_confirmation, :username, :login, :remember_me
13
14
 
14
- def self.find_for_authentication(warden_conditions)
15
+ def self.find_first_by_auth_conditions(warden_conditions)
15
16
  conditions = warden_conditions.dup
16
- login = conditions.delete(:login)
17
- where(conditions).where(["lower(username) = :value OR lower(email) = :value", {:value => login.downcase}]).first
17
+ if login = conditions.delete(:login)
18
+ where(conditions).where(["lower(username) = :value OR lower(email) = :value", { :value => login.downcase }]).first
19
+ else
20
+ where(conditions).first
21
+ end
18
22
  end
19
23
 
20
24
  def update_with_password(params={})
@@ -3,7 +3,7 @@
3
3
  <%%= render 'shared/open_auth' %>
4
4
 
5
5
  <%% unless user_signed_in? %>
6
- <div class="left span-12 last">
6
+ <div class="left span-9 last">
7
7
  <h2 class="alt">... or a Normal Account:</h2>
8
8
  <%%= render 'shared/login_form' %>
9
9
  <%%= link_to "Forgot your password?", new_password_path('user') %>
@@ -1,11 +1,11 @@
1
1
  <h2>Sign In Using...</h2>
2
2
 
3
- <%= render 'shared/open_auth' %>
3
+ <%%= render 'shared/open_auth' %>
4
4
 
5
- <% unless user_signed_in? %>
5
+ <%% unless user_signed_in? %>
6
6
  <div class="left span-9 last">
7
7
  <h2 class="alt">... or a Normal Account:</h2>
8
- <%= render 'shared/login_form' %>
9
- <%= render "devise/shared/links" %>
8
+ <%%= render 'shared/login_form' %>
9
+ <%%= render "devise/shared/links" %>
10
10
  </div>
11
- <% end %>
11
+ <%% end %>
@@ -10,7 +10,7 @@
10
10
 
11
11
  <p><%%= f.label :email %></p>
12
12
 
13
- <p><%%= f.text_field :email, :class => "text" %></p>
13
+ <p><%%= f.email_field :email, :class => "text" %></p>
14
14
 
15
15
  <p><%%= f.label :password %> <span class="alt large">(leave blank if you don't want to change it)</span></p>
16
16
 
@@ -1,25 +1,29 @@
1
1
  <%% title "Sign up" %>
2
2
 
3
- <h2>Sign up</h2>
3
+ <div class="left span-9">
4
+ <h2>Sign up</h2>
4
5
 
5
- <%%= form_for(resource, :as => resource_name, :url => registration_path(resource_name)) do |f| %>
6
- <%%= render 'shared/error_messages', :object => f.object %>
6
+ <%%= form_for(resource, :as => resource_name, :url => registration_path(resource_name)) do |f| %>
7
+ <%%= render 'shared/error_messages', :object => f.object %>
7
8
 
8
- <p><%%= f.label :username %></p>
9
- <p><%%= f.text_field :username %></p>
10
-
11
- <p><%%= f.label :email %></p>
12
- <p><%%= f.text_field :email %></p>
9
+ <p><%%= f.label :username %></p>
10
+ <p><%%= f.text_field :username, :class => "text" %></p>
13
11
 
14
- <%% if @user.password_required? %>
15
- <p><%%= f.label :password %></p>
16
- <p><%%= f.password_field :password %></p>
12
+ <p><%%= f.label :email %></p>
13
+ <p><%%= f.email_field :email, :class => "text" %></p>
17
14
 
18
- <p><%%= f.label :password_confirmation %></p>
19
- <p><%%= f.password_field :password_confirmation %></p>
20
- <%% end %>
15
+ <%% if @user.password_required? %>
16
+ <p><%%= f.label :password %></p>
17
+ <p><%%= f.password_field :password, :class => "text" %></p>
21
18
 
22
- <p><%%= f.submit "Sign up" %></p>
23
- <%% end %>
19
+ <p><%%= f.label :password_confirmation %></p>
20
+ <p><%%= f.password_field :password_confirmation, :class => "text" %></p>
21
+ <%% end %>
24
22
 
25
- <%%= render :partial => "devise/shared/links" %>
23
+ <p><%%= f.submit "Sign up" %></p>
24
+ <%% end %>
25
+
26
+ <%%= render :partial => "devise/shared/links" %>
27
+ </div>
28
+
29
+ <%%= render 'shared/open_auth' %>
@@ -1,13 +1,16 @@
1
1
  #require 'openid/store/filesystem'
2
2
  Rails.application.config.middleware.use OmniAuth::Builder do
3
3
  #require 'omniauth-google-oauth2'
4
- config.omniauth :google_oauth2, 'APP_ID', 'APP_SECRET', { :scope => 'https://www.googleapis.com/auth/userinfo.email', :redirect_uri => 'http://tester.econtriver.com/auth/google_oauth2/callback', :approval_prompt => 'auto' }
4
+ provider :google_oauth2, 'APP_ID', 'APP_SECRET', { :scope => 'https://www.googleapis.com/auth/userinfo.email', :redirect_uri => 'http://econtriver.com/auth/google_oauth2/callback', :approval_prompt => 'auto' }
5
5
 
6
6
  #require 'omniauth-twitter'
7
- config.omniauth :twitter, 'APP_ID', 'APP_SECRET'
7
+ provider :twitter, 'APP_ID', 'APP_SECRET'
8
8
 
9
9
  #require 'omniauth-github'
10
- config.omniauth :github, 'APP_ID', 'APP_SECRET'
10
+ provider :github, 'APP_ID', 'APP_SECRET'
11
+
12
+ #require 'omniauth-facebook'
13
+ provider :facebook, 'APP_ID', 'APP_SECRET'
11
14
 
12
15
  #provider :open_id, OpenID::Store::Filesystem.new('/tmp')
13
16
  end
@@ -9,7 +9,7 @@ module Frame
9
9
 
10
10
  desc "Setup Pages."
11
11
 
12
- class_option :force, :type => :boolean, :default => false, :desc => "Force file regeneration"
12
+ class_option :force, :type => :boolean, :default => true, :desc => "Force file overwriting"
13
13
 
14
14
  #def add_gems
15
15
  # #add_gem "mysql2"
@@ -26,9 +26,9 @@ module Frame
26
26
 
27
27
  def remove_index
28
28
  filename="public/index.html"
29
- if File.exists?(filename) and yes?("Would you like to remove '#{filename}'?")
29
+ #if File.exists?(filename) and yes?("Would you like to remove '#{filename}'?")
30
30
  remove_file filename
31
- end
31
+ #end
32
32
  end
33
33
 
34
34
  def generate_scaffold
@@ -40,7 +40,7 @@ module Frame
40
40
  end
41
41
 
42
42
  def add_root_route
43
- insert_into_file 'config/routes.rb', " root :to => 'pages#show', :id => 0\n", :after => "#{Rails.application.class.parent_name}::Application.routes.draw do\n"
43
+ insert_into_file 'config/routes.rb', " root :to => 'pages#show', :id => 0\n get 'sessions/new'\n", :after => "#{Rails.application.class.parent_name}::Application.routes.draw do\n"
44
44
  end
45
45
 
46
46
  def update_page_controller
@@ -67,17 +67,17 @@ module Frame
67
67
  end
68
68
 
69
69
  def create_pages_partials
70
- template '_links.html.erb', 'app/views/pages/_links.html.erb'
71
- template '_form.html.erb', 'app/views/pages/_form.html.erb'
72
- template '_error_messages.html.erb', 'app/views/shared/_error_messages.html.erb'
73
- template '_sidebar.html.erb', 'app/views/shared/_sidebar.html.erb'
74
- template '_page.html.erb', 'app/views/pages/_page.html.erb'
70
+ template('app/views/pages/_form.html.erb')
71
+ template('app/views/pages/_links.html.erb')
72
+ template('app/views/pages/_page.html.erb')
73
+ template('app/views/shared/_error_messages.html.erb')
74
+ template('app/views/shared/_sidebar.html.erb')
75
75
  end
76
76
 
77
77
  def create_pages_views
78
- template 'pages.html.erb', 'app/views/layouts/pages.html.erb'
79
- template 'index.html.erb', 'app/views/pages/index.html.erb'
80
- template 'show.html.erb', 'app/views/pages/show.html.erb'
78
+ template('app/views/layouts/pages.html.erb')
79
+ template('app/views/pages/index.html.erb')
80
+ template('app/views/pages/show.html.erb')
81
81
  end
82
82
 
83
83
  def add_scopes
@@ -120,10 +120,10 @@ module Frame
120
120
  end
121
121
 
122
122
  def update_db
123
- if yes?("Would you like to migrate the database?")
123
+ #if yes?("Would you like to migrate the database?")
124
124
  rake("db:migrate")
125
125
  rake("db:seed")
126
- end
126
+ #end
127
127
  end
128
128
 
129
129
  private
@@ -33,6 +33,7 @@ module Frame
33
33
  def create_rake_file
34
34
  #@title = Rails.application.class.parent_name.downcase
35
35
  template('Rakefile')
36
+ gsub_file 'Rakefile', /Rails\.application\.class\.parent_name\:\:Application\.load_tasks/, "#{Rails.application.class.parent_name}::Application.load_tasks"
36
37
  end
37
38
 
38
39
  end
@@ -5,7 +5,7 @@
5
5
 
6
6
  require File.expand_path('../config/application', __FILE__)
7
7
 
8
- Tester::Application.load_tasks
8
+ Rails.application.class.parent_name::Application.load_tasks
9
9
 
10
10
  files = ['config/initializers/omniauth.rb','config/database.yml','config/initializers/secret_token.rb']
11
11
 
@@ -29,11 +29,9 @@ task :get_secret do
29
29
  end
30
30
  end
31
31
 
32
- task :backup, :roles => :db, :only => { :primary => true } do
32
+ task :backup do
33
33
  filename = "#{Rails.application.class.parent_name.downcase}.db_backup.#{Time.now.to_f}.sql.bz2"
34
34
  filepath = File.join(deploy_to,'current',filename)
35
35
  config = YAML.load_file(File.join(deploy_to,'private', 'config', 'database.yml'))
36
- run "mysqldump -u #{config['production']['username']} -p #{config['production']['database']} | bzip2 -c > #{filepath}" do |ch, stream, out|
37
- ch.send_data "#{config['production']['password']}\n" if out =~ /^Enter password:/
38
- end
36
+ system("mysqldump -u #{config['production']['username']} -p'#{config['production']['password']}' #{config['production']['database']} | bzip2 -c > #{filepath}\n")
39
37
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: frame
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.1
4
+ version: 0.1.2
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-10-16 00:00:00.000000000 Z
12
+ date: 2012-10-20 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: activeadmin
@@ -330,11 +330,11 @@ files:
330
330
  - lib/generators/frame/layout/templates/app/assets/images/favicon.ico
331
331
  - lib/generators/frame/layout/templates/app/assets/images/econ_f_256.png
332
332
  - lib/generators/frame/layout/templates/app/assets/images/econ_f_32.png
333
+ - lib/generators/frame/layout/templates/app/assets/stylesheets/frame.css
333
334
  - lib/generators/frame/layout/templates/app/views/layouts/defaults.html.erb
334
335
  - lib/generators/frame/layout/templates/app/views/layouts/application.html.erb
335
336
  - lib/generators/frame/layout/templates/app/views/layouts/default_layout.html.erb
336
337
  - lib/generators/frame/layout/templates/app/helpers/application_helper.rb
337
- - lib/generators/frame/layout/templates/app/stylesheets/frame.css
338
338
  - lib/generators/frame/layout/USAGE
339
339
  - lib/generators/frame/mysql/USAGE
340
340
  - lib/generators/frame/mysql/mysql_generator.rb
@@ -344,20 +344,29 @@ files:
344
344
  - lib/generators/frame/admin/templates/app/admin/pages.rb
345
345
  - lib/generators/frame/admin/USAGE
346
346
  - lib/generators/frame/pages/pages_generator.rb
347
- - lib/generators/frame/pages/templates/_form.html.erb
348
- - lib/generators/frame/pages/templates/_links.html.erb
349
- - lib/generators/frame/pages/templates/pages.html.erb
350
- - lib/generators/frame/pages/templates/_sidebar.html.erb
351
- - lib/generators/frame/pages/templates/_error_messages.html.erb
352
- - lib/generators/frame/pages/templates/index.html.erb
353
- - lib/generators/frame/pages/templates/show.html.erb
354
- - lib/generators/frame/pages/templates/_page.html.erb
347
+ - lib/generators/frame/pages/templates/app/views/pages/_form.html.erb
348
+ - lib/generators/frame/pages/templates/app/views/pages/_links.html.erb
349
+ - lib/generators/frame/pages/templates/app/views/pages/index.html.erb
350
+ - lib/generators/frame/pages/templates/app/views/pages/show.html.erb
351
+ - lib/generators/frame/pages/templates/app/views/pages/_page.html.erb
352
+ - lib/generators/frame/pages/templates/app/views/shared/_sidebar.html.erb
353
+ - lib/generators/frame/pages/templates/app/views/shared/_error_messages.html.erb
354
+ - lib/generators/frame/pages/templates/app/views/layouts/pages.html.erb
355
355
  - lib/generators/frame/pages/USAGE
356
356
  - lib/generators/frame/gitignore/gitignore_generator.rb
357
357
  - lib/generators/frame/gitignore/USAGE
358
358
  - lib/generators/frame/devise/templates/app/views/layouts/defaults.html.erb
359
359
  - lib/generators/frame/devise/devise_generator.rb
360
360
  - lib/generators/frame/devise/USAGE
361
+ - lib/generators/frame/devise_omniauth/templates/app/models/user.rb
362
+ - lib/generators/frame/devise_omniauth/templates/app/views/devise/sessions/new.html.erb
363
+ - lib/generators/frame/devise_omniauth/templates/app/views/devise/registrations/edit.html.erb
364
+ - lib/generators/frame/devise_omniauth/templates/app/views/devise/registrations/new.html.erb
365
+ - lib/generators/frame/devise_omniauth/templates/app/views/layouts/defaults.html.erb
366
+ - lib/generators/frame/devise_omniauth/templates/app/controllers/omniauth_callbacks_controller.rb
367
+ - lib/generators/frame/devise_omniauth/templates/config/routes.rb
368
+ - lib/generators/frame/devise_omniauth/devise_omniauth_generator.rb
369
+ - lib/generators/frame/devise_omniauth/USAGE
361
370
  - lib/generators/frame/secret/templates/database.yml
362
371
  - lib/generators/frame/secret/templates/Rakefile
363
372
  - lib/generators/frame/secret/secret_generator.rb