caseadilla 0.0.1 → 0.0.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitignore +0 -0
- data/Gemfile +0 -0
- data/LICENSE.txt +0 -0
- data/README.md +0 -0
- data/Rakefile +0 -0
- data/app/assets/fonts/caseadilla/glyphicons-halflings-regular.eot +0 -0
- data/app/assets/fonts/caseadilla/glyphicons-halflings-regular.svg +228 -228
- data/app/assets/fonts/caseadilla/glyphicons-halflings-regular.ttf +0 -0
- data/app/assets/fonts/caseadilla/glyphicons-halflings-regular.woff +0 -0
- data/app/assets/images/caseadilla/caseadilla.png +0 -0
- data/app/assets/javascripts/caseadilla/bootstrap.js +2114 -2114
- data/app/assets/javascripts/caseadilla/bootstrap3-wysihtml5.js +520 -520
- data/app/assets/javascripts/caseadilla/caseadilla.js +50 -50
- data/app/assets/javascripts/caseadilla/html5shiv.js +8 -8
- data/app/assets/javascripts/caseadilla/wysihtml5-0.3.0.min.js +260 -260
- data/app/assets/stylesheets/caseadilla/bootstrap-glyphicons.css.scss +2 -2
- data/app/assets/stylesheets/caseadilla/bootstrap-theme.css +442 -442
- data/app/assets/stylesheets/caseadilla/bootstrap-wysihtml5.css +101 -101
- data/app/assets/stylesheets/caseadilla/bootstrap.css +6203 -6203
- data/app/assets/stylesheets/caseadilla/caseadilla-bootstrap-overrides.css.scss +79 -79
- data/app/assets/stylesheets/caseadilla/caseadilla.scss +269 -269
- data/app/assets/stylesheets/caseadilla/login.css.scss +80 -80
- data/app/controllers/caseadilla/caseadilla_controller.rb +56 -56
- data/app/controllers/caseadilla/caseadilla_user_sessions_controller.rb +35 -35
- data/app/controllers/caseadilla/password_resets_controller.rb +63 -63
- data/app/controllers/caseadilla/roles_controller.rb +64 -64
- data/app/controllers/caseadilla/users_controller.rb +117 -117
- data/app/helpers/caseadilla/caseadilla_helper.rb +261 -261
- data/app/mailers/caseadilla/caseadilla_notification.rb +38 -38
- data/app/views/caseadilla/caseadilla/blank.html.erb +11 -11
- data/app/views/caseadilla/caseadilla_notification/generate_new_password.erb +11 -11
- data/app/views/caseadilla/caseadilla_notification/new_user_information.erb +11 -11
- data/app/views/caseadilla/caseadilla_notification/password_reset_instructions.erb +10 -10
- data/app/views/caseadilla/caseadilla_user_sessions/new.html.erb +38 -38
- data/app/views/caseadilla/roles/_form.html.erb +11 -11
- data/app/views/caseadilla/roles/_table.html.erb +27 -27
- data/app/views/caseadilla/roles/index.html.erb +14 -14
- data/app/views/caseadilla/roles/new.html.erb +17 -17
- data/app/views/caseadilla/roles/show.html.erb +17 -17
- data/app/views/caseadilla/users/index.html.erb +36 -36
- data/app/views/caseadilla/users/new.html.erb +49 -49
- data/app/views/caseadilla/users/show.html.erb +38 -38
- data/app/views/layouts/caseadilla_auth.html.erb +36 -36
- data/app/views/layouts/caseadilla_main.html.erb +110 -118
- data/caseadilla.gemspec +48 -48
- data/config/initializers/will_paginate.rb +39 -39
- data/config/routes.rb +22 -22
- data/lib/caseadilla.rb +13 -13
- data/lib/caseadilla/engine.rb +34 -34
- data/lib/caseadilla/version.rb +1 -1
- data/lib/generators/caseadilla/install/install_generator.rb +153 -153
- data/lib/generators/caseadilla/install/templates/app/assets/javascripts/caseadilla/custom.js +1 -1
- data/lib/generators/caseadilla/install/templates/app/assets/stylesheets/caseadilla/custom.css.scss +2 -2
- data/lib/generators/caseadilla/install/templates/app/helpers/caseadilla/config_helper.rb +44 -44
- data/lib/generators/caseadilla/install/templates/app/models/user.rb +23 -23
- data/lib/generators/caseadilla/install/templates/app/views/caseadilla/layouts/_tab_navigation.html.erb +1 -1
- data/lib/generators/caseadilla/install/templates/app/views/caseadilla/layouts/_top_navigation.html.erb +3 -3
- data/lib/generators/caseadilla/install/templates/public/robots.txt +4 -4
- data/lib/generators/caseadilla/install/templates/steak/config/initializers/caseadilla.rb +7 -7
- data/lib/generators/caseadilla/install/templates/steak/db/migrate/add_name_to_users.rb +8 -8
- data/lib/generators/caseadilla/install/templates/veggie/config/initializers/caseadilla.rb +7 -7
- data/lib/generators/caseadilla/scaffold/scaffold_generator.rb +110 -110
- data/lib/generators/caseadilla/scaffold/templates/controller.rb +71 -71
- data/lib/generators/caseadilla/scaffold/templates/migration.rb +12 -12
- data/lib/generators/caseadilla/scaffold/templates/model.rb +2 -2
- data/lib/generators/caseadilla/scaffold/templates/views/_form.html.erb +11 -11
- data/lib/generators/caseadilla/scaffold/templates/views/_table.html.erb +18 -18
- data/lib/generators/caseadilla/scaffold/templates/views/index.html.erb +14 -14
- data/lib/generators/caseadilla/scaffold/templates/views/new.html.erb +17 -17
- data/lib/generators/caseadilla/scaffold/templates/views/show.html.erb +17 -17
- data/lib/railties/tasks.rake +31 -31
- metadata +2 -2
data/caseadilla.gemspec
CHANGED
@@ -1,49 +1,49 @@
|
|
1
|
-
# coding: utf-8
|
2
|
-
lib = File.expand_path('../lib', __FILE__)
|
3
|
-
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
-
require 'caseadilla/version'
|
5
|
-
|
6
|
-
Gem::Specification.new do |spec|
|
7
|
-
spec.name = "caseadilla"
|
8
|
-
spec.version = Caseadilla::VERSION
|
9
|
-
spec.authors = ["Xavier Bick"]
|
10
|
-
spec.email = ["fxb9500@gmail.com"]
|
11
|
-
spec.description = "Caseadilla is a CMS for Rails based on Casein and Comfortable Mexican Sofa. It is designed to allow you to easily fit the CMS to your app, not the other way around. By default, Caseadilla installs with Devise for authentication and Declarative Authorization, however it can be installed without either if you want to use an existing auth system."
|
12
|
-
spec.summary = "A powerful yet unobtrusive CMS and data management system for Rails."
|
13
|
-
spec.homepage = ""
|
14
|
-
spec.license = "MIT"
|
15
|
-
|
16
|
-
spec.files = `git ls-files`.split($/)
|
17
|
-
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
|
18
|
-
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
19
|
-
spec.require_paths = ["lib"]
|
20
|
-
|
21
|
-
spec.add_development_dependency "bundler", "~> 1.3"
|
22
|
-
spec.add_development_dependency "rake"
|
23
|
-
if spec.respond_to? :specification_version then
|
24
|
-
spec.specification_version = 4
|
25
|
-
|
26
|
-
if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
|
27
|
-
spec.add_runtime_dependency(%q<caseadilla>, [">= 0"])
|
28
|
-
spec.add_runtime_dependency(%q<will_paginate>, ["= 3.0.5"])
|
29
|
-
spec.add_runtime_dependency(%q<devise>, [">= 3.2"])
|
30
|
-
spec.add_runtime_dependency(%q<declarative_authorization>, [">= 0.5.7"])
|
31
|
-
spec.add_runtime_dependency(%q<scrypt>, ["= 1.2.1"])
|
32
|
-
spec.add_runtime_dependency(%q<jquery-rails>, [">= 0"])
|
33
|
-
else
|
34
|
-
spec.add_dependency(%q<caseadilla>, [">= 0"])
|
35
|
-
spec.add_dependency(%q<will_paginate>, ["= 3.0.5"])
|
36
|
-
spec.add_dependency(%q<devise>, [">= 3.2"])
|
37
|
-
spec.add_dependency(%q<declarative_authorization>, [">= 0.5.7"])
|
38
|
-
spec.add_dependency(%q<scrypt>, ["= 1.2.1"])
|
39
|
-
spec.add_dependency(%q<jquery-rails>, [">= 0"])
|
40
|
-
end
|
41
|
-
else
|
42
|
-
spec.add_dependency(%q<caseadilla>, [">= 0"])
|
43
|
-
spec.add_dependency(%q<will_paginate>, ["= 3.0.5"])
|
44
|
-
spec.add_dependency(%q<devise>, ["= 3.2"])
|
45
|
-
spec.add_dependency(%q<declarative_authorization>, [">= 0.5.7"])
|
46
|
-
spec.add_dependency(%q<scrypt>, ["= 1.2.1"])
|
47
|
-
spec.add_dependency(%q<jquery-rails>, [">= 0"])
|
48
|
-
end
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'caseadilla/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = "caseadilla"
|
8
|
+
spec.version = Caseadilla::VERSION
|
9
|
+
spec.authors = ["Xavier Bick"]
|
10
|
+
spec.email = ["fxb9500@gmail.com"]
|
11
|
+
spec.description = "Caseadilla is a CMS for Rails based on Casein and Comfortable Mexican Sofa. It is designed to allow you to easily fit the CMS to your app, not the other way around. By default, Caseadilla installs with Devise for authentication and Declarative Authorization, however it can be installed without either if you want to use an existing auth system."
|
12
|
+
spec.summary = "A powerful yet unobtrusive CMS and data management system for Rails."
|
13
|
+
spec.homepage = ""
|
14
|
+
spec.license = "MIT"
|
15
|
+
|
16
|
+
spec.files = `git ls-files`.split($/)
|
17
|
+
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
|
18
|
+
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
19
|
+
spec.require_paths = ["lib"]
|
20
|
+
|
21
|
+
spec.add_development_dependency "bundler", "~> 1.3"
|
22
|
+
spec.add_development_dependency "rake"
|
23
|
+
if spec.respond_to? :specification_version then
|
24
|
+
spec.specification_version = 4
|
25
|
+
|
26
|
+
if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
|
27
|
+
spec.add_runtime_dependency(%q<caseadilla>, [">= 0"])
|
28
|
+
spec.add_runtime_dependency(%q<will_paginate>, ["= 3.0.5"])
|
29
|
+
spec.add_runtime_dependency(%q<devise>, [">= 3.2"])
|
30
|
+
spec.add_runtime_dependency(%q<declarative_authorization>, [">= 0.5.7"])
|
31
|
+
spec.add_runtime_dependency(%q<scrypt>, ["= 1.2.1"])
|
32
|
+
spec.add_runtime_dependency(%q<jquery-rails>, [">= 0"])
|
33
|
+
else
|
34
|
+
spec.add_dependency(%q<caseadilla>, [">= 0"])
|
35
|
+
spec.add_dependency(%q<will_paginate>, ["= 3.0.5"])
|
36
|
+
spec.add_dependency(%q<devise>, [">= 3.2"])
|
37
|
+
spec.add_dependency(%q<declarative_authorization>, [">= 0.5.7"])
|
38
|
+
spec.add_dependency(%q<scrypt>, ["= 1.2.1"])
|
39
|
+
spec.add_dependency(%q<jquery-rails>, [">= 0"])
|
40
|
+
end
|
41
|
+
else
|
42
|
+
spec.add_dependency(%q<caseadilla>, [">= 0"])
|
43
|
+
spec.add_dependency(%q<will_paginate>, ["= 3.0.5"])
|
44
|
+
spec.add_dependency(%q<devise>, ["= 3.2"])
|
45
|
+
spec.add_dependency(%q<declarative_authorization>, [">= 0.5.7"])
|
46
|
+
spec.add_dependency(%q<scrypt>, ["= 1.2.1"])
|
47
|
+
spec.add_dependency(%q<jquery-rails>, [">= 0"])
|
48
|
+
end
|
49
49
|
end
|
@@ -1,40 +1,40 @@
|
|
1
|
-
# config/initializers/will_paginate.rb
|
2
|
-
#
|
3
|
-
# This extension code was written by Isaac Bowen, originally found
|
4
|
-
# at http://isaacbowen.com/blog/using-will_paginate-action_view-and-bootstrap/
|
5
|
-
|
6
|
-
require 'will_paginate/view_helpers/action_view'
|
7
|
-
|
8
|
-
module WillPaginate
|
9
|
-
module ActionView
|
10
|
-
|
11
|
-
def will_paginate(collection = nil, options = {})
|
12
|
-
options, collection = collection, nil if collection.is_a? Hash
|
13
|
-
# Taken from original will_paginate code to handle if the helper is not passed a collection object.
|
14
|
-
collection ||= infer_collection_from_controller
|
15
|
-
options[:renderer] ||= BootstrapLinkRenderer
|
16
|
-
super.try :html_safe
|
17
|
-
end
|
18
|
-
|
19
|
-
class BootstrapLinkRenderer < LinkRenderer
|
20
|
-
protected
|
21
|
-
|
22
|
-
def html_container(html)
|
23
|
-
tag :div, tag(:ul, html, :class => "pagination"), container_attributes
|
24
|
-
end
|
25
|
-
|
26
|
-
def page_number(page)
|
27
|
-
tag :li, link(page, page, :rel => rel_value(page)), :class => ('active' if page == current_page)
|
28
|
-
end
|
29
|
-
|
30
|
-
def gap
|
31
|
-
tag :li, link('…'.html_safe, '#'), :class => 'disabled'
|
32
|
-
end
|
33
|
-
|
34
|
-
def previous_or_next_page(page, text, classname)
|
35
|
-
tag :li, link(text, page || '#'),
|
36
|
-
:class => [(classname[0..3] if @options[:page_links]), (classname if @options[:page_links]), ('disabled' unless page)].join(' ')
|
37
|
-
end
|
38
|
-
end
|
39
|
-
end
|
1
|
+
# config/initializers/will_paginate.rb
|
2
|
+
#
|
3
|
+
# This extension code was written by Isaac Bowen, originally found
|
4
|
+
# at http://isaacbowen.com/blog/using-will_paginate-action_view-and-bootstrap/
|
5
|
+
|
6
|
+
require 'will_paginate/view_helpers/action_view'
|
7
|
+
|
8
|
+
module WillPaginate
|
9
|
+
module ActionView
|
10
|
+
|
11
|
+
def will_paginate(collection = nil, options = {})
|
12
|
+
options, collection = collection, nil if collection.is_a? Hash
|
13
|
+
# Taken from original will_paginate code to handle if the helper is not passed a collection object.
|
14
|
+
collection ||= infer_collection_from_controller
|
15
|
+
options[:renderer] ||= BootstrapLinkRenderer
|
16
|
+
super.try :html_safe
|
17
|
+
end
|
18
|
+
|
19
|
+
class BootstrapLinkRenderer < LinkRenderer
|
20
|
+
protected
|
21
|
+
|
22
|
+
def html_container(html)
|
23
|
+
tag :div, tag(:ul, html, :class => "pagination"), container_attributes
|
24
|
+
end
|
25
|
+
|
26
|
+
def page_number(page)
|
27
|
+
tag :li, link(page, page, :rel => rel_value(page)), :class => ('active' if page == current_page)
|
28
|
+
end
|
29
|
+
|
30
|
+
def gap
|
31
|
+
tag :li, link('…'.html_safe, '#'), :class => 'disabled'
|
32
|
+
end
|
33
|
+
|
34
|
+
def previous_or_next_page(page, text, classname)
|
35
|
+
tag :li, link(text, page || '#'),
|
36
|
+
:class => [(classname[0..3] if @options[:page_links]), (classname if @options[:page_links]), ('disabled' unless page)].join(' ')
|
37
|
+
end
|
38
|
+
end
|
39
|
+
end
|
40
40
|
end
|
data/config/routes.rb
CHANGED
@@ -1,23 +1,23 @@
|
|
1
|
-
Rails.application.routes.draw do
|
2
|
-
|
3
|
-
match "/admin" => redirect("/caseadilla"), :via => :get
|
4
|
-
|
5
|
-
namespace :caseadilla do
|
6
|
-
|
7
|
-
if Caseadilla::Engine.flavor = :steak
|
8
|
-
resources :users do
|
9
|
-
# member do
|
10
|
-
# patch :update_password, :reset_password
|
11
|
-
# end
|
12
|
-
end
|
13
|
-
resources :roles
|
14
|
-
|
15
|
-
match "/sign_in" => "caseadilla_user_sessions#new", via: :get
|
16
|
-
# resource :password_reset, :only => [:create, :edit, :update]
|
17
|
-
end
|
18
|
-
|
19
|
-
match "/blank" => "caseadilla#blank", :via => :get
|
20
|
-
root :to => "caseadilla#index"
|
21
|
-
end
|
22
|
-
|
1
|
+
Rails.application.routes.draw do
|
2
|
+
|
3
|
+
match "/admin" => redirect("/caseadilla"), :via => :get
|
4
|
+
|
5
|
+
namespace :caseadilla do
|
6
|
+
|
7
|
+
if Caseadilla::Engine.flavor = :steak
|
8
|
+
resources :users do
|
9
|
+
# member do
|
10
|
+
# patch :update_password, :reset_password
|
11
|
+
# end
|
12
|
+
end
|
13
|
+
resources :roles
|
14
|
+
|
15
|
+
match "/sign_in" => "caseadilla_user_sessions#new", via: :get
|
16
|
+
# resource :password_reset, :only => [:create, :edit, :update]
|
17
|
+
end
|
18
|
+
|
19
|
+
match "/blank" => "caseadilla#blank", :via => :get
|
20
|
+
root :to => "caseadilla#index"
|
21
|
+
end
|
22
|
+
|
23
23
|
end
|
data/lib/caseadilla.rb
CHANGED
@@ -1,14 +1,14 @@
|
|
1
|
-
require "caseadilla/version"
|
2
|
-
|
3
|
-
if defined?(Rails) && Rails::VERSION::MAJOR == 4
|
4
|
-
require 'caseadilla/engine'
|
5
|
-
require 'will_paginate'
|
6
|
-
if Caseadilla::Engine.flavor = :steak
|
7
|
-
require 'devise'
|
8
|
-
require 'declarative_authorization'
|
9
|
-
end
|
10
|
-
else
|
11
|
-
puts("!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!")
|
12
|
-
puts("!!! WARNING !!! Caseadilla requires Rails >= 4.x !!!")
|
13
|
-
puts("!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!")
|
1
|
+
require "caseadilla/version"
|
2
|
+
|
3
|
+
if defined?(Rails) && Rails::VERSION::MAJOR == 4
|
4
|
+
require 'caseadilla/engine'
|
5
|
+
require 'will_paginate'
|
6
|
+
if Caseadilla::Engine.flavor = :steak
|
7
|
+
require 'devise'
|
8
|
+
require 'declarative_authorization'
|
9
|
+
end
|
10
|
+
else
|
11
|
+
puts("!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!")
|
12
|
+
puts("!!! WARNING !!! Caseadilla requires Rails >= 4.x !!!")
|
13
|
+
puts("!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!")
|
14
14
|
end
|
data/lib/caseadilla/engine.rb
CHANGED
@@ -1,35 +1,35 @@
|
|
1
|
-
require "caseadilla"
|
2
|
-
require "rails"
|
3
|
-
|
4
|
-
module Caseadilla
|
5
|
-
class Engine < Rails::Engine
|
6
|
-
@flavor = nil
|
7
|
-
|
8
|
-
class << self
|
9
|
-
attr_accessor :flavor
|
10
|
-
end
|
11
|
-
|
12
|
-
config.after_initialize do
|
13
|
-
Rails.application.config.assets.paths << root.join("app", "assets", "fonts")
|
14
|
-
end
|
15
|
-
|
16
|
-
initializer "caseadilla.assets.precompile" do |app|
|
17
|
-
app.config.assets.precompile += %w(caseadilla/*.svg caseadilla/*.eot caseadilla/*.woff caseadilla/*.ttf caseadilla/login.css caseadilla/caseadilla.css caseadilla/caseadilla.js caseadilla/html5shiv.js caseadilla/custom.css caseadilla/custom.js caseadilla/*.png)
|
18
|
-
end
|
19
|
-
|
20
|
-
rake_tasks do
|
21
|
-
load "railties/tasks.rake"
|
22
|
-
end
|
23
|
-
|
24
|
-
end
|
25
|
-
|
26
|
-
class RouteConstraint
|
27
|
-
|
28
|
-
def matches?(request)
|
29
|
-
return false if request.fullpath.include?("/caseadilla")
|
30
|
-
return false if request.fullpath.include?("/admin")
|
31
|
-
true
|
32
|
-
end
|
33
|
-
|
34
|
-
end
|
1
|
+
require "caseadilla"
|
2
|
+
require "rails"
|
3
|
+
|
4
|
+
module Caseadilla
|
5
|
+
class Engine < Rails::Engine
|
6
|
+
@flavor = nil
|
7
|
+
|
8
|
+
class << self
|
9
|
+
attr_accessor :flavor
|
10
|
+
end
|
11
|
+
|
12
|
+
config.after_initialize do
|
13
|
+
Rails.application.config.assets.paths << root.join("app", "assets", "fonts")
|
14
|
+
end
|
15
|
+
|
16
|
+
initializer "caseadilla.assets.precompile" do |app|
|
17
|
+
app.config.assets.precompile += %w(caseadilla/*.svg caseadilla/*.eot caseadilla/*.woff caseadilla/*.ttf caseadilla/login.css caseadilla/caseadilla.css caseadilla/caseadilla.js caseadilla/html5shiv.js caseadilla/custom.css caseadilla/custom.js caseadilla/*.png)
|
18
|
+
end
|
19
|
+
|
20
|
+
rake_tasks do
|
21
|
+
load "railties/tasks.rake"
|
22
|
+
end
|
23
|
+
|
24
|
+
end
|
25
|
+
|
26
|
+
class RouteConstraint
|
27
|
+
|
28
|
+
def matches?(request)
|
29
|
+
return false if request.fullpath.include?("/caseadilla")
|
30
|
+
return false if request.fullpath.include?("/admin")
|
31
|
+
true
|
32
|
+
end
|
33
|
+
|
34
|
+
end
|
35
35
|
end
|
data/lib/caseadilla/version.rb
CHANGED
@@ -1,154 +1,154 @@
|
|
1
|
-
module Caseadilla
|
2
|
-
class InstallGenerator < Rails::Generators::Base
|
3
|
-
|
4
|
-
include Rails::Generators::Migration
|
5
|
-
source_root File.expand_path('../templates', __FILE__)
|
6
|
-
argument :flavor, type: :string, default: "auto"
|
7
|
-
class_option :no_commit, type: :boolean, default: false, desc: 'Skip bundle install and rake tasks such as migrate and seed'
|
8
|
-
class_option :skip_decl_auth, type: :boolean, default: false, desc: 'Skip installation of declarative_authorization'
|
9
|
-
class_option :auth_model, type: :string, default: "User", desc: 'Name of Model to be created for auth'
|
10
|
-
class_option :user_habtm_roles, type: :boolean, default: false, desc: 'Allow users to have multiple roles by setting up a HABTM association between roles'
|
11
|
-
|
12
|
-
def self.next_migration_number dirname
|
13
|
-
if ActiveRecord::Base.timestamped_migrations
|
14
|
-
Time.now.utc.strftime("%Y%m%d%H%M%S")
|
15
|
-
else
|
16
|
-
"%.3d" % (current_migration_number(dirname) + 1)
|
17
|
-
end
|
18
|
-
end
|
19
|
-
|
20
|
-
def install_flavor
|
21
|
-
@flavor = self.flavor
|
22
|
-
if @flavor == "auto"
|
23
|
-
puts "\nWelcome to Caseadilla! Please enter a flavor to install:"
|
24
|
-
puts "\n[steak] This is recommended for a fresh Rails app. Caseadilla will set up Devise and Declarative Authorization for you, along with an admin user and various authorization roles."
|
25
|
-
puts "\n[chicken] Select this if you have auth in place already or plan to use something other than Devise or Declarative Authorization. Caseadilla will use methods such as `current_user.is_admin?` to help with auth integration. See the readme for more details."
|
26
|
-
puts "\n[veggie] This flavor will install Caseadilla as minimally as possible, without any auth support. You will be responsible for implementing authorization and authentication into Caseadilla.\n\n"
|
27
|
-
flavor_choice = STDIN.gets.chomp
|
28
|
-
@flavor = flavor_choice
|
29
|
-
end
|
30
|
-
|
31
|
-
case @flavor
|
32
|
-
when "steak"
|
33
|
-
@target = "steak"
|
34
|
-
|
35
|
-
gem 'simple_form'
|
36
|
-
gem 'devise'
|
37
|
-
gem 'declarative_authorization', git: 'git://github.com/zeiv/declarative_authorization', branch: '1.0.0' unless options[:skip_decl_auth]
|
38
|
-
gem 'best_in_place'
|
39
|
-
gem 'mercury-rails'
|
40
|
-
Bundler.with_clean_env do
|
41
|
-
run 'bundle install' unless options[:no_commit]
|
42
|
-
end
|
43
|
-
|
44
|
-
generate 'devise:install'
|
45
|
-
generate 'devise', "#{options[:auth_model].capitalize}"
|
46
|
-
generate 'devise:views'
|
47
|
-
rake 'db:migrate' unless options[:no_commit]
|
48
|
-
|
49
|
-
generate "authorization:install","#{options[:auth_model].capitalize} --commit --user-belongs-to-role" unless options[:skip_decl_auth] or options[:no_commit] or options[:user_habtm_roles]
|
50
|
-
generate "authorization:install","#{options[:auth_model].capitalize} --commit" if options[:user_habtm_roles] and not options[:skip_decl_auth]
|
51
|
-
generate "authorization:install","#{options[:auth_model].capitalize}" if options[:no_commit] and not options[:skip_decl_auth]
|
52
|
-
|
53
|
-
migration_template 'steak/db/migrate/add_name_to_users.rb', "db/migrate/add_name_to_users.rb"
|
54
|
-
rake 'db:migrate' unless options[:no_commit]
|
55
|
-
|
56
|
-
inject_into_file "app/models/#{options[:auth_model].downcase}.rb", " before_create :add_user_role", after: "belongs_to :role\n"
|
57
|
-
inject_into_file "app/models/#{options[:auth_model].downcase}.rb", after: /def role_symbols.*?end\n/m do <<-'RUBY'
|
58
|
-
|
59
|
-
def name
|
60
|
-
"#{first_name} #{last_name}"
|
61
|
-
end
|
62
|
-
|
63
|
-
private
|
64
|
-
|
65
|
-
def add_user_role
|
66
|
-
self.role = Role.find_by_title 'user'
|
67
|
-
end
|
68
|
-
|
69
|
-
|
70
|
-
RUBY
|
71
|
-
end
|
72
|
-
|
73
|
-
inject_into_file 'app/helpers/application_helper.rb', after: "module ApplicationHelper\n" do <<-'RUBY'
|
74
|
-
def resource_name
|
75
|
-
:user
|
76
|
-
end
|
77
|
-
|
78
|
-
def resource
|
79
|
-
@resource ||= User.new
|
80
|
-
end
|
81
|
-
|
82
|
-
def devise_mapping
|
83
|
-
@devise_mapping ||= Devise.mappings[:user]
|
84
|
-
end
|
85
|
-
RUBY
|
86
|
-
end
|
87
|
-
|
88
|
-
inject_into_file 'app/controllers/application_controller.rb', after: "ActionController::Base\n" do <<-'RUBY'
|
89
|
-
before_action :configure_permitted_parameters, if: :devise_controller?
|
90
|
-
|
91
|
-
RUBY
|
92
|
-
end
|
93
|
-
|
94
|
-
inject_into_file 'app/controllers/application_controller.rb', before: "\nend" do <<-'RUBY'
|
95
|
-
|
96
|
-
|
97
|
-
protected
|
98
|
-
|
99
|
-
def configure_permitted_parameters
|
100
|
-
devise_parameter_sanitizer.for(:account_update) { |u| u.permit({ role_ids: [] }, :email, :password, :password_confirmation, :current_password, :first_name, :last_name, :time_zone) }
|
101
|
-
end
|
102
|
-
RUBY
|
103
|
-
end
|
104
|
-
|
105
|
-
inject_into_file 'config/authorization_rules.rb', after: "authorization do\n" do <<-'RUBY'
|
106
|
-
|
107
|
-
role :admin do
|
108
|
-
has_permission_on :caseadilla_users, to: :manage
|
109
|
-
has_permission_on :caseadilla_roles, to: :manage
|
110
|
-
end
|
111
|
-
|
112
|
-
RUBY
|
113
|
-
end
|
114
|
-
when "chicken"
|
115
|
-
@target = "chicken"
|
116
|
-
when "veggie"
|
117
|
-
@target = "veggie"
|
118
|
-
else
|
119
|
-
puts "That flavor is not recognized. Please enter steak, chicken, or veggie. E.g., for a full install use `rails g caseadilla:install steak`"
|
120
|
-
end
|
121
|
-
end
|
122
|
-
|
123
|
-
def flavor_files
|
124
|
-
copy_file "#{@target}/config/initializers/caseadilla.rb", "config/initializers/caseadilla.rb"
|
125
|
-
end
|
126
|
-
|
127
|
-
def common_files
|
128
|
-
puts "*** WARNING - Generating configuration files. Make sure you have backed up any files before overwriting them. ***"
|
129
|
-
|
130
|
-
#config helper
|
131
|
-
copy_file "app/helpers/caseadilla/config_helper.rb", "app/helpers/caseadilla/config_helper.rb"
|
132
|
-
|
133
|
-
#initial view partials
|
134
|
-
copy_file "app/views/caseadilla/layouts/_tab_navigation.html.erb", "app/views/caseadilla/layouts/_tab_navigation.html.erb"
|
135
|
-
copy_file "app/views/caseadilla/layouts/_top_navigation.html.erb", "app/views/caseadilla/layouts/_top_navigation.html.erb"
|
136
|
-
|
137
|
-
#blank stylesheets and JavaScript files
|
138
|
-
copy_file "app/assets/stylesheets/caseadilla/custom.css.scss", "app/assets/stylesheets/caseadilla/custom.css.scss"
|
139
|
-
copy_file "app/assets/javascripts/caseadilla/custom.js", "app/assets/javascripts/caseadilla/custom.js"
|
140
|
-
end
|
141
|
-
|
142
|
-
def copy_robots
|
143
|
-
puts " ** Overwrite if you haven't yet modified your robots.txt, otherwise add disallow rules for /caseadilla and /admin manually **"
|
144
|
-
copy_file "public/robots.txt", "public/robots.txt"
|
145
|
-
end
|
146
|
-
|
147
|
-
# protected
|
148
|
-
# attr_reader :flavor
|
149
|
-
|
150
|
-
# def assign_flavor!(f)
|
151
|
-
# @flavor = f
|
152
|
-
# end
|
153
|
-
end
|
1
|
+
module Caseadilla
|
2
|
+
class InstallGenerator < Rails::Generators::Base
|
3
|
+
|
4
|
+
include Rails::Generators::Migration
|
5
|
+
source_root File.expand_path('../templates', __FILE__)
|
6
|
+
argument :flavor, type: :string, default: "auto"
|
7
|
+
class_option :no_commit, type: :boolean, default: false, desc: 'Skip bundle install and rake tasks such as migrate and seed'
|
8
|
+
class_option :skip_decl_auth, type: :boolean, default: false, desc: 'Skip installation of declarative_authorization'
|
9
|
+
class_option :auth_model, type: :string, default: "User", desc: 'Name of Model to be created for auth'
|
10
|
+
class_option :user_habtm_roles, type: :boolean, default: false, desc: 'Allow users to have multiple roles by setting up a HABTM association between roles'
|
11
|
+
|
12
|
+
def self.next_migration_number dirname
|
13
|
+
if ActiveRecord::Base.timestamped_migrations
|
14
|
+
Time.now.utc.strftime("%Y%m%d%H%M%S")
|
15
|
+
else
|
16
|
+
"%.3d" % (current_migration_number(dirname) + 1)
|
17
|
+
end
|
18
|
+
end
|
19
|
+
|
20
|
+
def install_flavor
|
21
|
+
@flavor = self.flavor
|
22
|
+
if @flavor == "auto"
|
23
|
+
puts "\nWelcome to Caseadilla! Please enter a flavor to install:"
|
24
|
+
puts "\n[steak] This is recommended for a fresh Rails app. Caseadilla will set up Devise and Declarative Authorization for you, along with an admin user and various authorization roles."
|
25
|
+
puts "\n[chicken] Select this if you have auth in place already or plan to use something other than Devise or Declarative Authorization. Caseadilla will use methods such as `current_user.is_admin?` to help with auth integration. See the readme for more details."
|
26
|
+
puts "\n[veggie] This flavor will install Caseadilla as minimally as possible, without any auth support. You will be responsible for implementing authorization and authentication into Caseadilla.\n\n"
|
27
|
+
flavor_choice = STDIN.gets.chomp
|
28
|
+
@flavor = flavor_choice
|
29
|
+
end
|
30
|
+
|
31
|
+
case @flavor
|
32
|
+
when "steak"
|
33
|
+
@target = "steak"
|
34
|
+
|
35
|
+
gem 'simple_form'
|
36
|
+
gem 'devise'
|
37
|
+
gem 'declarative_authorization', git: 'git://github.com/zeiv/declarative_authorization', branch: '1.0.0' unless options[:skip_decl_auth]
|
38
|
+
gem 'best_in_place'
|
39
|
+
gem 'mercury-rails'
|
40
|
+
Bundler.with_clean_env do
|
41
|
+
run 'bundle install' unless options[:no_commit]
|
42
|
+
end
|
43
|
+
|
44
|
+
generate 'devise:install'
|
45
|
+
generate 'devise', "#{options[:auth_model].capitalize}"
|
46
|
+
generate 'devise:views'
|
47
|
+
rake 'db:migrate' unless options[:no_commit]
|
48
|
+
|
49
|
+
generate "authorization:install","#{options[:auth_model].capitalize} --commit --user-belongs-to-role" unless options[:skip_decl_auth] or options[:no_commit] or options[:user_habtm_roles]
|
50
|
+
generate "authorization:install","#{options[:auth_model].capitalize} --commit" if options[:user_habtm_roles] and not options[:skip_decl_auth]
|
51
|
+
generate "authorization:install","#{options[:auth_model].capitalize}" if options[:no_commit] and not options[:skip_decl_auth]
|
52
|
+
|
53
|
+
migration_template 'steak/db/migrate/add_name_to_users.rb', "db/migrate/add_name_to_users.rb"
|
54
|
+
rake 'db:migrate' unless options[:no_commit]
|
55
|
+
|
56
|
+
inject_into_file "app/models/#{options[:auth_model].downcase}.rb", " before_create :add_user_role", after: "belongs_to :role\n"
|
57
|
+
inject_into_file "app/models/#{options[:auth_model].downcase}.rb", after: /def role_symbols.*?end\n/m do <<-'RUBY'
|
58
|
+
|
59
|
+
def name
|
60
|
+
"#{first_name} #{last_name}"
|
61
|
+
end
|
62
|
+
|
63
|
+
private
|
64
|
+
|
65
|
+
def add_user_role
|
66
|
+
self.role = Role.find_by_title 'user'
|
67
|
+
end
|
68
|
+
|
69
|
+
|
70
|
+
RUBY
|
71
|
+
end
|
72
|
+
|
73
|
+
inject_into_file 'app/helpers/application_helper.rb', after: "module ApplicationHelper\n" do <<-'RUBY'
|
74
|
+
def resource_name
|
75
|
+
:user
|
76
|
+
end
|
77
|
+
|
78
|
+
def resource
|
79
|
+
@resource ||= User.new
|
80
|
+
end
|
81
|
+
|
82
|
+
def devise_mapping
|
83
|
+
@devise_mapping ||= Devise.mappings[:user]
|
84
|
+
end
|
85
|
+
RUBY
|
86
|
+
end
|
87
|
+
|
88
|
+
inject_into_file 'app/controllers/application_controller.rb', after: "ActionController::Base\n" do <<-'RUBY'
|
89
|
+
before_action :configure_permitted_parameters, if: :devise_controller?
|
90
|
+
|
91
|
+
RUBY
|
92
|
+
end
|
93
|
+
|
94
|
+
inject_into_file 'app/controllers/application_controller.rb', before: "\nend" do <<-'RUBY'
|
95
|
+
|
96
|
+
|
97
|
+
protected
|
98
|
+
|
99
|
+
def configure_permitted_parameters
|
100
|
+
devise_parameter_sanitizer.for(:account_update) { |u| u.permit({ role_ids: [] }, :email, :password, :password_confirmation, :current_password, :first_name, :last_name, :time_zone) }
|
101
|
+
end
|
102
|
+
RUBY
|
103
|
+
end
|
104
|
+
|
105
|
+
inject_into_file 'config/authorization_rules.rb', after: "authorization do\n" do <<-'RUBY'
|
106
|
+
|
107
|
+
role :admin do
|
108
|
+
has_permission_on :caseadilla_users, to: :manage
|
109
|
+
has_permission_on :caseadilla_roles, to: :manage
|
110
|
+
end
|
111
|
+
|
112
|
+
RUBY
|
113
|
+
end
|
114
|
+
when "chicken"
|
115
|
+
@target = "chicken"
|
116
|
+
when "veggie"
|
117
|
+
@target = "veggie"
|
118
|
+
else
|
119
|
+
puts "That flavor is not recognized. Please enter steak, chicken, or veggie. E.g., for a full install use `rails g caseadilla:install steak`"
|
120
|
+
end
|
121
|
+
end
|
122
|
+
|
123
|
+
def flavor_files
|
124
|
+
copy_file "#{@target}/config/initializers/caseadilla.rb", "config/initializers/caseadilla.rb"
|
125
|
+
end
|
126
|
+
|
127
|
+
def common_files
|
128
|
+
puts "*** WARNING - Generating configuration files. Make sure you have backed up any files before overwriting them. ***"
|
129
|
+
|
130
|
+
#config helper
|
131
|
+
copy_file "app/helpers/caseadilla/config_helper.rb", "app/helpers/caseadilla/config_helper.rb"
|
132
|
+
|
133
|
+
#initial view partials
|
134
|
+
copy_file "app/views/caseadilla/layouts/_tab_navigation.html.erb", "app/views/caseadilla/layouts/_tab_navigation.html.erb"
|
135
|
+
copy_file "app/views/caseadilla/layouts/_top_navigation.html.erb", "app/views/caseadilla/layouts/_top_navigation.html.erb"
|
136
|
+
|
137
|
+
#blank stylesheets and JavaScript files
|
138
|
+
copy_file "app/assets/stylesheets/caseadilla/custom.css.scss", "app/assets/stylesheets/caseadilla/custom.css.scss"
|
139
|
+
copy_file "app/assets/javascripts/caseadilla/custom.js", "app/assets/javascripts/caseadilla/custom.js"
|
140
|
+
end
|
141
|
+
|
142
|
+
def copy_robots
|
143
|
+
puts " ** Overwrite if you haven't yet modified your robots.txt, otherwise add disallow rules for /caseadilla and /admin manually **"
|
144
|
+
copy_file "public/robots.txt", "public/robots.txt"
|
145
|
+
end
|
146
|
+
|
147
|
+
# protected
|
148
|
+
# attr_reader :flavor
|
149
|
+
|
150
|
+
# def assign_flavor!(f)
|
151
|
+
# @flavor = f
|
152
|
+
# end
|
153
|
+
end
|
154
154
|
end
|