rich_cms 2.1.7 → 3.0.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.
- data/{CHANGELOG → CHANGELOG.rdoc} +24 -0
- data/README.textile +49 -33
- data/Rakefile +92 -10
- data/VERSION +1 -1
- data/app/controllers/rich/cms_controller.rb +10 -39
- data/app/controllers/rich/cms_sessions_controller.rb +31 -0
- data/app/views/rich/cms/dock/_menu.html.erb +10 -8
- data/app/views/rich/cms/dock/_panel.html.erb +1 -1
- data/app/views/rich/cms/dock/panel/edit/_rails2.html.erb +5 -3
- data/app/views/rich/cms/dock/panel/edit/_rails3.html.erb +4 -2
- data/app/views/rich/cms/dock/panel/login/_rails2.html.erb +18 -12
- data/app/views/rich/cms/dock/panel/login/_rails3.html.erb +18 -12
- data/app/views/rich_cms.html.erb +1 -1
- data/assets/jzip/jquery/cleditor.js +1132 -1132
- data/assets/jzip/jquery/extensions/browser_detect.js +1 -2
- data/assets/jzip/native/extensions.js +41 -0
- data/assets/jzip/rich/cms/editor.js +41 -7
- data/assets/jzip/rich_cms.jz +2 -1
- data/assets/sass/rich_cms/_panel.sass +11 -1
- data/config/routes.rb +12 -11
- data/lib/generators/rich/cms_admin/cms_admin_generator.rb +82 -0
- data/lib/generators/rich/{authlogic_user/templates → cms_admin/templates/authlogic}/migration.rb +0 -0
- data/lib/generators/rich/{authlogic_user/templates → cms_admin/templates/authlogic}/model.rb +0 -0
- data/lib/generators/rich/{authlogic_user/templates → cms_admin/templates/authlogic}/session.rb +0 -0
- data/lib/rich/cms/actionpack/action_controller/base.rb +3 -44
- data/lib/rich/cms/actionpack/action_view/base.rb +32 -10
- data/lib/rich/cms/actionpack.rb +1 -2
- data/lib/rich/cms/auth.rb +110 -0
- data/lib/rich/cms/content/group.rb +1 -2
- data/lib/rich/cms/content/item.rb +2 -3
- data/lib/rich/cms/core/string/html_safe.rb +1 -2
- data/lib/rich/cms/core/string.rb +1 -2
- data/lib/rich/cms/engine.rb +23 -51
- data/lib/rich/cms/rails/engine.rb +1 -2
- data/lib/rich/cms/version.rb +11 -0
- data/lib/rich_cms.rb +2 -2
- data/rails_generators/rich_cms_admin/lib/devise/route_devise.rb +32 -0
- data/rails_generators/rich_cms_admin/rich_cms_admin_generator.rb +113 -0
- data/rails_generators/{rich_authlogic_user/templates → rich_cms_admin/templates/authlogic}/migration.rb +0 -0
- data/rails_generators/{rich_authlogic_user/templates → rich_cms_admin/templates/authlogic}/model.rb +0 -0
- data/rails_generators/{rich_authlogic_user/templates → rich_cms_admin/templates/authlogic}/session.rb +0 -0
- data/rails_generators/{rich_authlogic_user → rich_cms_admin}/templates/config.rb +0 -0
- data/rails_generators/rich_cms_admin/templates/devise/README +23 -0
- data/rails_generators/rich_cms_admin/templates/devise/devise.rb +105 -0
- data/rails_generators/rich_cms_admin/templates/devise/en.yml +35 -0
- data/rails_generators/rich_cms_admin/templates/devise/migration.rb +23 -0
- data/rails_generators/rich_cms_admin/templates/devise/model.rb +9 -0
- data/rails_generators/rich_cms_content/rich_cms_content_generator.rb +18 -12
- data/rich_cms.gemspec +295 -105
- data/test/integrator.rb +89 -0
- data/test/rails-2/dummy/.bundle/config +2 -0
- data/test/rails-2/dummy/Gemfile +15 -0
- data/test/rails-2/dummy/Gemfile.lock +97 -0
- data/test/rails-2/dummy/Rakefile +10 -0
- data/test/rails-2/dummy/app/controllers/application_controller.rb +10 -0
- data/test/rails-2/dummy/app/helpers/application_helper.rb +3 -0
- data/test/rails-2/dummy/config/boot.rb +124 -0
- data/test/rails-2/dummy/config/database.yml +23 -0
- data/test/rails-2/dummy/config/environment.rb +41 -0
- data/test/rails-2/dummy/config/environments/development.rb +17 -0
- data/test/rails-2/dummy/config/environments/production.rb +28 -0
- data/test/rails-2/dummy/config/environments/test.rb +28 -0
- data/test/rails-2/dummy/config/initializers/backtrace_silencers.rb +7 -0
- data/test/rails-2/dummy/config/initializers/cookie_verification_secret.rb +7 -0
- data/test/rails-2/dummy/config/initializers/devise.rb +105 -0
- data/test/rails-2/dummy/config/initializers/enrichments.rb +5 -0
- data/test/rails-2/dummy/config/initializers/inflections.rb +10 -0
- data/test/rails-2/dummy/config/initializers/mime_types.rb +5 -0
- data/test/rails-2/dummy/config/initializers/new_rails_defaults.rb +21 -0
- data/test/rails-2/dummy/config/initializers/session_store.rb +15 -0
- data/test/rails-2/dummy/config/locales/en.yml +5 -0
- data/test/rails-2/dummy/config/preinitializer.rb +20 -0
- data/test/rails-2/dummy/config/routes.rb +44 -0
- data/test/rails-2/dummy/db/schema.rb +49 -0
- data/test/rails-2/dummy/db/seeds.rb +10 -0
- data/test/rails-2/dummy/public/404.html +30 -0
- data/test/rails-2/dummy/public/422.html +30 -0
- data/test/rails-2/dummy/public/500.html +30 -0
- data/test/rails-2/dummy/public/favicon.ico +0 -0
- data/test/rails-2/dummy/public/images/rails.png +0 -0
- data/test/rails-2/dummy/public/images/rich/cms/cleditor/buttons.gif +0 -0
- data/test/rails-2/dummy/public/images/rich/cms/cleditor/toolbar.gif +0 -0
- data/test/rails-2/dummy/public/javascripts/jquery/core.js +158 -0
- data/test/rails-2/dummy/public/javascripts/jquery/ui/rich_cms/core.js +1207 -0
- data/test/rails-2/dummy/public/javascripts/jquery/ui/rich_cms/draggable.js +798 -0
- data/test/rails-2/dummy/public/javascripts/jquery/ui/rich_cms/mouse.js +950 -0
- data/test/rails-2/dummy/public/javascripts/jquery/ui/rich_cms/widget.js +1188 -0
- data/test/rails-2/dummy/public/javascripts/rich_cms.js +1746 -0
- data/test/rails-2/dummy/public/robots.txt +5 -0
- data/test/rails-2/dummy/script/about +4 -0
- data/test/rails-2/dummy/script/console +3 -0
- data/test/rails-2/dummy/script/dbconsole +3 -0
- data/test/rails-2/dummy/script/destroy +3 -0
- data/test/rails-2/dummy/script/generate +3 -0
- data/test/rails-2/dummy/script/performance/benchmarker +3 -0
- data/test/rails-2/dummy/script/performance/profiler +3 -0
- data/test/rails-2/dummy/script/plugin +3 -0
- data/test/rails-2/dummy/script/runner +3 -0
- data/test/rails-2/dummy/script/server +3 -0
- data/test/rails-2/dummy/test/fixtures/authlogic_users.yml +6 -0
- data/test/rails-2/dummy/test/fixtures/devise_users.yml +5 -0
- data/test/rails-2/pending.rb +88 -0
- data/test/rails-2/test_helper.rb +13 -0
- data/test/rails-3/dummy/.bundle/config +2 -0
- data/test/rails-3/dummy/Gemfile +15 -0
- data/test/rails-3/dummy/Gemfile.lock +139 -0
- data/test/rails-3/dummy/Rakefile +7 -0
- data/test/rails-3/dummy/app/controllers/application_controller.rb +3 -0
- data/test/rails-3/dummy/app/helpers/application_helper.rb +2 -0
- data/test/rails-3/dummy/config/application.rb +42 -0
- data/test/rails-3/dummy/config/boot.rb +13 -0
- data/test/rails-3/dummy/config/database.yml +23 -0
- data/test/rails-3/dummy/config/environment.rb +5 -0
- data/test/rails-3/dummy/config/environments/development.rb +26 -0
- data/test/rails-3/dummy/config/environments/production.rb +49 -0
- data/test/rails-3/dummy/config/environments/test.rb +35 -0
- data/test/rails-3/dummy/config/initializers/backtrace_silencers.rb +7 -0
- data/test/rails-3/dummy/config/initializers/devise.rb +142 -0
- data/test/rails-3/dummy/config/initializers/enrichments.rb +5 -0
- data/test/rails-3/dummy/config/initializers/inflections.rb +10 -0
- data/test/rails-3/dummy/config/initializers/mime_types.rb +5 -0
- data/test/rails-3/dummy/config/initializers/secret_token.rb +7 -0
- data/test/rails-3/dummy/config/initializers/session_store.rb +8 -0
- data/test/rails-3/dummy/config/locales/en.yml +5 -0
- data/test/rails-3/dummy/config/routes.rb +59 -0
- data/test/rails-3/dummy/config.ru +4 -0
- data/test/rails-3/dummy/db/schema.rb +49 -0
- data/test/rails-3/dummy/db/seeds.rb +10 -0
- data/test/rails-3/dummy/public/404.html +26 -0
- data/test/rails-3/dummy/public/422.html +26 -0
- data/test/rails-3/dummy/public/500.html +26 -0
- data/test/rails-3/dummy/public/favicon.ico +0 -0
- data/test/rails-3/dummy/public/images/rich/cms/cleditor/buttons.gif +0 -0
- data/test/rails-3/dummy/public/images/rich/cms/cleditor/toolbar.gif +0 -0
- data/test/rails-3/dummy/public/javascripts/jquery/core.js +158 -0
- data/test/rails-3/dummy/public/javascripts/jquery/ui/rich_cms/core.js +1207 -0
- data/test/rails-3/dummy/public/javascripts/jquery/ui/rich_cms/draggable.js +798 -0
- data/test/rails-3/dummy/public/javascripts/jquery/ui/rich_cms/mouse.js +950 -0
- data/test/rails-3/dummy/public/javascripts/jquery/ui/rich_cms/widget.js +1188 -0
- data/test/rails-3/dummy/public/javascripts/rich_cms.js +1746 -0
- data/test/rails-3/dummy/script/rails +6 -0
- data/test/rails-3/dummy/test/fixtures/authlogic_users.yml +6 -0
- data/test/rails-3/dummy/test/fixtures/devise_users.yml +5 -0
- data/test/rails-3/test_helper.rb +17 -0
- data/test/shared/dummy/db/schema.rb +49 -0
- data/test/shared/dummy/db/seeds.rb +10 -0
- data/test/shared/dummy/fixtures/authlogic_users.yml +6 -0
- data/test/shared/dummy/models/authlogic_user.rb +8 -0
- data/test/shared/dummy/models/authlogic_user_session.rb +10 -0
- data/test/shared/dummy/models/cms_content.rb +2 -0
- data/test/shared/dummy/models/devise_user.rb +3 -0
- data/test/shared/dummy/stylesheets/app.css +100 -0
- data/test/shared/dummy/stylesheets/rich_cms.css +159 -0
- data/test/shared/dummy/views/application/index.html.erb +13 -0
- data/test/shared/dummy/views/layouts/application.html.erb +12 -0
- data/test/shared/support/action_controller/integration.rb +55 -0
- data/test/shared/support/action_controller/test_case.rb +28 -0
- data/test/shared/support/capybara/setup.rb +14 -0
- data/test/shared/support/test_helper.rb +1 -0
- data/test/shared/tests/actionpack/action_controller/base_test.rb +14 -0
- data/test/shared/tests/actionpack/action_view/base_test.rb +19 -0
- data/test/shared/tests/activesupport/active_support/dependencies_test.rb +15 -0
- data/test/shared/tests/app/integration/authenticated/authlogic.rb +88 -0
- data/test/shared/tests/app/integration/authenticated/devise_test.rb +89 -0
- data/test/shared/tests/app/integration/non_authenticated.rb +63 -0
- data/test/shared/tests/app/routing_test.rb +31 -0
- data/test/shared/tests/auth_test.rb +11 -0
- data/test/shared/tests/content/group.rb +10 -0
- data/test/shared/tests/content/item.rb +10 -0
- data/test/shared/tests/core/string/html_safe.rb +15 -0
- data/test/shared/tests/dummy_app.rb +228 -0
- data/test/shared/tests/engine_test.rb +19 -0
- data/test/shared/tests/rails/engine_test.rb +13 -0
- data/test/shared/tests/readme_test.rb +13 -0
- metadata +231 -63
- data/.gitignore +0 -2
- data/lib/generators/rich/authlogic_user/authlogic_user_generator.rb +0 -64
- data/rails_generators/rich_authlogic_user/rich_authlogic_user_generator.rb +0 -64
- data/test/test_helper.rb +0 -6
data/lib/rich/cms/engine.rb
CHANGED
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
|
|
2
1
|
module Rich
|
|
3
2
|
module Cms
|
|
4
3
|
class Engine < Rails::Engine
|
|
@@ -7,24 +6,41 @@ module Rich
|
|
|
7
6
|
end
|
|
8
7
|
|
|
9
8
|
class << self
|
|
10
|
-
|
|
11
|
-
|
|
9
|
+
attr_reader :editable_content
|
|
10
|
+
attr_writer :current_controller
|
|
12
11
|
|
|
13
12
|
def init
|
|
14
|
-
@authentication = AuthenticationSpecs.new
|
|
15
13
|
@editable_content = {}
|
|
14
|
+
append_to_load_path
|
|
15
|
+
setup_assets
|
|
16
|
+
end
|
|
16
17
|
|
|
18
|
+
def register(*args)
|
|
19
|
+
(editables = args.first.is_a?(Hash) ? args.first : Hash[*args]).each do |selector, specs|
|
|
20
|
+
if @editable_content.keys.include?(selector)
|
|
21
|
+
raise RichCmsError, "Already registered editable content identified with #{selector.inspect}"
|
|
22
|
+
else
|
|
23
|
+
@editable_content[selector] = Cms::Content::Group.build(selector, specs)
|
|
24
|
+
end
|
|
25
|
+
end
|
|
26
|
+
end
|
|
27
|
+
|
|
28
|
+
private
|
|
29
|
+
|
|
30
|
+
def append_to_load_path
|
|
17
31
|
%w(controllers).each do |dir|
|
|
18
32
|
path = File.join File.dirname(__FILE__), "..", "..", "app", dir
|
|
19
33
|
$LOAD_PATH << path
|
|
20
34
|
ActiveSupport::Dependencies.autoload_paths << path
|
|
21
35
|
ActiveSupport::Dependencies.autoload_once_paths.delete path
|
|
22
36
|
end
|
|
37
|
+
end
|
|
23
38
|
|
|
39
|
+
def setup_assets
|
|
24
40
|
procedure = proc {
|
|
25
41
|
::Jzip::Engine.add_template_location({File.expand_path("../../../../assets/jzip", __FILE__) => File.join(Rails.root, "public", "javascripts")})
|
|
26
42
|
::Sass::Plugin.add_template_location( File.expand_path("../../../../assets/sass", __FILE__), File.join(Rails.root, "public", "stylesheets") )
|
|
27
|
-
|
|
43
|
+
copy_images
|
|
28
44
|
}
|
|
29
45
|
|
|
30
46
|
if Rails::VERSION::MAJOR >= 3
|
|
@@ -36,7 +52,7 @@ module Rich
|
|
|
36
52
|
end
|
|
37
53
|
end
|
|
38
54
|
|
|
39
|
-
def
|
|
55
|
+
def copy_images
|
|
40
56
|
return if Rails.env == "test"
|
|
41
57
|
|
|
42
58
|
source_dir = File.join File.dirname(__FILE__), "..", "..", "..", "assets", "images", "."
|
|
@@ -47,54 +63,10 @@ module Rich
|
|
|
47
63
|
FileUtils.cp_r source_dir, target_dir
|
|
48
64
|
end
|
|
49
65
|
|
|
50
|
-
def current_controller=(current_controller)
|
|
51
|
-
@current_controller = current_controller
|
|
52
|
-
@can_render_metadata = nil
|
|
53
|
-
end
|
|
54
|
-
|
|
55
|
-
def authenticate(logic, specs)
|
|
56
|
-
@authentication = AuthenticationSpecs.new(logic, specs)
|
|
57
|
-
end
|
|
58
|
-
|
|
59
|
-
def register(*args)
|
|
60
|
-
(editables = args.first.is_a?(Hash) ? args.first : Hash[*args]).each do |selector, specs|
|
|
61
|
-
if @editable_content.keys.include?(selector)
|
|
62
|
-
raise RichCmsError, "Already registered editable content identified with #{selector.inspect}"
|
|
63
|
-
else
|
|
64
|
-
@editable_content[selector] = Cms::Content::Group.build(selector, specs)
|
|
65
|
-
end
|
|
66
|
-
end
|
|
67
|
-
end
|
|
68
|
-
|
|
69
|
-
def to_content_tag(selector, identifiers, options = {})
|
|
70
|
-
editable_content[selector].fetch(identifiers).to_tag options
|
|
71
|
-
end
|
|
72
|
-
|
|
73
|
-
def editable_content_javascript_hash
|
|
74
|
-
"{#{@editable_content.collect{|k, v| v.to_javascript_hash}.join ", "}}".html_safe
|
|
75
|
-
end
|
|
76
|
-
|
|
77
|
-
def can_render_metadata?
|
|
78
|
-
if @can_render_metadata.nil?
|
|
79
|
-
@can_render_metadata = case authentication.logic
|
|
80
|
-
when :authlogic
|
|
81
|
-
@current_controller.try :current_rich_cms_admin
|
|
82
|
-
when nil
|
|
83
|
-
true
|
|
84
|
-
end
|
|
85
|
-
else
|
|
86
|
-
@can_render_metadata
|
|
87
|
-
end
|
|
88
|
-
end
|
|
89
|
-
|
|
90
|
-
private
|
|
91
|
-
|
|
92
|
-
AuthenticationSpecs = Struct.new(:logic, :specs)
|
|
93
|
-
|
|
94
66
|
end
|
|
95
67
|
|
|
96
68
|
end
|
|
97
69
|
end
|
|
98
70
|
end
|
|
99
71
|
|
|
100
|
-
Rich::Cms::Engine.init
|
|
72
|
+
Rich::Cms::Engine.init
|
data/lib/rich_cms.rb
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
|
-
require "authlogic"
|
|
2
|
-
require "formtastic"
|
|
3
1
|
require "jzip"
|
|
4
2
|
require "haml"
|
|
3
|
+
require "devise/version" if defined?(Devise)
|
|
5
4
|
|
|
6
5
|
require "rich/cms/core"
|
|
7
6
|
require "rich/cms/activesupport"
|
|
8
7
|
require "rich/cms/actionpack"
|
|
9
8
|
require "rich/cms/rails"
|
|
9
|
+
require "rich/cms/auth"
|
|
10
10
|
require "rich/cms/engine"
|
|
11
11
|
require "rich/cms/content/group"
|
|
12
12
|
require "rich/cms/content/item"
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
module Rails
|
|
2
|
+
module Generator
|
|
3
|
+
module Commands
|
|
4
|
+
class Create < Base
|
|
5
|
+
|
|
6
|
+
# Create devise route. Based on route_resources
|
|
7
|
+
def route_devise(*resources)
|
|
8
|
+
resource_list = resources.map { |r| r.to_sym.inspect }.join(', ')
|
|
9
|
+
sentinel = 'ActionController::Routing::Routes.draw do |map|'
|
|
10
|
+
|
|
11
|
+
logger.route "map.devise_for #{resource_list}"
|
|
12
|
+
unless options[:pretend]
|
|
13
|
+
gsub_file 'config/routes.rb', /(#{Regexp.escape(sentinel)})/mi do |match|
|
|
14
|
+
"#{match}\n map.devise_for #{resource_list}\n"
|
|
15
|
+
end
|
|
16
|
+
end
|
|
17
|
+
end
|
|
18
|
+
end
|
|
19
|
+
|
|
20
|
+
class Destroy < RewindBase
|
|
21
|
+
|
|
22
|
+
# Destroy devise route. Based on route_resources
|
|
23
|
+
def route_devise(*resources)
|
|
24
|
+
resource_list = resources.map { |r| r.to_sym.inspect }.join(', ')
|
|
25
|
+
look_for = "\n map.devise_for #{resource_list}\n"
|
|
26
|
+
logger.route "map.devise_for #{resource_list}"
|
|
27
|
+
gsub_file 'config/routes.rb', /(#{look_for})/mi, ''
|
|
28
|
+
end
|
|
29
|
+
end
|
|
30
|
+
end
|
|
31
|
+
end
|
|
32
|
+
end
|
|
@@ -0,0 +1,113 @@
|
|
|
1
|
+
require File.expand_path("../lib/devise/route_devise.rb", __FILE__)
|
|
2
|
+
|
|
3
|
+
class RichCmsAdminGenerator < Rails::Generator::Base
|
|
4
|
+
def initialize(runtime_args, runtime_options = {})
|
|
5
|
+
super
|
|
6
|
+
@name = @args.first || "user"
|
|
7
|
+
@logic = options[:logic] || "Devise"
|
|
8
|
+
end
|
|
9
|
+
|
|
10
|
+
def manifest
|
|
11
|
+
check_for_warnings
|
|
12
|
+
record do |m|
|
|
13
|
+
m.file "config.rb", "config/initializers/enrichments.rb", {:collision => :skip}
|
|
14
|
+
send :"generate_#{@logic.underscore}_assets", m
|
|
15
|
+
end
|
|
16
|
+
end
|
|
17
|
+
|
|
18
|
+
def after_generate
|
|
19
|
+
filename = destination_path("config/initializers/enrichments.rb")
|
|
20
|
+
line = "Rich::Cms::Auth.setup do |config|"
|
|
21
|
+
|
|
22
|
+
return if File.open(filename).readlines.collect(&:strip).include? line.strip
|
|
23
|
+
|
|
24
|
+
File.open(filename, "a+") do |file|
|
|
25
|
+
file << "#{line}\n"
|
|
26
|
+
file << " config.logic = :#{@logic.underscore}\n"
|
|
27
|
+
file << " config.klass = \"#{model_class_name}\"\n"
|
|
28
|
+
file << "end"
|
|
29
|
+
end
|
|
30
|
+
|
|
31
|
+
system "rake db:migrate" if options[:migrate]
|
|
32
|
+
end
|
|
33
|
+
|
|
34
|
+
# //////////////////////////////////
|
|
35
|
+
# // Helper methods
|
|
36
|
+
# //////////////////////////////////
|
|
37
|
+
|
|
38
|
+
def model_file_name
|
|
39
|
+
@name.underscore
|
|
40
|
+
end
|
|
41
|
+
|
|
42
|
+
def model_class_name
|
|
43
|
+
@name.classify
|
|
44
|
+
end
|
|
45
|
+
|
|
46
|
+
def table_name
|
|
47
|
+
model_file_name.gsub("/", "_").pluralize
|
|
48
|
+
end
|
|
49
|
+
|
|
50
|
+
def migration_file_name
|
|
51
|
+
"create_#{table_name}"
|
|
52
|
+
end
|
|
53
|
+
|
|
54
|
+
def migration_class_name
|
|
55
|
+
migration_file_name.camelize
|
|
56
|
+
end
|
|
57
|
+
|
|
58
|
+
protected
|
|
59
|
+
|
|
60
|
+
def banner
|
|
61
|
+
<<-BANNER.gsub(/^ {7}/, "")
|
|
62
|
+
Creates Devise / Authlogic model and configures your Rails application for Rich-CMS authentication.
|
|
63
|
+
|
|
64
|
+
USAGE: #{$0} #{spec.name} [model_name]
|
|
65
|
+
BANNER
|
|
66
|
+
end
|
|
67
|
+
|
|
68
|
+
def add_options!(opt)
|
|
69
|
+
opt.separator ""
|
|
70
|
+
opt.separator "Options:"
|
|
71
|
+
opt.on("-d", "--devise" , "Use Devise as authentication logic (this is default)." ) { options[:logic ] = "Devise" }
|
|
72
|
+
opt.on("-a", "--authlogic", "Use Authlogic as authentication logic." ) { options[:logic ] = "Authlogic" }
|
|
73
|
+
opt.on("-m", "--migrate" , "Run 'rake db:migrate' after generating model and migration.") { options[:migrate] = true }
|
|
74
|
+
end
|
|
75
|
+
|
|
76
|
+
private
|
|
77
|
+
|
|
78
|
+
def check_for_warnings
|
|
79
|
+
unless defined?(Devise) || @logic.to_s.underscore != "devise"
|
|
80
|
+
puts <<-WARNING.gsub(/^ {9}/, "")
|
|
81
|
+
Don't forget to install Devise 1.0.9!
|
|
82
|
+
WARNING
|
|
83
|
+
end
|
|
84
|
+
unless defined?(Authlogic) || @logic.to_s.underscore != "authlogic"
|
|
85
|
+
puts <<-WARNING.gsub(/^ {9}/, "")
|
|
86
|
+
Don't forget to install Authlogic 2.1.6!
|
|
87
|
+
WARNING
|
|
88
|
+
end
|
|
89
|
+
end
|
|
90
|
+
|
|
91
|
+
def generate_devise_assets(m)
|
|
92
|
+
if defined?(Devise)
|
|
93
|
+
m.directory "config/initializers"
|
|
94
|
+
m.directory "config/locales"
|
|
95
|
+
m.template "devise/devise.rb", "config/initializers/devise.rb"
|
|
96
|
+
m.file "devise/en.yml" , "config/locales/devise.en.yml"
|
|
97
|
+
m.readme "devise/README"
|
|
98
|
+
end
|
|
99
|
+
|
|
100
|
+
m.directory "app/models"
|
|
101
|
+
m.template "devise/model.rb" , "app/models/#{model_file_name}.rb"
|
|
102
|
+
m.migration_template "devise/migration.rb", "db/migrate", :migration_file_name => "devise_#{migration_file_name}"
|
|
103
|
+
m.route_devise table_name
|
|
104
|
+
end
|
|
105
|
+
|
|
106
|
+
def generate_authlogic_assets(m)
|
|
107
|
+
m.directory "app/models"
|
|
108
|
+
m.template "authlogic/model.rb" , "app/models/#{model_file_name}.rb"
|
|
109
|
+
m.template "authlogic/session.rb" , "app/models/#{model_file_name}_session.rb"
|
|
110
|
+
m.migration_template "authlogic/migration.rb", "db/migrate", :migration_file_name => migration_file_name
|
|
111
|
+
end
|
|
112
|
+
|
|
113
|
+
end
|
|
File without changes
|
data/rails_generators/{rich_authlogic_user/templates → rich_cms_admin/templates/authlogic}/model.rb
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
===============================================================================
|
|
2
|
+
|
|
3
|
+
Some setup you must do manually if you haven't yet:
|
|
4
|
+
|
|
5
|
+
1. Setup default url options for your specific environment. Here is an
|
|
6
|
+
example of development environment:
|
|
7
|
+
|
|
8
|
+
config.action_mailer.default_url_options = { :host => 'localhost:3000' }
|
|
9
|
+
|
|
10
|
+
This is a required Rails configuration. In production is must be the
|
|
11
|
+
actual host of your application
|
|
12
|
+
|
|
13
|
+
2. Ensure you have defined root_url to *something* in your config/routes.rb:
|
|
14
|
+
|
|
15
|
+
map.root :controller => 'home'
|
|
16
|
+
|
|
17
|
+
3. Ensure you have a default layout in app/views/layouts and it shows
|
|
18
|
+
flash messages. For example:
|
|
19
|
+
|
|
20
|
+
<p class="notice"><%= flash[:notice] %></p>
|
|
21
|
+
<p class="alert"><%= flash[:alert] %></p>
|
|
22
|
+
|
|
23
|
+
===============================================================================
|
|
@@ -0,0 +1,105 @@
|
|
|
1
|
+
# Use this hook to configure devise mailer, warden hooks and so forth. The first
|
|
2
|
+
# four configuration values can also be set straight in your models.
|
|
3
|
+
Devise.setup do |config|
|
|
4
|
+
# Configure the e-mail address which will be shown in DeviseMailer.
|
|
5
|
+
config.mailer_sender = "please-change-me@config-initializers-devise.com"
|
|
6
|
+
|
|
7
|
+
# Configure the content type of DeviseMailer mails (defaults to text/html")
|
|
8
|
+
# config.mailer_content_type = "text/plain"
|
|
9
|
+
|
|
10
|
+
# ==> Configuration for :authenticatable
|
|
11
|
+
# Invoke `rake secret` and use the printed value to setup a pepper to generate
|
|
12
|
+
# the encrypted password. By default no pepper is used.
|
|
13
|
+
# config.pepper = "rake secret output"
|
|
14
|
+
|
|
15
|
+
# Configure how many times you want the password is reencrypted. Default is 10.
|
|
16
|
+
# config.stretches = 10
|
|
17
|
+
|
|
18
|
+
# Define which will be the encryption algorithm. Supported algorithms are :sha1
|
|
19
|
+
# (default), :sha512 and :bcrypt. Devise also supports encryptors from others
|
|
20
|
+
# authentication tools as :clearance_sha1, :authlogic_sha512 (then you should set
|
|
21
|
+
# stretches above to 20 for default behavior) and :restful_authentication_sha1
|
|
22
|
+
# (then you should set stretches to 10, and copy REST_AUTH_SITE_KEY to pepper)
|
|
23
|
+
# config.encryptor = :sha1
|
|
24
|
+
|
|
25
|
+
# Configure which keys are used when authenticating an user. By default is
|
|
26
|
+
# just :email. You can configure it to use [:username, :subdomain], so for
|
|
27
|
+
# authenticating an user, both parameters are required. Remember that those
|
|
28
|
+
# parameters are used only when authenticating and not when retrieving from
|
|
29
|
+
# session. If you need permissions, you should implement that in a before filter.
|
|
30
|
+
# config.authentication_keys = [ :email ]
|
|
31
|
+
|
|
32
|
+
# The realm used in Http Basic Authentication
|
|
33
|
+
# config.http_authentication_realm = "Application"
|
|
34
|
+
|
|
35
|
+
# ==> Configuration for :confirmable
|
|
36
|
+
# The time you want give to your user to confirm his account. During this time
|
|
37
|
+
# he will be able to access your application without confirming. Default is nil.
|
|
38
|
+
# config.confirm_within = 2.days
|
|
39
|
+
|
|
40
|
+
# ==> Configuration for :rememberable
|
|
41
|
+
# The time the user will be remembered without asking for credentials again.
|
|
42
|
+
# config.remember_for = 2.weeks
|
|
43
|
+
|
|
44
|
+
# ==> Configuration for :timeoutable
|
|
45
|
+
# The time you want to timeout the user session without activity. After this
|
|
46
|
+
# time the user will be asked for credentials again.
|
|
47
|
+
# config.timeout_in = 10.minutes
|
|
48
|
+
|
|
49
|
+
# ==> Configuration for :lockable
|
|
50
|
+
# Number of authentication tries before locking an account.
|
|
51
|
+
# config.maximum_attempts = 20
|
|
52
|
+
|
|
53
|
+
# Defines which strategy will be used to unlock an account.
|
|
54
|
+
# :email = Sends an unlock link to the user email
|
|
55
|
+
# :time = Reanables login after a certain ammount of time (see :unlock_in below)
|
|
56
|
+
# :both = enables both strategies
|
|
57
|
+
# config.unlock_strategy = :both
|
|
58
|
+
|
|
59
|
+
# Time interval to unlock the account if :time is enabled as unlock_strategy.
|
|
60
|
+
# config.unlock_in = 1.hour
|
|
61
|
+
|
|
62
|
+
# ==> Configuration for :token_authenticatable
|
|
63
|
+
# Defines name of the authentication token params key
|
|
64
|
+
# config.token_authentication_key = :auth_token
|
|
65
|
+
|
|
66
|
+
# ==> General configuration
|
|
67
|
+
# Load and configure the ORM. Supports :active_record (default), :mongo_mapper
|
|
68
|
+
# (requires mongo_ext installed) and :data_mapper (experimental).
|
|
69
|
+
# require 'devise/orm/mongo_mapper'
|
|
70
|
+
# config.orm = :mongo_mapper
|
|
71
|
+
|
|
72
|
+
# Turn scoped views on. Before rendering "sessions/new", it will first check for
|
|
73
|
+
# "sessions/users/new". It's turned off by default because it's slower if you
|
|
74
|
+
# are using only default views.
|
|
75
|
+
# config.scoped_views = true
|
|
76
|
+
|
|
77
|
+
# By default, devise detects the role accessed based on the url. So whenever
|
|
78
|
+
# accessing "/users/sign_in", it knows you are accessing an User. This makes
|
|
79
|
+
# routes as "/sign_in" not possible, unless you tell Devise to use the default
|
|
80
|
+
# scope, setting true below.
|
|
81
|
+
# config.use_default_scope = true
|
|
82
|
+
|
|
83
|
+
# Configure the default scope used by Devise. By default it's the first devise
|
|
84
|
+
# role declared in your routes.
|
|
85
|
+
# config.default_scope = :user
|
|
86
|
+
|
|
87
|
+
# If you want to use other strategies, that are not (yet) supported by Devise,
|
|
88
|
+
# you can configure them inside the config.warden block. The example below
|
|
89
|
+
# allows you to setup OAuth, using http://github.com/roman/warden_oauth
|
|
90
|
+
#
|
|
91
|
+
# config.warden do |manager|
|
|
92
|
+
# manager.oauth(:twitter) do |twitter|
|
|
93
|
+
# twitter.consumer_secret = <YOUR CONSUMER SECRET>
|
|
94
|
+
# twitter.consumer_key = <YOUR CONSUMER KEY>
|
|
95
|
+
# twitter.options :site => 'http://twitter.com'
|
|
96
|
+
# end
|
|
97
|
+
# manager.default_strategies.unshift :twitter_oauth
|
|
98
|
+
# end
|
|
99
|
+
|
|
100
|
+
# Configure default_url_options if you are using dynamic segments in :path_prefix
|
|
101
|
+
# for devise_for.
|
|
102
|
+
# config.default_url_options do
|
|
103
|
+
# { :locale => I18n.locale }
|
|
104
|
+
# end
|
|
105
|
+
end
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
en:
|
|
2
|
+
devise:
|
|
3
|
+
sessions:
|
|
4
|
+
link: 'Sign in'
|
|
5
|
+
signed_in: 'Signed in successfully.'
|
|
6
|
+
signed_out: 'Signed out successfully.'
|
|
7
|
+
unauthenticated: 'You need to sign in or sign up before continuing.'
|
|
8
|
+
unconfirmed: 'You have to confirm your account before continuing.'
|
|
9
|
+
locked: 'Your account is locked.'
|
|
10
|
+
invalid: 'Invalid email or password.'
|
|
11
|
+
invalid_token: 'Invalid authentication token.'
|
|
12
|
+
timeout: 'Your session expired, please sign in again to continue.'
|
|
13
|
+
inactive: 'Your account was not activated yet.'
|
|
14
|
+
passwords:
|
|
15
|
+
link: 'Forgot password?'
|
|
16
|
+
send_instructions: 'You will receive an email with instructions about how to reset your password in a few minutes.'
|
|
17
|
+
updated: 'Your password was changed successfully. You are now signed in.'
|
|
18
|
+
confirmations:
|
|
19
|
+
link: "Didn't receive confirmation instructions?"
|
|
20
|
+
send_instructions: 'You will receive an email with instructions about how to confirm your account in a few minutes.'
|
|
21
|
+
confirmed: 'Your account was successfully confirmed. You are now signed in.'
|
|
22
|
+
registrations:
|
|
23
|
+
link: 'Sign up'
|
|
24
|
+
signed_up: 'You have signed up successfully. If enabled, a confirmation was sent to your e-mail.'
|
|
25
|
+
updated: 'You updated your account successfully.'
|
|
26
|
+
destroyed: 'Bye! Your account was successfully cancelled. We hope to see you again soon.'
|
|
27
|
+
unlocks:
|
|
28
|
+
link: "Didn't receive unlock instructions?"
|
|
29
|
+
send_instructions: 'You will receive an email with instructions about how to unlock your account in a few minutes.'
|
|
30
|
+
unlocked: 'Your account was successfully unlocked. You are now signed in.'
|
|
31
|
+
mailer:
|
|
32
|
+
confirmation_instructions: 'Confirmation instructions'
|
|
33
|
+
reset_password_instructions: 'Reset password instructions'
|
|
34
|
+
unlock_instructions: 'Unlock Instructions'
|
|
35
|
+
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
class Devise<%= migration_class_name %> < ActiveRecord::Migration
|
|
2
|
+
def self.up
|
|
3
|
+
create_table(:<%= table_name %>) do |t|
|
|
4
|
+
t.database_authenticatable :null => false
|
|
5
|
+
t.confirmable
|
|
6
|
+
t.recoverable
|
|
7
|
+
t.rememberable
|
|
8
|
+
t.trackable
|
|
9
|
+
# t.lockable
|
|
10
|
+
|
|
11
|
+
t.timestamps
|
|
12
|
+
end
|
|
13
|
+
|
|
14
|
+
add_index :<%= table_name %>, :email, :unique => true
|
|
15
|
+
add_index :<%= table_name %>, :confirmation_token, :unique => true
|
|
16
|
+
add_index :<%= table_name %>, :reset_password_token, :unique => true
|
|
17
|
+
# add_index :<%= table_name %>, :unlock_token, :unique => true
|
|
18
|
+
end
|
|
19
|
+
|
|
20
|
+
def self.down
|
|
21
|
+
drop_table :<%= table_name %>
|
|
22
|
+
end
|
|
23
|
+
end
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
class <%= model_class_name %> < ActiveRecord::Base
|
|
2
|
+
# Include default devise modules. Others available are:
|
|
3
|
+
# :http_authenticatable, :token_authenticatable, :confirmable, :lockable, :timeoutable and :activatable
|
|
4
|
+
devise :registerable, :database_authenticatable, :recoverable,
|
|
5
|
+
:rememberable, :trackable, :validatable
|
|
6
|
+
|
|
7
|
+
# Setup accessible (or protected) attributes for your model
|
|
8
|
+
attr_accessible :email, :password, :password_confirmation
|
|
9
|
+
end
|
|
@@ -6,9 +6,9 @@ class RichCmsContentGenerator < Rails::Generator::Base
|
|
|
6
6
|
|
|
7
7
|
def manifest
|
|
8
8
|
record do |m|
|
|
9
|
-
m.directory
|
|
10
|
-
m.template
|
|
11
|
-
m.
|
|
9
|
+
m.directory "app/models"
|
|
10
|
+
m.template "model.rb" , "app/models/#{model_file_name}.rb"
|
|
11
|
+
m.file "config.rb" , "config/initializers/enrichments.rb", {:collision => :skip}
|
|
12
12
|
m.migration_template "migration.rb", "db/migrate", :migration_file_name => migration_file_name
|
|
13
13
|
end
|
|
14
14
|
end
|
|
@@ -17,13 +17,19 @@ class RichCmsContentGenerator < Rails::Generator::Base
|
|
|
17
17
|
filename = destination_path("config/initializers/enrichments.rb")
|
|
18
18
|
line = "\nRich::Cms::Engine.register(\".#{model_file_name}\", {:class_name => \"#{model_class_name}\"})"
|
|
19
19
|
|
|
20
|
+
return if File.open(filename).readlines.collect(&:strip).include? line.strip
|
|
21
|
+
|
|
20
22
|
File.open(filename, "a+") do |file|
|
|
21
23
|
file << line
|
|
22
|
-
end
|
|
24
|
+
end
|
|
23
25
|
|
|
24
26
|
system "rake db:migrate" if options[:migrate]
|
|
25
27
|
end
|
|
26
28
|
|
|
29
|
+
# //////////////////////////////////
|
|
30
|
+
# // Helper methods
|
|
31
|
+
# //////////////////////////////////
|
|
32
|
+
|
|
27
33
|
def model_file_name
|
|
28
34
|
@name.underscore
|
|
29
35
|
end
|
|
@@ -46,18 +52,18 @@ class RichCmsContentGenerator < Rails::Generator::Base
|
|
|
46
52
|
|
|
47
53
|
protected
|
|
48
54
|
|
|
49
|
-
def add_options!(opt)
|
|
50
|
-
opt.separator ""
|
|
51
|
-
opt.separator "Options:"
|
|
52
|
-
opt.on("-m", "--migrate", "Run 'rake db:migrate' after generating model and migration.") { options[:migrate] = true }
|
|
53
|
-
end
|
|
54
|
-
|
|
55
55
|
def banner
|
|
56
|
-
<<-
|
|
56
|
+
<<-BANNER.gsub(/^ {7}/, "")
|
|
57
57
|
Creates Rich-CMS content model and migration and also registers content to Rich-CMS.
|
|
58
58
|
|
|
59
59
|
USAGE: #{$0} #{spec.name} [model_name]
|
|
60
|
-
|
|
60
|
+
BANNER
|
|
61
|
+
end
|
|
62
|
+
|
|
63
|
+
def add_options!(opt)
|
|
64
|
+
opt.separator ""
|
|
65
|
+
opt.separator "Options:"
|
|
66
|
+
opt.on("-m", "--migrate", "Run 'rake db:migrate' after generating model and migration.") { options[:migrate] = true }
|
|
61
67
|
end
|
|
62
68
|
|
|
63
69
|
end
|