alchemy_cms 3.2.0.beta → 3.2.0.rc1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (146) hide show
  1. checksums.yaml +4 -4
  2. data/.rubocop.yml +661 -863
  3. data/README.md +5 -63
  4. data/app/assets/javascripts/alchemy/alchemy.base.js.coffee +11 -10
  5. data/app/assets/javascripts/alchemy/alchemy.initializer.js.coffee +6 -0
  6. data/app/assets/stylesheets/alchemy/_extends.scss +0 -6
  7. data/app/assets/stylesheets/alchemy/_mixins.scss +6 -0
  8. data/app/assets/stylesheets/alchemy/buttons.scss +1 -1
  9. data/app/assets/stylesheets/alchemy/elements.scss +1 -1
  10. data/app/assets/stylesheets/alchemy/menubar.scss +1 -1
  11. data/app/assets/stylesheets/alchemy/selects.scss +5 -1
  12. data/app/assets/stylesheets/alchemy/upload.scss +1 -1
  13. data/app/controllers/alchemy/admin/pages_controller.rb +1 -1
  14. data/app/controllers/alchemy/base_controller.rb +4 -57
  15. data/app/controllers/alchemy/messages_controller.rb +2 -2
  16. data/app/controllers/alchemy/pages_controller.rb +22 -31
  17. data/app/controllers/alchemy/pictures_controller.rb +2 -2
  18. data/app/helpers/alchemy/admin/base_helper.rb +7 -0
  19. data/app/helpers/alchemy/admin/elements_helper.rb +31 -15
  20. data/app/helpers/alchemy/admin/pages_helper.rb +17 -0
  21. data/app/helpers/alchemy/base_helper.rb +0 -28
  22. data/app/helpers/alchemy/pages_helper.rb +18 -12
  23. data/app/helpers/alchemy/url_helper.rb +2 -2
  24. data/app/models/alchemy/cell.rb +1 -1
  25. data/app/models/alchemy/content/factory.rb +12 -6
  26. data/app/models/alchemy/element.rb +3 -3
  27. data/app/models/alchemy/element/definitions.rb +1 -1
  28. data/app/models/alchemy/element_to_page.rb +7 -0
  29. data/app/models/alchemy/language.rb +1 -1
  30. data/app/models/alchemy/page.rb +8 -1
  31. data/app/models/alchemy/page/page_cells.rb +2 -2
  32. data/app/models/alchemy/page/page_elements.rb +23 -5
  33. data/app/models/alchemy/page/page_natures.rb +3 -3
  34. data/app/models/alchemy/page/page_scopes.rb +1 -1
  35. data/app/models/alchemy/picture.rb +1 -1
  36. data/app/views/alchemy/admin/pages/_create_language_form.html.erb +1 -1
  37. data/app/views/alchemy/admin/pages/_form.html.erb +1 -1
  38. data/app/views/alchemy/admin/pictures/_picture_to_assign.html.erb +1 -1
  39. data/app/views/alchemy/breadcrumb/_page.html.erb +3 -2
  40. data/app/views/alchemy/breadcrumb/_separator.html.erb +1 -0
  41. data/app/views/alchemy/breadcrumb/_wrapper.html.erb +13 -0
  42. data/app/views/alchemy/language_links/_language.html.erb +1 -1
  43. data/app/views/alchemy/navigation/_link.html.erb +1 -1
  44. data/app/views/alchemy/pages/show.rss.builder +5 -7
  45. data/app/views/layouts/alchemy/admin.html.erb +5 -0
  46. data/config/routes.rb +13 -10
  47. data/lib/alchemy/configuration_methods.rb +29 -0
  48. data/lib/alchemy/controller_actions.rb +12 -4
  49. data/lib/alchemy/engine.rb +3 -0
  50. data/lib/alchemy/errors.rb +1 -1
  51. data/lib/alchemy/essence.rb +14 -12
  52. data/lib/alchemy/on_page_layout.rb +58 -0
  53. data/lib/alchemy/page_layout.rb +1 -1
  54. data/lib/alchemy/permissions.rb +21 -16
  55. data/lib/alchemy/routing_constraints.rb +49 -0
  56. data/lib/alchemy/seeder.rb +4 -2
  57. data/lib/alchemy/ssl_protection.rb +30 -0
  58. data/lib/alchemy/test_support/essence_shared_examples.rb +118 -25
  59. data/lib/alchemy/test_support/factories.rb +5 -8
  60. data/lib/alchemy/test_support/integration_helpers.rb +16 -10
  61. data/lib/alchemy/upgrader/three_point_two.rb +34 -4
  62. data/lib/alchemy/version.rb +1 -1
  63. data/lib/rails/generators/alchemy/{scaffold → install}/files/_article_editor.html.erb +0 -0
  64. data/lib/rails/generators/alchemy/{scaffold → install}/files/_article_view.html.erb +0 -0
  65. data/lib/rails/generators/alchemy/{scaffold → install}/files/_standard.html.erb +0 -0
  66. data/lib/rails/generators/alchemy/{scaffold → install}/files/alchemy.de.yml +0 -0
  67. data/lib/rails/generators/alchemy/{scaffold → install}/files/alchemy.elements.css.scss +0 -0
  68. data/lib/rails/generators/alchemy/{scaffold → install}/files/alchemy.en.yml +0 -0
  69. data/lib/rails/generators/alchemy/{scaffold → install}/files/alchemy.es.yml +0 -0
  70. data/lib/rails/generators/alchemy/{scaffold → install}/files/application.html.erb +0 -0
  71. data/lib/rails/generators/alchemy/install/install_generator.rb +69 -0
  72. data/lib/rails/generators/alchemy/{scaffold/files/elements.yml → install/templates/elements.yml.tt} +2 -0
  73. data/lib/rails/generators/alchemy/{scaffold → install}/templates/page_layouts.yml.tt +2 -0
  74. data/lib/rails/generators/alchemy/views/views_generator.rb +41 -0
  75. data/lib/rails/templates/alchemy.rb +2 -2
  76. data/lib/tasks/alchemy/db.rake +0 -5
  77. data/lib/tasks/alchemy/install.rake +10 -5
  78. data/lib/tasks/alchemy/tidy.rake +2 -0
  79. data/spec/controllers/admin/attachments_controller_spec.rb +1 -1
  80. data/spec/controllers/admin/clipboard_controller_spec.rb +1 -1
  81. data/spec/controllers/admin/contents_controller_spec.rb +1 -1
  82. data/spec/controllers/admin/dashboard_controller_spec.rb +2 -2
  83. data/spec/controllers/admin/elements_controller_spec.rb +1 -1
  84. data/spec/controllers/admin/essence_files_controller_spec.rb +1 -1
  85. data/spec/controllers/admin/essence_pictures_controller_spec.rb +1 -1
  86. data/spec/controllers/admin/languages_controller_spec.rb +1 -1
  87. data/spec/controllers/admin/layoutpages_controller_spec.rb +1 -1
  88. data/spec/controllers/admin/pages_controller_spec.rb +4 -4
  89. data/spec/controllers/admin/pictures_controller_spec.rb +1 -1
  90. data/spec/controllers/admin/resources_controller_spec.rb +1 -1
  91. data/spec/controllers/admin/trash_controller_spec.rb +1 -1
  92. data/spec/controllers/alchemy/admin/tags_controller_spec.rb +1 -1
  93. data/spec/controllers/attachments_controller_spec.rb +1 -1
  94. data/spec/controllers/base_controller_spec.rb +22 -0
  95. data/spec/controllers/elements_controller_spec.rb +1 -1
  96. data/spec/controllers/pages_controller_spec.rb +15 -16
  97. data/spec/controllers/pictures_controller_spec.rb +212 -162
  98. data/spec/dummy/app/controllers/login_controller.rb +5 -0
  99. data/spec/dummy/app/models/dummy_model.rb +3 -0
  100. data/spec/dummy/config/alchemy/cells.yml +4 -1
  101. data/spec/dummy/config/alchemy/elements.yml +8 -0
  102. data/spec/dummy/config/alchemy/page_layouts.yml +5 -1
  103. data/spec/dummy/config/routes.rb +1 -2
  104. data/spec/dummy/db/migrate/20150412103152_create_dummy_model.rb +7 -0
  105. data/spec/dummy/db/schema.rb +30 -26
  106. data/spec/features/admin/dashboard_spec.rb +11 -9
  107. data/spec/features/admin/language_tree_feature_spec.rb +5 -6
  108. data/spec/features/admin/legacy_page_url_management_spec.rb +1 -1
  109. data/spec/features/admin/link_overlay_spec.rb +1 -1
  110. data/spec/features/admin/locale_select_feature_spec.rb +1 -1
  111. data/spec/features/admin/modules_integration_spec.rb +1 -1
  112. data/spec/features/admin/navigation_feature_spec.rb +1 -1
  113. data/spec/features/admin/page_creation_feature_spec.rb +1 -1
  114. data/spec/features/admin/page_editing_feature_spec.rb +3 -3
  115. data/spec/features/admin/picture_library_integration_spec.rb +1 -1
  116. data/spec/features/admin/resources_integration_spec.rb +1 -1
  117. data/spec/features/admin/site_select_feature_spec.rb +32 -0
  118. data/spec/features/admin/tinymce_feature_spec.rb +1 -3
  119. data/spec/features/page_feature_spec.rb +36 -27
  120. data/spec/features/security_spec.rb +1 -1
  121. data/spec/features/translation_integration_spec.rb +3 -3
  122. data/spec/helpers/admin/elements_helper_spec.rb +103 -26
  123. data/spec/helpers/admin/pages_helper_spec.rb +32 -1
  124. data/spec/helpers/base_helper_spec.rb +0 -45
  125. data/spec/helpers/pages_helper_spec.rb +18 -17
  126. data/spec/helpers/url_helper_spec.rb +8 -5
  127. data/spec/libraries/controller_actions_spec.rb +2 -2
  128. data/spec/libraries/on_page_layout_spec.rb +112 -0
  129. data/spec/libraries/page_layout_spec.rb +5 -1
  130. data/spec/libraries/permissions_spec.rb +13 -15
  131. data/spec/models/cell_spec.rb +4 -0
  132. data/spec/models/content_spec.rb +6 -0
  133. data/spec/models/dummy_model_spec.rb +11 -0
  134. data/spec/models/element_spec.rb +6 -1
  135. data/spec/models/element_to_page_spec.rb +14 -0
  136. data/spec/models/page_spec.rb +111 -19
  137. data/spec/routing/routing_spec.rb +120 -101
  138. data/spec/spec_helper.rb +3 -3
  139. metadata +36 -21
  140. data/app/views/alchemy/breadcrumb/_spacer.html.erb +0 -1
  141. data/lib/alchemy/capistrano.rb +0 -230
  142. data/lib/alchemy/test_support/auth_helpers.rb +0 -35
  143. data/lib/rails/generators/alchemy/deploy_script/deploy_script_generator.rb +0 -90
  144. data/lib/rails/generators/alchemy/deploy_script/templates/deploy.rb.tt +0 -113
  145. data/lib/rails/generators/alchemy/scaffold/scaffold_generator.rb +0 -63
  146. data/spec/dummy/app/controllers/errors_controller.rb +0 -5
@@ -1,35 +0,0 @@
1
- module Alchemy
2
- module TestSupport
3
-
4
- # Helpers for authentication
5
- #
6
- module AuthHelpers
7
-
8
- def sign_in(user = admin_user)
9
- allow(controller).to receive(:current_alchemy_user).and_return user
10
- end
11
-
12
- def member_user
13
- mock_user([:member])
14
- end
15
-
16
- def author_user
17
- mock_user([:author])
18
- end
19
-
20
- def editor_user
21
- mock_user([:editor])
22
- end
23
-
24
- def admin_user
25
- mock_user([:admin])
26
- end
27
-
28
- def mock_user(roles)
29
- mock_model(Alchemy.user_class, alchemy_roles: roles.map(&:to_sym))
30
- end
31
-
32
- end
33
-
34
- end
35
- end
@@ -1,90 +0,0 @@
1
- require 'rails/generators'
2
-
3
- module Alchemy
4
- module Generators
5
- class DeployScriptGenerator < ::Rails::Generators::Base
6
-
7
- desc "This generator generates a Capistrano receipt for deploying Alchemy CMS."
8
-
9
- class_option :scm,
10
- type: 'string',
11
- desc: "Set the type of scm you use for deployment.",
12
- default: 'git'
13
-
14
- class_option :db,
15
- type: 'string',
16
- desc: "Set the type of database you use on your server.",
17
- default: 'mysql'
18
-
19
- source_root File.expand_path('templates', File.dirname(__FILE__))
20
-
21
- def copy_script
22
- @scm = options[:scm]
23
- @database_type = options[:db]
24
- ask_questions
25
- template "deploy.rb.tt", Rails.root.join('config', 'deploy.rb')
26
- setup_capistrano
27
- show_read_me
28
- end
29
-
30
- private
31
-
32
- def ask_questions
33
- @app_name = ask('Please enter a name for your application:')
34
- @server = ask('Please enter server ip or domain:')
35
- if @store_credentials = yes?('Do want to store the ssh credentials? (PLEASE DO NOT STORE THEM IF THE REPOSITORY IS PUBLIC) (y/N)')
36
- ask_for_credentials
37
- end
38
- @deploy_path = ask('Please enter the path to the public html folder:')
39
- if @scm == "git"
40
- @repository_url = get_git_remote
41
- end
42
- if @repository_url.nil?
43
- @repository_url = ask('Please enter the URL to your projects repository:')
44
- end
45
- if @scm == "svn" && yes?('Is your repository private? (y/N)')
46
- ask_for_repo_credentials
47
- end
48
- end
49
-
50
- def ask_for_credentials
51
- @ssh_user = ask('Please enter ssh username:')
52
- port = ask('Please enter ssh port (22):')
53
- @ssh_port = port.blank? ? "22" : port
54
- @no_ssh_public_keys = !yes?('Do you use ssh public keys to connect to your server? (y/N)')
55
- if @no_ssh_public_keys
56
- @ssh_password = ask('Please enter ssh password:')
57
- end
58
- end
59
-
60
- def ask_for_repo_credentials
61
- @scm_user = ask('Please enter the username for your repository:')
62
- @scm_password = ask('Please enter the password to your repository:')
63
- end
64
-
65
- def get_git_remote
66
- remotes = `git remote -v`.split("\n")
67
- remote = remotes.first
68
- if remote
69
- remote.split("\t")[1].split(" ")[0]
70
- end
71
- end
72
-
73
- def setup_capistrano
74
- puts "\nSetting up Capistrano"
75
- if system 'capify .'
76
- gsub_file 'Capfile',
77
- /\s{4}#\sload\s'deploy\/assets'/,
78
- "load 'deploy/assets'"
79
- end
80
- end
81
-
82
- def show_read_me
83
- puts "\nWe are done!\n"
84
- puts "\nPlease run 'cap deploy:setup'\n to setup the server for deployment."
85
- puts "\nIf you want to deploy Alchemy the first time type:\ncap deploy:cold"
86
- puts "\nAfter the first deploy you just need to type:\ncap deploy"
87
- end
88
- end
89
- end
90
- end
@@ -1,113 +0,0 @@
1
- require 'bundler/capistrano'
2
- require 'alchemy/capistrano'
3
-
4
- # application name
5
- set :application, "<%= @app_name %>"
6
-
7
- # ssh settings
8
- <%- if @ssh_user.blank? || !@store_credentials -%>
9
- set(:user) { Capistrano::CLI.ui.ask('Enter your ssh username: ') }
10
- <%- else -%>
11
- set :user, "<%= @ssh_user %>"
12
- <%- end -%>
13
- <%- if @no_ssh_public_keys -%>
14
- <%- if @ssh_password.blank? -%>
15
- set(:password) { Capistrano::CLI.password_prompt("Enter the password for #{user}: ") }
16
- <%- else -%>
17
- set :password, "<%= @ssh_password %>"
18
- <%- end -%>
19
- <%- end -%>
20
- <%- if @ssh_port != "22" && !@store_credentials -%>
21
- set(:port) { Capistrano::CLI.ui.ask('Enter the ssh port: ') }
22
- <%- elsif @ssh_port != "22" && @store_credentials -%>
23
- set :port, <%= @ssh_port %>
24
- <%- end -%>
25
-
26
- # domain names
27
- role :app, "<%= @server %>"
28
- role :web, "<%= @server %>"
29
- role :db, "<%= @server %>", :primary => true
30
-
31
- # the webserver path
32
- set :deploy_to, "<%= @deploy_path %>"
33
- set :deploy_via, :remote_cache
34
-
35
- # repository settings
36
- <%- if @scm == "svn" -%>
37
- set :scm, "subversion"
38
- set :repository_url, "<%= @repository_url %>"
39
- <%- if @scm_user && @scm_password -%>
40
- set :scm_user, "<%= @scm_user %>"
41
- set :scm_password, "<%= @scm_password %>"
42
- set :repository, Proc.new { "--username #{scm_user} --password #{scm_password} #{repository_url}" }
43
- <%- else -%>
44
- set :repository, "<%= @repository_url %>"
45
- <%- end -%>
46
- <%- elsif @scm == "git" -%>
47
- set :scm, "git"
48
- set :repository, "<%= @repository_url %>"
49
- set :branch, "master"
50
- <%- end -%>
51
-
52
- # rails env
53
- set :rails_env, "production"
54
-
55
- # before hooks
56
- before "deploy:start", "deploy:seed"
57
- <%- if @database_type == "mysql" -%>
58
- before "deploy:migrate", "alchemy:db:dump"
59
- <%- end -%>
60
- before "deploy:create_symlink", "deploy:migrate"
61
-
62
- # after hooks
63
- <%- if @database_type == "mysql" -%>
64
- after "deploy:setup", "alchemy:database_yml:create"
65
- after "deploy:finalize_update", "alchemy:database_yml:symlink"
66
- <%- end -%>
67
- after "deploy", "deploy:cleanup"
68
-
69
- # special tasks
70
-
71
- namespace :log do
72
-
73
- desc "show last 100 lines of log"
74
- task :show do
75
- run "tail -n100 #{shared_path}/log/#{rails_env}.log"
76
- end
77
-
78
- desc "watch tail of log and wait for additional data to be appended to the input"
79
- task :watch do
80
- stream("tail -f #{shared_path}/log/#{rails_env}.log")
81
- end
82
-
83
- end
84
-
85
- namespace :deploy do
86
-
87
- task :start do ; end
88
- task :stop do ; end
89
-
90
- task :restart, :roles => :app, :except => { :no_release => true } do
91
- run "#{try_sudo} touch #{File.join(current_path,'tmp','restart.txt')}"
92
- end
93
-
94
- desc 'Seeds the database'
95
- task :seed, :roles => :app, :except => { :no_release => true } do
96
- run "cd #{release_path} && #{rake} RAILS_ENV=#{rails_env} db:seed"
97
- end
98
-
99
- end
100
-
101
- ## defaults
102
-
103
- # enable bundler binstubs
104
- set :bundle_flags, "--deployment --binstubs"
105
-
106
- # do not use sudo
107
- set :use_sudo, false
108
-
109
- # enable ssh-agent forwarding
110
- ssh_options[:forward_agent] = true
111
-
112
- # Enable git password prompting
113
- default_run_options[:pty] = true
@@ -1,63 +0,0 @@
1
- require 'rails'
2
-
3
- module Alchemy
4
- module Generators
5
- class ScaffoldGenerator < ::Rails::Generators::Base
6
-
7
- ALCHEMY_VIEWS = %w(breadcrumb language_links messages navigation)
8
-
9
- desc "This generator generates the Alchemy scaffold."
10
- class_option :copy_views, :default => false, :type => :boolean, :desc => "Copy all Alchemy views into your app.", :aliases => '-v'
11
- source_root File.expand_path('templates', File.dirname(__FILE__))
12
-
13
- def create_config_dir
14
- empty_directory "#{Rails.root}/config/alchemy"
15
- end
16
-
17
- def create_view_dirs
18
- empty_directory Rails.root.join("app/views/alchemy/elements")
19
- empty_directory Rails.root.join("app/views/alchemy/page_layouts")
20
- end
21
-
22
- def copy_view_dirs
23
- copy_alchemy_views if @options['copy_views']
24
- end
25
-
26
- def copy_config
27
- copy_file "#{config_path}/config.yml", "#{Rails.root}/config/alchemy/config.yml"
28
- end
29
-
30
- def copy_files
31
- copy_file "#{current_path}/files/elements.yml", "#{Rails.root}/config/alchemy/elements.yml"
32
- template "page_layouts.yml.tt", "#{Rails.root}/config/alchemy/page_layouts.yml"
33
- copy_file "#{current_path}/files/alchemy.en.yml", "#{Rails.root}/config/locales/alchemy.en.yml"
34
- copy_file "#{current_path}/files/alchemy.de.yml", "#{Rails.root}/config/locales/alchemy.de.yml"
35
- copy_file "#{current_path}/files/alchemy.es.yml", "#{Rails.root}/config/locales/alchemy.es.yml"
36
- copy_file "#{current_path}/files/application.html.erb", "#{Rails.root}/app/views/layouts/application.html.erb"
37
- copy_file "#{current_path}/files/_standard.html.erb", "#{Rails.root}/app/views/alchemy/page_layouts/_standard.html.erb"
38
- copy_file "#{current_path}/files/_article_view.html.erb", "#{Rails.root}/app/views/alchemy/elements/_article_view.html.erb"
39
- copy_file "#{current_path}/files/_article_editor.html.erb", "#{Rails.root}/app/views/alchemy/elements/_article_editor.html.erb"
40
- copy_file "#{current_path}/files/alchemy.elements.css.scss", "#{Rails.root}/app/assets/stylesheets/alchemy.elements.css.scss"
41
- end
42
-
43
- private
44
-
45
- def config_path
46
- @config_path ||= File.expand_path('../../../../../config/alchemy', current_path)
47
- end
48
-
49
- def copy_alchemy_views
50
- ALCHEMY_VIEWS.each do |dir|
51
- src = File.expand_path("../../../../../app/views/alchemy/#{dir}", current_path)
52
- dest = Rails.root.join('app/views/alchemy', dir)
53
- directory src, dest
54
- end
55
- end
56
-
57
- def current_path
58
- @current_path ||= File.dirname(__FILE__)
59
- end
60
-
61
- end
62
- end
63
- end
@@ -1,5 +0,0 @@
1
- class ErrorsController < ApplicationController
2
- def status_404
3
- render :text => "custom error handling"
4
- end
5
- end